From 9389ffbfcdabdd1a22f751a2202f7922d2911f0c Mon Sep 17 00:00:00 2001 From: "Xiaxin Yi (from Dev Box)" Date: Fri, 29 Mar 2024 10:04:25 +0800 Subject: [PATCH 1/8] support certificate order key vault binding --- ...p_service_certificate_order_certificate.go | 243 +++++++++++ ...vice_certificate_order_certificate_test.go | 328 +++++++++++++++ internal/services/appservice/client/client.go | 29 +- internal/services/appservice/registration.go | 1 + .../app_service_certificate_order_resource.go | 6 + .../app_service_certificate_order.go | 166 ++++++++ .../services/web/parse/certificate_order.go | 2 +- .../web/parse/certificate_order_old.go | 72 ++++ .../web/parse/certificate_order_old_test.go | 115 ++++++ .../web/parse/certificate_order_test.go | 10 +- internal/services/web/resourceids.go | 3 +- .../web/validate/certificate_order_id_test.go | 8 +- .../web/validate/certificate_order_old_id.go | 26 ++ .../validate/certificate_order_old_id_test.go | 79 ++++ .../appservicecertificateorders/README.md | 381 ++++++++++++++++++ .../appservicecertificateorders/client.go | 26 ++ .../appservicecertificateorders/constants.go | 355 ++++++++++++++++ .../id_certificate.go | 134 ++++++ .../id_certificateorder.go | 125 ++++++ .../method_createorupdate.go | 75 ++++ .../method_createorupdatecertificate.go | 75 ++++ .../method_delete.go | 47 +++ .../method_deletecertificate.go | 47 +++ .../appservicecertificateorders/method_get.go | 54 +++ .../method_getcertificate.go | 54 +++ .../method_list.go | 92 +++++ .../method_listbyresourcegroup.go | 92 +++++ .../method_listcertificates.go | 91 +++++ .../method_reissue.go | 51 +++ .../method_renew.go | 51 +++ .../method_resendemail.go | 47 +++ .../method_resendrequestemails.go | 51 +++ .../method_retrievecertificateactions.go | 55 +++ .../method_retrievecertificateemailhistory.go | 55 +++ .../method_retrievesiteseal.go | 59 +++ .../method_update.go | 58 +++ .../method_updatecertificate.go | 58 +++ .../method_validatepurchaseinformation.go | 52 +++ .../method_verifydomainownership.go | 47 +++ .../model_appservicecertificate.go | 10 + .../model_appservicecertificateorder.go | 14 + ...appservicecertificateorderpatchresource.go | 12 + ...certificateorderpatchresourceproperties.go | 69 ++++ ...el_appservicecertificateorderproperties.go | 69 ++++ ...odel_appservicecertificatepatchresource.go | 12 + .../model_appservicecertificateresource.go | 14 + .../model_certificatedetails.go | 46 +++ .../model_certificateemail.go | 27 ++ .../model_certificateorderaction.go | 27 ++ .../model_certificateordercontact.go | 11 + .../model_nameidentifier.go | 8 + .../model_reissuecertificateorderrequest.go | 12 + ...eissuecertificateorderrequestproperties.go | 11 + .../model_renewcertificateorderrequest.go | 12 + ..._renewcertificateorderrequestproperties.go | 10 + .../model_siteseal.go | 8 + .../model_sitesealrequest.go | 9 + .../appservicecertificateorders/predicates.go | 70 ++++ .../appservicecertificateorders/version.go | 12 + vendor/modules.txt | 1 + ...ertificate_order_certificate.html.markdown | 133 ++++++ 61 files changed, 3896 insertions(+), 21 deletions(-) create mode 100644 internal/services/appservice/app_service_certificate_order_certificate.go create mode 100644 internal/services/appservice/app_service_certificate_order_certificate_test.go create mode 100644 internal/services/web/migration/app_service_certificate_order.go create mode 100644 internal/services/web/parse/certificate_order_old.go create mode 100644 internal/services/web/parse/certificate_order_old_test.go create mode 100644 internal/services/web/validate/certificate_order_old_id.go create mode 100644 internal/services/web/validate/certificate_order_old_id_test.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/constants.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/id_certificate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/id_certificateorder.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_createorupdate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_createorupdatecertificate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_delete.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_deletecertificate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_get.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_getcertificate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_list.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_listbyresourcegroup.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_listcertificates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_reissue.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_renew.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_resendemail.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_resendrequestemails.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_retrievecertificateactions.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_retrievecertificateemailhistory.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_retrievesiteseal.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_update.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_updatecertificate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_validatepurchaseinformation.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_verifydomainownership.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_appservicecertificate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_appservicecertificateorder.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_appservicecertificateorderpatchresource.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_appservicecertificateorderpatchresourceproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_appservicecertificateorderproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_appservicecertificatepatchresource.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_appservicecertificateresource.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_certificatedetails.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_certificateemail.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_certificateorderaction.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_certificateordercontact.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_nameidentifier.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_reissuecertificateorderrequest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_reissuecertificateorderrequestproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_renewcertificateorderrequest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_renewcertificateorderrequestproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_siteseal.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_sitesealrequest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/predicates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/version.go create mode 100644 website/docs/r/app_service_certificate_order_certificate.html.markdown diff --git a/internal/services/appservice/app_service_certificate_order_certificate.go b/internal/services/appservice/app_service_certificate_order_certificate.go new file mode 100644 index 000000000000..128cfc058c04 --- /dev/null +++ b/internal/services/appservice/app_service_certificate_order_certificate.go @@ -0,0 +1,243 @@ +package appservice + +import ( + "context" + "fmt" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/suppress" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders" + "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" + keyVaultValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/keyvault/validate" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/validate" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" +) + +type CertificateOrderCertificateResource struct{} + +type CertificateOrderCertificateModel struct { + Name string `tfschema:"name"` + CertificateOrderId string `tfschema:"certificate_order_id"` + Location string `tfschema:"location"` + KeyVaultId string `tfschema:"key_vault_id"` + KeyVaultSecretName string `tfschema:"key_vault_secret_name"` +} + +func (r CertificateOrderCertificateResource) Arguments() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "certificate_order_id": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.CertificateOrderID, + }, + + "key_vault_id": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: commonids.ValidateKeyVaultID, + // TODO -- remove when issue https://github.com/Azure/azure-rest-api-specs/issues/28498 is addressed + DiffSuppressFunc: suppress.CaseDifference, + }, + + "key_vault_secret_name": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: keyVaultValidate.NestedItemName, + }, + } +} + +func (r CertificateOrderCertificateResource) Attributes() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + "location": commonschema.LocationComputed(), + + "type": { + Type: pluginsdk.TypeString, + Computed: true, + }, + } +} + +func (r CertificateOrderCertificateResource) ModelObject() interface{} { + return &CertificateOrderCertificateModel{} +} + +func (r CertificateOrderCertificateResource) ResourceType() string { + return "azurerm_app_service_certificate_order_certificate" +} + +func (r CertificateOrderCertificateResource) Create() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 60 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + var certificateOrderCertificate CertificateOrderCertificateModel + if err := metadata.Decode(&certificateOrderCertificate); err != nil { + return err + } + + client := metadata.Client.AppService.AppServiceCertificatesOrderClient + subscriptionId := metadata.Client.Account.SubscriptionId + + certificateOrderId, err := appservicecertificateorders.ParseCertificateOrderID(certificateOrderCertificate.CertificateOrderId) + if err != nil { + return fmt.Errorf("parsing certificate order error %+v", err) + } + id := appservicecertificateorders.NewCertificateID(subscriptionId, certificateOrderId.ResourceGroupName, certificateOrderId.CertificateOrderName, certificateOrderCertificate.Name) + + keyVaultId, err := commonids.ParseKeyVaultIDInsensitively(certificateOrderCertificate.KeyVaultId) + if err != nil { + return err + } + kvId := commonids.NewKeyVaultID(keyVaultId.SubscriptionId, keyVaultId.ResourceGroupName, keyVaultId.VaultName) + + existing, err := client.GetCertificate(ctx, id) + if err != nil && !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("retreiving %s: %v", id, err) + } + if !response.WasNotFound(existing.HttpResponse) { + return metadata.ResourceRequiresImport(r.ResourceType(), id) + } + + certOrderCertificate := appservicecertificateorders.AppServiceCertificateResource{ + Name: pointer.To(certificateOrderCertificate.Name), + Properties: &appservicecertificateorders.AppServiceCertificate{ + KeyVaultId: pointer.To(kvId.ID()), + KeyVaultSecretName: pointer.To(certificateOrderCertificate.KeyVaultSecretName), + }, + } + + if err := client.CreateOrUpdateCertificateThenPoll(ctx, id, certOrderCertificate); err != nil { + return fmt.Errorf("creating %s: %+v", id, err) + } + + metadata.SetID(id) + + return nil + }, + } +} + +func (r CertificateOrderCertificateResource) Read() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 5 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.AppService.AppServiceCertificatesOrderClient + id, err := appservicecertificateorders.ParseCertificateIDInsensitively(metadata.ResourceData.Id()) + if err != nil { + return err + } + + certificateOrderCertificate, err := client.GetCertificate(ctx, *id) + if err != nil { + if response.WasNotFound(certificateOrderCertificate.HttpResponse) { + return metadata.MarkAsGone(id) + } + return fmt.Errorf("reading %s: %+v", id, err) + } + + state := CertificateOrderCertificateModel{ + Name: id.CertificateName, + } + + certificateOrderId := appservicecertificateorders.NewCertificateOrderID(id.SubscriptionId, id.ResourceGroupName, id.CertificateOrderName) + state.CertificateOrderId = certificateOrderId.ID() + + if model := certificateOrderCertificate.Model; model != nil { + state.Location = model.Location + if props := model.Properties; props != nil { + if props.KeyVaultId != nil { + keyVaultId, err := commonids.ParseKeyVaultIDInsensitively(*props.KeyVaultId) + if err != nil { + return err + } + state.KeyVaultId = keyVaultId.ID() + } + state.KeyVaultSecretName = pointer.From(props.KeyVaultSecretName) + } + } + if err := metadata.Encode(&state); err != nil { + return fmt.Errorf("encoding: %+v", err) + } + + return nil + }, + } +} + +func (r CertificateOrderCertificateResource) Delete() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 60 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + id, err := appservicecertificateorders.ParseCertificateIDInsensitively(metadata.ResourceData.Id()) + if err != nil { + return err + } + + client := metadata.Client.AppService.AppServiceCertificatesOrderClient + metadata.Logger.Infof("deleting %s", id) + + if _, err := client.DeleteCertificate(ctx, *id); err != nil { + return fmt.Errorf("deleting %s: %+v", id, err) + } + + return nil + }, + } +} + +func (r CertificateOrderCertificateResource) Update() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 60 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + id, err := appservicecertificateorders.ParseCertificateIDInsensitively(metadata.ResourceData.Id()) + if err != nil { + return err + } + + client := metadata.Client.AppService.AppServiceCertificatesOrderClient + + var state CertificateOrderCertificateModel + if err := metadata.Decode(&state); err != nil { + return fmt.Errorf("decoding: %+v", err) + } + + existing, err := client.GetCertificate(ctx, *id) + if err != nil { + return fmt.Errorf("reading %s: %+v", id, err) + } + + model := *existing.Model + + if metadata.ResourceData.HasChange("key_vault_id") { + model.Properties.KeyVaultId = pointer.To(state.KeyVaultId) + } + + if metadata.ResourceData.HasChange("key_vault_secret_name") { + model.Properties.KeyVaultSecretName = pointer.To(state.KeyVaultSecretName) + } + + if err := client.CreateOrUpdateCertificateThenPoll(ctx, *id, model); err != nil { + return fmt.Errorf("updating %s: %+v", id, err) + } + + return nil + }, + } +} + +func (r CertificateOrderCertificateResource) IDValidationFunc() pluginsdk.SchemaValidateFunc { + return appservicecertificateorders.ValidateCertificateID +} diff --git a/internal/services/appservice/app_service_certificate_order_certificate_test.go b/internal/services/appservice/app_service_certificate_order_certificate_test.go new file mode 100644 index 000000000000..4f51fa880d7f --- /dev/null +++ b/internal/services/appservice/app_service_certificate_order_certificate_test.go @@ -0,0 +1,328 @@ +package appservice_test + +import ( + "context" + "fmt" + "testing" + + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" + "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/utils" +) + +type CertificateOrderCertificateResource struct{} + +func TestAccAppServiceCertificateOrderCertificate_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_app_service_certificate_order_certificate", "test") + r := CertificateOrderCertificateResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func TestAccAppServiceCertificateOrderCertificate_updateKeyVaultId(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_app_service_certificate_order_certificate", "test") + r := CertificateOrderCertificateResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + { + Config: r.keyVaultIdUpdate(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} +func TestAccAppServiceCertificateOrderCertificate_updateKeyVaultName(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_app_service_certificate_order_certificate", "test") + r := CertificateOrderCertificateResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + { + Config: r.keyVaultNameUpdate(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func (r CertificateOrderCertificateResource) Exists(ctx context.Context, client *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { + id, err := appservicecertificateorders.ParseCertificateIDInsensitively(state.ID) + if err != nil { + return nil, err + } + + resp, err := client.AppService.AppServiceCertificatesOrderClient.GetCertificate(ctx, *id) + if err != nil { + if response.WasNotFound(resp.HttpResponse) { + return utils.Bool(false), nil + } + return nil, fmt.Errorf("retreiving %s: %v", id, err) + } + + if response.WasNotFound(resp.HttpResponse) { + return utils.Bool(false), nil + } + return utils.Bool(true), nil +} + +// Configs + +func (r CertificateOrderCertificateResource) basic(data acceptance.TestData) string { + template := r.template(data) + return fmt.Sprintf(` +%s +resource "azurerm_app_service_certificate_order_certificate" "test" { + name = "acctestcokv-%[2]s" + certificate_order_id = data.azurerm_app_service_certificate_order.test.id + key_vault_id = azurerm_key_vault.test.id + key_vault_secret_name = "kvsec%[2]s" +} +`, template, data.RandomStringOfLength(5)) +} + +func (r CertificateOrderCertificateResource) keyVaultIdUpdate(data acceptance.TestData) string { + template := r.template(data) + return fmt.Sprintf(` +%s +resource "azurerm_app_service_certificate_order_certificate" "test" { + name = "acctestcokv-%[2]s" + certificate_order_id = data.azurerm_app_service_certificate_order.test.id + key_vault_id = azurerm_key_vault.test1.id + key_vault_secret_name = "kvsec%[2]s" +} +`, template, data.RandomStringOfLength(5)) +} + +func (r CertificateOrderCertificateResource) keyVaultNameUpdate(data acceptance.TestData) string { + template := r.template(data) + return fmt.Sprintf(` +%s +resource "azurerm_app_service_certificate_order_certificate" "test" { + name = "acctestcokv-%[2]s" + certificate_order_id = data.azurerm_app_service_certificate_order.test.id + key_vault_id = azurerm_key_vault.test.id + key_vault_secret_name = "kvsec1%[2]s" +} +`, template, data.RandomStringOfLength(5)) +} + +func (r CertificateOrderCertificateResource) template(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +provider "azuread" {} + +data "azurerm_client_config" "test" {} + +data "azuread_service_principal" "cert-spn" { + display_name = "Microsoft.Azure.CertificateRegistration" +} + +data "azuread_service_principal" "app-service-spn" { + display_name = "Microsoft Azure App Service" +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_key_vault" "test" { + name = "acctestkv-%[3]s" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + + tenant_id = data.azurerm_client_config.test.tenant_id + + sku_name = "standard" + + + access_policy { + tenant_id = data.azurerm_client_config.test.tenant_id + object_id = data.azurerm_client_config.test.object_id + + secret_permissions = [ + "Delete", + "Get", + "Purge", + "Set", + "List" + ] + + certificate_permissions = [ + "Create", + "Delete", + "Get", + "Purge", + "Import", + "List" + ] + } + + // app service + access_policy { + tenant_id = data.azurerm_client_config.test.tenant_id + object_id = data.azuread_service_principal.app-service-spn.object_id + + secret_permissions = [ + "Delete", + "Get", + "Purge", + "Set", + "List" + ] + + certificate_permissions = [ + "Create", + "Delete", + "Get", + "Purge", + "Import", + "List" + ] + } + + // Microsoft.Azure.CertificateRegistration + access_policy { + tenant_id = data.azurerm_client_config.test.tenant_id + object_id = data.azuread_service_principal.cert-spn.object_id + + secret_permissions = [ + "Delete", + "Get", + "Purge", + "Set", + "List" + ] + + certificate_permissions = [ + "Create", + "Delete", + "Get", + "Purge", + "Import", + "List" + ] + } +} + +resource "azurerm_key_vault" "test1" { + name = "acctestkv1-%[3]s" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + + tenant_id = data.azurerm_client_config.test.tenant_id + + sku_name = "standard" + + + access_policy { + tenant_id = data.azurerm_client_config.test.tenant_id + object_id = data.azurerm_client_config.test.object_id + + secret_permissions = [ + "Delete", + "Get", + "Purge", + "Set", + "List" + ] + + certificate_permissions = [ + "Create", + "Delete", + "Get", + "Purge", + "Import", + "List" + ] + } + + // app service + access_policy { + tenant_id = data.azurerm_client_config.test.tenant_id + object_id = data.azuread_service_principal.app-service-spn.object_id + + secret_permissions = [ + "Delete", + "Get", + "Purge", + "Set", + "List" + ] + + certificate_permissions = [ + "Create", + "Delete", + "Get", + "Purge", + "Import", + "List" + ] + } + + // Microsoft.Azure.CertificateRegistration + access_policy { + tenant_id = data.azurerm_client_config.test.tenant_id + object_id = data.azuread_service_principal.cert-spn.object_id + + secret_permissions = [ + "Delete", + "Get", + "Purge", + "Set", + "List" + ] + + certificate_permissions = [ + "Create", + "Delete", + "Get", + "Purge", + "Import", + "List" + ] + } +} + +resource "azurerm_app_service_certificate_order" "test" { + name = "tftestASCO-cert-%[3]s" + location = "global" + resource_group_name = azurerm_resource_group.test.name + distinguished_name = "CN=example.com" + product_type = "Standard" +} + +`, data.RandomInteger, data.Locations.Primary, data.RandomStringOfLength(5)) +} diff --git a/internal/services/appservice/client/client.go b/internal/services/appservice/client/client.go index 1063269f2138..c3dd6853a63d 100644 --- a/internal/services/appservice/client/client.go +++ b/internal/services/appservice/client/client.go @@ -6,6 +6,7 @@ package client import ( "fmt" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders" "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appserviceenvironments" "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appserviceplans" "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/resourceproviders" @@ -15,11 +16,12 @@ import ( ) type Client struct { - AppServiceEnvironmentClient *appserviceenvironments.AppServiceEnvironmentsClient - ResourceProvidersClient *resourceproviders.ResourceProvidersClient - ServicePlanClient *appserviceplans.AppServicePlansClient - StaticSitesClient *staticsites.StaticSitesClient - WebAppsClient *webapps.WebAppsClient + AppServiceEnvironmentClient *appserviceenvironments.AppServiceEnvironmentsClient + ResourceProvidersClient *resourceproviders.ResourceProvidersClient + ServicePlanClient *appserviceplans.AppServicePlansClient + StaticSitesClient *staticsites.StaticSitesClient + WebAppsClient *webapps.WebAppsClient + AppServiceCertificatesOrderClient *appservicecertificateorders.AppServiceCertificateOrdersClient } func NewClient(o *common.ClientOptions) (*Client, error) { @@ -53,11 +55,18 @@ func NewClient(o *common.ClientOptions) (*Client, error) { } o.Configure(servicePlanClient.Client, o.Authorizers.ResourceManager) + appServiceCertificatesOrderClient, err := appservicecertificateorders.NewAppServiceCertificateOrdersClientWithBaseURI(o.Environment.ResourceManager) + if err != nil { + return nil, fmt.Errorf("building Appservice Certificate Order client: %+v", err) + } + o.Configure(appServiceCertificatesOrderClient.Client, o.Authorizers.ResourceManager) + return &Client{ - AppServiceEnvironmentClient: appServiceEnvironmentClient, - ResourceProvidersClient: resourceProvidersClient, - ServicePlanClient: servicePlanClient, - StaticSitesClient: staticSitesClient, - WebAppsClient: webAppServiceClient, + AppServiceEnvironmentClient: appServiceEnvironmentClient, + ResourceProvidersClient: resourceProvidersClient, + ServicePlanClient: servicePlanClient, + StaticSitesClient: staticSitesClient, + WebAppsClient: webAppServiceClient, + AppServiceCertificatesOrderClient: appServiceCertificatesOrderClient, }, nil } diff --git a/internal/services/appservice/registration.go b/internal/services/appservice/registration.go index 27ea650960cf..62c4626b0035 100644 --- a/internal/services/appservice/registration.go +++ b/internal/services/appservice/registration.go @@ -58,5 +58,6 @@ func (r Registration) Resources() []sdk.Resource { WindowsFunctionAppSlotResource{}, WindowsWebAppResource{}, WindowsWebAppSlotResource{}, + CertificateOrderCertificateResource{}, } } diff --git a/internal/services/web/app_service_certificate_order_resource.go b/internal/services/web/app_service_certificate_order_resource.go index 415467db71a7..cf219be2e2ec 100644 --- a/internal/services/web/app_service_certificate_order_resource.go +++ b/internal/services/web/app_service_certificate_order_resource.go @@ -13,6 +13,7 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/migration" "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tags" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" @@ -32,6 +33,11 @@ func resourceAppServiceCertificateOrder() *pluginsdk.Resource { return err }), + SchemaVersion: 1, + StateUpgraders: pluginsdk.StateUpgrades(map[int]pluginsdk.StateUpgrade{ + 0: migration.AppServiceCertificateOrderResourceV0ToV1{}, + }), + Timeouts: &pluginsdk.ResourceTimeout{ Create: pluginsdk.DefaultTimeout(30 * time.Minute), Read: pluginsdk.DefaultTimeout(5 * time.Minute), diff --git a/internal/services/web/migration/app_service_certificate_order.go b/internal/services/web/migration/app_service_certificate_order.go new file mode 100644 index 000000000000..c14edfec6b34 --- /dev/null +++ b/internal/services/web/migration/app_service_certificate_order.go @@ -0,0 +1,166 @@ +package migration + +import ( + "context" + "fmt" + + "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/parse" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" +) + +var _ pluginsdk.StateUpgrade = AppServiceCertificateOrderResourceV0ToV1{} + +type AppServiceCertificateOrderResourceV0ToV1 struct{} + +func (AppServiceCertificateOrderResourceV0ToV1) Schema() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + }, + + "location": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + }, + + "resource_group_name": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + }, + + "auto_renew": { + Type: pluginsdk.TypeBool, + Default: true, + Optional: true, + }, + + "certificates": { + Type: pluginsdk.TypeList, + Computed: true, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "certificate_name": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "key_vault_id": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "key_vault_secret_name": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "provisioning_state": { + Type: pluginsdk.TypeString, + Computed: true, + }, + }, + }, + }, + + "csr": { + Type: pluginsdk.TypeString, + Optional: true, + Computed: true, + }, + + "distinguished_name": { + Type: pluginsdk.TypeString, + Optional: true, + Computed: true, + }, + + "key_size": { + Type: pluginsdk.TypeInt, + Optional: true, + Default: 2048, + }, + + "product_type": { + Type: pluginsdk.TypeString, + Optional: true, + Default: "Standard", + }, + + "validity_in_years": { + Type: pluginsdk.TypeInt, + Optional: true, + Default: 1, + }, + + "domain_verification_token": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "status": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "expiration_time": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "is_private_key_external": { + Type: pluginsdk.TypeBool, + Computed: true, + }, + + "app_service_certificate_not_renewable_reasons": { + Type: pluginsdk.TypeList, + Computed: true, + Elem: &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + }, + }, + + "signed_certificate_thumbprint": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "root_thumbprint": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "intermediate_thumbprint": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "tags": { + Type: pluginsdk.TypeMap, + Optional: true, + Elem: &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + }, + }, + } +} + +func (AppServiceCertificateOrderResourceV0ToV1) UpgradeFunc() pluginsdk.StateUpgraderFunc { + return func(ctx context.Context, rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) { + oldIdRaw := rawState["id"].(string) + oldId, err := parse.CertificateOrderOldID(oldIdRaw) + if err != nil { + return rawState, fmt.Errorf("parsing ID %q to upgrade: %+v", oldIdRaw, err) + } + + appServiceCertOrderId := parse.NewCertificateOrderID(oldId.SubscriptionId, oldId.ResourceGroup, oldId.CertificateOrderName) + newId := appServiceCertOrderId.ID() + + rawState["id"] = newId + return rawState, nil + } +} diff --git a/internal/services/web/parse/certificate_order.go b/internal/services/web/parse/certificate_order.go index 3a154491a35b..5096f5d419ce 100644 --- a/internal/services/web/parse/certificate_order.go +++ b/internal/services/web/parse/certificate_order.go @@ -36,7 +36,7 @@ func (id CertificateOrderId) String() string { } func (id CertificateOrderId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/certificateOrders/%s" + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CertificateRegistration/certificateOrders/%s" return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.Name) } diff --git a/internal/services/web/parse/certificate_order_old.go b/internal/services/web/parse/certificate_order_old.go new file mode 100644 index 000000000000..3d96cd9e3121 --- /dev/null +++ b/internal/services/web/parse/certificate_order_old.go @@ -0,0 +1,72 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package parse + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +type CertificateOrderOldId struct { + SubscriptionId string + ResourceGroup string + CertificateOrderName string +} + +func NewCertificateOrderOldID(subscriptionId, resourceGroup, certificateOrderName string) CertificateOrderOldId { + return CertificateOrderOldId{ + SubscriptionId: subscriptionId, + ResourceGroup: resourceGroup, + CertificateOrderName: certificateOrderName, + } +} + +func (id CertificateOrderOldId) String() string { + segments := []string{ + fmt.Sprintf("Certificate Order Name %q", id.CertificateOrderName), + fmt.Sprintf("Resource Group %q", id.ResourceGroup), + } + segmentsStr := strings.Join(segments, " / ") + return fmt.Sprintf("%s: (%s)", "Certificate Order Old", segmentsStr) +} + +func (id CertificateOrderOldId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/certificateOrders/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.CertificateOrderName) +} + +// CertificateOrderOldID parses a CertificateOrderOld ID into an CertificateOrderOldId struct +func CertificateOrderOldID(input string) (*CertificateOrderOldId, error) { + id, err := resourceids.ParseAzureResourceID(input) + if err != nil { + return nil, fmt.Errorf("parsing %q as an CertificateOrderOld ID: %+v", input, err) + } + + resourceId := CertificateOrderOldId{ + SubscriptionId: id.SubscriptionID, + ResourceGroup: id.ResourceGroup, + } + + if resourceId.SubscriptionId == "" { + return nil, fmt.Errorf("ID was missing the 'subscriptions' element") + } + + if resourceId.ResourceGroup == "" { + return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") + } + + if resourceId.CertificateOrderName, err = id.PopSegment("certificateOrders"); err != nil { + return nil, err + } + + if err := id.ValidateNoEmptySegments(input); err != nil { + return nil, err + } + + return &resourceId, nil +} diff --git a/internal/services/web/parse/certificate_order_old_test.go b/internal/services/web/parse/certificate_order_old_test.go new file mode 100644 index 000000000000..bc83154d70f3 --- /dev/null +++ b/internal/services/web/parse/certificate_order_old_test.go @@ -0,0 +1,115 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package parse + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.Id = CertificateOrderOldId{} + +func TestCertificateOrderOldIDFormatter(t *testing.T) { + actual := NewCertificateOrderOldID("12345678-1234-9876-4563-123456789012", "resGroup1", "order1").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/certificateOrders/order1" + if actual != expected { + t.Fatalf("Expected %q but got %q", expected, actual) + } +} + +func TestCertificateOrderOldID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CertificateOrderOldId + }{ + + { + // empty + Input: "", + Error: true, + }, + + { + // missing SubscriptionId + Input: "/", + Error: true, + }, + + { + // missing value for SubscriptionId + Input: "/subscriptions/", + Error: true, + }, + + { + // missing ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", + Error: true, + }, + + { + // missing value for ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", + Error: true, + }, + + { + // missing CertificateOrderName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/", + Error: true, + }, + + { + // missing value for CertificateOrderName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/certificateOrders/", + Error: true, + }, + + { + // valid + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/certificateOrders/order1", + Expected: &CertificateOrderOldId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroup: "resGroup1", + CertificateOrderName: "order1", + }, + }, + + { + // upper-cased + Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.WEB/CERTIFICATEORDERS/ORDER1", + Error: true, + }, + } + + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := CertificateOrderOldID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %s", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + if actual.ResourceGroup != v.Expected.ResourceGroup { + t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) + } + if actual.CertificateOrderName != v.Expected.CertificateOrderName { + t.Fatalf("Expected %q but got %q for CertificateOrderName", v.Expected.CertificateOrderName, actual.CertificateOrderName) + } + } +} diff --git a/internal/services/web/parse/certificate_order_test.go b/internal/services/web/parse/certificate_order_test.go index ef9db848cd5f..6a61346d1112 100644 --- a/internal/services/web/parse/certificate_order_test.go +++ b/internal/services/web/parse/certificate_order_test.go @@ -15,7 +15,7 @@ var _ resourceids.Id = CertificateOrderId{} func TestCertificateOrderIDFormatter(t *testing.T) { actual := NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "resGroup1", "order1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/certificateOrders/order1" + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.CertificateRegistration/certificateOrders/order1" if actual != expected { t.Fatalf("Expected %q but got %q", expected, actual) } @@ -60,19 +60,19 @@ func TestCertificateOrderID(t *testing.T) { { // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.CertificateRegistration/", Error: true, }, { // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/certificateOrders/", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.CertificateRegistration/certificateOrders/", Error: true, }, { // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/certificateOrders/order1", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.CertificateRegistration/certificateOrders/order1", Expected: &CertificateOrderId{ SubscriptionId: "12345678-1234-9876-4563-123456789012", ResourceGroup: "resGroup1", @@ -82,7 +82,7 @@ func TestCertificateOrderID(t *testing.T) { { // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.WEB/CERTIFICATEORDERS/ORDER1", + Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.CERTIFICATEREGISTRATION/CERTIFICATEORDERS/ORDER1", Error: true, }, } diff --git a/internal/services/web/resourceids.go b/internal/services/web/resourceids.go index 583675d96961..1c3aa139bfbb 100644 --- a/internal/services/web/resourceids.go +++ b/internal/services/web/resourceids.go @@ -8,7 +8,8 @@ package web //go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=AppServiceSlot -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/site1/slots/slot1 //go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=AppServiceSlotCustomHostnameBinding -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/site1/slots/slot1/hostNameBindings/binding1 //go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=Certificate -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/certificates/certificate1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=CertificateOrder -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/certificateOrders/order1 +//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=CertificateOrder -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.CertificateRegistration/certificateOrders/order1 +//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=CertificateOrderOld -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/certificateOrders/order1 //go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=FunctionApp -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/site1 //go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=FunctionAppSlot -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/site1/slots/slot1 //go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=HostnameBinding -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/mygroup1/providers/Microsoft.Web/sites/site1/hostNameBindings/binding1 diff --git a/internal/services/web/validate/certificate_order_id_test.go b/internal/services/web/validate/certificate_order_id_test.go index 3216c6c35cd1..51ab5b32dbc2 100644 --- a/internal/services/web/validate/certificate_order_id_test.go +++ b/internal/services/web/validate/certificate_order_id_test.go @@ -45,25 +45,25 @@ func TestCertificateOrderID(t *testing.T) { { // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.CertificateRegistration/", Valid: false, }, { // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/certificateOrders/", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.CertificateRegistration/certificateOrders/", Valid: false, }, { // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/certificateOrders/order1", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.CertificateRegistration/certificateOrders/order1", Valid: true, }, { // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.WEB/CERTIFICATEORDERS/ORDER1", + Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.CERTIFICATEREGISTRATION/CERTIFICATEORDERS/ORDER1", Valid: false, }, } diff --git a/internal/services/web/validate/certificate_order_old_id.go b/internal/services/web/validate/certificate_order_old_id.go new file mode 100644 index 000000000000..19a5eec78e1e --- /dev/null +++ b/internal/services/web/validate/certificate_order_old_id.go @@ -0,0 +1,26 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package validate + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import ( + "fmt" + + "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/parse" +) + +func CertificateOrderOldID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := parse.CertificateOrderOldID(v); err != nil { + errors = append(errors, err) + } + + return +} diff --git a/internal/services/web/validate/certificate_order_old_id_test.go b/internal/services/web/validate/certificate_order_old_id_test.go new file mode 100644 index 000000000000..22de06e892da --- /dev/null +++ b/internal/services/web/validate/certificate_order_old_id_test.go @@ -0,0 +1,79 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package validate + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import "testing" + +func TestCertificateOrderOldID(t *testing.T) { + cases := []struct { + Input string + Valid bool + }{ + + { + // empty + Input: "", + Valid: false, + }, + + { + // missing SubscriptionId + Input: "/", + Valid: false, + }, + + { + // missing value for SubscriptionId + Input: "/subscriptions/", + Valid: false, + }, + + { + // missing ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", + Valid: false, + }, + + { + // missing value for ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", + Valid: false, + }, + + { + // missing CertificateOrderName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/", + Valid: false, + }, + + { + // missing value for CertificateOrderName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/certificateOrders/", + Valid: false, + }, + + { + // valid + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/certificateOrders/order1", + Valid: true, + }, + + { + // upper-cased + Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.WEB/CERTIFICATEORDERS/ORDER1", + Valid: false, + }, + } + for _, tc := range cases { + t.Logf("[DEBUG] Testing Value %s", tc.Input) + _, errors := CertificateOrderOldID(tc.Input, "test") + valid := len(errors) == 0 + + if tc.Valid != valid { + t.Fatalf("Expected %t but got %t", tc.Valid, valid) + } + } +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/README.md new file mode 100644 index 000000000000..cc613a5b9a75 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/README.md @@ -0,0 +1,381 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders` Documentation + +The `appservicecertificateorders` SDK allows for interaction with the Azure Resource Manager Service `web` (API Version `2023-01-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders" +``` + + +### Client Initialization + +```go +client := appservicecertificateorders.NewAppServiceCertificateOrdersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue") + +payload := appservicecertificateorders.AppServiceCertificateOrder{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.CreateOrUpdateCertificate` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue", "certificateValue") + +payload := appservicecertificateorders.AppServiceCertificateResource{ + // ... +} + + +if err := client.CreateOrUpdateCertificateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.Delete` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.DeleteCertificate` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue", "certificateValue") + +read, err := client.DeleteCertificate(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.Get` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.GetCertificate` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue", "certificateValue") + +read, err := client.GetCertificate(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.ListCertificates` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue") + +// alternatively `client.ListCertificates(ctx, id)` can be used to do batched pagination +items, err := client.ListCertificatesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.Reissue` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue") + +payload := appservicecertificateorders.ReissueCertificateOrderRequest{ + // ... +} + + +read, err := client.Reissue(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.Renew` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue") + +payload := appservicecertificateorders.RenewCertificateOrderRequest{ + // ... +} + + +read, err := client.Renew(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.ResendEmail` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue") + +read, err := client.ResendEmail(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.ResendRequestEmails` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue") + +payload := appservicecertificateorders.NameIdentifier{ + // ... +} + + +read, err := client.ResendRequestEmails(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.RetrieveCertificateActions` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue") + +read, err := client.RetrieveCertificateActions(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.RetrieveCertificateEmailHistory` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue") + +read, err := client.RetrieveCertificateEmailHistory(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.RetrieveSiteSeal` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue") + +payload := appservicecertificateorders.SiteSealRequest{ + // ... +} + + +read, err := client.RetrieveSiteSeal(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.Update` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue") + +payload := appservicecertificateorders.AppServiceCertificateOrderPatchResource{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.UpdateCertificate` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue", "certificateValue") + +payload := appservicecertificateorders.AppServiceCertificatePatchResource{ + // ... +} + + +read, err := client.UpdateCertificate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.ValidatePurchaseInformation` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +payload := appservicecertificateorders.AppServiceCertificateOrder{ + // ... +} + + +read, err := client.ValidatePurchaseInformation(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.VerifyDomainOwnership` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue") + +read, err := client.VerifyDomainOwnership(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/client.go new file mode 100644 index 000000000000..06d6b4e29628 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/client.go @@ -0,0 +1,26 @@ +package appservicecertificateorders + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceCertificateOrdersClient struct { + Client *resourcemanager.Client +} + +func NewAppServiceCertificateOrdersClientWithBaseURI(sdkApi sdkEnv.Api) (*AppServiceCertificateOrdersClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "appservicecertificateorders", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AppServiceCertificateOrdersClient: %+v", err) + } + + return &AppServiceCertificateOrdersClient{ + Client: client, + }, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/constants.go new file mode 100644 index 000000000000..7fd04266697e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/constants.go @@ -0,0 +1,355 @@ +package appservicecertificateorders + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateOrderActionType string + +const ( + CertificateOrderActionTypeCertificateExpirationWarning CertificateOrderActionType = "CertificateExpirationWarning" + CertificateOrderActionTypeCertificateExpired CertificateOrderActionType = "CertificateExpired" + CertificateOrderActionTypeCertificateIssued CertificateOrderActionType = "CertificateIssued" + CertificateOrderActionTypeCertificateOrderCanceled CertificateOrderActionType = "CertificateOrderCanceled" + CertificateOrderActionTypeCertificateOrderCreated CertificateOrderActionType = "CertificateOrderCreated" + CertificateOrderActionTypeCertificateRevoked CertificateOrderActionType = "CertificateRevoked" + CertificateOrderActionTypeDomainValidationComplete CertificateOrderActionType = "DomainValidationComplete" + CertificateOrderActionTypeFraudCleared CertificateOrderActionType = "FraudCleared" + CertificateOrderActionTypeFraudDetected CertificateOrderActionType = "FraudDetected" + CertificateOrderActionTypeFraudDocumentationRequired CertificateOrderActionType = "FraudDocumentationRequired" + CertificateOrderActionTypeOrgNameChange CertificateOrderActionType = "OrgNameChange" + CertificateOrderActionTypeOrgValidationComplete CertificateOrderActionType = "OrgValidationComplete" + CertificateOrderActionTypeSanDrop CertificateOrderActionType = "SanDrop" + CertificateOrderActionTypeUnknown CertificateOrderActionType = "Unknown" +) + +func PossibleValuesForCertificateOrderActionType() []string { + return []string{ + string(CertificateOrderActionTypeCertificateExpirationWarning), + string(CertificateOrderActionTypeCertificateExpired), + string(CertificateOrderActionTypeCertificateIssued), + string(CertificateOrderActionTypeCertificateOrderCanceled), + string(CertificateOrderActionTypeCertificateOrderCreated), + string(CertificateOrderActionTypeCertificateRevoked), + string(CertificateOrderActionTypeDomainValidationComplete), + string(CertificateOrderActionTypeFraudCleared), + string(CertificateOrderActionTypeFraudDetected), + string(CertificateOrderActionTypeFraudDocumentationRequired), + string(CertificateOrderActionTypeOrgNameChange), + string(CertificateOrderActionTypeOrgValidationComplete), + string(CertificateOrderActionTypeSanDrop), + string(CertificateOrderActionTypeUnknown), + } +} + +func (s *CertificateOrderActionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCertificateOrderActionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCertificateOrderActionType(input string) (*CertificateOrderActionType, error) { + vals := map[string]CertificateOrderActionType{ + "certificateexpirationwarning": CertificateOrderActionTypeCertificateExpirationWarning, + "certificateexpired": CertificateOrderActionTypeCertificateExpired, + "certificateissued": CertificateOrderActionTypeCertificateIssued, + "certificateordercanceled": CertificateOrderActionTypeCertificateOrderCanceled, + "certificateordercreated": CertificateOrderActionTypeCertificateOrderCreated, + "certificaterevoked": CertificateOrderActionTypeCertificateRevoked, + "domainvalidationcomplete": CertificateOrderActionTypeDomainValidationComplete, + "fraudcleared": CertificateOrderActionTypeFraudCleared, + "frauddetected": CertificateOrderActionTypeFraudDetected, + "frauddocumentationrequired": CertificateOrderActionTypeFraudDocumentationRequired, + "orgnamechange": CertificateOrderActionTypeOrgNameChange, + "orgvalidationcomplete": CertificateOrderActionTypeOrgValidationComplete, + "sandrop": CertificateOrderActionTypeSanDrop, + "unknown": CertificateOrderActionTypeUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CertificateOrderActionType(input) + return &out, nil +} + +type CertificateOrderStatus string + +const ( + CertificateOrderStatusCanceled CertificateOrderStatus = "Canceled" + CertificateOrderStatusDenied CertificateOrderStatus = "Denied" + CertificateOrderStatusExpired CertificateOrderStatus = "Expired" + CertificateOrderStatusIssued CertificateOrderStatus = "Issued" + CertificateOrderStatusNotSubmitted CertificateOrderStatus = "NotSubmitted" + CertificateOrderStatusPendingRekey CertificateOrderStatus = "PendingRekey" + CertificateOrderStatusPendingissuance CertificateOrderStatus = "Pendingissuance" + CertificateOrderStatusPendingrevocation CertificateOrderStatus = "Pendingrevocation" + CertificateOrderStatusRevoked CertificateOrderStatus = "Revoked" + CertificateOrderStatusUnused CertificateOrderStatus = "Unused" +) + +func PossibleValuesForCertificateOrderStatus() []string { + return []string{ + string(CertificateOrderStatusCanceled), + string(CertificateOrderStatusDenied), + string(CertificateOrderStatusExpired), + string(CertificateOrderStatusIssued), + string(CertificateOrderStatusNotSubmitted), + string(CertificateOrderStatusPendingRekey), + string(CertificateOrderStatusPendingissuance), + string(CertificateOrderStatusPendingrevocation), + string(CertificateOrderStatusRevoked), + string(CertificateOrderStatusUnused), + } +} + +func (s *CertificateOrderStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCertificateOrderStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCertificateOrderStatus(input string) (*CertificateOrderStatus, error) { + vals := map[string]CertificateOrderStatus{ + "canceled": CertificateOrderStatusCanceled, + "denied": CertificateOrderStatusDenied, + "expired": CertificateOrderStatusExpired, + "issued": CertificateOrderStatusIssued, + "notsubmitted": CertificateOrderStatusNotSubmitted, + "pendingrekey": CertificateOrderStatusPendingRekey, + "pendingissuance": CertificateOrderStatusPendingissuance, + "pendingrevocation": CertificateOrderStatusPendingrevocation, + "revoked": CertificateOrderStatusRevoked, + "unused": CertificateOrderStatusUnused, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CertificateOrderStatus(input) + return &out, nil +} + +type CertificateProductType string + +const ( + CertificateProductTypeStandardDomainValidatedSsl CertificateProductType = "StandardDomainValidatedSsl" + CertificateProductTypeStandardDomainValidatedWildCardSsl CertificateProductType = "StandardDomainValidatedWildCardSsl" +) + +func PossibleValuesForCertificateProductType() []string { + return []string{ + string(CertificateProductTypeStandardDomainValidatedSsl), + string(CertificateProductTypeStandardDomainValidatedWildCardSsl), + } +} + +func (s *CertificateProductType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCertificateProductType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCertificateProductType(input string) (*CertificateProductType, error) { + vals := map[string]CertificateProductType{ + "standarddomainvalidatedssl": CertificateProductTypeStandardDomainValidatedSsl, + "standarddomainvalidatedwildcardssl": CertificateProductTypeStandardDomainValidatedWildCardSsl, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CertificateProductType(input) + return &out, nil +} + +type KeyVaultSecretStatus string + +const ( + KeyVaultSecretStatusAzureServiceUnauthorizedToAccessKeyVault KeyVaultSecretStatus = "AzureServiceUnauthorizedToAccessKeyVault" + KeyVaultSecretStatusCertificateOrderFailed KeyVaultSecretStatus = "CertificateOrderFailed" + KeyVaultSecretStatusExternalPrivateKey KeyVaultSecretStatus = "ExternalPrivateKey" + KeyVaultSecretStatusInitialized KeyVaultSecretStatus = "Initialized" + KeyVaultSecretStatusKeyVaultDoesNotExist KeyVaultSecretStatus = "KeyVaultDoesNotExist" + KeyVaultSecretStatusKeyVaultSecretDoesNotExist KeyVaultSecretStatus = "KeyVaultSecretDoesNotExist" + KeyVaultSecretStatusOperationNotPermittedOnKeyVault KeyVaultSecretStatus = "OperationNotPermittedOnKeyVault" + KeyVaultSecretStatusSucceeded KeyVaultSecretStatus = "Succeeded" + KeyVaultSecretStatusUnknown KeyVaultSecretStatus = "Unknown" + KeyVaultSecretStatusUnknownError KeyVaultSecretStatus = "UnknownError" + KeyVaultSecretStatusWaitingOnCertificateOrder KeyVaultSecretStatus = "WaitingOnCertificateOrder" +) + +func PossibleValuesForKeyVaultSecretStatus() []string { + return []string{ + string(KeyVaultSecretStatusAzureServiceUnauthorizedToAccessKeyVault), + string(KeyVaultSecretStatusCertificateOrderFailed), + string(KeyVaultSecretStatusExternalPrivateKey), + string(KeyVaultSecretStatusInitialized), + string(KeyVaultSecretStatusKeyVaultDoesNotExist), + string(KeyVaultSecretStatusKeyVaultSecretDoesNotExist), + string(KeyVaultSecretStatusOperationNotPermittedOnKeyVault), + string(KeyVaultSecretStatusSucceeded), + string(KeyVaultSecretStatusUnknown), + string(KeyVaultSecretStatusUnknownError), + string(KeyVaultSecretStatusWaitingOnCertificateOrder), + } +} + +func (s *KeyVaultSecretStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeyVaultSecretStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKeyVaultSecretStatus(input string) (*KeyVaultSecretStatus, error) { + vals := map[string]KeyVaultSecretStatus{ + "azureserviceunauthorizedtoaccesskeyvault": KeyVaultSecretStatusAzureServiceUnauthorizedToAccessKeyVault, + "certificateorderfailed": KeyVaultSecretStatusCertificateOrderFailed, + "externalprivatekey": KeyVaultSecretStatusExternalPrivateKey, + "initialized": KeyVaultSecretStatusInitialized, + "keyvaultdoesnotexist": KeyVaultSecretStatusKeyVaultDoesNotExist, + "keyvaultsecretdoesnotexist": KeyVaultSecretStatusKeyVaultSecretDoesNotExist, + "operationnotpermittedonkeyvault": KeyVaultSecretStatusOperationNotPermittedOnKeyVault, + "succeeded": KeyVaultSecretStatusSucceeded, + "unknown": KeyVaultSecretStatusUnknown, + "unknownerror": KeyVaultSecretStatusUnknownError, + "waitingoncertificateorder": KeyVaultSecretStatusWaitingOnCertificateOrder, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KeyVaultSecretStatus(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateInProgress ProvisioningState = "InProgress" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateInProgress), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "inprogress": ProvisioningStateInProgress, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type ResourceNotRenewableReason string + +const ( + ResourceNotRenewableReasonExpirationNotInRenewalTimeRange ResourceNotRenewableReason = "ExpirationNotInRenewalTimeRange" + ResourceNotRenewableReasonRegistrationStatusNotSupportedForRenewal ResourceNotRenewableReason = "RegistrationStatusNotSupportedForRenewal" + ResourceNotRenewableReasonSubscriptionNotActive ResourceNotRenewableReason = "SubscriptionNotActive" +) + +func PossibleValuesForResourceNotRenewableReason() []string { + return []string{ + string(ResourceNotRenewableReasonExpirationNotInRenewalTimeRange), + string(ResourceNotRenewableReasonRegistrationStatusNotSupportedForRenewal), + string(ResourceNotRenewableReasonSubscriptionNotActive), + } +} + +func (s *ResourceNotRenewableReason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResourceNotRenewableReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResourceNotRenewableReason(input string) (*ResourceNotRenewableReason, error) { + vals := map[string]ResourceNotRenewableReason{ + "expirationnotinrenewaltimerange": ResourceNotRenewableReasonExpirationNotInRenewalTimeRange, + "registrationstatusnotsupportedforrenewal": ResourceNotRenewableReasonRegistrationStatusNotSupportedForRenewal, + "subscriptionnotactive": ResourceNotRenewableReasonSubscriptionNotActive, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResourceNotRenewableReason(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/id_certificate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/id_certificate.go new file mode 100644 index 000000000000..9b186c754cbc --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/id_certificate.go @@ -0,0 +1,134 @@ +package appservicecertificateorders + +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 + CertificateOrderName string + CertificateName string +} + +// NewCertificateID returns a new CertificateId struct +func NewCertificateID(subscriptionId string, resourceGroupName string, certificateOrderName string, certificateName string) CertificateId { + return CertificateId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CertificateOrderName: certificateOrderName, + 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.CertificateOrderName, ok = input.Parsed["certificateOrderName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "certificateOrderName", input) + } + + if id.CertificateName, ok = input.Parsed["certificateName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "certificateName", input) + } + + return nil +} + +// ValidateCertificateID checks that 'input' can be parsed as a Certificate ID +func ValidateCertificateID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCertificateID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Certificate ID +func (id CertificateId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CertificateRegistration/certificateOrders/%s/certificates/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CertificateOrderName, id.CertificateName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Certificate 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("staticMicrosoftCertificateRegistration", "Microsoft.CertificateRegistration", "Microsoft.CertificateRegistration"), + resourceids.StaticSegment("staticCertificateOrders", "certificateOrders", "certificateOrders"), + resourceids.UserSpecifiedSegment("certificateOrderName", "certificateOrderValue"), + 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("Certificate Order Name: %q", id.CertificateOrderName), + fmt.Sprintf("Certificate Name: %q", id.CertificateName), + } + return fmt.Sprintf("Certificate (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/id_certificateorder.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/id_certificateorder.go new file mode 100644 index 000000000000..2abf9c64b375 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/id_certificateorder.go @@ -0,0 +1,125 @@ +package appservicecertificateorders + +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 = &CertificateOrderId{} + +// CertificateOrderId is a struct representing the Resource ID for a Certificate Order +type CertificateOrderId struct { + SubscriptionId string + ResourceGroupName string + CertificateOrderName string +} + +// NewCertificateOrderID returns a new CertificateOrderId struct +func NewCertificateOrderID(subscriptionId string, resourceGroupName string, certificateOrderName string) CertificateOrderId { + return CertificateOrderId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CertificateOrderName: certificateOrderName, + } +} + +// ParseCertificateOrderID parses 'input' into a CertificateOrderId +func ParseCertificateOrderID(input string) (*CertificateOrderId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateOrderId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateOrderId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCertificateOrderIDInsensitively parses 'input' case-insensitively into a CertificateOrderId +// note: this method should only be used for API response data and not user input +func ParseCertificateOrderIDInsensitively(input string) (*CertificateOrderId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateOrderId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateOrderId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CertificateOrderId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CertificateOrderName, ok = input.Parsed["certificateOrderName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "certificateOrderName", input) + } + + return nil +} + +// ValidateCertificateOrderID checks that 'input' can be parsed as a Certificate Order ID +func ValidateCertificateOrderID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCertificateOrderID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Certificate Order ID +func (id CertificateOrderId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CertificateRegistration/certificateOrders/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CertificateOrderName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Certificate Order ID +func (id CertificateOrderId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftCertificateRegistration", "Microsoft.CertificateRegistration", "Microsoft.CertificateRegistration"), + resourceids.StaticSegment("staticCertificateOrders", "certificateOrders", "certificateOrders"), + resourceids.UserSpecifiedSegment("certificateOrderName", "certificateOrderValue"), + } +} + +// String returns a human-readable description of this Certificate Order ID +func (id CertificateOrderId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Certificate Order Name: %q", id.CertificateOrderName), + } + return fmt.Sprintf("Certificate Order (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_createorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_createorupdate.go new file mode 100644 index 000000000000..0ee50f716941 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_createorupdate.go @@ -0,0 +1,75 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AppServiceCertificateOrder +} + +// CreateOrUpdate ... +func (c AppServiceCertificateOrdersClient) CreateOrUpdate(ctx context.Context, id CertificateOrderId, input AppServiceCertificateOrder) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c AppServiceCertificateOrdersClient) CreateOrUpdateThenPoll(ctx context.Context, id CertificateOrderId, input AppServiceCertificateOrder) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_createorupdatecertificate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_createorupdatecertificate.go new file mode 100644 index 000000000000..f8d50a20ddcb --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_createorupdatecertificate.go @@ -0,0 +1,75 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateCertificateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AppServiceCertificateResource +} + +// CreateOrUpdateCertificate ... +func (c AppServiceCertificateOrdersClient) CreateOrUpdateCertificate(ctx context.Context, id CertificateId, input AppServiceCertificateResource) (result CreateOrUpdateCertificateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateCertificateThenPoll performs CreateOrUpdateCertificate then polls until it's completed +func (c AppServiceCertificateOrdersClient) CreateOrUpdateCertificateThenPoll(ctx context.Context, id CertificateId, input AppServiceCertificateResource) error { + result, err := c.CreateOrUpdateCertificate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdateCertificate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdateCertificate: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_delete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_delete.go new file mode 100644 index 000000000000..f8f40a08c11d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_delete.go @@ -0,0 +1,47 @@ +package appservicecertificateorders + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c AppServiceCertificateOrdersClient) Delete(ctx context.Context, id CertificateOrderId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_deletecertificate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_deletecertificate.go new file mode 100644 index 000000000000..1bd00712f787 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_deletecertificate.go @@ -0,0 +1,47 @@ +package appservicecertificateorders + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteCertificateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteCertificate ... +func (c AppServiceCertificateOrdersClient) DeleteCertificate(ctx context.Context, id CertificateId) (result DeleteCertificateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_get.go new file mode 100644 index 000000000000..b4df83fdd650 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_get.go @@ -0,0 +1,54 @@ +package appservicecertificateorders + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AppServiceCertificateOrder +} + +// Get ... +func (c AppServiceCertificateOrdersClient) Get(ctx context.Context, id CertificateOrderId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AppServiceCertificateOrder + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_getcertificate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_getcertificate.go new file mode 100644 index 000000000000..45675824b492 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_getcertificate.go @@ -0,0 +1,54 @@ +package appservicecertificateorders + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetCertificateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AppServiceCertificateResource +} + +// GetCertificate ... +func (c AppServiceCertificateOrdersClient) GetCertificate(ctx context.Context, id CertificateId) (result GetCertificateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AppServiceCertificateResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_list.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_list.go new file mode 100644 index 000000000000..a6c3ac262121 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_list.go @@ -0,0 +1,92 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AppServiceCertificateOrder +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []AppServiceCertificateOrder +} + +// List ... +func (c AppServiceCertificateOrdersClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.CertificateRegistration/certificateOrders", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AppServiceCertificateOrder `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c AppServiceCertificateOrdersClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, AppServiceCertificateOrderOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceCertificateOrdersClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate AppServiceCertificateOrderOperationPredicate) (result ListCompleteResult, err error) { + items := make([]AppServiceCertificateOrder, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_listbyresourcegroup.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_listbyresourcegroup.go new file mode 100644 index 000000000000..74ea0faa4b02 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_listbyresourcegroup.go @@ -0,0 +1,92 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AppServiceCertificateOrder +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []AppServiceCertificateOrder +} + +// ListByResourceGroup ... +func (c AppServiceCertificateOrdersClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.CertificateRegistration/certificateOrders", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AppServiceCertificateOrder `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c AppServiceCertificateOrdersClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, AppServiceCertificateOrderOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceCertificateOrdersClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AppServiceCertificateOrderOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]AppServiceCertificateOrder, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_listcertificates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_listcertificates.go new file mode 100644 index 000000000000..f13d03c4b86f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_listcertificates.go @@ -0,0 +1,91 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListCertificatesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AppServiceCertificateResource +} + +type ListCertificatesCompleteResult struct { + LatestHttpResponse *http.Response + Items []AppServiceCertificateResource +} + +// ListCertificates ... +func (c AppServiceCertificateOrdersClient) ListCertificates(ctx context.Context, id CertificateOrderId) (result ListCertificatesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/certificates", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AppServiceCertificateResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListCertificatesComplete retrieves all the results into a single object +func (c AppServiceCertificateOrdersClient) ListCertificatesComplete(ctx context.Context, id CertificateOrderId) (ListCertificatesCompleteResult, error) { + return c.ListCertificatesCompleteMatchingPredicate(ctx, id, AppServiceCertificateResourceOperationPredicate{}) +} + +// ListCertificatesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceCertificateOrdersClient) ListCertificatesCompleteMatchingPredicate(ctx context.Context, id CertificateOrderId, predicate AppServiceCertificateResourceOperationPredicate) (result ListCertificatesCompleteResult, err error) { + items := make([]AppServiceCertificateResource, 0) + + resp, err := c.ListCertificates(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCertificatesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_reissue.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_reissue.go new file mode 100644 index 000000000000..91b863f81f7e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_reissue.go @@ -0,0 +1,51 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReissueOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Reissue ... +func (c AppServiceCertificateOrdersClient) Reissue(ctx context.Context, id CertificateOrderId, input ReissueCertificateOrderRequest) (result ReissueOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/reissue", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_renew.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_renew.go new file mode 100644 index 000000000000..0d15451ed17f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_renew.go @@ -0,0 +1,51 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RenewOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Renew ... +func (c AppServiceCertificateOrdersClient) Renew(ctx context.Context, id CertificateOrderId, input RenewCertificateOrderRequest) (result RenewOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/renew", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_resendemail.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_resendemail.go new file mode 100644 index 000000000000..49de4389c594 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_resendemail.go @@ -0,0 +1,47 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResendEmailOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ResendEmail ... +func (c AppServiceCertificateOrdersClient) ResendEmail(ctx context.Context, id CertificateOrderId) (result ResendEmailOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resendEmail", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_resendrequestemails.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_resendrequestemails.go new file mode 100644 index 000000000000..e758b4dd7068 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_resendrequestemails.go @@ -0,0 +1,51 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResendRequestEmailsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ResendRequestEmails ... +func (c AppServiceCertificateOrdersClient) ResendRequestEmails(ctx context.Context, id CertificateOrderId, input NameIdentifier) (result ResendRequestEmailsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resendRequestEmails", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_retrievecertificateactions.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_retrievecertificateactions.go new file mode 100644 index 000000000000..306f696af317 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_retrievecertificateactions.go @@ -0,0 +1,55 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetrieveCertificateActionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CertificateOrderAction +} + +// RetrieveCertificateActions ... +func (c AppServiceCertificateOrdersClient) RetrieveCertificateActions(ctx context.Context, id CertificateOrderId) (result RetrieveCertificateActionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/retrieveCertificateActions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []CertificateOrderAction + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_retrievecertificateemailhistory.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_retrievecertificateemailhistory.go new file mode 100644 index 000000000000..7fc5e4324d71 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_retrievecertificateemailhistory.go @@ -0,0 +1,55 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetrieveCertificateEmailHistoryOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CertificateEmail +} + +// RetrieveCertificateEmailHistory ... +func (c AppServiceCertificateOrdersClient) RetrieveCertificateEmailHistory(ctx context.Context, id CertificateOrderId) (result RetrieveCertificateEmailHistoryOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/retrieveEmailHistory", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []CertificateEmail + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_retrievesiteseal.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_retrievesiteseal.go new file mode 100644 index 000000000000..d84e5f865114 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_retrievesiteseal.go @@ -0,0 +1,59 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetrieveSiteSealOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteSeal +} + +// RetrieveSiteSeal ... +func (c AppServiceCertificateOrdersClient) RetrieveSiteSeal(ctx context.Context, id CertificateOrderId, input SiteSealRequest) (result RetrieveSiteSealOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/retrieveSiteSeal", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteSeal + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_update.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_update.go new file mode 100644 index 000000000000..999e03e24aed --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_update.go @@ -0,0 +1,58 @@ +package appservicecertificateorders + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AppServiceCertificateOrder +} + +// Update ... +func (c AppServiceCertificateOrdersClient) Update(ctx context.Context, id CertificateOrderId, input AppServiceCertificateOrderPatchResource) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AppServiceCertificateOrder + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_updatecertificate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_updatecertificate.go new file mode 100644 index 000000000000..b94998c44aa5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_updatecertificate.go @@ -0,0 +1,58 @@ +package appservicecertificateorders + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateCertificateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AppServiceCertificateResource +} + +// UpdateCertificate ... +func (c AppServiceCertificateOrdersClient) UpdateCertificate(ctx context.Context, id CertificateId, input AppServiceCertificatePatchResource) (result UpdateCertificateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AppServiceCertificateResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_validatepurchaseinformation.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_validatepurchaseinformation.go new file mode 100644 index 000000000000..1a4c9a08f692 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_validatepurchaseinformation.go @@ -0,0 +1,52 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidatePurchaseInformationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ValidatePurchaseInformation ... +func (c AppServiceCertificateOrdersClient) ValidatePurchaseInformation(ctx context.Context, id commonids.SubscriptionId, input AppServiceCertificateOrder) (result ValidatePurchaseInformationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.CertificateRegistration/validateCertificateRegistrationInformation", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_verifydomainownership.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_verifydomainownership.go new file mode 100644 index 000000000000..413d50089946 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_verifydomainownership.go @@ -0,0 +1,47 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VerifyDomainOwnershipOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// VerifyDomainOwnership ... +func (c AppServiceCertificateOrdersClient) VerifyDomainOwnership(ctx context.Context, id CertificateOrderId) (result VerifyDomainOwnershipOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/verifyDomainOwnership", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_appservicecertificate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_appservicecertificate.go new file mode 100644 index 000000000000..5572932e2570 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_appservicecertificate.go @@ -0,0 +1,10 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceCertificate struct { + KeyVaultId *string `json:"keyVaultId,omitempty"` + KeyVaultSecretName *string `json:"keyVaultSecretName,omitempty"` + ProvisioningState *KeyVaultSecretStatus `json:"provisioningState,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_appservicecertificateorder.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_appservicecertificateorder.go new file mode 100644 index 000000000000..3f171abb6db2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_appservicecertificateorder.go @@ -0,0 +1,14 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceCertificateOrder struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *AppServiceCertificateOrderProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_appservicecertificateorderpatchresource.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_appservicecertificateorderpatchresource.go new file mode 100644 index 000000000000..f0b6b7d477df --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_appservicecertificateorderpatchresource.go @@ -0,0 +1,12 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceCertificateOrderPatchResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AppServiceCertificateOrderPatchResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_appservicecertificateorderpatchresourceproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_appservicecertificateorderpatchresourceproperties.go new file mode 100644 index 000000000000..4657e81b440a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_appservicecertificateorderpatchresourceproperties.go @@ -0,0 +1,69 @@ +package appservicecertificateorders + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceCertificateOrderPatchResourceProperties struct { + AppServiceCertificateNotRenewableReasons *[]ResourceNotRenewableReason `json:"appServiceCertificateNotRenewableReasons,omitempty"` + AutoRenew *bool `json:"autoRenew,omitempty"` + Certificates *map[string]AppServiceCertificate `json:"certificates,omitempty"` + Contact *CertificateOrderContact `json:"contact,omitempty"` + Csr *string `json:"csr,omitempty"` + DistinguishedName *string `json:"distinguishedName,omitempty"` + DomainVerificationToken *string `json:"domainVerificationToken,omitempty"` + ExpirationTime *string `json:"expirationTime,omitempty"` + Intermediate *CertificateDetails `json:"intermediate,omitempty"` + IsPrivateKeyExternal *bool `json:"isPrivateKeyExternal,omitempty"` + KeySize *int64 `json:"keySize,omitempty"` + LastCertificateIssuanceTime *string `json:"lastCertificateIssuanceTime,omitempty"` + NextAutoRenewalTimeStamp *string `json:"nextAutoRenewalTimeStamp,omitempty"` + ProductType CertificateProductType `json:"productType"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Root *CertificateDetails `json:"root,omitempty"` + SerialNumber *string `json:"serialNumber,omitempty"` + SignedCertificate *CertificateDetails `json:"signedCertificate,omitempty"` + Status *CertificateOrderStatus `json:"status,omitempty"` + ValidityInYears *int64 `json:"validityInYears,omitempty"` +} + +func (o *AppServiceCertificateOrderPatchResourceProperties) GetExpirationTimeAsTime() (*time.Time, error) { + if o.ExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServiceCertificateOrderPatchResourceProperties) SetExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationTime = &formatted +} + +func (o *AppServiceCertificateOrderPatchResourceProperties) GetLastCertificateIssuanceTimeAsTime() (*time.Time, error) { + if o.LastCertificateIssuanceTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastCertificateIssuanceTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServiceCertificateOrderPatchResourceProperties) SetLastCertificateIssuanceTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastCertificateIssuanceTime = &formatted +} + +func (o *AppServiceCertificateOrderPatchResourceProperties) GetNextAutoRenewalTimeStampAsTime() (*time.Time, error) { + if o.NextAutoRenewalTimeStamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NextAutoRenewalTimeStamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServiceCertificateOrderPatchResourceProperties) SetNextAutoRenewalTimeStampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NextAutoRenewalTimeStamp = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_appservicecertificateorderproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_appservicecertificateorderproperties.go new file mode 100644 index 000000000000..9b30d4ae973c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_appservicecertificateorderproperties.go @@ -0,0 +1,69 @@ +package appservicecertificateorders + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceCertificateOrderProperties struct { + AppServiceCertificateNotRenewableReasons *[]ResourceNotRenewableReason `json:"appServiceCertificateNotRenewableReasons,omitempty"` + AutoRenew *bool `json:"autoRenew,omitempty"` + Certificates *map[string]AppServiceCertificate `json:"certificates,omitempty"` + Contact *CertificateOrderContact `json:"contact,omitempty"` + Csr *string `json:"csr,omitempty"` + DistinguishedName *string `json:"distinguishedName,omitempty"` + DomainVerificationToken *string `json:"domainVerificationToken,omitempty"` + ExpirationTime *string `json:"expirationTime,omitempty"` + Intermediate *CertificateDetails `json:"intermediate,omitempty"` + IsPrivateKeyExternal *bool `json:"isPrivateKeyExternal,omitempty"` + KeySize *int64 `json:"keySize,omitempty"` + LastCertificateIssuanceTime *string `json:"lastCertificateIssuanceTime,omitempty"` + NextAutoRenewalTimeStamp *string `json:"nextAutoRenewalTimeStamp,omitempty"` + ProductType CertificateProductType `json:"productType"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Root *CertificateDetails `json:"root,omitempty"` + SerialNumber *string `json:"serialNumber,omitempty"` + SignedCertificate *CertificateDetails `json:"signedCertificate,omitempty"` + Status *CertificateOrderStatus `json:"status,omitempty"` + ValidityInYears *int64 `json:"validityInYears,omitempty"` +} + +func (o *AppServiceCertificateOrderProperties) GetExpirationTimeAsTime() (*time.Time, error) { + if o.ExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServiceCertificateOrderProperties) SetExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationTime = &formatted +} + +func (o *AppServiceCertificateOrderProperties) GetLastCertificateIssuanceTimeAsTime() (*time.Time, error) { + if o.LastCertificateIssuanceTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastCertificateIssuanceTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServiceCertificateOrderProperties) SetLastCertificateIssuanceTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastCertificateIssuanceTime = &formatted +} + +func (o *AppServiceCertificateOrderProperties) GetNextAutoRenewalTimeStampAsTime() (*time.Time, error) { + if o.NextAutoRenewalTimeStamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NextAutoRenewalTimeStamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServiceCertificateOrderProperties) SetNextAutoRenewalTimeStampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NextAutoRenewalTimeStamp = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_appservicecertificatepatchresource.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_appservicecertificatepatchresource.go new file mode 100644 index 000000000000..8f8d91b6c870 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_appservicecertificatepatchresource.go @@ -0,0 +1,12 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceCertificatePatchResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AppServiceCertificate `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_appservicecertificateresource.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_appservicecertificateresource.go new file mode 100644 index 000000000000..7cd601e38f72 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_appservicecertificateresource.go @@ -0,0 +1,14 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceCertificateResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *AppServiceCertificate `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_certificatedetails.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_certificatedetails.go new file mode 100644 index 000000000000..6905351a7c5f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_certificatedetails.go @@ -0,0 +1,46 @@ +package appservicecertificateorders + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateDetails struct { + Issuer *string `json:"issuer,omitempty"` + NotAfter *string `json:"notAfter,omitempty"` + NotBefore *string `json:"notBefore,omitempty"` + RawData *string `json:"rawData,omitempty"` + SerialNumber *string `json:"serialNumber,omitempty"` + SignatureAlgorithm *string `json:"signatureAlgorithm,omitempty"` + Subject *string `json:"subject,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` + Version *int64 `json:"version,omitempty"` +} + +func (o *CertificateDetails) GetNotAfterAsTime() (*time.Time, error) { + if o.NotAfter == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NotAfter, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificateDetails) SetNotAfterAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NotAfter = &formatted +} + +func (o *CertificateDetails) GetNotBeforeAsTime() (*time.Time, error) { + if o.NotBefore == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NotBefore, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificateDetails) SetNotBeforeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NotBefore = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_certificateemail.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_certificateemail.go new file mode 100644 index 000000000000..27ec4e4d6f2c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_certificateemail.go @@ -0,0 +1,27 @@ +package appservicecertificateorders + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateEmail struct { + EmailId *string `json:"emailId,omitempty"` + TimeStamp *string `json:"timeStamp,omitempty"` +} + +func (o *CertificateEmail) GetTimeStampAsTime() (*time.Time, error) { + if o.TimeStamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeStamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificateEmail) SetTimeStampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeStamp = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_certificateorderaction.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_certificateorderaction.go new file mode 100644 index 000000000000..5a7f75ca6644 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_certificateorderaction.go @@ -0,0 +1,27 @@ +package appservicecertificateorders + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateOrderAction struct { + ActionType *CertificateOrderActionType `json:"actionType,omitempty"` + CreatedAt *string `json:"createdAt,omitempty"` +} + +func (o *CertificateOrderAction) GetCreatedAtAsTime() (*time.Time, error) { + if o.CreatedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificateOrderAction) SetCreatedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedAt = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_certificateordercontact.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_certificateordercontact.go new file mode 100644 index 000000000000..65e867d21029 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_certificateordercontact.go @@ -0,0 +1,11 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateOrderContact struct { + Email *string `json:"email,omitempty"` + NameFirst *string `json:"nameFirst,omitempty"` + NameLast *string `json:"nameLast,omitempty"` + Phone *string `json:"phone,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_nameidentifier.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_nameidentifier.go new file mode 100644 index 000000000000..72477ac557df --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_nameidentifier.go @@ -0,0 +1,8 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NameIdentifier struct { + Name *string `json:"name,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_reissuecertificateorderrequest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_reissuecertificateorderrequest.go new file mode 100644 index 000000000000..15d4fec95725 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_reissuecertificateorderrequest.go @@ -0,0 +1,12 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReissueCertificateOrderRequest struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ReissueCertificateOrderRequestProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_reissuecertificateorderrequestproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_reissuecertificateorderrequestproperties.go new file mode 100644 index 000000000000..edcc06283c9b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_reissuecertificateorderrequestproperties.go @@ -0,0 +1,11 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReissueCertificateOrderRequestProperties struct { + Csr *string `json:"csr,omitempty"` + DelayExistingRevokeInHours *int64 `json:"delayExistingRevokeInHours,omitempty"` + IsPrivateKeyExternal *bool `json:"isPrivateKeyExternal,omitempty"` + KeySize *int64 `json:"keySize,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_renewcertificateorderrequest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_renewcertificateorderrequest.go new file mode 100644 index 000000000000..cacc0bada974 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_renewcertificateorderrequest.go @@ -0,0 +1,12 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RenewCertificateOrderRequest struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RenewCertificateOrderRequestProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_renewcertificateorderrequestproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_renewcertificateorderrequestproperties.go new file mode 100644 index 000000000000..161c783b54e5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_renewcertificateorderrequestproperties.go @@ -0,0 +1,10 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RenewCertificateOrderRequestProperties struct { + Csr *string `json:"csr,omitempty"` + IsPrivateKeyExternal *bool `json:"isPrivateKeyExternal,omitempty"` + KeySize *int64 `json:"keySize,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_siteseal.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_siteseal.go new file mode 100644 index 000000000000..64f302c54e8b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_siteseal.go @@ -0,0 +1,8 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteSeal struct { + Html string `json:"html"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_sitesealrequest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_sitesealrequest.go new file mode 100644 index 000000000000..ed81319016d8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/model_sitesealrequest.go @@ -0,0 +1,9 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteSealRequest struct { + LightTheme *bool `json:"lightTheme,omitempty"` + Locale *string `json:"locale,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/predicates.go new file mode 100644 index 000000000000..e7457040d0bd --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/predicates.go @@ -0,0 +1,70 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceCertificateOrderOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p AppServiceCertificateOrderOperationPredicate) Matches(input AppServiceCertificateOrder) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type AppServiceCertificateResourceOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p AppServiceCertificateResourceOperationPredicate) Matches(input AppServiceCertificateResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/version.go new file mode 100644 index 000000000000..d6c5f65bfbb8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/version.go @@ -0,0 +1,12 @@ +package appservicecertificateorders + +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 = "2023-01-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/appservicecertificateorders/%s", defaultApiVersion) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 5811401a4c8d..bdf60f9ef5b9 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1052,6 +1052,7 @@ github.com/hashicorp/go-azure-sdk/resource-manager/voiceservices/2023-04-03/comm github.com/hashicorp/go-azure-sdk/resource-manager/voiceservices/2023-04-03/testlines github.com/hashicorp/go-azure-sdk/resource-manager/web/2016-06-01/connections github.com/hashicorp/go-azure-sdk/resource-manager/web/2016-06-01/managedapis +github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appserviceenvironments github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appserviceplans github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/resourceproviders diff --git a/website/docs/r/app_service_certificate_order_certificate.html.markdown b/website/docs/r/app_service_certificate_order_certificate.html.markdown new file mode 100644 index 000000000000..5c9dcbe585aa --- /dev/null +++ b/website/docs/r/app_service_certificate_order_certificate.html.markdown @@ -0,0 +1,133 @@ +--- +subcategory: "App Service (Web Apps)" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_app_sevice_certificate_order_certificate" +description: |- + Manages an App Service Certificate Order. + +--- + +# azurerm_app_service_certificate_order_certificate + +Manages an App Service Certificate Order Certificate. + +## Example Usage + +```hcl +data "azurerm_client_config" "test" {} + +resource "azurerm_resource_group" "example" { + name = "example-resources" + location = "West Europe" +} + +resource "azurerm_key_vault" "test" { + name = "example-keyvault" + location = azurerm_resource_group.example.location + resource_group_name = azurerm_resource_group.example.name + + tenant_id = data.azurerm_client_config.test.tenant_id + + sku_name = "standard" + + // app service object ID + access_policy { + tenant_id = data.azurerm_client_config.test.tenant_id + object_id = "f8daea97-62e7-4026-becf-13c2ea98e8b4" + + secret_permissions = [ + "Delete", + "Get", + "Purge", + "Set", + "List" + ] + + certificate_permissions = [ + "Create", + "Delete", + "Get", + "Purge", + "Import", + "List" + ] + } + + // Microsoft.Azure.CertificateRegistration object ID + access_policy { + tenant_id = data.azurerm_client_config.test.tenant_id + object_id = "ed47c2a1-bd23-4341-b39c-f4fd69138dd3" + + secret_permissions = [ + "Delete", + "Get", + "Purge", + "Set", + "List" + ] + + certificate_permissions = [ + "Create", + "Delete", + "Get", + "Purge", + "Import", + "List" + ] + } +} + +resource "azurerm_app_service_certificate_order" "example" { + name = "example-cert-order" + resource_group_name = azurerm_resource_group.example.name + location = "global" + distinguished_name = "CN=example.com" + product_type = "Standard" +} + +resource "azurerm_app_service_certificate_order_certificate" "test" { + name = "example-certorder-cert" + certificate_order_id = azurerm_app_service_certificate_order.example.id + key_vault_id = azurerm_key_vault.example.id + key_vault_secret_name = "example-keyvault-secret" +} +``` + +-> **Note:** Please make sure the domain ownership is verified before configure the key vault. + +## Argument Reference + +The following arguments are supported: + +* `name` - (Required) Specifies the name of the certificate. Changing this forces a new resource to be created. + +* `certificate_order_id` - (Required) The id of the certificate order in which to create the certificate. Changing this forces a new resource to be created. + +* `key_vault_id` - (Required) The id of the key vault in which to bind the certificate. + +* `key_vault_secret_name` - (Required) The name of the key vault secrete in which to bind the certificate. + +## Attributes Reference + +* `location` - The location of the certificate. + +* `type` - The type of the certificate. + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/language/resources/syntax#operation-timeouts) for certain actions: + +* `create` - (Defaults to 30 minutes) Used when creating the App Service Certificate Order Certificate. +* `update` - (Defaults to 30 minutes) Used when updating the App Service Certificate Order Certificate. +* `read` - (Defaults to 5 minutes) Used when retrieving the App Service Certificate Order Certificate. +* `delete` - (Defaults to 30 minutes) Used when deleting the App Service Certificate Order Certificate. + +## Import + +App Service Certificate Orders can be imported using the `resource id`, e.g. + +```shell +terraform import azurerm_app_service_certificate_order.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.CertificateRegistration/certificateOrders/certificateorder1/certificates/certificates1 +``` + + From f9a2788ce87e6dd6dd256d115057f164fcc50a4b Mon Sep 17 00:00:00 2001 From: "Xiaxin Yi (from Dev Box)" Date: Fri, 29 Mar 2024 10:13:56 +0800 Subject: [PATCH 2/8] update fmt --- .../appservice/app_service_certificate_order_certificate.go | 2 +- .../app_service_certificate_order_certificate_test.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/services/appservice/app_service_certificate_order_certificate.go b/internal/services/appservice/app_service_certificate_order_certificate.go index 128cfc058c04..8e7693eb7efa 100644 --- a/internal/services/appservice/app_service_certificate_order_certificate.go +++ b/internal/services/appservice/app_service_certificate_order_certificate.go @@ -3,7 +3,6 @@ package appservice import ( "context" "fmt" - "github.com/hashicorp/terraform-provider-azurerm/internal/tf/suppress" "time" "github.com/hashicorp/go-azure-helpers/lang/pointer" @@ -15,6 +14,7 @@ import ( keyVaultValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/keyvault/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/suppress" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" ) diff --git a/internal/services/appservice/app_service_certificate_order_certificate_test.go b/internal/services/appservice/app_service_certificate_order_certificate_test.go index 4f51fa880d7f..5c42e0c2c49f 100644 --- a/internal/services/appservice/app_service_certificate_order_certificate_test.go +++ b/internal/services/appservice/app_service_certificate_order_certificate_test.go @@ -102,7 +102,7 @@ func (r CertificateOrderCertificateResource) basic(data acceptance.TestData) str %s resource "azurerm_app_service_certificate_order_certificate" "test" { name = "acctestcokv-%[2]s" - certificate_order_id = data.azurerm_app_service_certificate_order.test.id + certificate_order_id = azurerm_app_service_certificate_order.test.id key_vault_id = azurerm_key_vault.test.id key_vault_secret_name = "kvsec%[2]s" } @@ -115,7 +115,7 @@ func (r CertificateOrderCertificateResource) keyVaultIdUpdate(data acceptance.Te %s resource "azurerm_app_service_certificate_order_certificate" "test" { name = "acctestcokv-%[2]s" - certificate_order_id = data.azurerm_app_service_certificate_order.test.id + certificate_order_id = azurerm_app_service_certificate_order.test.id key_vault_id = azurerm_key_vault.test1.id key_vault_secret_name = "kvsec%[2]s" } @@ -128,7 +128,7 @@ func (r CertificateOrderCertificateResource) keyVaultNameUpdate(data acceptance. %s resource "azurerm_app_service_certificate_order_certificate" "test" { name = "acctestcokv-%[2]s" - certificate_order_id = data.azurerm_app_service_certificate_order.test.id + certificate_order_id = azurerm_app_service_certificate_order.test.id key_vault_id = azurerm_key_vault.test.id key_vault_secret_name = "kvsec1%[2]s" } From aad93cbbe0517f6386053fad5a280820440bc8bb Mon Sep 17 00:00:00 2001 From: "Xiaxin Yi (from Dev Box)" Date: Fri, 29 Mar 2024 10:42:38 +0800 Subject: [PATCH 3/8] fix doc issue --- ...ertificate_order_certificate.html.markdown | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/website/docs/r/app_service_certificate_order_certificate.html.markdown b/website/docs/r/app_service_certificate_order_certificate.html.markdown index 5c9dcbe585aa..c98ffa7fe701 100644 --- a/website/docs/r/app_service_certificate_order_certificate.html.markdown +++ b/website/docs/r/app_service_certificate_order_certificate.html.markdown @@ -1,9 +1,9 @@ --- subcategory: "App Service (Web Apps)" layout: "azurerm" -page_title: "Azure Resource Manager: azurerm_app_sevice_certificate_order_certificate" +page_title: "Azure Resource Manager: azurerm_app_service_certificate_order_certificate" description: |- - Manages an App Service Certificate Order. + Manages an App Service Certificate Order Certificate. --- @@ -99,19 +99,19 @@ resource "azurerm_app_service_certificate_order_certificate" "test" { The following arguments are supported: -* `name` - (Required) Specifies the name of the certificate. Changing this forces a new resource to be created. +* `name` - (Required) Specifies the name of the certificate order certificate key vault binding. Changing this forces a new resource to be created. -* `certificate_order_id` - (Required) The id of the certificate order in which to create the certificate. Changing this forces a new resource to be created. +* `certificate_order_id` - (Required) The id of the certificate order in which to configure the certificate. Changing this forces a new resource to be created. -* `key_vault_id` - (Required) The id of the key vault in which to bind the certificate. +* `key_vault_id` - (Required) The id of the key vault in which to bind the certificate order certificate. -* `key_vault_secret_name` - (Required) The name of the key vault secrete in which to bind the certificate. +* `key_vault_secret_name` - (Required) The name of the key vault secrete in which to bind the certificate order certificate. ## Attributes Reference -* `location` - The location of the certificate. +* `location` - The location of the certificate order certificate. -* `type` - The type of the certificate. +* `type` - The type of the certificate order certificate. ## Timeouts @@ -124,10 +124,10 @@ The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/l ## Import -App Service Certificate Orders can be imported using the `resource id`, e.g. +App Service Certificate Order Certificate can be imported using the `resource id`, e.g. ```shell -terraform import azurerm_app_service_certificate_order.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.CertificateRegistration/certificateOrders/certificateorder1/certificates/certificates1 +terraform import azurerm_app_service_certificate_order_certificate.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.CertificateRegistration/certificateOrders/certificateorder1/certificates/certificates1 ``` From 7e29db41a566b71a6987c6b2730cbc30ec9109d0 Mon Sep 17 00:00:00 2001 From: "Xiaxin Yi (from Dev Box)" Date: Fri, 29 Mar 2024 11:18:16 +0800 Subject: [PATCH 4/8] regenerate code --- .github/labeler-issue-triage.yml | 2 +- ...service_certificate_order_certificate.html.markdown | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/labeler-issue-triage.yml b/.github/labeler-issue-triage.yml index 114f21bfa4ae..f4e2cea6532c 100644 --- a/.github/labeler-issue-triage.yml +++ b/.github/labeler-issue-triage.yml @@ -25,7 +25,7 @@ service/app-configuration: - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_app_configuration((.|\n)*)###' service/app-service: - - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_(app_service_environment_v3\W+|app_service_environment_v3\W+|app_service_source_control\W+|app_service_source_control_slot\W+|function_app_active_slot\W+|function_app_function\W+|function_app_hybrid_connection\W+|linux_function_app\W+|linux_function_app\W+|linux_function_app_slot\W+|linux_web_app\W+|linux_web_app\W+|linux_web_app_slot\W+|service_plan|source_control_token|static_web_app|web_app_|windows_function_app\W+|windows_function_app\W+|windows_function_app_slot\W+|windows_web_app\W+|windows_web_app\W+|windows_web_app_slot\W+)((.|\n)*)###' + - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_(app_service_certificate_order_certificate\W+|app_service_environment_v3\W+|app_service_environment_v3\W+|app_service_source_control\W+|app_service_source_control_slot\W+|function_app_active_slot\W+|function_app_function\W+|function_app_hybrid_connection\W+|linux_function_app\W+|linux_function_app\W+|linux_function_app_slot\W+|linux_web_app\W+|linux_web_app\W+|linux_web_app_slot\W+|service_plan|source_control_token|static_web_app|web_app_|windows_function_app\W+|windows_function_app\W+|windows_function_app_slot\W+|windows_web_app\W+|windows_web_app\W+|windows_web_app_slot\W+)((.|\n)*)###' service/application-insights: - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_application_insights((.|\n)*)###' diff --git a/website/docs/r/app_service_certificate_order_certificate.html.markdown b/website/docs/r/app_service_certificate_order_certificate.html.markdown index c98ffa7fe701..0e2757524925 100644 --- a/website/docs/r/app_service_certificate_order_certificate.html.markdown +++ b/website/docs/r/app_service_certificate_order_certificate.html.markdown @@ -14,13 +14,13 @@ Manages an App Service Certificate Order Certificate. ## Example Usage ```hcl -data "azurerm_client_config" "test" {} - resource "azurerm_resource_group" "example" { name = "example-resources" location = "West Europe" } +data "azurerm_client_config" "test" {} + resource "azurerm_key_vault" "test" { name = "example-keyvault" location = azurerm_resource_group.example.location @@ -86,9 +86,9 @@ resource "azurerm_app_service_certificate_order" "example" { } resource "azurerm_app_service_certificate_order_certificate" "test" { - name = "example-certorder-cert" - certificate_order_id = azurerm_app_service_certificate_order.example.id - key_vault_id = azurerm_key_vault.example.id + name = "example-certorder-cert" + certificate_order_id = azurerm_app_service_certificate_order.example.id + key_vault_id = azurerm_key_vault.example.id key_vault_secret_name = "example-keyvault-secret" } ``` From 57477df57e5d5e38bac0cc68607c54539e3abed0 Mon Sep 17 00:00:00 2001 From: "Xiaxin Yi (from Dev Box)" Date: Fri, 29 Mar 2024 14:33:49 +0800 Subject: [PATCH 5/8] update test case --- ...vice_certificate_order_certificate_test.go | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/internal/services/appservice/app_service_certificate_order_certificate_test.go b/internal/services/appservice/app_service_certificate_order_certificate_test.go index 5c42e0c2c49f..a55d69a76120 100644 --- a/internal/services/appservice/app_service_certificate_order_certificate_test.go +++ b/internal/services/appservice/app_service_certificate_order_certificate_test.go @@ -3,6 +3,7 @@ package appservice_test import ( "context" "fmt" + "os" "testing" "github.com/hashicorp/go-azure-helpers/lang/response" @@ -136,6 +137,8 @@ resource "azurerm_app_service_certificate_order_certificate" "test" { } func (r CertificateOrderCertificateResource) template(data acceptance.TestData) string { + dnsZone := os.Getenv("ARM_TEST_DNS_ZONE") + dnsZoneRG := os.Getenv("ARM_TEST_DATA_RESOURCE_GROUP") return fmt.Sprintf(` provider "azurerm" { features {} @@ -190,9 +193,10 @@ resource "azurerm_key_vault" "test" { ] } - // app service + // app service object ID access_policy { tenant_id = data.azurerm_client_config.test.tenant_id + //object_id = "f8daea97-62e7-4026-becf-13c2ea98e8b4" object_id = data.azuread_service_principal.app-service-spn.object_id secret_permissions = [ @@ -213,10 +217,11 @@ resource "azurerm_key_vault" "test" { ] } - // Microsoft.Azure.CertificateRegistration + // Microsoft.Azure.CertificateRegistration access_policy { tenant_id = data.azurerm_client_config.test.tenant_id object_id = data.azuread_service_principal.cert-spn.object_id + //object_id = "ed47c2a1-bd23-4341-b39c-f4fd69138dd3" secret_permissions = [ "Delete", @@ -273,6 +278,7 @@ resource "azurerm_key_vault" "test1" { access_policy { tenant_id = data.azurerm_client_config.test.tenant_id object_id = data.azuread_service_principal.app-service-spn.object_id + //object_id = "f8daea97-62e7-4026-becf-13c2ea98e8b4" secret_permissions = [ "Delete", @@ -296,6 +302,7 @@ resource "azurerm_key_vault" "test1" { access_policy { tenant_id = data.azurerm_client_config.test.tenant_id object_id = data.azuread_service_principal.cert-spn.object_id + //object_id = "ed47c2a1-bd23-4341-b39c-f4fd69138dd3" secret_permissions = [ "Delete", @@ -316,13 +323,28 @@ resource "azurerm_key_vault" "test1" { } } +data "azurerm_dns_zone" "test" { + name = "%[4]s" + resource_group_name = "%[5]s" +} + resource "azurerm_app_service_certificate_order" "test" { name = "tftestASCO-cert-%[3]s" location = "global" resource_group_name = azurerm_resource_group.test.name - distinguished_name = "CN=example.com" + distinguished_name = "CN=${data.azurerm_dns_zone.test.name}" product_type = "Standard" } -`, data.RandomInteger, data.Locations.Primary, data.RandomStringOfLength(5)) +resource "azurerm_dns_txt_record" "test" { + name = "@" + zone_name = data.azurerm_dns_zone.test.name + resource_group_name = data.azurerm_dns_zone.test.resource_group_name + ttl = 3600 + + record { + value = azurerm_app_service_certificate_order.test.domain_verification_token + } +} +`, data.RandomInteger, data.Locations.Primary, data.RandomStringOfLength(5), dnsZone, dnsZoneRG) } From 74f90504f00f6847ca25d176f925a0f5bc1a3b74 Mon Sep 17 00:00:00 2001 From: "Xiaxin Yi (from Dev Box)" Date: Fri, 14 Jun 2024 17:17:54 +0800 Subject: [PATCH 6/8] update code per reviewer's comments --- ...vice_certificate_order_key_vault_store.go} | 26 ++++----- ...certificate_order_key_vault_store_test.go} | 58 ++++++------------- internal/services/appservice/client/client.go | 2 +- internal/services/appservice/registration.go | 2 +- ...icate_order_key_vault_store.html.markdown} | 22 ++++--- 5 files changed, 44 insertions(+), 66 deletions(-) rename internal/services/appservice/{app_service_certificate_order_certificate.go => app_service_certificate_order_key_vault_store.go} (87%) rename internal/services/appservice/{app_service_certificate_order_certificate_test.go => app_service_certificate_order_key_vault_store_test.go} (80%) rename website/docs/r/{app_service_certificate_order_certificate.html.markdown => app_service_certificate_order_key_vault_store.html.markdown} (71%) diff --git a/internal/services/appservice/app_service_certificate_order_certificate.go b/internal/services/appservice/app_service_certificate_order_key_vault_store.go similarity index 87% rename from internal/services/appservice/app_service_certificate_order_certificate.go rename to internal/services/appservice/app_service_certificate_order_key_vault_store.go index 8e7693eb7efa..139f586776e4 100644 --- a/internal/services/appservice/app_service_certificate_order_certificate.go +++ b/internal/services/appservice/app_service_certificate_order_key_vault_store.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-helpers/resourcemanager/location" "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders" "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" keyVaultValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/keyvault/validate" @@ -76,7 +77,7 @@ func (r CertificateOrderCertificateResource) ModelObject() interface{} { } func (r CertificateOrderCertificateResource) ResourceType() string { - return "azurerm_app_service_certificate_order_certificate" + return "azurerm_app_service_certificate_order_key_vault_store" } func (r CertificateOrderCertificateResource) Create() sdk.ResourceFunc { @@ -93,19 +94,18 @@ func (r CertificateOrderCertificateResource) Create() sdk.ResourceFunc { certificateOrderId, err := appservicecertificateorders.ParseCertificateOrderID(certificateOrderCertificate.CertificateOrderId) if err != nil { - return fmt.Errorf("parsing certificate order error %+v", err) + return err } id := appservicecertificateorders.NewCertificateID(subscriptionId, certificateOrderId.ResourceGroupName, certificateOrderId.CertificateOrderName, certificateOrderCertificate.Name) - keyVaultId, err := commonids.ParseKeyVaultIDInsensitively(certificateOrderCertificate.KeyVaultId) + keyVaultId, err := commonids.ParseKeyVaultID(certificateOrderCertificate.KeyVaultId) if err != nil { return err } - kvId := commonids.NewKeyVaultID(keyVaultId.SubscriptionId, keyVaultId.ResourceGroupName, keyVaultId.VaultName) existing, err := client.GetCertificate(ctx, id) if err != nil && !response.WasNotFound(existing.HttpResponse) { - return fmt.Errorf("retreiving %s: %v", id, err) + return fmt.Errorf("retrieving %s: %v", id, err) } if !response.WasNotFound(existing.HttpResponse) { return metadata.ResourceRequiresImport(r.ResourceType(), id) @@ -114,7 +114,7 @@ func (r CertificateOrderCertificateResource) Create() sdk.ResourceFunc { certOrderCertificate := appservicecertificateorders.AppServiceCertificateResource{ Name: pointer.To(certificateOrderCertificate.Name), Properties: &appservicecertificateorders.AppServiceCertificate{ - KeyVaultId: pointer.To(kvId.ID()), + KeyVaultId: pointer.To(keyVaultId.ID()), KeyVaultSecretName: pointer.To(certificateOrderCertificate.KeyVaultSecretName), }, } @@ -135,7 +135,7 @@ func (r CertificateOrderCertificateResource) Read() sdk.ResourceFunc { Timeout: 5 * time.Minute, Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { client := metadata.Client.AppService.AppServiceCertificatesOrderClient - id, err := appservicecertificateorders.ParseCertificateIDInsensitively(metadata.ResourceData.Id()) + id, err := appservicecertificateorders.ParseCertificateID(metadata.ResourceData.Id()) if err != nil { return err } @@ -145,7 +145,7 @@ func (r CertificateOrderCertificateResource) Read() sdk.ResourceFunc { if response.WasNotFound(certificateOrderCertificate.HttpResponse) { return metadata.MarkAsGone(id) } - return fmt.Errorf("reading %s: %+v", id, err) + return fmt.Errorf("retrieving %s: %+v", id, err) } state := CertificateOrderCertificateModel{ @@ -155,8 +155,9 @@ func (r CertificateOrderCertificateResource) Read() sdk.ResourceFunc { certificateOrderId := appservicecertificateorders.NewCertificateOrderID(id.SubscriptionId, id.ResourceGroupName, id.CertificateOrderName) state.CertificateOrderId = certificateOrderId.ID() + // we need to parse the key vault id insensitively as the resource group part was changed https://github.com/Azure/azure-rest-api-specs/issues/new?assignees=&labels=bug&projects=&template=02_bug.yml&title=%5BBUG%5D if model := certificateOrderCertificate.Model; model != nil { - state.Location = model.Location + state.Location = location.Normalize(model.Location) if props := model.Properties; props != nil { if props.KeyVaultId != nil { keyVaultId, err := commonids.ParseKeyVaultIDInsensitively(*props.KeyVaultId) @@ -181,13 +182,12 @@ func (r CertificateOrderCertificateResource) Delete() sdk.ResourceFunc { return sdk.ResourceFunc{ Timeout: 60 * time.Minute, Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { - id, err := appservicecertificateorders.ParseCertificateIDInsensitively(metadata.ResourceData.Id()) + id, err := appservicecertificateorders.ParseCertificateID(metadata.ResourceData.Id()) if err != nil { return err } client := metadata.Client.AppService.AppServiceCertificatesOrderClient - metadata.Logger.Infof("deleting %s", id) if _, err := client.DeleteCertificate(ctx, *id); err != nil { return fmt.Errorf("deleting %s: %+v", id, err) @@ -202,7 +202,7 @@ func (r CertificateOrderCertificateResource) Update() sdk.ResourceFunc { return sdk.ResourceFunc{ Timeout: 60 * time.Minute, Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { - id, err := appservicecertificateorders.ParseCertificateIDInsensitively(metadata.ResourceData.Id()) + id, err := appservicecertificateorders.ParseCertificateID(metadata.ResourceData.Id()) if err != nil { return err } @@ -216,7 +216,7 @@ func (r CertificateOrderCertificateResource) Update() sdk.ResourceFunc { existing, err := client.GetCertificate(ctx, *id) if err != nil { - return fmt.Errorf("reading %s: %+v", id, err) + return fmt.Errorf("retrieving %s: %+v", id, err) } model := *existing.Model diff --git a/internal/services/appservice/app_service_certificate_order_certificate_test.go b/internal/services/appservice/app_service_certificate_order_key_vault_store_test.go similarity index 80% rename from internal/services/appservice/app_service_certificate_order_certificate_test.go rename to internal/services/appservice/app_service_certificate_order_key_vault_store_test.go index a55d69a76120..6e11ff01093b 100644 --- a/internal/services/appservice/app_service_certificate_order_certificate_test.go +++ b/internal/services/appservice/app_service_certificate_order_key_vault_store_test.go @@ -3,22 +3,20 @@ package appservice_test import ( "context" "fmt" - "os" "testing" - "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/lang/pointer" "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) type CertificateOrderCertificateResource struct{} -func TestAccAppServiceCertificateOrderCertificate_basic(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_app_service_certificate_order_certificate", "test") +func TestAccAppServiceCertificateOrderKeyVaultStore_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_app_service_certificate_order_key_vault_store", "test") r := CertificateOrderCertificateResource{} data.ResourceTest(t, r, []acceptance.TestStep{ @@ -32,8 +30,8 @@ func TestAccAppServiceCertificateOrderCertificate_basic(t *testing.T) { }) } -func TestAccAppServiceCertificateOrderCertificate_updateKeyVaultId(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_app_service_certificate_order_certificate", "test") +func TestAccAppServiceCertificateOrderKeyVaultStore_updateKeyVaultId(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_app_service_certificate_order_key_vault_store", "test") r := CertificateOrderCertificateResource{} data.ResourceTest(t, r, []acceptance.TestStep{ @@ -53,8 +51,8 @@ func TestAccAppServiceCertificateOrderCertificate_updateKeyVaultId(t *testing.T) data.ImportStep(), }) } -func TestAccAppServiceCertificateOrderCertificate_updateKeyVaultName(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_app_service_certificate_order_certificate", "test") +func TestAccAppServiceCertificateOrderKeyVaultStore_updateKeyVaultName(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_app_service_certificate_order_key_vault_store", "test") r := CertificateOrderCertificateResource{} data.ResourceTest(t, r, []acceptance.TestStep{ @@ -76,32 +74,24 @@ func TestAccAppServiceCertificateOrderCertificate_updateKeyVaultName(t *testing. } func (r CertificateOrderCertificateResource) Exists(ctx context.Context, client *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := appservicecertificateorders.ParseCertificateIDInsensitively(state.ID) + id, err := appservicecertificateorders.ParseCertificateID(state.ID) if err != nil { return nil, err } resp, err := client.AppService.AppServiceCertificatesOrderClient.GetCertificate(ctx, *id) if err != nil { - if response.WasNotFound(resp.HttpResponse) { - return utils.Bool(false), nil - } return nil, fmt.Errorf("retreiving %s: %v", id, err) } - if response.WasNotFound(resp.HttpResponse) { - return utils.Bool(false), nil - } - return utils.Bool(true), nil + return pointer.To(resp.Model != nil), nil } -// Configs - func (r CertificateOrderCertificateResource) basic(data acceptance.TestData) string { template := r.template(data) return fmt.Sprintf(` %s -resource "azurerm_app_service_certificate_order_certificate" "test" { +resource "azurerm_app_service_certificate_order_key_vault_store" "test" { name = "acctestcokv-%[2]s" certificate_order_id = azurerm_app_service_certificate_order.test.id key_vault_id = azurerm_key_vault.test.id @@ -114,7 +104,7 @@ func (r CertificateOrderCertificateResource) keyVaultIdUpdate(data acceptance.Te template := r.template(data) return fmt.Sprintf(` %s -resource "azurerm_app_service_certificate_order_certificate" "test" { +resource "azurerm_app_service_certificate_order_key_vault_store" "test" { name = "acctestcokv-%[2]s" certificate_order_id = azurerm_app_service_certificate_order.test.id key_vault_id = azurerm_key_vault.test1.id @@ -127,7 +117,7 @@ func (r CertificateOrderCertificateResource) keyVaultNameUpdate(data acceptance. template := r.template(data) return fmt.Sprintf(` %s -resource "azurerm_app_service_certificate_order_certificate" "test" { +resource "azurerm_app_service_certificate_order_key_vault_store" "test" { name = "acctestcokv-%[2]s" certificate_order_id = azurerm_app_service_certificate_order.test.id key_vault_id = azurerm_key_vault.test.id @@ -137,8 +127,6 @@ resource "azurerm_app_service_certificate_order_certificate" "test" { } func (r CertificateOrderCertificateResource) template(data acceptance.TestData) string { - dnsZone := os.Getenv("ARM_TEST_DNS_ZONE") - dnsZoneRG := os.Getenv("ARM_TEST_DATA_RESOURCE_GROUP") return fmt.Sprintf(` provider "azurerm" { features {} @@ -193,10 +181,8 @@ resource "azurerm_key_vault" "test" { ] } - // app service object ID access_policy { tenant_id = data.azurerm_client_config.test.tenant_id - //object_id = "f8daea97-62e7-4026-becf-13c2ea98e8b4" object_id = data.azuread_service_principal.app-service-spn.object_id secret_permissions = [ @@ -217,11 +203,9 @@ resource "azurerm_key_vault" "test" { ] } - // Microsoft.Azure.CertificateRegistration access_policy { tenant_id = data.azurerm_client_config.test.tenant_id object_id = data.azuread_service_principal.cert-spn.object_id - //object_id = "ed47c2a1-bd23-4341-b39c-f4fd69138dd3" secret_permissions = [ "Delete", @@ -274,11 +258,9 @@ resource "azurerm_key_vault" "test1" { ] } - // app service access_policy { tenant_id = data.azurerm_client_config.test.tenant_id object_id = data.azuread_service_principal.app-service-spn.object_id - //object_id = "f8daea97-62e7-4026-becf-13c2ea98e8b4" secret_permissions = [ "Delete", @@ -298,11 +280,9 @@ resource "azurerm_key_vault" "test1" { ] } - // Microsoft.Azure.CertificateRegistration access_policy { tenant_id = data.azurerm_client_config.test.tenant_id object_id = data.azuread_service_principal.cert-spn.object_id - //object_id = "ed47c2a1-bd23-4341-b39c-f4fd69138dd3" secret_permissions = [ "Delete", @@ -323,28 +303,28 @@ resource "azurerm_key_vault" "test1" { } } -data "azurerm_dns_zone" "test" { - name = "%[4]s" - resource_group_name = "%[5]s" +resource "azurerm_dns_zone" "test" { + name = "acctestzone%[1]d.com" + resource_group_name = azurerm_resource_group.test.name } resource "azurerm_app_service_certificate_order" "test" { name = "tftestASCO-cert-%[3]s" location = "global" resource_group_name = azurerm_resource_group.test.name - distinguished_name = "CN=${data.azurerm_dns_zone.test.name}" + distinguished_name = "CN=${azurerm_dns_zone.test.name}" product_type = "Standard" } resource "azurerm_dns_txt_record" "test" { name = "@" - zone_name = data.azurerm_dns_zone.test.name - resource_group_name = data.azurerm_dns_zone.test.resource_group_name + zone_name = azurerm_dns_zone.test.name + resource_group_name = azurerm_dns_zone.test.resource_group_name ttl = 3600 record { value = azurerm_app_service_certificate_order.test.domain_verification_token } } -`, data.RandomInteger, data.Locations.Primary, data.RandomStringOfLength(5), dnsZone, dnsZoneRG) +`, data.RandomInteger, data.Locations.Primary, data.RandomStringOfLength(5), data.RandomInteger) } diff --git a/internal/services/appservice/client/client.go b/internal/services/appservice/client/client.go index c3dd6853a63d..92a5ed12ca87 100644 --- a/internal/services/appservice/client/client.go +++ b/internal/services/appservice/client/client.go @@ -57,7 +57,7 @@ func NewClient(o *common.ClientOptions) (*Client, error) { appServiceCertificatesOrderClient, err := appservicecertificateorders.NewAppServiceCertificateOrdersClientWithBaseURI(o.Environment.ResourceManager) if err != nil { - return nil, fmt.Errorf("building Appservice Certificate Order client: %+v", err) + return nil, fmt.Errorf("building Certificate Order client: %+v", err) } o.Configure(appServiceCertificatesOrderClient.Client, o.Authorizers.ResourceManager) diff --git a/internal/services/appservice/registration.go b/internal/services/appservice/registration.go index 98bd813a590b..3c8916947de1 100644 --- a/internal/services/appservice/registration.go +++ b/internal/services/appservice/registration.go @@ -40,6 +40,7 @@ func (r Registration) Resources() []sdk.Resource { return []sdk.Resource{ AppServiceEnvironmentV3Resource{}, AppServiceSourceControlTokenResource{}, + CertificateOrderCertificateResource{}, FunctionAppActiveSlotResource{}, FunctionAppFunctionResource{}, FunctionAppHybridConnectionResource{}, @@ -59,6 +60,5 @@ func (r Registration) Resources() []sdk.Resource { WindowsFunctionAppSlotResource{}, WindowsWebAppResource{}, WindowsWebAppSlotResource{}, - CertificateOrderCertificateResource{}, } } diff --git a/website/docs/r/app_service_certificate_order_certificate.html.markdown b/website/docs/r/app_service_certificate_order_key_vault_store.html.markdown similarity index 71% rename from website/docs/r/app_service_certificate_order_certificate.html.markdown rename to website/docs/r/app_service_certificate_order_key_vault_store.html.markdown index 0e2757524925..2f3865f24bd8 100644 --- a/website/docs/r/app_service_certificate_order_certificate.html.markdown +++ b/website/docs/r/app_service_certificate_order_key_vault_store.html.markdown @@ -1,13 +1,13 @@ --- subcategory: "App Service (Web Apps)" layout: "azurerm" -page_title: "Azure Resource Manager: azurerm_app_service_certificate_order_certificate" +page_title: "Azure Resource Manager: azurerm_app_service_certificate_order_key_vault_store" description: |- Manages an App Service Certificate Order Certificate. --- -# azurerm_app_service_certificate_order_certificate +# azurerm_app_service_certificate_order_key_vault_store Manages an App Service Certificate Order Certificate. @@ -30,7 +30,6 @@ resource "azurerm_key_vault" "test" { sku_name = "standard" - // app service object ID access_policy { tenant_id = data.azurerm_client_config.test.tenant_id object_id = "f8daea97-62e7-4026-becf-13c2ea98e8b4" @@ -53,7 +52,6 @@ resource "azurerm_key_vault" "test" { ] } - // Microsoft.Azure.CertificateRegistration object ID access_policy { tenant_id = data.azurerm_client_config.test.tenant_id object_id = "ed47c2a1-bd23-4341-b39c-f4fd69138dd3" @@ -85,7 +83,7 @@ resource "azurerm_app_service_certificate_order" "example" { product_type = "Standard" } -resource "azurerm_app_service_certificate_order_certificate" "test" { +resource "azurerm_app_service_certificate_order_key_vault_store" "test" { name = "example-certorder-cert" certificate_order_id = azurerm_app_service_certificate_order.example.id key_vault_id = azurerm_key_vault.example.id @@ -99,19 +97,19 @@ resource "azurerm_app_service_certificate_order_certificate" "test" { The following arguments are supported: -* `name` - (Required) Specifies the name of the certificate order certificate key vault binding. Changing this forces a new resource to be created. +* `name` - (Required) Specifies the name of the Certificate Key Vault Store. Changing this forces a new resource to be created. -* `certificate_order_id` - (Required) The id of the certificate order in which to configure the certificate. Changing this forces a new resource to be created. +* `certificate_order_id` - (Required) The ID of the Certificate Order in which to configure the Certificate Key Vault Store Binding. Changing this forces a new resource to be created. -* `key_vault_id` - (Required) The id of the key vault in which to bind the certificate order certificate. +* `key_vault_id` - (Required) The ID of the Key Vault in which to bind the Certificate. -* `key_vault_secret_name` - (Required) The name of the key vault secrete in which to bind the certificate order certificate. +* `key_vault_secret_name` - (Required) The name of the Key Vault Secret to bind to the Certificate. ## Attributes Reference -* `location` - The location of the certificate order certificate. +* `location` - The location of the certificate. -* `type` - The type of the certificate order certificate. +* `type` - The type of the certificate. ## Timeouts @@ -127,7 +125,7 @@ The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/l App Service Certificate Order Certificate can be imported using the `resource id`, e.g. ```shell -terraform import azurerm_app_service_certificate_order_certificate.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.CertificateRegistration/certificateOrders/certificateorder1/certificates/certificates1 +terraform import azurerm_app_service_certificate_order_key_vault_store.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.CertificateRegistration/certificateOrders/certificateorder1/certificates/certificates1 ``` From dbc5a63f44d4190403690590420f82c6ad15bcd6 Mon Sep 17 00:00:00 2001 From: "Xiaxin Yi (from Dev Box)" Date: Fri, 14 Jun 2024 22:05:16 +0800 Subject: [PATCH 7/8] update vendor --- .../2023-01-01/appservicecertificateorders/id_certificate.go | 5 +++++ .../appservicecertificateorders/id_certificateorder.go | 5 +++++ .../2023-01-01/appservicecertificateorders/method_list.go | 1 + .../method_listbyresourcegroup.go | 1 + .../appservicecertificateorders/method_listcertificates.go | 1 + 5 files changed, 13 insertions(+) diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/id_certificate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/id_certificate.go index 9b186c754cbc..e1678574f380 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/id_certificate.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/id_certificate.go @@ -4,12 +4,17 @@ import ( "fmt" "strings" + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" ) // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. +func init() { + recaser.RegisterResourceId(&CertificateId{}) +} + var _ resourceids.ResourceId = &CertificateId{} // CertificateId is a struct representing the Resource ID for a Certificate diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/id_certificateorder.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/id_certificateorder.go index 2abf9c64b375..7f0356716b26 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/id_certificateorder.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/id_certificateorder.go @@ -4,12 +4,17 @@ import ( "fmt" "strings" + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" ) // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. +func init() { + recaser.RegisterResourceId(&CertificateOrderId{}) +} + var _ resourceids.ResourceId = &CertificateOrderId{} // CertificateOrderId is a struct representing the Resource ID for a Certificate Order diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_list.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_list.go index a6c3ac262121..bf5fb68e51bc 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_list.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_list.go @@ -73,6 +73,7 @@ func (c AppServiceCertificateOrdersClient) ListCompleteMatchingPredicate(ctx con resp, err := c.List(ctx, id) if err != nil { + result.LatestHttpResponse = resp.HttpResponse err = fmt.Errorf("loading results: %+v", err) return } diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_listbyresourcegroup.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_listbyresourcegroup.go index 74ea0faa4b02..ec4e47be229f 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_listbyresourcegroup.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_listbyresourcegroup.go @@ -73,6 +73,7 @@ func (c AppServiceCertificateOrdersClient) ListByResourceGroupCompleteMatchingPr resp, err := c.ListByResourceGroup(ctx, id) if err != nil { + result.LatestHttpResponse = resp.HttpResponse err = fmt.Errorf("loading results: %+v", err) return } diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_listcertificates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_listcertificates.go index f13d03c4b86f..60eb5b6d8e8d 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_listcertificates.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appservicecertificateorders/method_listcertificates.go @@ -72,6 +72,7 @@ func (c AppServiceCertificateOrdersClient) ListCertificatesCompleteMatchingPredi resp, err := c.ListCertificates(ctx, id) if err != nil { + result.LatestHttpResponse = resp.HttpResponse err = fmt.Errorf("loading results: %+v", err) return } From e646b0aa32005cbb53ebbf619c537fd85b350c72 Mon Sep 17 00:00:00 2001 From: "Xiaxin Yi (from Dev Box)" Date: Sat, 15 Jun 2024 13:20:44 +0800 Subject: [PATCH 8/8] regenerate the yml file --- .github/labeler-issue-triage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/labeler-issue-triage.yml b/.github/labeler-issue-triage.yml index ebcf84a589e0..2343c54c8db8 100644 --- a/.github/labeler-issue-triage.yml +++ b/.github/labeler-issue-triage.yml @@ -25,7 +25,7 @@ service/app-configuration: - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_app_configuration((.|\n)*)###' service/app-service: - - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_(app_service_certificate_order_certificate\W+|app_service_environment_v3\W+|app_service_environment_v3\W+|app_service_source_control\W+|app_service_source_control_slot\W+|function_app_active_slot\W+|function_app_function\W+|function_app_hybrid_connection\W+|linux_function_app\W+|linux_function_app\W+|linux_function_app_slot\W+|linux_web_app\W+|linux_web_app\W+|linux_web_app_slot\W+|service_plan|source_control_token|static_web_app|web_app_|windows_function_app\W+|windows_function_app\W+|windows_function_app_slot\W+|windows_web_app\W+|windows_web_app\W+|windows_web_app_slot\W+)((.|\n)*)###' + - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_(app_service_certificate_order_key_vault_store\W+|app_service_environment_v3\W+|app_service_environment_v3\W+|app_service_source_control\W+|app_service_source_control_slot\W+|function_app_active_slot\W+|function_app_function\W+|function_app_hybrid_connection\W+|linux_function_app\W+|linux_function_app\W+|linux_function_app_slot\W+|linux_web_app\W+|linux_web_app\W+|linux_web_app_slot\W+|service_plan|source_control_token|static_web_app|web_app_|windows_function_app\W+|windows_function_app\W+|windows_function_app_slot\W+|windows_web_app\W+|windows_web_app\W+|windows_web_app_slot\W+)((.|\n)*)###' service/application-insights: - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_application_insights((.|\n)*)###'