From b86361065be1606dd13648b446bd86a6277139c1 Mon Sep 17 00:00:00 2001 From: hc-github-team-tf-azure <> Date: Wed, 21 Feb 2024 16:40:47 +0000 Subject: [PATCH] Updating based on 13165ff8 --- .../nginx/2024-01-01-preview/client.go | 55 +++ .../nginxcertificate/README.md | 82 +++++ .../nginxcertificate/client.go | 26 ++ .../nginxcertificate/constants.go | 72 ++++ .../nginxcertificate/id_certificate.go | 134 +++++++ .../nginxcertificate/id_certificate_test.go | 327 ++++++++++++++++++ .../nginxcertificate/id_nginxdeployment.go | 125 +++++++ .../id_nginxdeployment_test.go | 282 +++++++++++++++ .../method_certificatescreateorupdate.go | 75 ++++ .../method_certificatesdelete.go | 71 ++++ .../method_certificatesget.go | 51 +++ .../method_certificateslist.go | 91 +++++ .../model_nginxcertificate.go | 17 + ...model_nginxcertificateerrorresponsebody.go | 9 + .../model_nginxcertificateproperties.go | 33 ++ .../nginxcertificate/predicates.go | 32 ++ .../nginxcertificate/version.go | 12 + .../nginxconfiguration/README.md | 82 +++++ .../nginxconfiguration/client.go | 26 ++ .../nginxconfiguration/constants.go | 72 ++++ .../nginxconfiguration/id_configuration.go | 134 +++++++ .../id_configuration_test.go | 327 ++++++++++++++++++ .../nginxconfiguration/id_nginxdeployment.go | 125 +++++++ .../id_nginxdeployment_test.go | 282 +++++++++++++++ .../method_configurationscreateorupdate.go | 75 ++++ .../method_configurationsdelete.go | 71 ++++ .../method_configurationsget.go | 51 +++ .../method_configurationslist.go | 91 +++++ .../model_nginxconfiguration.go | 17 + .../model_nginxconfigurationfile.go | 9 + .../model_nginxconfigurationpackage.go | 9 + .../model_nginxconfigurationproperties.go | 12 + .../nginxconfiguration/predicates.go | 32 ++ .../nginxconfiguration/version.go | 12 + .../nginxconfigurationanalysis/README.md | 41 +++ .../nginxconfigurationanalysis/client.go | 26 ++ .../id_configuration.go | 134 +++++++ .../id_configuration_test.go | 327 ++++++++++++++++++ .../method_configurationsanalysis.go | 56 +++ .../model_analysiscreate.go | 8 + .../model_analysiscreateconfig.go | 11 + .../model_analysisdiagnostic.go | 14 + .../model_analysisresult.go | 9 + .../model_analysisresultdata.go | 8 + .../model_nginxconfigurationfile.go | 9 + .../model_nginxconfigurationpackage.go | 9 + .../nginxconfigurationanalysis/version.go | 12 + .../nginxdeployment/README.md | 117 +++++++ .../nginxdeployment/client.go | 26 ++ .../nginxdeployment/constants.go | 113 ++++++ .../nginxdeployment/id_nginxdeployment.go | 125 +++++++ .../id_nginxdeployment_test.go | 282 +++++++++++++++ .../method_deploymentscreateorupdate.go | 75 ++++ .../method_deploymentsdelete.go | 71 ++++ .../nginxdeployment/method_deploymentsget.go | 51 +++ .../nginxdeployment/method_deploymentslist.go | 92 +++++ .../method_deploymentslistbyresourcegroup.go | 92 +++++ .../method_deploymentsupdate.go | 75 ++++ .../model_autoupgradeprofile.go | 8 + .../nginxdeployment/model_nginxdeployment.go | 21 ++ .../model_nginxdeploymentproperties.go | 17 + .../model_nginxdeploymentscalingproperties.go | 9 + ...ymentscalingpropertiesautoscalesettings.go | 8 + .../model_nginxdeploymentupdateparameters.go | 16 + .../model_nginxdeploymentupdateproperties.go | 12 + .../model_nginxdeploymentuserprofile.go | 8 + .../model_nginxfrontendipconfiguration.go | 9 + .../nginxdeployment/model_nginxlogging.go | 8 + ...odel_nginxnetworkinterfaceconfiguration.go | 8 + .../model_nginxnetworkprofile.go | 9 + .../model_nginxprivateipaddress.go | 10 + .../model_nginxpublicipaddress.go | 8 + .../model_nginxstorageaccount.go | 9 + .../nginxdeployment/model_resourcesku.go | 8 + .../nginxdeployment/model_scaleprofile.go | 9 + .../model_scaleprofilecapacity.go | 9 + .../nginxdeployment/predicates.go | 32 ++ .../nginxdeployment/version.go | 12 + 78 files changed, 4934 insertions(+) create mode 100644 resource-manager/nginx/2024-01-01-preview/client.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxcertificate/README.md create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxcertificate/client.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxcertificate/constants.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxcertificate/id_certificate.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxcertificate/id_certificate_test.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxcertificate/id_nginxdeployment.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxcertificate/id_nginxdeployment_test.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxcertificate/method_certificatescreateorupdate.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxcertificate/method_certificatesdelete.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxcertificate/method_certificatesget.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxcertificate/method_certificateslist.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxcertificate/model_nginxcertificate.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxcertificate/model_nginxcertificateerrorresponsebody.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxcertificate/model_nginxcertificateproperties.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxcertificate/predicates.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxcertificate/version.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxconfiguration/README.md create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxconfiguration/client.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxconfiguration/constants.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxconfiguration/id_configuration.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxconfiguration/id_configuration_test.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxconfiguration/id_nginxdeployment.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxconfiguration/id_nginxdeployment_test.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxconfiguration/method_configurationscreateorupdate.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxconfiguration/method_configurationsdelete.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxconfiguration/method_configurationsget.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxconfiguration/method_configurationslist.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxconfiguration/model_nginxconfiguration.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxconfiguration/model_nginxconfigurationfile.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxconfiguration/model_nginxconfigurationpackage.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxconfiguration/model_nginxconfigurationproperties.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxconfiguration/predicates.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxconfiguration/version.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxconfigurationanalysis/README.md create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxconfigurationanalysis/client.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxconfigurationanalysis/id_configuration.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxconfigurationanalysis/id_configuration_test.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxconfigurationanalysis/method_configurationsanalysis.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxconfigurationanalysis/model_analysiscreate.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxconfigurationanalysis/model_analysiscreateconfig.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxconfigurationanalysis/model_analysisdiagnostic.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxconfigurationanalysis/model_analysisresult.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxconfigurationanalysis/model_analysisresultdata.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxconfigurationanalysis/model_nginxconfigurationfile.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxconfigurationanalysis/model_nginxconfigurationpackage.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxconfigurationanalysis/version.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxdeployment/README.md create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxdeployment/client.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxdeployment/constants.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxdeployment/id_nginxdeployment.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxdeployment/id_nginxdeployment_test.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxdeployment/method_deploymentscreateorupdate.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxdeployment/method_deploymentsdelete.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxdeployment/method_deploymentsget.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxdeployment/method_deploymentslist.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxdeployment/method_deploymentslistbyresourcegroup.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxdeployment/method_deploymentsupdate.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxdeployment/model_autoupgradeprofile.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxdeployment/model_nginxdeployment.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxdeployment/model_nginxdeploymentproperties.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxdeployment/model_nginxdeploymentscalingproperties.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxdeployment/model_nginxdeploymentscalingpropertiesautoscalesettings.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxdeployment/model_nginxdeploymentupdateparameters.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxdeployment/model_nginxdeploymentupdateproperties.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxdeployment/model_nginxdeploymentuserprofile.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxdeployment/model_nginxfrontendipconfiguration.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxdeployment/model_nginxlogging.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxdeployment/model_nginxnetworkinterfaceconfiguration.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxdeployment/model_nginxnetworkprofile.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxdeployment/model_nginxprivateipaddress.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxdeployment/model_nginxpublicipaddress.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxdeployment/model_nginxstorageaccount.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxdeployment/model_resourcesku.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxdeployment/model_scaleprofile.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxdeployment/model_scaleprofilecapacity.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxdeployment/predicates.go create mode 100644 resource-manager/nginx/2024-01-01-preview/nginxdeployment/version.go diff --git a/resource-manager/nginx/2024-01-01-preview/client.go b/resource-manager/nginx/2024-01-01-preview/client.go new file mode 100644 index 00000000000..dc18e417990 --- /dev/null +++ b/resource-manager/nginx/2024-01-01-preview/client.go @@ -0,0 +1,55 @@ +package v2024_01_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-01-01-preview/nginxcertificate" + "github.com/hashicorp/go-azure-sdk/resource-manager/nginx/2024-01-01-preview/nginxconfiguration" + "github.com/hashicorp/go-azure-sdk/resource-manager/nginx/2024-01-01-preview/nginxconfigurationanalysis" + "github.com/hashicorp/go-azure-sdk/resource-manager/nginx/2024-01-01-preview/nginxdeployment" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + NginxCertificate *nginxcertificate.NginxCertificateClient + NginxConfiguration *nginxconfiguration.NginxConfigurationClient + NginxConfigurationAnalysis *nginxconfigurationanalysis.NginxConfigurationAnalysisClient + NginxDeployment *nginxdeployment.NginxDeploymentClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + 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{ + NginxCertificate: nginxCertificateClient, + NginxConfiguration: nginxConfigurationClient, + NginxConfigurationAnalysis: nginxConfigurationAnalysisClient, + NginxDeployment: nginxDeploymentClient, + }, nil +} diff --git a/resource-manager/nginx/2024-01-01-preview/nginxcertificate/README.md b/resource-manager/nginx/2024-01-01-preview/nginxcertificate/README.md new file mode 100644 index 00000000000..ed8eb84e85e --- /dev/null +++ b/resource-manager/nginx/2024-01-01-preview/nginxcertificate/README.md @@ -0,0 +1,82 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/nginx/2024-01-01-preview/nginxcertificate` Documentation + +The `nginxcertificate` SDK allows for interaction with the Azure Resource Manager Service `nginx` (API Version `2024-01-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-01-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", "nginxDeploymentValue", "certificateValue") + +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", "nginxDeploymentValue", "certificateValue") + +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", "nginxDeploymentValue", "certificateValue") + +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", "nginxDeploymentValue") + +// 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-01-01-preview/nginxcertificate/client.go b/resource-manager/nginx/2024-01-01-preview/nginxcertificate/client.go new file mode 100644 index 00000000000..afeaf1e338a --- /dev/null +++ b/resource-manager/nginx/2024-01-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.NewResourceManagerClient(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-01-01-preview/nginxcertificate/constants.go b/resource-manager/nginx/2024-01-01-preview/nginxcertificate/constants.go new file mode 100644 index 00000000000..5cea630d9fe --- /dev/null +++ b/resource-manager/nginx/2024-01-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-01-01-preview/nginxcertificate/id_certificate.go b/resource-manager/nginx/2024-01-01-preview/nginxcertificate/id_certificate.go new file mode 100644 index 00000000000..ae87bf1c9fd --- /dev/null +++ b/resource-manager/nginx/2024-01-01-preview/nginxcertificate/id_certificate.go @@ -0,0 +1,134 @@ +package nginxcertificate + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (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{} + +// 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", "nginxDeploymentValue"), + resourceids.StaticSegment("staticCertificates", "certificates", "certificates"), + resourceids.UserSpecifiedSegment("certificateName", "certificateValue"), + } +} + +// 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-01-01-preview/nginxcertificate/id_certificate_test.go b/resource-manager/nginx/2024-01-01-preview/nginxcertificate/id_certificate_test.go new file mode 100644 index 00000000000..79991d6321b --- /dev/null +++ b/resource-manager/nginx/2024-01-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", "nginxDeploymentValue", "certificateValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-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 != "nginxDeploymentValue" { + t.Fatalf("Expected %q but got %q for Segment 'NginxDeploymentName'", id.NginxDeploymentName, "nginxDeploymentValue") + } + + if id.CertificateName != "certificateValue" { + t.Fatalf("Expected %q but got %q for Segment 'CertificateName'", id.CertificateName, "certificateValue") + } +} + +func TestFormatCertificateID(t *testing.T) { + actual := NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "nginxDeploymentValue", "certificateValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentValue/certificates/certificateValue" + 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/nginxDeploymentValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentValue/certificates", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentValue/certificates/certificateValue", + Expected: &CertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NginxDeploymentName: "nginxDeploymentValue", + CertificateName: "certificateValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentValue/certificates/certificateValue/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/nginxDeploymentValue", + 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/nGiNxDePlOyMeNtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentValue/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/nGiNxDePlOyMeNtVaLuE/cErTiFiCaTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentValue/certificates/certificateValue", + Expected: &CertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NginxDeploymentName: "nginxDeploymentValue", + CertificateName: "certificateValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentValue/certificates/certificateValue/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/nGiNxDePlOyMeNtVaLuE/cErTiFiCaTeS/cErTiFiCaTeVaLuE", + Expected: &CertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NginxDeploymentName: "nGiNxDePlOyMeNtVaLuE", + CertificateName: "cErTiFiCaTeVaLuE", + }, + }, + { + // 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/nGiNxDePlOyMeNtVaLuE/cErTiFiCaTeS/cErTiFiCaTeVaLuE/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-01-01-preview/nginxcertificate/id_nginxdeployment.go b/resource-manager/nginx/2024-01-01-preview/nginxcertificate/id_nginxdeployment.go new file mode 100644 index 00000000000..5a0a6a0569c --- /dev/null +++ b/resource-manager/nginx/2024-01-01-preview/nginxcertificate/id_nginxdeployment.go @@ -0,0 +1,125 @@ +package nginxcertificate + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (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{} + +// 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", "nginxDeploymentValue"), + } +} + +// 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-01-01-preview/nginxcertificate/id_nginxdeployment_test.go b/resource-manager/nginx/2024-01-01-preview/nginxcertificate/id_nginxdeployment_test.go new file mode 100644 index 00000000000..6728a9958a3 --- /dev/null +++ b/resource-manager/nginx/2024-01-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", "nginxDeploymentValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-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 != "nginxDeploymentValue" { + t.Fatalf("Expected %q but got %q for Segment 'NginxDeploymentName'", id.NginxDeploymentName, "nginxDeploymentValue") + } +} + +func TestFormatNginxDeploymentID(t *testing.T) { + actual := NewNginxDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "nginxDeploymentValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentValue" + 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/nginxDeploymentValue", + Expected: &NginxDeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NginxDeploymentName: "nginxDeploymentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentValue/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/nginxDeploymentValue", + Expected: &NginxDeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NginxDeploymentName: "nginxDeploymentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentValue/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/nGiNxDePlOyMeNtVaLuE", + Expected: &NginxDeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NginxDeploymentName: "nGiNxDePlOyMeNtVaLuE", + }, + }, + { + // 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/nGiNxDePlOyMeNtVaLuE/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-01-01-preview/nginxcertificate/method_certificatescreateorupdate.go b/resource-manager/nginx/2024-01-01-preview/nginxcertificate/method_certificatescreateorupdate.go new file mode 100644 index 00000000000..2a7b5830e86 --- /dev/null +++ b/resource-manager/nginx/2024-01-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-01-01-preview/nginxcertificate/method_certificatesdelete.go b/resource-manager/nginx/2024-01-01-preview/nginxcertificate/method_certificatesdelete.go new file mode 100644 index 00000000000..2e68fad4bb8 --- /dev/null +++ b/resource-manager/nginx/2024-01-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-01-01-preview/nginxcertificate/method_certificatesget.go b/resource-manager/nginx/2024-01-01-preview/nginxcertificate/method_certificatesget.go new file mode 100644 index 00000000000..85b4e7490cd --- /dev/null +++ b/resource-manager/nginx/2024-01-01-preview/nginxcertificate/method_certificatesget.go @@ -0,0 +1,51 @@ +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 + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/nginx/2024-01-01-preview/nginxcertificate/method_certificateslist.go b/resource-manager/nginx/2024-01-01-preview/nginxcertificate/method_certificateslist.go new file mode 100644 index 00000000000..48dde168d6a --- /dev/null +++ b/resource-manager/nginx/2024-01-01-preview/nginxcertificate/method_certificateslist.go @@ -0,0 +1,91 @@ +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 +} + +// 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, + 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 { + err = fmt.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-01-01-preview/nginxcertificate/model_nginxcertificate.go b/resource-manager/nginx/2024-01-01-preview/nginxcertificate/model_nginxcertificate.go new file mode 100644 index 00000000000..0a59d6e6aee --- /dev/null +++ b/resource-manager/nginx/2024-01-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-01-01-preview/nginxcertificate/model_nginxcertificateerrorresponsebody.go b/resource-manager/nginx/2024-01-01-preview/nginxcertificate/model_nginxcertificateerrorresponsebody.go new file mode 100644 index 00000000000..2244c48f5dd --- /dev/null +++ b/resource-manager/nginx/2024-01-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-01-01-preview/nginxcertificate/model_nginxcertificateproperties.go b/resource-manager/nginx/2024-01-01-preview/nginxcertificate/model_nginxcertificateproperties.go new file mode 100644 index 00000000000..41bbb8a097a --- /dev/null +++ b/resource-manager/nginx/2024-01-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-01-01-preview/nginxcertificate/predicates.go b/resource-manager/nginx/2024-01-01-preview/nginxcertificate/predicates.go new file mode 100644 index 00000000000..b01a724d879 --- /dev/null +++ b/resource-manager/nginx/2024-01-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-01-01-preview/nginxcertificate/version.go b/resource-manager/nginx/2024-01-01-preview/nginxcertificate/version.go new file mode 100644 index 00000000000..a74fdde51b5 --- /dev/null +++ b/resource-manager/nginx/2024-01-01-preview/nginxcertificate/version.go @@ -0,0 +1,12 @@ +package nginxcertificate + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-01-01-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/nginxcertificate/%s", defaultApiVersion) +} diff --git a/resource-manager/nginx/2024-01-01-preview/nginxconfiguration/README.md b/resource-manager/nginx/2024-01-01-preview/nginxconfiguration/README.md new file mode 100644 index 00000000000..6daa7e77b40 --- /dev/null +++ b/resource-manager/nginx/2024-01-01-preview/nginxconfiguration/README.md @@ -0,0 +1,82 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/nginx/2024-01-01-preview/nginxconfiguration` Documentation + +The `nginxconfiguration` SDK allows for interaction with the Azure Resource Manager Service `nginx` (API Version `2024-01-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-01-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", "nginxDeploymentValue", "configurationValue") + +payload := nginxconfiguration.NginxConfiguration{ + // ... +} + + +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", "nginxDeploymentValue", "configurationValue") + +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", "nginxDeploymentValue", "configurationValue") + +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", "nginxDeploymentValue") + +// 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-01-01-preview/nginxconfiguration/client.go b/resource-manager/nginx/2024-01-01-preview/nginxconfiguration/client.go new file mode 100644 index 00000000000..d845625bb59 --- /dev/null +++ b/resource-manager/nginx/2024-01-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.NewResourceManagerClient(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-01-01-preview/nginxconfiguration/constants.go b/resource-manager/nginx/2024-01-01-preview/nginxconfiguration/constants.go new file mode 100644 index 00000000000..9abf4d96b6b --- /dev/null +++ b/resource-manager/nginx/2024-01-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-01-01-preview/nginxconfiguration/id_configuration.go b/resource-manager/nginx/2024-01-01-preview/nginxconfiguration/id_configuration.go new file mode 100644 index 00000000000..e05e56017fa --- /dev/null +++ b/resource-manager/nginx/2024-01-01-preview/nginxconfiguration/id_configuration.go @@ -0,0 +1,134 @@ +package nginxconfiguration + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (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{} + +// 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", "nginxDeploymentValue"), + resourceids.StaticSegment("staticConfigurations", "configurations", "configurations"), + resourceids.UserSpecifiedSegment("configurationName", "configurationValue"), + } +} + +// 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-01-01-preview/nginxconfiguration/id_configuration_test.go b/resource-manager/nginx/2024-01-01-preview/nginxconfiguration/id_configuration_test.go new file mode 100644 index 00000000000..f234c08f8e9 --- /dev/null +++ b/resource-manager/nginx/2024-01-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", "nginxDeploymentValue", "configurationValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-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 != "nginxDeploymentValue" { + t.Fatalf("Expected %q but got %q for Segment 'NginxDeploymentName'", id.NginxDeploymentName, "nginxDeploymentValue") + } + + if id.ConfigurationName != "configurationValue" { + t.Fatalf("Expected %q but got %q for Segment 'ConfigurationName'", id.ConfigurationName, "configurationValue") + } +} + +func TestFormatConfigurationID(t *testing.T) { + actual := NewConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "nginxDeploymentValue", "configurationValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentValue/configurations/configurationValue" + 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/nginxDeploymentValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentValue/configurations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentValue/configurations/configurationValue", + Expected: &ConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NginxDeploymentName: "nginxDeploymentValue", + ConfigurationName: "configurationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentValue/configurations/configurationValue/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/nginxDeploymentValue", + 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/nGiNxDePlOyMeNtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentValue/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/nGiNxDePlOyMeNtVaLuE/cOnFiGuRaTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentValue/configurations/configurationValue", + Expected: &ConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NginxDeploymentName: "nginxDeploymentValue", + ConfigurationName: "configurationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentValue/configurations/configurationValue/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/nGiNxDePlOyMeNtVaLuE/cOnFiGuRaTiOnS/cOnFiGuRaTiOnVaLuE", + Expected: &ConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NginxDeploymentName: "nGiNxDePlOyMeNtVaLuE", + ConfigurationName: "cOnFiGuRaTiOnVaLuE", + }, + }, + { + // 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/nGiNxDePlOyMeNtVaLuE/cOnFiGuRaTiOnS/cOnFiGuRaTiOnVaLuE/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-01-01-preview/nginxconfiguration/id_nginxdeployment.go b/resource-manager/nginx/2024-01-01-preview/nginxconfiguration/id_nginxdeployment.go new file mode 100644 index 00000000000..f04ef081103 --- /dev/null +++ b/resource-manager/nginx/2024-01-01-preview/nginxconfiguration/id_nginxdeployment.go @@ -0,0 +1,125 @@ +package nginxconfiguration + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (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{} + +// 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", "nginxDeploymentValue"), + } +} + +// 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-01-01-preview/nginxconfiguration/id_nginxdeployment_test.go b/resource-manager/nginx/2024-01-01-preview/nginxconfiguration/id_nginxdeployment_test.go new file mode 100644 index 00000000000..f47b5a616f4 --- /dev/null +++ b/resource-manager/nginx/2024-01-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", "nginxDeploymentValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-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 != "nginxDeploymentValue" { + t.Fatalf("Expected %q but got %q for Segment 'NginxDeploymentName'", id.NginxDeploymentName, "nginxDeploymentValue") + } +} + +func TestFormatNginxDeploymentID(t *testing.T) { + actual := NewNginxDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "nginxDeploymentValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentValue" + 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/nginxDeploymentValue", + Expected: &NginxDeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NginxDeploymentName: "nginxDeploymentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentValue/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/nginxDeploymentValue", + Expected: &NginxDeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NginxDeploymentName: "nginxDeploymentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentValue/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/nGiNxDePlOyMeNtVaLuE", + Expected: &NginxDeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NginxDeploymentName: "nGiNxDePlOyMeNtVaLuE", + }, + }, + { + // 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/nGiNxDePlOyMeNtVaLuE/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-01-01-preview/nginxconfiguration/method_configurationscreateorupdate.go b/resource-manager/nginx/2024-01-01-preview/nginxconfiguration/method_configurationscreateorupdate.go new file mode 100644 index 00000000000..dea245223f0 --- /dev/null +++ b/resource-manager/nginx/2024-01-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 *NginxConfiguration +} + +// ConfigurationsCreateOrUpdate ... +func (c NginxConfigurationClient) ConfigurationsCreateOrUpdate(ctx context.Context, id ConfigurationId, input NginxConfiguration) (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 NginxConfiguration) 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-01-01-preview/nginxconfiguration/method_configurationsdelete.go b/resource-manager/nginx/2024-01-01-preview/nginxconfiguration/method_configurationsdelete.go new file mode 100644 index 00000000000..37e56e51da7 --- /dev/null +++ b/resource-manager/nginx/2024-01-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-01-01-preview/nginxconfiguration/method_configurationsget.go b/resource-manager/nginx/2024-01-01-preview/nginxconfiguration/method_configurationsget.go new file mode 100644 index 00000000000..159fea21927 --- /dev/null +++ b/resource-manager/nginx/2024-01-01-preview/nginxconfiguration/method_configurationsget.go @@ -0,0 +1,51 @@ +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 *NginxConfiguration +} + +// 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 + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/nginx/2024-01-01-preview/nginxconfiguration/method_configurationslist.go b/resource-manager/nginx/2024-01-01-preview/nginxconfiguration/method_configurationslist.go new file mode 100644 index 00000000000..6a06b27012d --- /dev/null +++ b/resource-manager/nginx/2024-01-01-preview/nginxconfiguration/method_configurationslist.go @@ -0,0 +1,91 @@ +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 *[]NginxConfiguration +} + +type ConfigurationsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []NginxConfiguration +} + +// 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, + 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 *[]NginxConfiguration `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, NginxConfigurationOperationPredicate{}) +} + +// ConfigurationsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NginxConfigurationClient) ConfigurationsListCompleteMatchingPredicate(ctx context.Context, id NginxDeploymentId, predicate NginxConfigurationOperationPredicate) (result ConfigurationsListCompleteResult, err error) { + items := make([]NginxConfiguration, 0) + + resp, err := c.ConfigurationsList(ctx, id) + if err != nil { + err = fmt.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-01-01-preview/nginxconfiguration/model_nginxconfiguration.go b/resource-manager/nginx/2024-01-01-preview/nginxconfiguration/model_nginxconfiguration.go new file mode 100644 index 00000000000..06645eebbba --- /dev/null +++ b/resource-manager/nginx/2024-01-01-preview/nginxconfiguration/model_nginxconfiguration.go @@ -0,0 +1,17 @@ +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 NginxConfiguration struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NginxConfigurationProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/nginx/2024-01-01-preview/nginxconfiguration/model_nginxconfigurationfile.go b/resource-manager/nginx/2024-01-01-preview/nginxconfiguration/model_nginxconfigurationfile.go new file mode 100644 index 00000000000..127f7ff425a --- /dev/null +++ b/resource-manager/nginx/2024-01-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-01-01-preview/nginxconfiguration/model_nginxconfigurationpackage.go b/resource-manager/nginx/2024-01-01-preview/nginxconfiguration/model_nginxconfigurationpackage.go new file mode 100644 index 00000000000..b247778b539 --- /dev/null +++ b/resource-manager/nginx/2024-01-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-01-01-preview/nginxconfiguration/model_nginxconfigurationproperties.go b/resource-manager/nginx/2024-01-01-preview/nginxconfiguration/model_nginxconfigurationproperties.go new file mode 100644 index 00000000000..b68a006b58d --- /dev/null +++ b/resource-manager/nginx/2024-01-01-preview/nginxconfiguration/model_nginxconfigurationproperties.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 NginxConfigurationProperties struct { + Files *[]NginxConfigurationFile `json:"files,omitempty"` + Package *NginxConfigurationPackage `json:"package,omitempty"` + ProtectedFiles *[]NginxConfigurationFile `json:"protectedFiles,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RootFile *string `json:"rootFile,omitempty"` +} diff --git a/resource-manager/nginx/2024-01-01-preview/nginxconfiguration/predicates.go b/resource-manager/nginx/2024-01-01-preview/nginxconfiguration/predicates.go new file mode 100644 index 00000000000..0958a9d2b5d --- /dev/null +++ b/resource-manager/nginx/2024-01-01-preview/nginxconfiguration/predicates.go @@ -0,0 +1,32 @@ +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 NginxConfigurationOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p NginxConfigurationOperationPredicate) Matches(input NginxConfiguration) 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-01-01-preview/nginxconfiguration/version.go b/resource-manager/nginx/2024-01-01-preview/nginxconfiguration/version.go new file mode 100644 index 00000000000..df4fab485ba --- /dev/null +++ b/resource-manager/nginx/2024-01-01-preview/nginxconfiguration/version.go @@ -0,0 +1,12 @@ +package nginxconfiguration + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-01-01-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/nginxconfiguration/%s", defaultApiVersion) +} diff --git a/resource-manager/nginx/2024-01-01-preview/nginxconfigurationanalysis/README.md b/resource-manager/nginx/2024-01-01-preview/nginxconfigurationanalysis/README.md new file mode 100644 index 00000000000..43108f487d6 --- /dev/null +++ b/resource-manager/nginx/2024-01-01-preview/nginxconfigurationanalysis/README.md @@ -0,0 +1,41 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/nginx/2024-01-01-preview/nginxconfigurationanalysis` Documentation + +The `nginxconfigurationanalysis` SDK allows for interaction with the Azure Resource Manager Service `nginx` (API Version `2024-01-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-01-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", "nginxDeploymentValue", "configurationValue") + +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-01-01-preview/nginxconfigurationanalysis/client.go b/resource-manager/nginx/2024-01-01-preview/nginxconfigurationanalysis/client.go new file mode 100644 index 00000000000..c35a72f8247 --- /dev/null +++ b/resource-manager/nginx/2024-01-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.NewResourceManagerClient(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-01-01-preview/nginxconfigurationanalysis/id_configuration.go b/resource-manager/nginx/2024-01-01-preview/nginxconfigurationanalysis/id_configuration.go new file mode 100644 index 00000000000..3984112440e --- /dev/null +++ b/resource-manager/nginx/2024-01-01-preview/nginxconfigurationanalysis/id_configuration.go @@ -0,0 +1,134 @@ +package nginxconfigurationanalysis + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (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{} + +// 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", "nginxDeploymentValue"), + resourceids.StaticSegment("staticConfigurations", "configurations", "configurations"), + resourceids.UserSpecifiedSegment("configurationName", "configurationValue"), + } +} + +// 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-01-01-preview/nginxconfigurationanalysis/id_configuration_test.go b/resource-manager/nginx/2024-01-01-preview/nginxconfigurationanalysis/id_configuration_test.go new file mode 100644 index 00000000000..9e453323577 --- /dev/null +++ b/resource-manager/nginx/2024-01-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", "nginxDeploymentValue", "configurationValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-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 != "nginxDeploymentValue" { + t.Fatalf("Expected %q but got %q for Segment 'NginxDeploymentName'", id.NginxDeploymentName, "nginxDeploymentValue") + } + + if id.ConfigurationName != "configurationValue" { + t.Fatalf("Expected %q but got %q for Segment 'ConfigurationName'", id.ConfigurationName, "configurationValue") + } +} + +func TestFormatConfigurationID(t *testing.T) { + actual := NewConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "nginxDeploymentValue", "configurationValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentValue/configurations/configurationValue" + 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/nginxDeploymentValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentValue/configurations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentValue/configurations/configurationValue", + Expected: &ConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NginxDeploymentName: "nginxDeploymentValue", + ConfigurationName: "configurationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentValue/configurations/configurationValue/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/nginxDeploymentValue", + 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/nGiNxDePlOyMeNtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentValue/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/nGiNxDePlOyMeNtVaLuE/cOnFiGuRaTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentValue/configurations/configurationValue", + Expected: &ConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NginxDeploymentName: "nginxDeploymentValue", + ConfigurationName: "configurationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentValue/configurations/configurationValue/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/nGiNxDePlOyMeNtVaLuE/cOnFiGuRaTiOnS/cOnFiGuRaTiOnVaLuE", + Expected: &ConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NginxDeploymentName: "nGiNxDePlOyMeNtVaLuE", + ConfigurationName: "cOnFiGuRaTiOnVaLuE", + }, + }, + { + // 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/nGiNxDePlOyMeNtVaLuE/cOnFiGuRaTiOnS/cOnFiGuRaTiOnVaLuE/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-01-01-preview/nginxconfigurationanalysis/method_configurationsanalysis.go b/resource-manager/nginx/2024-01-01-preview/nginxconfigurationanalysis/method_configurationsanalysis.go new file mode 100644 index 00000000000..cd79269cd88 --- /dev/null +++ b/resource-manager/nginx/2024-01-01-preview/nginxconfigurationanalysis/method_configurationsanalysis.go @@ -0,0 +1,56 @@ +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 + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/nginx/2024-01-01-preview/nginxconfigurationanalysis/model_analysiscreate.go b/resource-manager/nginx/2024-01-01-preview/nginxconfigurationanalysis/model_analysiscreate.go new file mode 100644 index 00000000000..9bd340960df --- /dev/null +++ b/resource-manager/nginx/2024-01-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-01-01-preview/nginxconfigurationanalysis/model_analysiscreateconfig.go b/resource-manager/nginx/2024-01-01-preview/nginxconfigurationanalysis/model_analysiscreateconfig.go new file mode 100644 index 00000000000..5a84286132c --- /dev/null +++ b/resource-manager/nginx/2024-01-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 *[]NginxConfigurationFile `json:"protectedFiles,omitempty"` + RootFile *string `json:"rootFile,omitempty"` +} diff --git a/resource-manager/nginx/2024-01-01-preview/nginxconfigurationanalysis/model_analysisdiagnostic.go b/resource-manager/nginx/2024-01-01-preview/nginxconfigurationanalysis/model_analysisdiagnostic.go new file mode 100644 index 00000000000..e4f1e75b97d --- /dev/null +++ b/resource-manager/nginx/2024-01-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-01-01-preview/nginxconfigurationanalysis/model_analysisresult.go b/resource-manager/nginx/2024-01-01-preview/nginxconfigurationanalysis/model_analysisresult.go new file mode 100644 index 00000000000..f84e0071ea6 --- /dev/null +++ b/resource-manager/nginx/2024-01-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-01-01-preview/nginxconfigurationanalysis/model_analysisresultdata.go b/resource-manager/nginx/2024-01-01-preview/nginxconfigurationanalysis/model_analysisresultdata.go new file mode 100644 index 00000000000..38119ba3240 --- /dev/null +++ b/resource-manager/nginx/2024-01-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-01-01-preview/nginxconfigurationanalysis/model_nginxconfigurationfile.go b/resource-manager/nginx/2024-01-01-preview/nginxconfigurationanalysis/model_nginxconfigurationfile.go new file mode 100644 index 00000000000..1a735e79e48 --- /dev/null +++ b/resource-manager/nginx/2024-01-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-01-01-preview/nginxconfigurationanalysis/model_nginxconfigurationpackage.go b/resource-manager/nginx/2024-01-01-preview/nginxconfigurationanalysis/model_nginxconfigurationpackage.go new file mode 100644 index 00000000000..0aa2af797f0 --- /dev/null +++ b/resource-manager/nginx/2024-01-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-01-01-preview/nginxconfigurationanalysis/version.go b/resource-manager/nginx/2024-01-01-preview/nginxconfigurationanalysis/version.go new file mode 100644 index 00000000000..b9f3bc1c757 --- /dev/null +++ b/resource-manager/nginx/2024-01-01-preview/nginxconfigurationanalysis/version.go @@ -0,0 +1,12 @@ +package nginxconfigurationanalysis + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-01-01-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/nginxconfigurationanalysis/%s", defaultApiVersion) +} diff --git a/resource-manager/nginx/2024-01-01-preview/nginxdeployment/README.md b/resource-manager/nginx/2024-01-01-preview/nginxdeployment/README.md new file mode 100644 index 00000000000..fa64f3c78e4 --- /dev/null +++ b/resource-manager/nginx/2024-01-01-preview/nginxdeployment/README.md @@ -0,0 +1,117 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/nginx/2024-01-01-preview/nginxdeployment` Documentation + +The `nginxdeployment` SDK allows for interaction with the Azure Resource Manager Service `nginx` (API Version `2024-01-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-01-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", "nginxDeploymentValue") + +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", "nginxDeploymentValue") + +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", "nginxDeploymentValue") + +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", "nginxDeploymentValue") + +payload := nginxdeployment.NginxDeploymentUpdateParameters{ + // ... +} + + +if err := client.DeploymentsUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/nginx/2024-01-01-preview/nginxdeployment/client.go b/resource-manager/nginx/2024-01-01-preview/nginxdeployment/client.go new file mode 100644 index 00000000000..7f5e031b02e --- /dev/null +++ b/resource-manager/nginx/2024-01-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.NewResourceManagerClient(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-01-01-preview/nginxdeployment/constants.go b/resource-manager/nginx/2024-01-01-preview/nginxdeployment/constants.go new file mode 100644 index 00000000000..4d2e27c3ab7 --- /dev/null +++ b/resource-manager/nginx/2024-01-01-preview/nginxdeployment/constants.go @@ -0,0 +1,113 @@ +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 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-01-01-preview/nginxdeployment/id_nginxdeployment.go b/resource-manager/nginx/2024-01-01-preview/nginxdeployment/id_nginxdeployment.go new file mode 100644 index 00000000000..718b72ec797 --- /dev/null +++ b/resource-manager/nginx/2024-01-01-preview/nginxdeployment/id_nginxdeployment.go @@ -0,0 +1,125 @@ +package nginxdeployment + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (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{} + +// 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", "nginxDeploymentValue"), + } +} + +// 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-01-01-preview/nginxdeployment/id_nginxdeployment_test.go b/resource-manager/nginx/2024-01-01-preview/nginxdeployment/id_nginxdeployment_test.go new file mode 100644 index 00000000000..25fcab0649a --- /dev/null +++ b/resource-manager/nginx/2024-01-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", "nginxDeploymentValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-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 != "nginxDeploymentValue" { + t.Fatalf("Expected %q but got %q for Segment 'NginxDeploymentName'", id.NginxDeploymentName, "nginxDeploymentValue") + } +} + +func TestFormatNginxDeploymentID(t *testing.T) { + actual := NewNginxDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "nginxDeploymentValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentValue" + 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/nginxDeploymentValue", + Expected: &NginxDeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NginxDeploymentName: "nginxDeploymentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentValue/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/nginxDeploymentValue", + Expected: &NginxDeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NginxDeploymentName: "nginxDeploymentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Nginx.NginxPlus/nginxDeployments/nginxDeploymentValue/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/nGiNxDePlOyMeNtVaLuE", + Expected: &NginxDeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NginxDeploymentName: "nGiNxDePlOyMeNtVaLuE", + }, + }, + { + // 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/nGiNxDePlOyMeNtVaLuE/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-01-01-preview/nginxdeployment/method_deploymentscreateorupdate.go b/resource-manager/nginx/2024-01-01-preview/nginxdeployment/method_deploymentscreateorupdate.go new file mode 100644 index 00000000000..e4c9f1cba7b --- /dev/null +++ b/resource-manager/nginx/2024-01-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-01-01-preview/nginxdeployment/method_deploymentsdelete.go b/resource-manager/nginx/2024-01-01-preview/nginxdeployment/method_deploymentsdelete.go new file mode 100644 index 00000000000..062f299f4a4 --- /dev/null +++ b/resource-manager/nginx/2024-01-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-01-01-preview/nginxdeployment/method_deploymentsget.go b/resource-manager/nginx/2024-01-01-preview/nginxdeployment/method_deploymentsget.go new file mode 100644 index 00000000000..d9da675e7ce --- /dev/null +++ b/resource-manager/nginx/2024-01-01-preview/nginxdeployment/method_deploymentsget.go @@ -0,0 +1,51 @@ +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 + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/nginx/2024-01-01-preview/nginxdeployment/method_deploymentslist.go b/resource-manager/nginx/2024-01-01-preview/nginxdeployment/method_deploymentslist.go new file mode 100644 index 00000000000..4dd69428b7a --- /dev/null +++ b/resource-manager/nginx/2024-01-01-preview/nginxdeployment/method_deploymentslist.go @@ -0,0 +1,92 @@ +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 +} + +// 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, + 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 { + err = fmt.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-01-01-preview/nginxdeployment/method_deploymentslistbyresourcegroup.go b/resource-manager/nginx/2024-01-01-preview/nginxdeployment/method_deploymentslistbyresourcegroup.go new file mode 100644 index 00000000000..4c94db61254 --- /dev/null +++ b/resource-manager/nginx/2024-01-01-preview/nginxdeployment/method_deploymentslistbyresourcegroup.go @@ -0,0 +1,92 @@ +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 +} + +// 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, + 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 { + err = fmt.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-01-01-preview/nginxdeployment/method_deploymentsupdate.go b/resource-manager/nginx/2024-01-01-preview/nginxdeployment/method_deploymentsupdate.go new file mode 100644 index 00000000000..d6ab0244f52 --- /dev/null +++ b/resource-manager/nginx/2024-01-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-01-01-preview/nginxdeployment/model_autoupgradeprofile.go b/resource-manager/nginx/2024-01-01-preview/nginxdeployment/model_autoupgradeprofile.go new file mode 100644 index 00000000000..2061898d495 --- /dev/null +++ b/resource-manager/nginx/2024-01-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-01-01-preview/nginxdeployment/model_nginxdeployment.go b/resource-manager/nginx/2024-01-01-preview/nginxdeployment/model_nginxdeployment.go new file mode 100644 index 00000000000..25453bf6d88 --- /dev/null +++ b/resource-manager/nginx/2024-01-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-01-01-preview/nginxdeployment/model_nginxdeploymentproperties.go b/resource-manager/nginx/2024-01-01-preview/nginxdeployment/model_nginxdeploymentproperties.go new file mode 100644 index 00000000000..6b389e3d43f --- /dev/null +++ b/resource-manager/nginx/2024-01-01-preview/nginxdeployment/model_nginxdeploymentproperties.go @@ -0,0 +1,17 @@ +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"` + EnableDiagnosticsSupport *bool `json:"enableDiagnosticsSupport,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + Logging *NginxLogging `json:"logging,omitempty"` + ManagedResourceGroup *string `json:"managedResourceGroup,omitempty"` + NetworkProfile *NginxNetworkProfile `json:"networkProfile,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-01-01-preview/nginxdeployment/model_nginxdeploymentscalingproperties.go b/resource-manager/nginx/2024-01-01-preview/nginxdeployment/model_nginxdeploymentscalingproperties.go new file mode 100644 index 00000000000..7142527f38a --- /dev/null +++ b/resource-manager/nginx/2024-01-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-01-01-preview/nginxdeployment/model_nginxdeploymentscalingpropertiesautoscalesettings.go b/resource-manager/nginx/2024-01-01-preview/nginxdeployment/model_nginxdeploymentscalingpropertiesautoscalesettings.go new file mode 100644 index 00000000000..28951659cae --- /dev/null +++ b/resource-manager/nginx/2024-01-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-01-01-preview/nginxdeployment/model_nginxdeploymentupdateparameters.go b/resource-manager/nginx/2024-01-01-preview/nginxdeployment/model_nginxdeploymentupdateparameters.go new file mode 100644 index 00000000000..00b1615d7e0 --- /dev/null +++ b/resource-manager/nginx/2024-01-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-01-01-preview/nginxdeployment/model_nginxdeploymentupdateproperties.go b/resource-manager/nginx/2024-01-01-preview/nginxdeployment/model_nginxdeploymentupdateproperties.go new file mode 100644 index 00000000000..d7963423da8 --- /dev/null +++ b/resource-manager/nginx/2024-01-01-preview/nginxdeployment/model_nginxdeploymentupdateproperties.go @@ -0,0 +1,12 @@ +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"` + ScalingProperties *NginxDeploymentScalingProperties `json:"scalingProperties,omitempty"` + UserProfile *NginxDeploymentUserProfile `json:"userProfile,omitempty"` +} diff --git a/resource-manager/nginx/2024-01-01-preview/nginxdeployment/model_nginxdeploymentuserprofile.go b/resource-manager/nginx/2024-01-01-preview/nginxdeployment/model_nginxdeploymentuserprofile.go new file mode 100644 index 00000000000..153bfb0e2e1 --- /dev/null +++ b/resource-manager/nginx/2024-01-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-01-01-preview/nginxdeployment/model_nginxfrontendipconfiguration.go b/resource-manager/nginx/2024-01-01-preview/nginxdeployment/model_nginxfrontendipconfiguration.go new file mode 100644 index 00000000000..e084038d690 --- /dev/null +++ b/resource-manager/nginx/2024-01-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-01-01-preview/nginxdeployment/model_nginxlogging.go b/resource-manager/nginx/2024-01-01-preview/nginxdeployment/model_nginxlogging.go new file mode 100644 index 00000000000..c5c8ff18d05 --- /dev/null +++ b/resource-manager/nginx/2024-01-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-01-01-preview/nginxdeployment/model_nginxnetworkinterfaceconfiguration.go b/resource-manager/nginx/2024-01-01-preview/nginxdeployment/model_nginxnetworkinterfaceconfiguration.go new file mode 100644 index 00000000000..b101806aebb --- /dev/null +++ b/resource-manager/nginx/2024-01-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-01-01-preview/nginxdeployment/model_nginxnetworkprofile.go b/resource-manager/nginx/2024-01-01-preview/nginxdeployment/model_nginxnetworkprofile.go new file mode 100644 index 00000000000..26ded847b53 --- /dev/null +++ b/resource-manager/nginx/2024-01-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-01-01-preview/nginxdeployment/model_nginxprivateipaddress.go b/resource-manager/nginx/2024-01-01-preview/nginxdeployment/model_nginxprivateipaddress.go new file mode 100644 index 00000000000..9bce7dba730 --- /dev/null +++ b/resource-manager/nginx/2024-01-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-01-01-preview/nginxdeployment/model_nginxpublicipaddress.go b/resource-manager/nginx/2024-01-01-preview/nginxdeployment/model_nginxpublicipaddress.go new file mode 100644 index 00000000000..05e8036a6e4 --- /dev/null +++ b/resource-manager/nginx/2024-01-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-01-01-preview/nginxdeployment/model_nginxstorageaccount.go b/resource-manager/nginx/2024-01-01-preview/nginxdeployment/model_nginxstorageaccount.go new file mode 100644 index 00000000000..f53382105bf --- /dev/null +++ b/resource-manager/nginx/2024-01-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-01-01-preview/nginxdeployment/model_resourcesku.go b/resource-manager/nginx/2024-01-01-preview/nginxdeployment/model_resourcesku.go new file mode 100644 index 00000000000..85a9b9b55da --- /dev/null +++ b/resource-manager/nginx/2024-01-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-01-01-preview/nginxdeployment/model_scaleprofile.go b/resource-manager/nginx/2024-01-01-preview/nginxdeployment/model_scaleprofile.go new file mode 100644 index 00000000000..35f11b10aa5 --- /dev/null +++ b/resource-manager/nginx/2024-01-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-01-01-preview/nginxdeployment/model_scaleprofilecapacity.go b/resource-manager/nginx/2024-01-01-preview/nginxdeployment/model_scaleprofilecapacity.go new file mode 100644 index 00000000000..a1fd2137891 --- /dev/null +++ b/resource-manager/nginx/2024-01-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-01-01-preview/nginxdeployment/predicates.go b/resource-manager/nginx/2024-01-01-preview/nginxdeployment/predicates.go new file mode 100644 index 00000000000..d1754320d3a --- /dev/null +++ b/resource-manager/nginx/2024-01-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-01-01-preview/nginxdeployment/version.go b/resource-manager/nginx/2024-01-01-preview/nginxdeployment/version.go new file mode 100644 index 00000000000..573a5620d75 --- /dev/null +++ b/resource-manager/nginx/2024-01-01-preview/nginxdeployment/version.go @@ -0,0 +1,12 @@ +package nginxdeployment + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-01-01-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/nginxdeployment/%s", defaultApiVersion) +}