diff --git a/resource-manager/nginx/2024-09-01-preview/client.go b/resource-manager/nginx/2024-09-01-preview/client.go new file mode 100644 index 00000000000..84a27449590 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/client.go @@ -0,0 +1,64 @@ +package v2024_09_01_preview + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/resource-manager/nginx/2024-09-01-preview/nginxapikey" + "github.com/hashicorp/go-azure-sdk/resource-manager/nginx/2024-09-01-preview/nginxcertificate" + "github.com/hashicorp/go-azure-sdk/resource-manager/nginx/2024-09-01-preview/nginxconfiguration" + "github.com/hashicorp/go-azure-sdk/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis" + "github.com/hashicorp/go-azure-sdk/resource-manager/nginx/2024-09-01-preview/nginxdeployment" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + NginxApiKey *nginxapikey.NginxApiKeyClient + NginxCertificate *nginxcertificate.NginxCertificateClient + NginxConfiguration *nginxconfiguration.NginxConfigurationClient + NginxConfigurationAnalysis *nginxconfigurationanalysis.NginxConfigurationAnalysisClient + NginxDeployment *nginxdeployment.NginxDeploymentClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + nginxApiKeyClient, err := nginxapikey.NewNginxApiKeyClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building NginxApiKey client: %+v", err) + } + configureFunc(nginxApiKeyClient.Client) + + nginxCertificateClient, err := nginxcertificate.NewNginxCertificateClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building NginxCertificate client: %+v", err) + } + configureFunc(nginxCertificateClient.Client) + + nginxConfigurationAnalysisClient, err := nginxconfigurationanalysis.NewNginxConfigurationAnalysisClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building NginxConfigurationAnalysis client: %+v", err) + } + configureFunc(nginxConfigurationAnalysisClient.Client) + + nginxConfigurationClient, err := nginxconfiguration.NewNginxConfigurationClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building NginxConfiguration client: %+v", err) + } + configureFunc(nginxConfigurationClient.Client) + + nginxDeploymentClient, err := nginxdeployment.NewNginxDeploymentClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building NginxDeployment client: %+v", err) + } + configureFunc(nginxDeploymentClient.Client) + + return &Client{ + NginxApiKey: nginxApiKeyClient, + NginxCertificate: nginxCertificateClient, + NginxConfiguration: nginxConfigurationClient, + NginxConfigurationAnalysis: nginxConfigurationAnalysisClient, + NginxDeployment: nginxDeploymentClient, + }, nil +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxapikey/README.md b/resource-manager/nginx/2024-09-01-preview/nginxapikey/README.md new file mode 100644 index 00000000000..1ce19cd0706 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxapikey/README.md @@ -0,0 +1,90 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/nginx/2024-09-01-preview/nginxapikey` Documentation + +The `nginxapikey` SDK allows for interaction with Azure Resource Manager `nginx` (API Version `2024-09-01-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/nginx/2024-09-01-preview/nginxapikey" +``` + + +### Client Initialization + +```go +client := nginxapikey.NewNginxApiKeyClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `NginxApiKeyClient.ApiKeysCreateOrUpdate` + +```go +ctx := context.TODO() +id := nginxapikey.NewApiKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "nginxDeploymentName", "apiKeyName") + +payload := nginxapikey.NginxDeploymentApiKeyRequest{ + // ... +} + + +read, err := client.ApiKeysCreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NginxApiKeyClient.ApiKeysDelete` + +```go +ctx := context.TODO() +id := nginxapikey.NewApiKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "nginxDeploymentName", "apiKeyName") + +read, err := client.ApiKeysDelete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NginxApiKeyClient.ApiKeysGet` + +```go +ctx := context.TODO() +id := nginxapikey.NewApiKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "nginxDeploymentName", "apiKeyName") + +read, err := client.ApiKeysGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NginxApiKeyClient.ApiKeysList` + +```go +ctx := context.TODO() +id := nginxapikey.NewNginxDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "nginxDeploymentName") + +// alternatively `client.ApiKeysList(ctx, id)` can be used to do batched pagination +items, err := client.ApiKeysListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/nginx/2024-09-01-preview/nginxapikey/client.go b/resource-manager/nginx/2024-09-01-preview/nginxapikey/client.go new file mode 100644 index 00000000000..e06ad907665 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxapikey/client.go @@ -0,0 +1,26 @@ +package nginxapikey + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NginxApiKeyClient struct { + Client *resourcemanager.Client +} + +func NewNginxApiKeyClientWithBaseURI(sdkApi sdkEnv.Api) (*NginxApiKeyClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "nginxapikey", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NginxApiKeyClient: %+v", err) + } + + return &NginxApiKeyClient{ + Client: client, + }, nil +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxapikey/id_apikey.go b/resource-manager/nginx/2024-09-01-preview/nginxapikey/id_apikey.go new file mode 100644 index 00000000000..87ef4495912 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxapikey/id_apikey.go @@ -0,0 +1,139 @@ +package nginxapikey + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ApiKeyId{}) +} + +var _ resourceids.ResourceId = &ApiKeyId{} + +// ApiKeyId is a struct representing the Resource ID for a Api Key +type ApiKeyId struct { + SubscriptionId string + ResourceGroupName string + NginxDeploymentName string + ApiKeyName string +} + +// NewApiKeyID returns a new ApiKeyId struct +func NewApiKeyID(subscriptionId string, resourceGroupName string, nginxDeploymentName string, apiKeyName string) ApiKeyId { + return ApiKeyId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NginxDeploymentName: nginxDeploymentName, + ApiKeyName: apiKeyName, + } +} + +// ParseApiKeyID parses 'input' into a ApiKeyId +func ParseApiKeyID(input string) (*ApiKeyId, error) { + parser := resourceids.NewParserFromResourceIdType(&ApiKeyId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ApiKeyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseApiKeyIDInsensitively parses 'input' case-insensitively into a ApiKeyId +// note: this method should only be used for API response data and not user input +func ParseApiKeyIDInsensitively(input string) (*ApiKeyId, error) { + parser := resourceids.NewParserFromResourceIdType(&ApiKeyId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ApiKeyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ApiKeyId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NginxDeploymentName, ok = input.Parsed["nginxDeploymentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "nginxDeploymentName", input) + } + + if id.ApiKeyName, ok = input.Parsed["apiKeyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "apiKeyName", input) + } + + return nil +} + +// ValidateApiKeyID checks that 'input' can be parsed as a Api Key ID +func ValidateApiKeyID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseApiKeyID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Api Key ID +func (id ApiKeyId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Nginx.NginxPlus/nginxDeployments/%s/apiKeys/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NginxDeploymentName, id.ApiKeyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Api Key ID +func (id ApiKeyId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticNginxNginxPlus", "Nginx.NginxPlus", "Nginx.NginxPlus"), + resourceids.StaticSegment("staticNginxDeployments", "nginxDeployments", "nginxDeployments"), + resourceids.UserSpecifiedSegment("nginxDeploymentName", "nginxDeploymentName"), + resourceids.StaticSegment("staticApiKeys", "apiKeys", "apiKeys"), + resourceids.UserSpecifiedSegment("apiKeyName", "apiKeyName"), + } +} + +// String returns a human-readable description of this Api Key ID +func (id ApiKeyId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Nginx Deployment Name: %q", id.NginxDeploymentName), + fmt.Sprintf("Api Key Name: %q", id.ApiKeyName), + } + return fmt.Sprintf("Api Key (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxapikey/id_apikey_test.go b/resource-manager/nginx/2024-09-01-preview/nginxapikey/id_apikey_test.go new file mode 100644 index 00000000000..86b819299ed --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxapikey/id_apikey_test.go @@ -0,0 +1,327 @@ +package nginxapikey + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ApiKeyId{} + +func TestNewApiKeyID(t *testing.T) { + id := NewApiKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "nginxDeploymentName", "apiKeyName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NginxDeploymentName != "nginxDeploymentName" { + t.Fatalf("Expected %q but got %q for Segment 'NginxDeploymentName'", id.NginxDeploymentName, "nginxDeploymentName") + } + + if id.ApiKeyName != "apiKeyName" { + t.Fatalf("Expected %q but got %q for Segment 'ApiKeyName'", id.ApiKeyName, "apiKeyName") + } +} + +func TestFormatApiKeyID(t *testing.T) { + actual := NewApiKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "nginxDeploymentName", "apiKeyName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName/apiKeys/apiKeyName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseApiKeyID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ApiKeyId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName/apiKeys", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName/apiKeys/apiKeyName", + Expected: &ApiKeyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NginxDeploymentName: "nginxDeploymentName", + ApiKeyName: "apiKeyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName/apiKeys/apiKeyName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseApiKeyID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NginxDeploymentName != v.Expected.NginxDeploymentName { + t.Fatalf("Expected %q but got %q for NginxDeploymentName", v.Expected.NginxDeploymentName, actual.NginxDeploymentName) + } + + if actual.ApiKeyName != v.Expected.ApiKeyName { + t.Fatalf("Expected %q but got %q for ApiKeyName", v.Expected.ApiKeyName, actual.ApiKeyName) + } + + } +} + +func TestParseApiKeyIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ApiKeyId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/nGiNx.nGiNxPlUs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/nGiNx.nGiNxPlUs/nGiNxDePlOyMeNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/nGiNx.nGiNxPlUs/nGiNxDePlOyMeNtS/nGiNxDePlOyMeNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName/apiKeys", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/nGiNx.nGiNxPlUs/nGiNxDePlOyMeNtS/nGiNxDePlOyMeNtNaMe/aPiKeYs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName/apiKeys/apiKeyName", + Expected: &ApiKeyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NginxDeploymentName: "nginxDeploymentName", + ApiKeyName: "apiKeyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName/apiKeys/apiKeyName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/nGiNx.nGiNxPlUs/nGiNxDePlOyMeNtS/nGiNxDePlOyMeNtNaMe/aPiKeYs/aPiKeYnAmE", + Expected: &ApiKeyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NginxDeploymentName: "nGiNxDePlOyMeNtNaMe", + ApiKeyName: "aPiKeYnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/nGiNx.nGiNxPlUs/nGiNxDePlOyMeNtS/nGiNxDePlOyMeNtNaMe/aPiKeYs/aPiKeYnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseApiKeyIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NginxDeploymentName != v.Expected.NginxDeploymentName { + t.Fatalf("Expected %q but got %q for NginxDeploymentName", v.Expected.NginxDeploymentName, actual.NginxDeploymentName) + } + + if actual.ApiKeyName != v.Expected.ApiKeyName { + t.Fatalf("Expected %q but got %q for ApiKeyName", v.Expected.ApiKeyName, actual.ApiKeyName) + } + + } +} + +func TestSegmentsForApiKeyId(t *testing.T) { + segments := ApiKeyId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ApiKeyId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxapikey/id_nginxdeployment.go b/resource-manager/nginx/2024-09-01-preview/nginxapikey/id_nginxdeployment.go new file mode 100644 index 00000000000..939b40cd353 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxapikey/id_nginxdeployment.go @@ -0,0 +1,130 @@ +package nginxapikey + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NginxDeploymentId{}) +} + +var _ resourceids.ResourceId = &NginxDeploymentId{} + +// NginxDeploymentId is a struct representing the Resource ID for a Nginx Deployment +type NginxDeploymentId struct { + SubscriptionId string + ResourceGroupName string + NginxDeploymentName string +} + +// NewNginxDeploymentID returns a new NginxDeploymentId struct +func NewNginxDeploymentID(subscriptionId string, resourceGroupName string, nginxDeploymentName string) NginxDeploymentId { + return NginxDeploymentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NginxDeploymentName: nginxDeploymentName, + } +} + +// ParseNginxDeploymentID parses 'input' into a NginxDeploymentId +func ParseNginxDeploymentID(input string) (*NginxDeploymentId, error) { + parser := resourceids.NewParserFromResourceIdType(&NginxDeploymentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NginxDeploymentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNginxDeploymentIDInsensitively parses 'input' case-insensitively into a NginxDeploymentId +// note: this method should only be used for API response data and not user input +func ParseNginxDeploymentIDInsensitively(input string) (*NginxDeploymentId, error) { + parser := resourceids.NewParserFromResourceIdType(&NginxDeploymentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NginxDeploymentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NginxDeploymentId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NginxDeploymentName, ok = input.Parsed["nginxDeploymentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "nginxDeploymentName", input) + } + + return nil +} + +// ValidateNginxDeploymentID checks that 'input' can be parsed as a Nginx Deployment ID +func ValidateNginxDeploymentID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNginxDeploymentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Nginx Deployment ID +func (id NginxDeploymentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Nginx.NginxPlus/nginxDeployments/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NginxDeploymentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Nginx Deployment ID +func (id NginxDeploymentId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticNginxNginxPlus", "Nginx.NginxPlus", "Nginx.NginxPlus"), + resourceids.StaticSegment("staticNginxDeployments", "nginxDeployments", "nginxDeployments"), + resourceids.UserSpecifiedSegment("nginxDeploymentName", "nginxDeploymentName"), + } +} + +// String returns a human-readable description of this Nginx Deployment ID +func (id NginxDeploymentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Nginx Deployment Name: %q", id.NginxDeploymentName), + } + return fmt.Sprintf("Nginx Deployment (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxapikey/id_nginxdeployment_test.go b/resource-manager/nginx/2024-09-01-preview/nginxapikey/id_nginxdeployment_test.go new file mode 100644 index 00000000000..dff2f0aac8a --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxapikey/id_nginxdeployment_test.go @@ -0,0 +1,282 @@ +package nginxapikey + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NginxDeploymentId{} + +func TestNewNginxDeploymentID(t *testing.T) { + id := NewNginxDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "nginxDeploymentName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NginxDeploymentName != "nginxDeploymentName" { + t.Fatalf("Expected %q but got %q for Segment 'NginxDeploymentName'", id.NginxDeploymentName, "nginxDeploymentName") + } +} + +func TestFormatNginxDeploymentID(t *testing.T) { + actual := NewNginxDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "nginxDeploymentName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNginxDeploymentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NginxDeploymentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName", + Expected: &NginxDeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NginxDeploymentName: "nginxDeploymentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNginxDeploymentID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NginxDeploymentName != v.Expected.NginxDeploymentName { + t.Fatalf("Expected %q but got %q for NginxDeploymentName", v.Expected.NginxDeploymentName, actual.NginxDeploymentName) + } + + } +} + +func TestParseNginxDeploymentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NginxDeploymentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/nGiNx.nGiNxPlUs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/nGiNx.nGiNxPlUs/nGiNxDePlOyMeNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName", + Expected: &NginxDeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NginxDeploymentName: "nginxDeploymentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/nGiNx.nGiNxPlUs/nGiNxDePlOyMeNtS/nGiNxDePlOyMeNtNaMe", + Expected: &NginxDeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NginxDeploymentName: "nGiNxDePlOyMeNtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/nGiNx.nGiNxPlUs/nGiNxDePlOyMeNtS/nGiNxDePlOyMeNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNginxDeploymentIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NginxDeploymentName != v.Expected.NginxDeploymentName { + t.Fatalf("Expected %q but got %q for NginxDeploymentName", v.Expected.NginxDeploymentName, actual.NginxDeploymentName) + } + + } +} + +func TestSegmentsForNginxDeploymentId(t *testing.T) { + segments := NginxDeploymentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NginxDeploymentId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxapikey/method_apikeyscreateorupdate.go b/resource-manager/nginx/2024-09-01-preview/nginxapikey/method_apikeyscreateorupdate.go new file mode 100644 index 00000000000..6ef1ef53dd8 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxapikey/method_apikeyscreateorupdate.go @@ -0,0 +1,58 @@ +package nginxapikey + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApiKeysCreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NginxDeploymentApiKeyResponse +} + +// ApiKeysCreateOrUpdate ... +func (c NginxApiKeyClient) ApiKeysCreateOrUpdate(ctx context.Context, id ApiKeyId, input NginxDeploymentApiKeyRequest) (result ApiKeysCreateOrUpdateOperationResponse, 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 NginxDeploymentApiKeyResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxapikey/method_apikeysdelete.go b/resource-manager/nginx/2024-09-01-preview/nginxapikey/method_apikeysdelete.go new file mode 100644 index 00000000000..94a964d5e1f --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxapikey/method_apikeysdelete.go @@ -0,0 +1,47 @@ +package nginxapikey + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApiKeysDeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ApiKeysDelete ... +func (c NginxApiKeyClient) ApiKeysDelete(ctx context.Context, id ApiKeyId) (result ApiKeysDeleteOperationResponse, 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/nginx/2024-09-01-preview/nginxapikey/method_apikeysget.go b/resource-manager/nginx/2024-09-01-preview/nginxapikey/method_apikeysget.go new file mode 100644 index 00000000000..86468339333 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxapikey/method_apikeysget.go @@ -0,0 +1,53 @@ +package nginxapikey + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApiKeysGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NginxDeploymentApiKeyResponse +} + +// ApiKeysGet ... +func (c NginxApiKeyClient) ApiKeysGet(ctx context.Context, id ApiKeyId) (result ApiKeysGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NginxDeploymentApiKeyResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxapikey/method_apikeyslist.go b/resource-manager/nginx/2024-09-01-preview/nginxapikey/method_apikeyslist.go new file mode 100644 index 00000000000..605ef0c05f4 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxapikey/method_apikeyslist.go @@ -0,0 +1,105 @@ +package nginxapikey + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApiKeysListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NginxDeploymentApiKeyResponse +} + +type ApiKeysListCompleteResult struct { + LatestHttpResponse *http.Response + Items []NginxDeploymentApiKeyResponse +} + +type ApiKeysListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ApiKeysListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ApiKeysList ... +func (c NginxApiKeyClient) ApiKeysList(ctx context.Context, id NginxDeploymentId) (result ApiKeysListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ApiKeysListCustomPager{}, + Path: fmt.Sprintf("%s/apiKeys", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NginxDeploymentApiKeyResponse `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ApiKeysListComplete retrieves all the results into a single object +func (c NginxApiKeyClient) ApiKeysListComplete(ctx context.Context, id NginxDeploymentId) (ApiKeysListCompleteResult, error) { + return c.ApiKeysListCompleteMatchingPredicate(ctx, id, NginxDeploymentApiKeyResponseOperationPredicate{}) +} + +// ApiKeysListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NginxApiKeyClient) ApiKeysListCompleteMatchingPredicate(ctx context.Context, id NginxDeploymentId, predicate NginxDeploymentApiKeyResponseOperationPredicate) (result ApiKeysListCompleteResult, err error) { + items := make([]NginxDeploymentApiKeyResponse, 0) + + resp, err := c.ApiKeysList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ApiKeysListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxapikey/model_nginxdeploymentapikeyrequest.go b/resource-manager/nginx/2024-09-01-preview/nginxapikey/model_nginxdeploymentapikeyrequest.go new file mode 100644 index 00000000000..f6ed5124da5 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxapikey/model_nginxdeploymentapikeyrequest.go @@ -0,0 +1,11 @@ +package nginxapikey + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NginxDeploymentApiKeyRequest struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NginxDeploymentApiKeyRequestProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxapikey/model_nginxdeploymentapikeyrequestproperties.go b/resource-manager/nginx/2024-09-01-preview/nginxapikey/model_nginxdeploymentapikeyrequestproperties.go new file mode 100644 index 00000000000..b731c4ed7cb --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxapikey/model_nginxdeploymentapikeyrequestproperties.go @@ -0,0 +1,27 @@ +package nginxapikey + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NginxDeploymentApiKeyRequestProperties struct { + EndDateTime *string `json:"endDateTime,omitempty"` + SecretText *string `json:"secretText,omitempty"` +} + +func (o *NginxDeploymentApiKeyRequestProperties) GetEndDateTimeAsTime() (*time.Time, error) { + if o.EndDateTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndDateTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *NginxDeploymentApiKeyRequestProperties) SetEndDateTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndDateTime = &formatted +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxapikey/model_nginxdeploymentapikeyresponse.go b/resource-manager/nginx/2024-09-01-preview/nginxapikey/model_nginxdeploymentapikeyresponse.go new file mode 100644 index 00000000000..d09829a5583 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxapikey/model_nginxdeploymentapikeyresponse.go @@ -0,0 +1,11 @@ +package nginxapikey + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NginxDeploymentApiKeyResponse struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NginxDeploymentApiKeyResponseProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxapikey/model_nginxdeploymentapikeyresponseproperties.go b/resource-manager/nginx/2024-09-01-preview/nginxapikey/model_nginxdeploymentapikeyresponseproperties.go new file mode 100644 index 00000000000..3ffa73e1748 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxapikey/model_nginxdeploymentapikeyresponseproperties.go @@ -0,0 +1,27 @@ +package nginxapikey + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NginxDeploymentApiKeyResponseProperties struct { + EndDateTime *string `json:"endDateTime,omitempty"` + Hint *string `json:"hint,omitempty"` +} + +func (o *NginxDeploymentApiKeyResponseProperties) GetEndDateTimeAsTime() (*time.Time, error) { + if o.EndDateTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndDateTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *NginxDeploymentApiKeyResponseProperties) SetEndDateTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndDateTime = &formatted +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxapikey/predicates.go b/resource-manager/nginx/2024-09-01-preview/nginxapikey/predicates.go new file mode 100644 index 00000000000..c7e879faa2c --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxapikey/predicates.go @@ -0,0 +1,27 @@ +package nginxapikey + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NginxDeploymentApiKeyResponseOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p NginxDeploymentApiKeyResponseOperationPredicate) Matches(input NginxDeploymentApiKeyResponse) 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/nginx/2024-09-01-preview/nginxapikey/version.go b/resource-manager/nginx/2024-09-01-preview/nginxapikey/version.go new file mode 100644 index 00000000000..4cf3a17d466 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxapikey/version.go @@ -0,0 +1,10 @@ +package nginxapikey + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/nginxapikey/2024-09-01-preview" +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxcertificate/README.md b/resource-manager/nginx/2024-09-01-preview/nginxcertificate/README.md new file mode 100644 index 00000000000..ebbe404e022 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxcertificate/README.md @@ -0,0 +1,82 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/nginx/2024-09-01-preview/nginxcertificate` Documentation + +The `nginxcertificate` SDK allows for interaction with Azure Resource Manager `nginx` (API Version `2024-09-01-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/nginx/2024-09-01-preview/nginxcertificate" +``` + + +### Client Initialization + +```go +client := nginxcertificate.NewNginxCertificateClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `NginxCertificateClient.CertificatesCreateOrUpdate` + +```go +ctx := context.TODO() +id := nginxcertificate.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "nginxDeploymentName", "certificateName") + +payload := nginxcertificate.NginxCertificate{ + // ... +} + + +if err := client.CertificatesCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NginxCertificateClient.CertificatesDelete` + +```go +ctx := context.TODO() +id := nginxcertificate.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "nginxDeploymentName", "certificateName") + +if err := client.CertificatesDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NginxCertificateClient.CertificatesGet` + +```go +ctx := context.TODO() +id := nginxcertificate.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "nginxDeploymentName", "certificateName") + +read, err := client.CertificatesGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NginxCertificateClient.CertificatesList` + +```go +ctx := context.TODO() +id := nginxcertificate.NewNginxDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "nginxDeploymentName") + +// alternatively `client.CertificatesList(ctx, id)` can be used to do batched pagination +items, err := client.CertificatesListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/nginx/2024-09-01-preview/nginxcertificate/client.go b/resource-manager/nginx/2024-09-01-preview/nginxcertificate/client.go new file mode 100644 index 00000000000..336c79aab81 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxcertificate/client.go @@ -0,0 +1,26 @@ +package nginxcertificate + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NginxCertificateClient struct { + Client *resourcemanager.Client +} + +func NewNginxCertificateClientWithBaseURI(sdkApi sdkEnv.Api) (*NginxCertificateClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "nginxcertificate", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NginxCertificateClient: %+v", err) + } + + return &NginxCertificateClient{ + Client: client, + }, nil +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxcertificate/constants.go b/resource-manager/nginx/2024-09-01-preview/nginxcertificate/constants.go new file mode 100644 index 00000000000..5cea630d9fe --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxcertificate/constants.go @@ -0,0 +1,72 @@ +package nginxcertificate + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateNotSpecified ProvisioningState = "NotSpecified" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleted), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateNotSpecified), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, + "deleted": ProvisioningStateDeleted, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "notspecified": ProvisioningStateNotSpecified, + "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/nginx/2024-09-01-preview/nginxcertificate/id_certificate.go b/resource-manager/nginx/2024-09-01-preview/nginxcertificate/id_certificate.go new file mode 100644 index 00000000000..2e67036475e --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxcertificate/id_certificate.go @@ -0,0 +1,139 @@ +package nginxcertificate + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) 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 + NginxDeploymentName string + CertificateName string +} + +// NewCertificateID returns a new CertificateId struct +func NewCertificateID(subscriptionId string, resourceGroupName string, nginxDeploymentName string, certificateName string) CertificateId { + return CertificateId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NginxDeploymentName: nginxDeploymentName, + 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.NginxDeploymentName, ok = input.Parsed["nginxDeploymentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "nginxDeploymentName", 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/Nginx.NginxPlus/nginxDeployments/%s/certificates/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NginxDeploymentName, 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("staticNginxNginxPlus", "Nginx.NginxPlus", "Nginx.NginxPlus"), + resourceids.StaticSegment("staticNginxDeployments", "nginxDeployments", "nginxDeployments"), + resourceids.UserSpecifiedSegment("nginxDeploymentName", "nginxDeploymentName"), + 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("Nginx Deployment Name: %q", id.NginxDeploymentName), + fmt.Sprintf("Certificate Name: %q", id.CertificateName), + } + return fmt.Sprintf("Certificate (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxcertificate/id_certificate_test.go b/resource-manager/nginx/2024-09-01-preview/nginxcertificate/id_certificate_test.go new file mode 100644 index 00000000000..6c6efd96508 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxcertificate/id_certificate_test.go @@ -0,0 +1,327 @@ +package nginxcertificate + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (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", "nginxDeploymentName", "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.NginxDeploymentName != "nginxDeploymentName" { + t.Fatalf("Expected %q but got %q for Segment 'NginxDeploymentName'", id.NginxDeploymentName, "nginxDeploymentName") + } + + 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", "nginxDeploymentName", "certificateName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName/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/Nginx.NginxPlus", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName/certificates", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName/certificates/certificateName", + Expected: &CertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NginxDeploymentName: "nginxDeploymentName", + CertificateName: "certificateName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName/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.NginxDeploymentName != v.Expected.NginxDeploymentName { + t.Fatalf("Expected %q but got %q for NginxDeploymentName", v.Expected.NginxDeploymentName, actual.NginxDeploymentName) + } + + 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/Nginx.NginxPlus", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/nGiNx.nGiNxPlUs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/nGiNx.nGiNxPlUs/nGiNxDePlOyMeNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/nGiNx.nGiNxPlUs/nGiNxDePlOyMeNtS/nGiNxDePlOyMeNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName/certificates", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/nGiNx.nGiNxPlUs/nGiNxDePlOyMeNtS/nGiNxDePlOyMeNtNaMe/cErTiFiCaTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName/certificates/certificateName", + Expected: &CertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NginxDeploymentName: "nginxDeploymentName", + CertificateName: "certificateName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName/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/nGiNx.nGiNxPlUs/nGiNxDePlOyMeNtS/nGiNxDePlOyMeNtNaMe/cErTiFiCaTeS/cErTiFiCaTeNaMe", + Expected: &CertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NginxDeploymentName: "nGiNxDePlOyMeNtNaMe", + 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/nGiNx.nGiNxPlUs/nGiNxDePlOyMeNtS/nGiNxDePlOyMeNtNaMe/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.NginxDeploymentName != v.Expected.NginxDeploymentName { + t.Fatalf("Expected %q but got %q for NginxDeploymentName", v.Expected.NginxDeploymentName, actual.NginxDeploymentName) + } + + 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/nginx/2024-09-01-preview/nginxcertificate/id_nginxdeployment.go b/resource-manager/nginx/2024-09-01-preview/nginxcertificate/id_nginxdeployment.go new file mode 100644 index 00000000000..1fcb78071af --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxcertificate/id_nginxdeployment.go @@ -0,0 +1,130 @@ +package nginxcertificate + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NginxDeploymentId{}) +} + +var _ resourceids.ResourceId = &NginxDeploymentId{} + +// NginxDeploymentId is a struct representing the Resource ID for a Nginx Deployment +type NginxDeploymentId struct { + SubscriptionId string + ResourceGroupName string + NginxDeploymentName string +} + +// NewNginxDeploymentID returns a new NginxDeploymentId struct +func NewNginxDeploymentID(subscriptionId string, resourceGroupName string, nginxDeploymentName string) NginxDeploymentId { + return NginxDeploymentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NginxDeploymentName: nginxDeploymentName, + } +} + +// ParseNginxDeploymentID parses 'input' into a NginxDeploymentId +func ParseNginxDeploymentID(input string) (*NginxDeploymentId, error) { + parser := resourceids.NewParserFromResourceIdType(&NginxDeploymentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NginxDeploymentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNginxDeploymentIDInsensitively parses 'input' case-insensitively into a NginxDeploymentId +// note: this method should only be used for API response data and not user input +func ParseNginxDeploymentIDInsensitively(input string) (*NginxDeploymentId, error) { + parser := resourceids.NewParserFromResourceIdType(&NginxDeploymentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NginxDeploymentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NginxDeploymentId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NginxDeploymentName, ok = input.Parsed["nginxDeploymentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "nginxDeploymentName", input) + } + + return nil +} + +// ValidateNginxDeploymentID checks that 'input' can be parsed as a Nginx Deployment ID +func ValidateNginxDeploymentID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNginxDeploymentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Nginx Deployment ID +func (id NginxDeploymentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Nginx.NginxPlus/nginxDeployments/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NginxDeploymentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Nginx Deployment ID +func (id NginxDeploymentId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticNginxNginxPlus", "Nginx.NginxPlus", "Nginx.NginxPlus"), + resourceids.StaticSegment("staticNginxDeployments", "nginxDeployments", "nginxDeployments"), + resourceids.UserSpecifiedSegment("nginxDeploymentName", "nginxDeploymentName"), + } +} + +// String returns a human-readable description of this Nginx Deployment ID +func (id NginxDeploymentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Nginx Deployment Name: %q", id.NginxDeploymentName), + } + return fmt.Sprintf("Nginx Deployment (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxcertificate/id_nginxdeployment_test.go b/resource-manager/nginx/2024-09-01-preview/nginxcertificate/id_nginxdeployment_test.go new file mode 100644 index 00000000000..25d1659324d --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxcertificate/id_nginxdeployment_test.go @@ -0,0 +1,282 @@ +package nginxcertificate + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NginxDeploymentId{} + +func TestNewNginxDeploymentID(t *testing.T) { + id := NewNginxDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "nginxDeploymentName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NginxDeploymentName != "nginxDeploymentName" { + t.Fatalf("Expected %q but got %q for Segment 'NginxDeploymentName'", id.NginxDeploymentName, "nginxDeploymentName") + } +} + +func TestFormatNginxDeploymentID(t *testing.T) { + actual := NewNginxDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "nginxDeploymentName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNginxDeploymentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NginxDeploymentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName", + Expected: &NginxDeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NginxDeploymentName: "nginxDeploymentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNginxDeploymentID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NginxDeploymentName != v.Expected.NginxDeploymentName { + t.Fatalf("Expected %q but got %q for NginxDeploymentName", v.Expected.NginxDeploymentName, actual.NginxDeploymentName) + } + + } +} + +func TestParseNginxDeploymentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NginxDeploymentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/nGiNx.nGiNxPlUs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/nGiNx.nGiNxPlUs/nGiNxDePlOyMeNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName", + Expected: &NginxDeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NginxDeploymentName: "nginxDeploymentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/nGiNx.nGiNxPlUs/nGiNxDePlOyMeNtS/nGiNxDePlOyMeNtNaMe", + Expected: &NginxDeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NginxDeploymentName: "nGiNxDePlOyMeNtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/nGiNx.nGiNxPlUs/nGiNxDePlOyMeNtS/nGiNxDePlOyMeNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNginxDeploymentIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NginxDeploymentName != v.Expected.NginxDeploymentName { + t.Fatalf("Expected %q but got %q for NginxDeploymentName", v.Expected.NginxDeploymentName, actual.NginxDeploymentName) + } + + } +} + +func TestSegmentsForNginxDeploymentId(t *testing.T) { + segments := NginxDeploymentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NginxDeploymentId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxcertificate/method_certificatescreateorupdate.go b/resource-manager/nginx/2024-09-01-preview/nginxcertificate/method_certificatescreateorupdate.go new file mode 100644 index 00000000000..2a7b5830e86 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxcertificate/method_certificatescreateorupdate.go @@ -0,0 +1,75 @@ +package nginxcertificate + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificatesCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *NginxCertificate +} + +// CertificatesCreateOrUpdate ... +func (c NginxCertificateClient) CertificatesCreateOrUpdate(ctx context.Context, id CertificateId, input NginxCertificate) (result CertificatesCreateOrUpdateOperationResponse, 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 +} + +// CertificatesCreateOrUpdateThenPoll performs CertificatesCreateOrUpdate then polls until it's completed +func (c NginxCertificateClient) CertificatesCreateOrUpdateThenPoll(ctx context.Context, id CertificateId, input NginxCertificate) error { + result, err := c.CertificatesCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CertificatesCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CertificatesCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxcertificate/method_certificatesdelete.go b/resource-manager/nginx/2024-09-01-preview/nginxcertificate/method_certificatesdelete.go new file mode 100644 index 00000000000..2e68fad4bb8 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxcertificate/method_certificatesdelete.go @@ -0,0 +1,71 @@ +package nginxcertificate + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificatesDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CertificatesDelete ... +func (c NginxCertificateClient) CertificatesDelete(ctx context.Context, id CertificateId) (result CertificatesDeleteOperationResponse, 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 +} + +// CertificatesDeleteThenPoll performs CertificatesDelete then polls until it's completed +func (c NginxCertificateClient) CertificatesDeleteThenPoll(ctx context.Context, id CertificateId) error { + result, err := c.CertificatesDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing CertificatesDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CertificatesDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxcertificate/method_certificatesget.go b/resource-manager/nginx/2024-09-01-preview/nginxcertificate/method_certificatesget.go new file mode 100644 index 00000000000..eda3885e158 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxcertificate/method_certificatesget.go @@ -0,0 +1,53 @@ +package nginxcertificate + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificatesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NginxCertificate +} + +// CertificatesGet ... +func (c NginxCertificateClient) CertificatesGet(ctx context.Context, id CertificateId) (result CertificatesGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NginxCertificate + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxcertificate/method_certificateslist.go b/resource-manager/nginx/2024-09-01-preview/nginxcertificate/method_certificateslist.go new file mode 100644 index 00000000000..759cf53eb4f --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxcertificate/method_certificateslist.go @@ -0,0 +1,105 @@ +package nginxcertificate + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificatesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NginxCertificate +} + +type CertificatesListCompleteResult struct { + LatestHttpResponse *http.Response + Items []NginxCertificate +} + +type CertificatesListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *CertificatesListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// CertificatesList ... +func (c NginxCertificateClient) CertificatesList(ctx context.Context, id NginxDeploymentId) (result CertificatesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &CertificatesListCustomPager{}, + 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 *[]NginxCertificate `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// CertificatesListComplete retrieves all the results into a single object +func (c NginxCertificateClient) CertificatesListComplete(ctx context.Context, id NginxDeploymentId) (CertificatesListCompleteResult, error) { + return c.CertificatesListCompleteMatchingPredicate(ctx, id, NginxCertificateOperationPredicate{}) +} + +// CertificatesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NginxCertificateClient) CertificatesListCompleteMatchingPredicate(ctx context.Context, id NginxDeploymentId, predicate NginxCertificateOperationPredicate) (result CertificatesListCompleteResult, err error) { + items := make([]NginxCertificate, 0) + + resp, err := c.CertificatesList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = CertificatesListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxcertificate/model_nginxcertificate.go b/resource-manager/nginx/2024-09-01-preview/nginxcertificate/model_nginxcertificate.go new file mode 100644 index 00000000000..0a59d6e6aee --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxcertificate/model_nginxcertificate.go @@ -0,0 +1,17 @@ +package nginxcertificate + +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 NginxCertificate struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NginxCertificateProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxcertificate/model_nginxcertificateerrorresponsebody.go b/resource-manager/nginx/2024-09-01-preview/nginxcertificate/model_nginxcertificateerrorresponsebody.go new file mode 100644 index 00000000000..2244c48f5dd --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxcertificate/model_nginxcertificateerrorresponsebody.go @@ -0,0 +1,9 @@ +package nginxcertificate + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NginxCertificateErrorResponseBody struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxcertificate/model_nginxcertificateproperties.go b/resource-manager/nginx/2024-09-01-preview/nginxcertificate/model_nginxcertificateproperties.go new file mode 100644 index 00000000000..41bbb8a097a --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxcertificate/model_nginxcertificateproperties.go @@ -0,0 +1,33 @@ +package nginxcertificate + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NginxCertificateProperties struct { + CertificateError *NginxCertificateErrorResponseBody `json:"certificateError,omitempty"` + CertificateVirtualPath *string `json:"certificateVirtualPath,omitempty"` + KeyVaultSecretCreated *string `json:"keyVaultSecretCreated,omitempty"` + KeyVaultSecretId *string `json:"keyVaultSecretId,omitempty"` + KeyVaultSecretVersion *string `json:"keyVaultSecretVersion,omitempty"` + KeyVirtualPath *string `json:"keyVirtualPath,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Sha1Thumbprint *string `json:"sha1Thumbprint,omitempty"` +} + +func (o *NginxCertificateProperties) GetKeyVaultSecretCreatedAsTime() (*time.Time, error) { + if o.KeyVaultSecretCreated == nil { + return nil, nil + } + return dates.ParseAsFormat(o.KeyVaultSecretCreated, "2006-01-02T15:04:05Z07:00") +} + +func (o *NginxCertificateProperties) SetKeyVaultSecretCreatedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.KeyVaultSecretCreated = &formatted +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxcertificate/predicates.go b/resource-manager/nginx/2024-09-01-preview/nginxcertificate/predicates.go new file mode 100644 index 00000000000..b01a724d879 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxcertificate/predicates.go @@ -0,0 +1,32 @@ +package nginxcertificate + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NginxCertificateOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p NginxCertificateOperationPredicate) Matches(input NginxCertificate) 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/nginx/2024-09-01-preview/nginxcertificate/version.go b/resource-manager/nginx/2024-09-01-preview/nginxcertificate/version.go new file mode 100644 index 00000000000..30f26213b28 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxcertificate/version.go @@ -0,0 +1,10 @@ +package nginxcertificate + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/nginxcertificate/2024-09-01-preview" +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/README.md b/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/README.md new file mode 100644 index 00000000000..4d864a70f1f --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/README.md @@ -0,0 +1,82 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/nginx/2024-09-01-preview/nginxconfiguration` Documentation + +The `nginxconfiguration` SDK allows for interaction with Azure Resource Manager `nginx` (API Version `2024-09-01-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/nginx/2024-09-01-preview/nginxconfiguration" +``` + + +### Client Initialization + +```go +client := nginxconfiguration.NewNginxConfigurationClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `NginxConfigurationClient.ConfigurationsCreateOrUpdate` + +```go +ctx := context.TODO() +id := nginxconfiguration.NewConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "nginxDeploymentName", "configurationName") + +payload := nginxconfiguration.NginxConfigurationRequest{ + // ... +} + + +if err := client.ConfigurationsCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NginxConfigurationClient.ConfigurationsDelete` + +```go +ctx := context.TODO() +id := nginxconfiguration.NewConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "nginxDeploymentName", "configurationName") + +if err := client.ConfigurationsDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NginxConfigurationClient.ConfigurationsGet` + +```go +ctx := context.TODO() +id := nginxconfiguration.NewConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "nginxDeploymentName", "configurationName") + +read, err := client.ConfigurationsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NginxConfigurationClient.ConfigurationsList` + +```go +ctx := context.TODO() +id := nginxconfiguration.NewNginxDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "nginxDeploymentName") + +// alternatively `client.ConfigurationsList(ctx, id)` can be used to do batched pagination +items, err := client.ConfigurationsListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/client.go b/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/client.go new file mode 100644 index 00000000000..4b271604186 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/client.go @@ -0,0 +1,26 @@ +package nginxconfiguration + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NginxConfigurationClient struct { + Client *resourcemanager.Client +} + +func NewNginxConfigurationClientWithBaseURI(sdkApi sdkEnv.Api) (*NginxConfigurationClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "nginxconfiguration", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NginxConfigurationClient: %+v", err) + } + + return &NginxConfigurationClient{ + Client: client, + }, nil +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/constants.go b/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/constants.go new file mode 100644 index 00000000000..9abf4d96b6b --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/constants.go @@ -0,0 +1,72 @@ +package nginxconfiguration + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateNotSpecified ProvisioningState = "NotSpecified" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleted), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateNotSpecified), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, + "deleted": ProvisioningStateDeleted, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "notspecified": ProvisioningStateNotSpecified, + "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/nginx/2024-09-01-preview/nginxconfiguration/id_configuration.go b/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/id_configuration.go new file mode 100644 index 00000000000..5b815b38c18 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/id_configuration.go @@ -0,0 +1,139 @@ +package nginxconfiguration + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ConfigurationId{}) +} + +var _ resourceids.ResourceId = &ConfigurationId{} + +// ConfigurationId is a struct representing the Resource ID for a Configuration +type ConfigurationId struct { + SubscriptionId string + ResourceGroupName string + NginxDeploymentName string + ConfigurationName string +} + +// NewConfigurationID returns a new ConfigurationId struct +func NewConfigurationID(subscriptionId string, resourceGroupName string, nginxDeploymentName string, configurationName string) ConfigurationId { + return ConfigurationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NginxDeploymentName: nginxDeploymentName, + ConfigurationName: configurationName, + } +} + +// ParseConfigurationID parses 'input' into a ConfigurationId +func ParseConfigurationID(input string) (*ConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConfigurationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConfigurationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseConfigurationIDInsensitively parses 'input' case-insensitively into a ConfigurationId +// note: this method should only be used for API response data and not user input +func ParseConfigurationIDInsensitively(input string) (*ConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConfigurationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConfigurationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ConfigurationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NginxDeploymentName, ok = input.Parsed["nginxDeploymentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "nginxDeploymentName", input) + } + + if id.ConfigurationName, ok = input.Parsed["configurationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "configurationName", input) + } + + return nil +} + +// ValidateConfigurationID checks that 'input' can be parsed as a Configuration ID +func ValidateConfigurationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseConfigurationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Configuration ID +func (id ConfigurationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Nginx.NginxPlus/nginxDeployments/%s/configurations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NginxDeploymentName, id.ConfigurationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Configuration ID +func (id ConfigurationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticNginxNginxPlus", "Nginx.NginxPlus", "Nginx.NginxPlus"), + resourceids.StaticSegment("staticNginxDeployments", "nginxDeployments", "nginxDeployments"), + resourceids.UserSpecifiedSegment("nginxDeploymentName", "nginxDeploymentName"), + resourceids.StaticSegment("staticConfigurations", "configurations", "configurations"), + resourceids.UserSpecifiedSegment("configurationName", "configurationName"), + } +} + +// String returns a human-readable description of this Configuration ID +func (id ConfigurationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Nginx Deployment Name: %q", id.NginxDeploymentName), + fmt.Sprintf("Configuration Name: %q", id.ConfigurationName), + } + return fmt.Sprintf("Configuration (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/id_configuration_test.go b/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/id_configuration_test.go new file mode 100644 index 00000000000..ae67bf963aa --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/id_configuration_test.go @@ -0,0 +1,327 @@ +package nginxconfiguration + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ConfigurationId{} + +func TestNewConfigurationID(t *testing.T) { + id := NewConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "nginxDeploymentName", "configurationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NginxDeploymentName != "nginxDeploymentName" { + t.Fatalf("Expected %q but got %q for Segment 'NginxDeploymentName'", id.NginxDeploymentName, "nginxDeploymentName") + } + + if id.ConfigurationName != "configurationName" { + t.Fatalf("Expected %q but got %q for Segment 'ConfigurationName'", id.ConfigurationName, "configurationName") + } +} + +func TestFormatConfigurationID(t *testing.T) { + actual := NewConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "nginxDeploymentName", "configurationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName/configurations/configurationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseConfigurationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConfigurationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName/configurations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName/configurations/configurationName", + Expected: &ConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NginxDeploymentName: "nginxDeploymentName", + ConfigurationName: "configurationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName/configurations/configurationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConfigurationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NginxDeploymentName != v.Expected.NginxDeploymentName { + t.Fatalf("Expected %q but got %q for NginxDeploymentName", v.Expected.NginxDeploymentName, actual.NginxDeploymentName) + } + + if actual.ConfigurationName != v.Expected.ConfigurationName { + t.Fatalf("Expected %q but got %q for ConfigurationName", v.Expected.ConfigurationName, actual.ConfigurationName) + } + + } +} + +func TestParseConfigurationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConfigurationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/nGiNx.nGiNxPlUs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/nGiNx.nGiNxPlUs/nGiNxDePlOyMeNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/nGiNx.nGiNxPlUs/nGiNxDePlOyMeNtS/nGiNxDePlOyMeNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName/configurations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/nGiNx.nGiNxPlUs/nGiNxDePlOyMeNtS/nGiNxDePlOyMeNtNaMe/cOnFiGuRaTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName/configurations/configurationName", + Expected: &ConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NginxDeploymentName: "nginxDeploymentName", + ConfigurationName: "configurationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName/configurations/configurationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/nGiNx.nGiNxPlUs/nGiNxDePlOyMeNtS/nGiNxDePlOyMeNtNaMe/cOnFiGuRaTiOnS/cOnFiGuRaTiOnNaMe", + Expected: &ConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NginxDeploymentName: "nGiNxDePlOyMeNtNaMe", + ConfigurationName: "cOnFiGuRaTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/nGiNx.nGiNxPlUs/nGiNxDePlOyMeNtS/nGiNxDePlOyMeNtNaMe/cOnFiGuRaTiOnS/cOnFiGuRaTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConfigurationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NginxDeploymentName != v.Expected.NginxDeploymentName { + t.Fatalf("Expected %q but got %q for NginxDeploymentName", v.Expected.NginxDeploymentName, actual.NginxDeploymentName) + } + + if actual.ConfigurationName != v.Expected.ConfigurationName { + t.Fatalf("Expected %q but got %q for ConfigurationName", v.Expected.ConfigurationName, actual.ConfigurationName) + } + + } +} + +func TestSegmentsForConfigurationId(t *testing.T) { + segments := ConfigurationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ConfigurationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/id_nginxdeployment.go b/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/id_nginxdeployment.go new file mode 100644 index 00000000000..a9894b6e912 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/id_nginxdeployment.go @@ -0,0 +1,130 @@ +package nginxconfiguration + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NginxDeploymentId{}) +} + +var _ resourceids.ResourceId = &NginxDeploymentId{} + +// NginxDeploymentId is a struct representing the Resource ID for a Nginx Deployment +type NginxDeploymentId struct { + SubscriptionId string + ResourceGroupName string + NginxDeploymentName string +} + +// NewNginxDeploymentID returns a new NginxDeploymentId struct +func NewNginxDeploymentID(subscriptionId string, resourceGroupName string, nginxDeploymentName string) NginxDeploymentId { + return NginxDeploymentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NginxDeploymentName: nginxDeploymentName, + } +} + +// ParseNginxDeploymentID parses 'input' into a NginxDeploymentId +func ParseNginxDeploymentID(input string) (*NginxDeploymentId, error) { + parser := resourceids.NewParserFromResourceIdType(&NginxDeploymentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NginxDeploymentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNginxDeploymentIDInsensitively parses 'input' case-insensitively into a NginxDeploymentId +// note: this method should only be used for API response data and not user input +func ParseNginxDeploymentIDInsensitively(input string) (*NginxDeploymentId, error) { + parser := resourceids.NewParserFromResourceIdType(&NginxDeploymentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NginxDeploymentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NginxDeploymentId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NginxDeploymentName, ok = input.Parsed["nginxDeploymentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "nginxDeploymentName", input) + } + + return nil +} + +// ValidateNginxDeploymentID checks that 'input' can be parsed as a Nginx Deployment ID +func ValidateNginxDeploymentID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNginxDeploymentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Nginx Deployment ID +func (id NginxDeploymentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Nginx.NginxPlus/nginxDeployments/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NginxDeploymentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Nginx Deployment ID +func (id NginxDeploymentId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticNginxNginxPlus", "Nginx.NginxPlus", "Nginx.NginxPlus"), + resourceids.StaticSegment("staticNginxDeployments", "nginxDeployments", "nginxDeployments"), + resourceids.UserSpecifiedSegment("nginxDeploymentName", "nginxDeploymentName"), + } +} + +// String returns a human-readable description of this Nginx Deployment ID +func (id NginxDeploymentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Nginx Deployment Name: %q", id.NginxDeploymentName), + } + return fmt.Sprintf("Nginx Deployment (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/id_nginxdeployment_test.go b/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/id_nginxdeployment_test.go new file mode 100644 index 00000000000..c3d651c79ab --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/id_nginxdeployment_test.go @@ -0,0 +1,282 @@ +package nginxconfiguration + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NginxDeploymentId{} + +func TestNewNginxDeploymentID(t *testing.T) { + id := NewNginxDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "nginxDeploymentName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NginxDeploymentName != "nginxDeploymentName" { + t.Fatalf("Expected %q but got %q for Segment 'NginxDeploymentName'", id.NginxDeploymentName, "nginxDeploymentName") + } +} + +func TestFormatNginxDeploymentID(t *testing.T) { + actual := NewNginxDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "nginxDeploymentName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNginxDeploymentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NginxDeploymentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName", + Expected: &NginxDeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NginxDeploymentName: "nginxDeploymentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNginxDeploymentID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NginxDeploymentName != v.Expected.NginxDeploymentName { + t.Fatalf("Expected %q but got %q for NginxDeploymentName", v.Expected.NginxDeploymentName, actual.NginxDeploymentName) + } + + } +} + +func TestParseNginxDeploymentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NginxDeploymentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/nGiNx.nGiNxPlUs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/nGiNx.nGiNxPlUs/nGiNxDePlOyMeNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName", + Expected: &NginxDeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NginxDeploymentName: "nginxDeploymentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/nGiNx.nGiNxPlUs/nGiNxDePlOyMeNtS/nGiNxDePlOyMeNtNaMe", + Expected: &NginxDeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NginxDeploymentName: "nGiNxDePlOyMeNtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/nGiNx.nGiNxPlUs/nGiNxDePlOyMeNtS/nGiNxDePlOyMeNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNginxDeploymentIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NginxDeploymentName != v.Expected.NginxDeploymentName { + t.Fatalf("Expected %q but got %q for NginxDeploymentName", v.Expected.NginxDeploymentName, actual.NginxDeploymentName) + } + + } +} + +func TestSegmentsForNginxDeploymentId(t *testing.T) { + segments := NginxDeploymentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NginxDeploymentId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/method_configurationscreateorupdate.go b/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/method_configurationscreateorupdate.go new file mode 100644 index 00000000000..d44e1ad3b1c --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/method_configurationscreateorupdate.go @@ -0,0 +1,75 @@ +package nginxconfiguration + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConfigurationsCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *NginxConfigurationResponse +} + +// ConfigurationsCreateOrUpdate ... +func (c NginxConfigurationClient) ConfigurationsCreateOrUpdate(ctx context.Context, id ConfigurationId, input NginxConfigurationRequest) (result ConfigurationsCreateOrUpdateOperationResponse, 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 +} + +// ConfigurationsCreateOrUpdateThenPoll performs ConfigurationsCreateOrUpdate then polls until it's completed +func (c NginxConfigurationClient) ConfigurationsCreateOrUpdateThenPoll(ctx context.Context, id ConfigurationId, input NginxConfigurationRequest) error { + result, err := c.ConfigurationsCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ConfigurationsCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ConfigurationsCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/method_configurationsdelete.go b/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/method_configurationsdelete.go new file mode 100644 index 00000000000..37e56e51da7 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/method_configurationsdelete.go @@ -0,0 +1,71 @@ +package nginxconfiguration + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConfigurationsDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ConfigurationsDelete ... +func (c NginxConfigurationClient) ConfigurationsDelete(ctx context.Context, id ConfigurationId) (result ConfigurationsDeleteOperationResponse, 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 +} + +// ConfigurationsDeleteThenPoll performs ConfigurationsDelete then polls until it's completed +func (c NginxConfigurationClient) ConfigurationsDeleteThenPoll(ctx context.Context, id ConfigurationId) error { + result, err := c.ConfigurationsDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing ConfigurationsDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ConfigurationsDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/method_configurationsget.go b/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/method_configurationsget.go new file mode 100644 index 00000000000..6355bd259f9 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/method_configurationsget.go @@ -0,0 +1,53 @@ +package nginxconfiguration + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConfigurationsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NginxConfigurationResponse +} + +// ConfigurationsGet ... +func (c NginxConfigurationClient) ConfigurationsGet(ctx context.Context, id ConfigurationId) (result ConfigurationsGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NginxConfigurationResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/method_configurationslist.go b/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/method_configurationslist.go new file mode 100644 index 00000000000..c018c6f3f61 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/method_configurationslist.go @@ -0,0 +1,105 @@ +package nginxconfiguration + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConfigurationsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NginxConfigurationResponse +} + +type ConfigurationsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []NginxConfigurationResponse +} + +type ConfigurationsListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ConfigurationsListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ConfigurationsList ... +func (c NginxConfigurationClient) ConfigurationsList(ctx context.Context, id NginxDeploymentId) (result ConfigurationsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ConfigurationsListCustomPager{}, + Path: fmt.Sprintf("%s/configurations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NginxConfigurationResponse `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ConfigurationsListComplete retrieves all the results into a single object +func (c NginxConfigurationClient) ConfigurationsListComplete(ctx context.Context, id NginxDeploymentId) (ConfigurationsListCompleteResult, error) { + return c.ConfigurationsListCompleteMatchingPredicate(ctx, id, NginxConfigurationResponseOperationPredicate{}) +} + +// ConfigurationsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NginxConfigurationClient) ConfigurationsListCompleteMatchingPredicate(ctx context.Context, id NginxDeploymentId, predicate NginxConfigurationResponseOperationPredicate) (result ConfigurationsListCompleteResult, err error) { + items := make([]NginxConfigurationResponse, 0) + + resp, err := c.ConfigurationsList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ConfigurationsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/model_nginxconfigurationfile.go b/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/model_nginxconfigurationfile.go new file mode 100644 index 00000000000..127f7ff425a --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/model_nginxconfigurationfile.go @@ -0,0 +1,9 @@ +package nginxconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NginxConfigurationFile struct { + Content *string `json:"content,omitempty"` + VirtualPath *string `json:"virtualPath,omitempty"` +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/model_nginxconfigurationpackage.go b/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/model_nginxconfigurationpackage.go new file mode 100644 index 00000000000..b247778b539 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/model_nginxconfigurationpackage.go @@ -0,0 +1,9 @@ +package nginxconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NginxConfigurationPackage struct { + Data *string `json:"data,omitempty"` + ProtectedFiles *[]string `json:"protectedFiles,omitempty"` +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/model_nginxconfigurationprotectedfilerequest.go b/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/model_nginxconfigurationprotectedfilerequest.go new file mode 100644 index 00000000000..656b565305f --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/model_nginxconfigurationprotectedfilerequest.go @@ -0,0 +1,10 @@ +package nginxconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NginxConfigurationProtectedFileRequest struct { + Content *string `json:"content,omitempty"` + ContentHash *string `json:"contentHash,omitempty"` + VirtualPath *string `json:"virtualPath,omitempty"` +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/model_nginxconfigurationprotectedfileresponse.go b/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/model_nginxconfigurationprotectedfileresponse.go new file mode 100644 index 00000000000..4810b098747 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/model_nginxconfigurationprotectedfileresponse.go @@ -0,0 +1,9 @@ +package nginxconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NginxConfigurationProtectedFileResponse struct { + ContentHash *string `json:"contentHash,omitempty"` + VirtualPath *string `json:"virtualPath,omitempty"` +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/model_nginxconfigurationrequest.go b/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/model_nginxconfigurationrequest.go new file mode 100644 index 00000000000..711a2fabb53 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/model_nginxconfigurationrequest.go @@ -0,0 +1,16 @@ +package nginxconfiguration + +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 NginxConfigurationRequest struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NginxConfigurationRequestProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/model_nginxconfigurationrequestproperties.go b/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/model_nginxconfigurationrequestproperties.go new file mode 100644 index 00000000000..520364b8166 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/model_nginxconfigurationrequestproperties.go @@ -0,0 +1,12 @@ +package nginxconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NginxConfigurationRequestProperties struct { + Files *[]NginxConfigurationFile `json:"files,omitempty"` + Package *NginxConfigurationPackage `json:"package,omitempty"` + ProtectedFiles *[]NginxConfigurationProtectedFileRequest `json:"protectedFiles,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RootFile *string `json:"rootFile,omitempty"` +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/model_nginxconfigurationresponse.go b/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/model_nginxconfigurationresponse.go new file mode 100644 index 00000000000..6af291341c6 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/model_nginxconfigurationresponse.go @@ -0,0 +1,16 @@ +package nginxconfiguration + +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 NginxConfigurationResponse struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NginxConfigurationResponseProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/model_nginxconfigurationresponseproperties.go b/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/model_nginxconfigurationresponseproperties.go new file mode 100644 index 00000000000..9469ee5e077 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/model_nginxconfigurationresponseproperties.go @@ -0,0 +1,12 @@ +package nginxconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NginxConfigurationResponseProperties struct { + Files *[]NginxConfigurationFile `json:"files,omitempty"` + Package *NginxConfigurationPackage `json:"package,omitempty"` + ProtectedFiles *[]NginxConfigurationProtectedFileResponse `json:"protectedFiles,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RootFile *string `json:"rootFile,omitempty"` +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/predicates.go b/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/predicates.go new file mode 100644 index 00000000000..e71118a80e0 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/predicates.go @@ -0,0 +1,27 @@ +package nginxconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NginxConfigurationResponseOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p NginxConfigurationResponseOperationPredicate) Matches(input NginxConfigurationResponse) 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/nginx/2024-09-01-preview/nginxconfiguration/version.go b/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/version.go new file mode 100644 index 00000000000..2cf2c230253 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxconfiguration/version.go @@ -0,0 +1,10 @@ +package nginxconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/nginxconfiguration/2024-09-01-preview" +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis/README.md b/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis/README.md new file mode 100644 index 00000000000..077e79a7e07 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis/README.md @@ -0,0 +1,41 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis` Documentation + +The `nginxconfigurationanalysis` SDK allows for interaction with Azure Resource Manager `nginx` (API Version `2024-09-01-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis" +``` + + +### Client Initialization + +```go +client := nginxconfigurationanalysis.NewNginxConfigurationAnalysisClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `NginxConfigurationAnalysisClient.ConfigurationsAnalysis` + +```go +ctx := context.TODO() +id := nginxconfigurationanalysis.NewConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "nginxDeploymentName", "configurationName") + +payload := nginxconfigurationanalysis.AnalysisCreate{ + // ... +} + + +read, err := client.ConfigurationsAnalysis(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/nginx/2024-09-01-preview/nginxconfigurationanalysis/client.go b/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis/client.go new file mode 100644 index 00000000000..f47cb464b95 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis/client.go @@ -0,0 +1,26 @@ +package nginxconfigurationanalysis + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NginxConfigurationAnalysisClient struct { + Client *resourcemanager.Client +} + +func NewNginxConfigurationAnalysisClientWithBaseURI(sdkApi sdkEnv.Api) (*NginxConfigurationAnalysisClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "nginxconfigurationanalysis", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NginxConfigurationAnalysisClient: %+v", err) + } + + return &NginxConfigurationAnalysisClient{ + Client: client, + }, nil +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis/id_configuration.go b/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis/id_configuration.go new file mode 100644 index 00000000000..3ceeb4f9371 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis/id_configuration.go @@ -0,0 +1,139 @@ +package nginxconfigurationanalysis + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ConfigurationId{}) +} + +var _ resourceids.ResourceId = &ConfigurationId{} + +// ConfigurationId is a struct representing the Resource ID for a Configuration +type ConfigurationId struct { + SubscriptionId string + ResourceGroupName string + NginxDeploymentName string + ConfigurationName string +} + +// NewConfigurationID returns a new ConfigurationId struct +func NewConfigurationID(subscriptionId string, resourceGroupName string, nginxDeploymentName string, configurationName string) ConfigurationId { + return ConfigurationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NginxDeploymentName: nginxDeploymentName, + ConfigurationName: configurationName, + } +} + +// ParseConfigurationID parses 'input' into a ConfigurationId +func ParseConfigurationID(input string) (*ConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConfigurationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConfigurationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseConfigurationIDInsensitively parses 'input' case-insensitively into a ConfigurationId +// note: this method should only be used for API response data and not user input +func ParseConfigurationIDInsensitively(input string) (*ConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConfigurationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConfigurationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ConfigurationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NginxDeploymentName, ok = input.Parsed["nginxDeploymentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "nginxDeploymentName", input) + } + + if id.ConfigurationName, ok = input.Parsed["configurationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "configurationName", input) + } + + return nil +} + +// ValidateConfigurationID checks that 'input' can be parsed as a Configuration ID +func ValidateConfigurationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseConfigurationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Configuration ID +func (id ConfigurationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Nginx.NginxPlus/nginxDeployments/%s/configurations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NginxDeploymentName, id.ConfigurationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Configuration ID +func (id ConfigurationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticNginxNginxPlus", "Nginx.NginxPlus", "Nginx.NginxPlus"), + resourceids.StaticSegment("staticNginxDeployments", "nginxDeployments", "nginxDeployments"), + resourceids.UserSpecifiedSegment("nginxDeploymentName", "nginxDeploymentName"), + resourceids.StaticSegment("staticConfigurations", "configurations", "configurations"), + resourceids.UserSpecifiedSegment("configurationName", "configurationName"), + } +} + +// String returns a human-readable description of this Configuration ID +func (id ConfigurationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Nginx Deployment Name: %q", id.NginxDeploymentName), + fmt.Sprintf("Configuration Name: %q", id.ConfigurationName), + } + return fmt.Sprintf("Configuration (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis/id_configuration_test.go b/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis/id_configuration_test.go new file mode 100644 index 00000000000..4c09f68d290 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis/id_configuration_test.go @@ -0,0 +1,327 @@ +package nginxconfigurationanalysis + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ConfigurationId{} + +func TestNewConfigurationID(t *testing.T) { + id := NewConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "nginxDeploymentName", "configurationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NginxDeploymentName != "nginxDeploymentName" { + t.Fatalf("Expected %q but got %q for Segment 'NginxDeploymentName'", id.NginxDeploymentName, "nginxDeploymentName") + } + + if id.ConfigurationName != "configurationName" { + t.Fatalf("Expected %q but got %q for Segment 'ConfigurationName'", id.ConfigurationName, "configurationName") + } +} + +func TestFormatConfigurationID(t *testing.T) { + actual := NewConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "nginxDeploymentName", "configurationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName/configurations/configurationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseConfigurationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConfigurationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName/configurations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName/configurations/configurationName", + Expected: &ConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NginxDeploymentName: "nginxDeploymentName", + ConfigurationName: "configurationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName/configurations/configurationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConfigurationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NginxDeploymentName != v.Expected.NginxDeploymentName { + t.Fatalf("Expected %q but got %q for NginxDeploymentName", v.Expected.NginxDeploymentName, actual.NginxDeploymentName) + } + + if actual.ConfigurationName != v.Expected.ConfigurationName { + t.Fatalf("Expected %q but got %q for ConfigurationName", v.Expected.ConfigurationName, actual.ConfigurationName) + } + + } +} + +func TestParseConfigurationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConfigurationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/nGiNx.nGiNxPlUs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/nGiNx.nGiNxPlUs/nGiNxDePlOyMeNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/nGiNx.nGiNxPlUs/nGiNxDePlOyMeNtS/nGiNxDePlOyMeNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName/configurations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/nGiNx.nGiNxPlUs/nGiNxDePlOyMeNtS/nGiNxDePlOyMeNtNaMe/cOnFiGuRaTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName/configurations/configurationName", + Expected: &ConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NginxDeploymentName: "nginxDeploymentName", + ConfigurationName: "configurationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName/configurations/configurationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/nGiNx.nGiNxPlUs/nGiNxDePlOyMeNtS/nGiNxDePlOyMeNtNaMe/cOnFiGuRaTiOnS/cOnFiGuRaTiOnNaMe", + Expected: &ConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NginxDeploymentName: "nGiNxDePlOyMeNtNaMe", + ConfigurationName: "cOnFiGuRaTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/nGiNx.nGiNxPlUs/nGiNxDePlOyMeNtS/nGiNxDePlOyMeNtNaMe/cOnFiGuRaTiOnS/cOnFiGuRaTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConfigurationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NginxDeploymentName != v.Expected.NginxDeploymentName { + t.Fatalf("Expected %q but got %q for NginxDeploymentName", v.Expected.NginxDeploymentName, actual.NginxDeploymentName) + } + + if actual.ConfigurationName != v.Expected.ConfigurationName { + t.Fatalf("Expected %q but got %q for ConfigurationName", v.Expected.ConfigurationName, actual.ConfigurationName) + } + + } +} + +func TestSegmentsForConfigurationId(t *testing.T) { + segments := ConfigurationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ConfigurationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis/method_configurationsanalysis.go b/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis/method_configurationsanalysis.go new file mode 100644 index 00000000000..9ab6de7a6c1 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis/method_configurationsanalysis.go @@ -0,0 +1,58 @@ +package nginxconfigurationanalysis + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConfigurationsAnalysisOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AnalysisResult +} + +// ConfigurationsAnalysis ... +func (c NginxConfigurationAnalysisClient) ConfigurationsAnalysis(ctx context.Context, id ConfigurationId, input AnalysisCreate) (result ConfigurationsAnalysisOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/analyze", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AnalysisResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis/model_analysiscreate.go b/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis/model_analysiscreate.go new file mode 100644 index 00000000000..9bd340960df --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis/model_analysiscreate.go @@ -0,0 +1,8 @@ +package nginxconfigurationanalysis + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AnalysisCreate struct { + Config AnalysisCreateConfig `json:"config"` +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis/model_analysiscreateconfig.go b/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis/model_analysiscreateconfig.go new file mode 100644 index 00000000000..486f2b5aaf9 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis/model_analysiscreateconfig.go @@ -0,0 +1,11 @@ +package nginxconfigurationanalysis + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AnalysisCreateConfig struct { + Files *[]NginxConfigurationFile `json:"files,omitempty"` + Package *NginxConfigurationPackage `json:"package,omitempty"` + ProtectedFiles *[]NginxConfigurationProtectedFileRequest `json:"protectedFiles,omitempty"` + RootFile *string `json:"rootFile,omitempty"` +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis/model_analysisdiagnostic.go b/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis/model_analysisdiagnostic.go new file mode 100644 index 00000000000..e4f1e75b97d --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis/model_analysisdiagnostic.go @@ -0,0 +1,14 @@ +package nginxconfigurationanalysis + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AnalysisDiagnostic struct { + Description string `json:"description"` + Directive string `json:"directive"` + File string `json:"file"` + Id *string `json:"id,omitempty"` + Line float64 `json:"line"` + Message string `json:"message"` + Rule string `json:"rule"` +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis/model_analysisresult.go b/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis/model_analysisresult.go new file mode 100644 index 00000000000..f84e0071ea6 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis/model_analysisresult.go @@ -0,0 +1,9 @@ +package nginxconfigurationanalysis + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AnalysisResult struct { + Data *AnalysisResultData `json:"data,omitempty"` + Status string `json:"status"` +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis/model_analysisresultdata.go b/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis/model_analysisresultdata.go new file mode 100644 index 00000000000..38119ba3240 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis/model_analysisresultdata.go @@ -0,0 +1,8 @@ +package nginxconfigurationanalysis + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AnalysisResultData struct { + Errors *[]AnalysisDiagnostic `json:"errors,omitempty"` +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis/model_nginxconfigurationfile.go b/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis/model_nginxconfigurationfile.go new file mode 100644 index 00000000000..1a735e79e48 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis/model_nginxconfigurationfile.go @@ -0,0 +1,9 @@ +package nginxconfigurationanalysis + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NginxConfigurationFile struct { + Content *string `json:"content,omitempty"` + VirtualPath *string `json:"virtualPath,omitempty"` +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis/model_nginxconfigurationpackage.go b/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis/model_nginxconfigurationpackage.go new file mode 100644 index 00000000000..0aa2af797f0 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis/model_nginxconfigurationpackage.go @@ -0,0 +1,9 @@ +package nginxconfigurationanalysis + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NginxConfigurationPackage struct { + Data *string `json:"data,omitempty"` + ProtectedFiles *[]string `json:"protectedFiles,omitempty"` +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis/model_nginxconfigurationprotectedfilerequest.go b/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis/model_nginxconfigurationprotectedfilerequest.go new file mode 100644 index 00000000000..0afc2893351 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis/model_nginxconfigurationprotectedfilerequest.go @@ -0,0 +1,10 @@ +package nginxconfigurationanalysis + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NginxConfigurationProtectedFileRequest struct { + Content *string `json:"content,omitempty"` + ContentHash *string `json:"contentHash,omitempty"` + VirtualPath *string `json:"virtualPath,omitempty"` +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis/version.go b/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis/version.go new file mode 100644 index 00000000000..f4a422cd861 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxconfigurationanalysis/version.go @@ -0,0 +1,10 @@ +package nginxconfigurationanalysis + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/nginxconfigurationanalysis/2024-09-01-preview" +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxdeployment/README.md b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/README.md new file mode 100644 index 00000000000..c174db0013a --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/README.md @@ -0,0 +1,117 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/nginx/2024-09-01-preview/nginxdeployment` Documentation + +The `nginxdeployment` SDK allows for interaction with Azure Resource Manager `nginx` (API Version `2024-09-01-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/nginx/2024-09-01-preview/nginxdeployment" +``` + + +### Client Initialization + +```go +client := nginxdeployment.NewNginxDeploymentClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `NginxDeploymentClient.DeploymentsCreateOrUpdate` + +```go +ctx := context.TODO() +id := nginxdeployment.NewNginxDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "nginxDeploymentName") + +payload := nginxdeployment.NginxDeployment{ + // ... +} + + +if err := client.DeploymentsCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NginxDeploymentClient.DeploymentsDelete` + +```go +ctx := context.TODO() +id := nginxdeployment.NewNginxDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "nginxDeploymentName") + +if err := client.DeploymentsDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NginxDeploymentClient.DeploymentsGet` + +```go +ctx := context.TODO() +id := nginxdeployment.NewNginxDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "nginxDeploymentName") + +read, err := client.DeploymentsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NginxDeploymentClient.DeploymentsList` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.DeploymentsList(ctx, id)` can be used to do batched pagination +items, err := client.DeploymentsListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NginxDeploymentClient.DeploymentsListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.DeploymentsListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.DeploymentsListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NginxDeploymentClient.DeploymentsUpdate` + +```go +ctx := context.TODO() +id := nginxdeployment.NewNginxDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "nginxDeploymentName") + +payload := nginxdeployment.NginxDeploymentUpdateParameters{ + // ... +} + + +if err := client.DeploymentsUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/nginx/2024-09-01-preview/nginxdeployment/client.go b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/client.go new file mode 100644 index 00000000000..493f06f65d1 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/client.go @@ -0,0 +1,26 @@ +package nginxdeployment + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NginxDeploymentClient struct { + Client *resourcemanager.Client +} + +func NewNginxDeploymentClientWithBaseURI(sdkApi sdkEnv.Api) (*NginxDeploymentClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "nginxdeployment", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NginxDeploymentClient: %+v", err) + } + + return &NginxDeploymentClient{ + Client: client, + }, nil +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxdeployment/constants.go b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/constants.go new file mode 100644 index 00000000000..08865eb91a2 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/constants.go @@ -0,0 +1,154 @@ +package nginxdeployment + +import ( + "encoding/json" + "fmt" + "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 ( + ActivationStateDisabled ActivationState = "Disabled" + ActivationStateEnabled ActivationState = "Enabled" +) + +func PossibleValuesForActivationState() []string { + return []string{ + string(ActivationStateDisabled), + string(ActivationStateEnabled), + } +} + +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{ + "disabled": ActivationStateDisabled, + "enabled": ActivationStateEnabled, + } + 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 NginxPrivateIPAllocationMethod string + +const ( + NginxPrivateIPAllocationMethodDynamic NginxPrivateIPAllocationMethod = "Dynamic" + NginxPrivateIPAllocationMethodStatic NginxPrivateIPAllocationMethod = "Static" +) + +func PossibleValuesForNginxPrivateIPAllocationMethod() []string { + return []string{ + string(NginxPrivateIPAllocationMethodDynamic), + string(NginxPrivateIPAllocationMethodStatic), + } +} + +func (s *NginxPrivateIPAllocationMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNginxPrivateIPAllocationMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNginxPrivateIPAllocationMethod(input string) (*NginxPrivateIPAllocationMethod, error) { + vals := map[string]NginxPrivateIPAllocationMethod{ + "dynamic": NginxPrivateIPAllocationMethodDynamic, + "static": NginxPrivateIPAllocationMethodStatic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NginxPrivateIPAllocationMethod(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateNotSpecified ProvisioningState = "NotSpecified" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleted), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateNotSpecified), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, + "deleted": ProvisioningStateDeleted, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "notspecified": ProvisioningStateNotSpecified, + "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/nginx/2024-09-01-preview/nginxdeployment/id_nginxdeployment.go b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/id_nginxdeployment.go new file mode 100644 index 00000000000..101e5a4b4be --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/id_nginxdeployment.go @@ -0,0 +1,130 @@ +package nginxdeployment + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NginxDeploymentId{}) +} + +var _ resourceids.ResourceId = &NginxDeploymentId{} + +// NginxDeploymentId is a struct representing the Resource ID for a Nginx Deployment +type NginxDeploymentId struct { + SubscriptionId string + ResourceGroupName string + NginxDeploymentName string +} + +// NewNginxDeploymentID returns a new NginxDeploymentId struct +func NewNginxDeploymentID(subscriptionId string, resourceGroupName string, nginxDeploymentName string) NginxDeploymentId { + return NginxDeploymentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NginxDeploymentName: nginxDeploymentName, + } +} + +// ParseNginxDeploymentID parses 'input' into a NginxDeploymentId +func ParseNginxDeploymentID(input string) (*NginxDeploymentId, error) { + parser := resourceids.NewParserFromResourceIdType(&NginxDeploymentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NginxDeploymentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNginxDeploymentIDInsensitively parses 'input' case-insensitively into a NginxDeploymentId +// note: this method should only be used for API response data and not user input +func ParseNginxDeploymentIDInsensitively(input string) (*NginxDeploymentId, error) { + parser := resourceids.NewParserFromResourceIdType(&NginxDeploymentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NginxDeploymentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NginxDeploymentId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NginxDeploymentName, ok = input.Parsed["nginxDeploymentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "nginxDeploymentName", input) + } + + return nil +} + +// ValidateNginxDeploymentID checks that 'input' can be parsed as a Nginx Deployment ID +func ValidateNginxDeploymentID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNginxDeploymentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Nginx Deployment ID +func (id NginxDeploymentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Nginx.NginxPlus/nginxDeployments/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NginxDeploymentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Nginx Deployment ID +func (id NginxDeploymentId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticNginxNginxPlus", "Nginx.NginxPlus", "Nginx.NginxPlus"), + resourceids.StaticSegment("staticNginxDeployments", "nginxDeployments", "nginxDeployments"), + resourceids.UserSpecifiedSegment("nginxDeploymentName", "nginxDeploymentName"), + } +} + +// String returns a human-readable description of this Nginx Deployment ID +func (id NginxDeploymentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Nginx Deployment Name: %q", id.NginxDeploymentName), + } + return fmt.Sprintf("Nginx Deployment (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxdeployment/id_nginxdeployment_test.go b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/id_nginxdeployment_test.go new file mode 100644 index 00000000000..55758302ad6 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/id_nginxdeployment_test.go @@ -0,0 +1,282 @@ +package nginxdeployment + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NginxDeploymentId{} + +func TestNewNginxDeploymentID(t *testing.T) { + id := NewNginxDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "nginxDeploymentName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NginxDeploymentName != "nginxDeploymentName" { + t.Fatalf("Expected %q but got %q for Segment 'NginxDeploymentName'", id.NginxDeploymentName, "nginxDeploymentName") + } +} + +func TestFormatNginxDeploymentID(t *testing.T) { + actual := NewNginxDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "nginxDeploymentName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNginxDeploymentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NginxDeploymentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName", + Expected: &NginxDeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NginxDeploymentName: "nginxDeploymentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNginxDeploymentID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NginxDeploymentName != v.Expected.NginxDeploymentName { + t.Fatalf("Expected %q but got %q for NginxDeploymentName", v.Expected.NginxDeploymentName, actual.NginxDeploymentName) + } + + } +} + +func TestParseNginxDeploymentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NginxDeploymentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/nGiNx.nGiNxPlUs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/nGiNx.nGiNxPlUs/nGiNxDePlOyMeNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName", + Expected: &NginxDeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NginxDeploymentName: "nginxDeploymentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/nGiNx.nGiNxPlUs/nGiNxDePlOyMeNtS/nGiNxDePlOyMeNtNaMe", + Expected: &NginxDeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NginxDeploymentName: "nGiNxDePlOyMeNtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/nGiNx.nGiNxPlUs/nGiNxDePlOyMeNtS/nGiNxDePlOyMeNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNginxDeploymentIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NginxDeploymentName != v.Expected.NginxDeploymentName { + t.Fatalf("Expected %q but got %q for NginxDeploymentName", v.Expected.NginxDeploymentName, actual.NginxDeploymentName) + } + + } +} + +func TestSegmentsForNginxDeploymentId(t *testing.T) { + segments := NginxDeploymentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NginxDeploymentId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxdeployment/method_deploymentscreateorupdate.go b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/method_deploymentscreateorupdate.go new file mode 100644 index 00000000000..e4c9f1cba7b --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/method_deploymentscreateorupdate.go @@ -0,0 +1,75 @@ +package nginxdeployment + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeploymentsCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *NginxDeployment +} + +// DeploymentsCreateOrUpdate ... +func (c NginxDeploymentClient) DeploymentsCreateOrUpdate(ctx context.Context, id NginxDeploymentId, input NginxDeployment) (result DeploymentsCreateOrUpdateOperationResponse, 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 +} + +// DeploymentsCreateOrUpdateThenPoll performs DeploymentsCreateOrUpdate then polls until it's completed +func (c NginxDeploymentClient) DeploymentsCreateOrUpdateThenPoll(ctx context.Context, id NginxDeploymentId, input NginxDeployment) error { + result, err := c.DeploymentsCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing DeploymentsCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeploymentsCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxdeployment/method_deploymentsdelete.go b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/method_deploymentsdelete.go new file mode 100644 index 00000000000..062f299f4a4 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/method_deploymentsdelete.go @@ -0,0 +1,71 @@ +package nginxdeployment + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeploymentsDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DeploymentsDelete ... +func (c NginxDeploymentClient) DeploymentsDelete(ctx context.Context, id NginxDeploymentId) (result DeploymentsDeleteOperationResponse, 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 +} + +// DeploymentsDeleteThenPoll performs DeploymentsDelete then polls until it's completed +func (c NginxDeploymentClient) DeploymentsDeleteThenPoll(ctx context.Context, id NginxDeploymentId) error { + result, err := c.DeploymentsDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing DeploymentsDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeploymentsDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxdeployment/method_deploymentsget.go b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/method_deploymentsget.go new file mode 100644 index 00000000000..cbf98927207 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/method_deploymentsget.go @@ -0,0 +1,53 @@ +package nginxdeployment + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeploymentsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NginxDeployment +} + +// DeploymentsGet ... +func (c NginxDeploymentClient) DeploymentsGet(ctx context.Context, id NginxDeploymentId) (result DeploymentsGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NginxDeployment + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxdeployment/method_deploymentslist.go b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/method_deploymentslist.go new file mode 100644 index 00000000000..f9a1c4b11c4 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/method_deploymentslist.go @@ -0,0 +1,106 @@ +package nginxdeployment + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeploymentsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NginxDeployment +} + +type DeploymentsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []NginxDeployment +} + +type DeploymentsListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *DeploymentsListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// DeploymentsList ... +func (c NginxDeploymentClient) DeploymentsList(ctx context.Context, id commonids.SubscriptionId) (result DeploymentsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &DeploymentsListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Nginx.NginxPlus/nginxDeployments", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NginxDeployment `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// DeploymentsListComplete retrieves all the results into a single object +func (c NginxDeploymentClient) DeploymentsListComplete(ctx context.Context, id commonids.SubscriptionId) (DeploymentsListCompleteResult, error) { + return c.DeploymentsListCompleteMatchingPredicate(ctx, id, NginxDeploymentOperationPredicate{}) +} + +// DeploymentsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NginxDeploymentClient) DeploymentsListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate NginxDeploymentOperationPredicate) (result DeploymentsListCompleteResult, err error) { + items := make([]NginxDeployment, 0) + + resp, err := c.DeploymentsList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = DeploymentsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxdeployment/method_deploymentslistbyresourcegroup.go b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/method_deploymentslistbyresourcegroup.go new file mode 100644 index 00000000000..3ac1cec05f7 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/method_deploymentslistbyresourcegroup.go @@ -0,0 +1,106 @@ +package nginxdeployment + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeploymentsListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NginxDeployment +} + +type DeploymentsListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []NginxDeployment +} + +type DeploymentsListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *DeploymentsListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// DeploymentsListByResourceGroup ... +func (c NginxDeploymentClient) DeploymentsListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result DeploymentsListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &DeploymentsListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Nginx.NginxPlus/nginxDeployments", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NginxDeployment `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// DeploymentsListByResourceGroupComplete retrieves all the results into a single object +func (c NginxDeploymentClient) DeploymentsListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (DeploymentsListByResourceGroupCompleteResult, error) { + return c.DeploymentsListByResourceGroupCompleteMatchingPredicate(ctx, id, NginxDeploymentOperationPredicate{}) +} + +// DeploymentsListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NginxDeploymentClient) DeploymentsListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate NginxDeploymentOperationPredicate) (result DeploymentsListByResourceGroupCompleteResult, err error) { + items := make([]NginxDeployment, 0) + + resp, err := c.DeploymentsListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = DeploymentsListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxdeployment/method_deploymentsupdate.go b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/method_deploymentsupdate.go new file mode 100644 index 00000000000..d6ab0244f52 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/method_deploymentsupdate.go @@ -0,0 +1,75 @@ +package nginxdeployment + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeploymentsUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *NginxDeployment +} + +// DeploymentsUpdate ... +func (c NginxDeploymentClient) DeploymentsUpdate(ctx context.Context, id NginxDeploymentId, input NginxDeploymentUpdateParameters) (result DeploymentsUpdateOperationResponse, 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 + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeploymentsUpdateThenPoll performs DeploymentsUpdate then polls until it's completed +func (c NginxDeploymentClient) DeploymentsUpdateThenPoll(ctx context.Context, id NginxDeploymentId, input NginxDeploymentUpdateParameters) error { + result, err := c.DeploymentsUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing DeploymentsUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeploymentsUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_autoupgradeprofile.go b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_autoupgradeprofile.go new file mode 100644 index 00000000000..2061898d495 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_autoupgradeprofile.go @@ -0,0 +1,8 @@ +package nginxdeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoUpgradeProfile struct { + UpgradeChannel string `json:"upgradeChannel"` +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxdeployment.go b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxdeployment.go new file mode 100644 index 00000000000..25453bf6d88 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxdeployment.go @@ -0,0 +1,21 @@ +package nginxdeployment + +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 NginxDeployment struct { + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NginxDeploymentProperties `json:"properties,omitempty"` + Sku *ResourceSku `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/nginx/2024-09-01-preview/nginxdeployment/model_nginxdeploymentproperties.go b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxdeploymentproperties.go new file mode 100644 index 00000000000..e07216cd37a --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxdeploymentproperties.go @@ -0,0 +1,18 @@ +package nginxdeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NginxDeploymentProperties struct { + AutoUpgradeProfile *AutoUpgradeProfile `json:"autoUpgradeProfile,omitempty"` + DataplaneApiEndpoint *string `json:"dataplaneApiEndpoint,omitempty"` + EnableDiagnosticsSupport *bool `json:"enableDiagnosticsSupport,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + Logging *NginxLogging `json:"logging,omitempty"` + NetworkProfile *NginxNetworkProfile `json:"networkProfile,omitempty"` + NginxAppProtect *NginxDeploymentPropertiesNginxAppProtect `json:"nginxAppProtect,omitempty"` + NginxVersion *string `json:"nginxVersion,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ScalingProperties *NginxDeploymentScalingProperties `json:"scalingProperties,omitempty"` + UserProfile *NginxDeploymentUserProfile `json:"userProfile,omitempty"` +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxdeploymentpropertiesnginxappprotect.go b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxdeploymentpropertiesnginxappprotect.go new file mode 100644 index 00000000000..326054a7d1e --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxdeploymentpropertiesnginxappprotect.go @@ -0,0 +1,9 @@ +package nginxdeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NginxDeploymentPropertiesNginxAppProtect struct { + WebApplicationFirewallSettings WebApplicationFirewallSettings `json:"webApplicationFirewallSettings"` + WebApplicationFirewallStatus *WebApplicationFirewallStatus `json:"webApplicationFirewallStatus,omitempty"` +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxdeploymentscalingproperties.go b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxdeploymentscalingproperties.go new file mode 100644 index 00000000000..7142527f38a --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxdeploymentscalingproperties.go @@ -0,0 +1,9 @@ +package nginxdeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NginxDeploymentScalingProperties struct { + AutoScaleSettings *NginxDeploymentScalingPropertiesAutoScaleSettings `json:"autoScaleSettings,omitempty"` + Capacity *int64 `json:"capacity,omitempty"` +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxdeploymentscalingpropertiesautoscalesettings.go b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxdeploymentscalingpropertiesautoscalesettings.go new file mode 100644 index 00000000000..28951659cae --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxdeploymentscalingpropertiesautoscalesettings.go @@ -0,0 +1,8 @@ +package nginxdeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NginxDeploymentScalingPropertiesAutoScaleSettings struct { + Profiles []ScaleProfile `json:"profiles"` +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxdeploymentupdateparameters.go b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxdeploymentupdateparameters.go new file mode 100644 index 00000000000..00b1615d7e0 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxdeploymentupdateparameters.go @@ -0,0 +1,16 @@ +package nginxdeployment + +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 NginxDeploymentUpdateParameters struct { + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Properties *NginxDeploymentUpdateProperties `json:"properties,omitempty"` + Sku *ResourceSku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxdeploymentupdateproperties.go b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxdeploymentupdateproperties.go new file mode 100644 index 00000000000..837727acbc8 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxdeploymentupdateproperties.go @@ -0,0 +1,13 @@ +package nginxdeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NginxDeploymentUpdateProperties struct { + AutoUpgradeProfile *AutoUpgradeProfile `json:"autoUpgradeProfile,omitempty"` + EnableDiagnosticsSupport *bool `json:"enableDiagnosticsSupport,omitempty"` + Logging *NginxLogging `json:"logging,omitempty"` + NginxAppProtect *NginxDeploymentUpdatePropertiesNginxAppProtect `json:"nginxAppProtect,omitempty"` + ScalingProperties *NginxDeploymentScalingProperties `json:"scalingProperties,omitempty"` + UserProfile *NginxDeploymentUserProfile `json:"userProfile,omitempty"` +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxdeploymentupdatepropertiesnginxappprotect.go b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxdeploymentupdatepropertiesnginxappprotect.go new file mode 100644 index 00000000000..1346c7a9fa9 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxdeploymentupdatepropertiesnginxappprotect.go @@ -0,0 +1,8 @@ +package nginxdeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NginxDeploymentUpdatePropertiesNginxAppProtect struct { + WebApplicationFirewallSettings *WebApplicationFirewallSettings `json:"webApplicationFirewallSettings,omitempty"` +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxdeploymentuserprofile.go b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxdeploymentuserprofile.go new file mode 100644 index 00000000000..153bfb0e2e1 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxdeploymentuserprofile.go @@ -0,0 +1,8 @@ +package nginxdeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NginxDeploymentUserProfile struct { + PreferredEmail *string `json:"preferredEmail,omitempty"` +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxfrontendipconfiguration.go b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxfrontendipconfiguration.go new file mode 100644 index 00000000000..e084038d690 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxfrontendipconfiguration.go @@ -0,0 +1,9 @@ +package nginxdeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NginxFrontendIPConfiguration struct { + PrivateIPAddresses *[]NginxPrivateIPAddress `json:"privateIPAddresses,omitempty"` + PublicIPAddresses *[]NginxPublicIPAddress `json:"publicIPAddresses,omitempty"` +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxlogging.go b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxlogging.go new file mode 100644 index 00000000000..c5c8ff18d05 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxlogging.go @@ -0,0 +1,8 @@ +package nginxdeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NginxLogging struct { + StorageAccount *NginxStorageAccount `json:"storageAccount,omitempty"` +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxnetworkinterfaceconfiguration.go b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxnetworkinterfaceconfiguration.go new file mode 100644 index 00000000000..b101806aebb --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxnetworkinterfaceconfiguration.go @@ -0,0 +1,8 @@ +package nginxdeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NginxNetworkInterfaceConfiguration struct { + SubnetId *string `json:"subnetId,omitempty"` +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxnetworkprofile.go b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxnetworkprofile.go new file mode 100644 index 00000000000..26ded847b53 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxnetworkprofile.go @@ -0,0 +1,9 @@ +package nginxdeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NginxNetworkProfile struct { + FrontEndIPConfiguration *NginxFrontendIPConfiguration `json:"frontEndIPConfiguration,omitempty"` + NetworkInterfaceConfiguration *NginxNetworkInterfaceConfiguration `json:"networkInterfaceConfiguration,omitempty"` +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxprivateipaddress.go b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxprivateipaddress.go new file mode 100644 index 00000000000..9bce7dba730 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxprivateipaddress.go @@ -0,0 +1,10 @@ +package nginxdeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NginxPrivateIPAddress struct { + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAllocationMethod *NginxPrivateIPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + SubnetId *string `json:"subnetId,omitempty"` +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxpublicipaddress.go b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxpublicipaddress.go new file mode 100644 index 00000000000..05e8036a6e4 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxpublicipaddress.go @@ -0,0 +1,8 @@ +package nginxdeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NginxPublicIPAddress struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxstorageaccount.go b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxstorageaccount.go new file mode 100644 index 00000000000..f53382105bf --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_nginxstorageaccount.go @@ -0,0 +1,9 @@ +package nginxdeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NginxStorageAccount struct { + AccountName *string `json:"accountName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_resourcesku.go b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_resourcesku.go new file mode 100644 index 00000000000..85a9b9b55da --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_resourcesku.go @@ -0,0 +1,8 @@ +package nginxdeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceSku struct { + Name string `json:"name"` +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_scaleprofile.go b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_scaleprofile.go new file mode 100644 index 00000000000..35f11b10aa5 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_scaleprofile.go @@ -0,0 +1,9 @@ +package nginxdeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScaleProfile struct { + Capacity ScaleProfileCapacity `json:"capacity"` + Name string `json:"name"` +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_scaleprofilecapacity.go b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_scaleprofilecapacity.go new file mode 100644 index 00000000000..a1fd2137891 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_scaleprofilecapacity.go @@ -0,0 +1,9 @@ +package nginxdeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScaleProfileCapacity struct { + Max int64 `json:"max"` + Min int64 `json:"min"` +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_webapplicationfirewallcomponentversions.go b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_webapplicationfirewallcomponentversions.go new file mode 100644 index 00000000000..b3a49fdab79 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_webapplicationfirewallcomponentversions.go @@ -0,0 +1,9 @@ +package nginxdeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebApplicationFirewallComponentVersions struct { + WafEngineVersion string `json:"wafEngineVersion"` + WafNginxVersion string `json:"wafNginxVersion"` +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_webapplicationfirewallpackage.go b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_webapplicationfirewallpackage.go new file mode 100644 index 00000000000..d86fe0ab588 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_webapplicationfirewallpackage.go @@ -0,0 +1,24 @@ +package nginxdeployment + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebApplicationFirewallPackage struct { + RevisionDatetime string `json:"revisionDatetime"` + Version string `json:"version"` +} + +func (o *WebApplicationFirewallPackage) GetRevisionDatetimeAsTime() (*time.Time, error) { + return dates.ParseAsFormat(&o.RevisionDatetime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WebApplicationFirewallPackage) SetRevisionDatetimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RevisionDatetime = formatted +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_webapplicationfirewallsettings.go b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_webapplicationfirewallsettings.go new file mode 100644 index 00000000000..5fef9fad979 --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_webapplicationfirewallsettings.go @@ -0,0 +1,8 @@ +package nginxdeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebApplicationFirewallSettings struct { + ActivationState *ActivationState `json:"activationState,omitempty"` +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_webapplicationfirewallstatus.go b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_webapplicationfirewallstatus.go new file mode 100644 index 00000000000..923f4f159db --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/model_webapplicationfirewallstatus.go @@ -0,0 +1,11 @@ +package nginxdeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebApplicationFirewallStatus struct { + AttackSignaturesPackage *WebApplicationFirewallPackage `json:"attackSignaturesPackage,omitempty"` + BotSignaturesPackage *WebApplicationFirewallPackage `json:"botSignaturesPackage,omitempty"` + ComponentVersions *WebApplicationFirewallComponentVersions `json:"componentVersions,omitempty"` + ThreatCampaignsPackage *WebApplicationFirewallPackage `json:"threatCampaignsPackage,omitempty"` +} diff --git a/resource-manager/nginx/2024-09-01-preview/nginxdeployment/predicates.go b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/predicates.go new file mode 100644 index 00000000000..d1754320d3a --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/predicates.go @@ -0,0 +1,32 @@ +package nginxdeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NginxDeploymentOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p NginxDeploymentOperationPredicate) Matches(input NginxDeployment) 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/nginx/2024-09-01-preview/nginxdeployment/version.go b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/version.go new file mode 100644 index 00000000000..ace4c64238d --- /dev/null +++ b/resource-manager/nginx/2024-09-01-preview/nginxdeployment/version.go @@ -0,0 +1,10 @@ +package nginxdeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-09-01-preview" + +func userAgent() string { + return "hashicorp/go-azure-sdk/nginxdeployment/2024-09-01-preview" +}