From 3c4b95e17c4e31989bb035c343833bea66893cd0 Mon Sep 17 00:00:00 2001 From: Pipeline Date: Wed, 31 Mar 2021 17:47:53 +0200 Subject: [PATCH 1/6] enable key vault certificates for api mgmt --- .../api_management_api_data_source.go | 2 +- .../api_management_certificate_resource.go | 65 +- ...pi_management_certificate_resource_test.go | 273 ++++++ .../api_management_resource_test.go | 2 +- .../apimanagement/deletedservices.go | 3 +- .../gatewaycertificateauthority.go | 3 +- .../mgmt/2020-12-01/apimanagement/models.go | 785 +++++++++++++++++- .../2020-12-01/apimanagement/namedvalue.go | 3 +- .../apimanagement/portalrevision.go | 3 +- .../mgmt/2020-12-01/apimanagement/skus.go | 3 +- .../apimanagement/tenantsettings.go | 3 +- .../authorization/CHANGELOG.md | 20 + .../authorization/roleassignmentmetrics.go | 3 +- .../api_management_certificate.html.markdown | 99 ++- 14 files changed, 1240 insertions(+), 27 deletions(-) diff --git a/azurerm/internal/services/apimanagement/api_management_api_data_source.go b/azurerm/internal/services/apimanagement/api_management_api_data_source.go index acd72605acf6..5d5ea7795109 100644 --- a/azurerm/internal/services/apimanagement/api_management_api_data_source.go +++ b/azurerm/internal/services/apimanagement/api_management_api_data_source.go @@ -132,7 +132,7 @@ func dataSourceApiManagementApiRead(d *schema.ResourceData, meta interface{}) er resp, err := client.Get(ctx, resourceGroup, serviceName, apiId) if err != nil { if utils.ResponseWasNotFound(resp.Response) { - return fmt.Errorf("API %q Revision %q (API Management Service %q / Resource Group %q) does not exist!", name, revision, serviceName, resourceGroup) + return fmt.Errorf("API %q Revision %q (API Management Service %q / Resource Group %q) does not exist", name, revision, serviceName, resourceGroup) } return fmt.Errorf("retrieving API %q / Revision %q (API Management Service %q / Resource Group %q): %+v", name, revision, serviceName, resourceGroup, err) diff --git a/azurerm/internal/services/apimanagement/api_management_certificate_resource.go b/azurerm/internal/services/apimanagement/api_management_certificate_resource.go index 780e32435851..a56ba7fd35f4 100644 --- a/azurerm/internal/services/apimanagement/api_management_certificate_resource.go +++ b/azurerm/internal/services/apimanagement/api_management_certificate_resource.go @@ -15,6 +15,8 @@ import ( "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" + keyVaultParse "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/keyvault/parse" + keyVaultValidate "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/keyvault/validate" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) @@ -43,16 +45,32 @@ func resourceApiManagementCertificate() *schema.Resource { "api_management_name": schemaz.SchemaApiManagementName(), "data": { + Type: schema.TypeString, + Optional: true, + Sensitive: true, + ValidateFunc: validation.StringIsBase64, + ConflictsWith: []string{"key_vault_secret_id", "key_vault_identity_client_id"}, + }, + + "password": { Type: schema.TypeString, - Required: true, + Optional: true, Sensitive: true, - ValidateFunc: validation.StringIsBase64, + RequiredWith: []string{"data"}, }, - "password": { - Type: schema.TypeString, - Optional: true, - Sensitive: true, + "key_vault_secret_id": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: keyVaultValidate.NestedItemIdWithOptionalVersion, + ConflictsWith: []string{"data", "password"}, + }, + + "key_vault_identity_client_id": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.IsUUID, + RequiredWith: []string{"key_vault_secret_id"}, }, "expiration": { @@ -83,6 +101,12 @@ func resourceApiManagementCertificateCreateUpdate(d *schema.ResourceData, meta i serviceName := d.Get("api_management_name").(string) data := d.Get("data").(string) password := d.Get("password").(string) + keyVaultSecretId := d.Get("key_vault_secret_id").(string) + keyVaultIdentity := d.Get("key_vault_identity_client_id").(string) + + if data == "" && keyVaultSecretId == "" { + return fmt.Errorf("either `data` or `key_vault_secret_id` must be set") + } if d.IsNewResource() { existing, err := client.Get(ctx, resourceGroup, serviceName, name) @@ -98,10 +122,27 @@ func resourceApiManagementCertificateCreateUpdate(d *schema.ResourceData, meta i } parameters := apimanagement.CertificateCreateOrUpdateParameters{ - CertificateCreateOrUpdateProperties: &apimanagement.CertificateCreateOrUpdateProperties{ - Data: utils.String(data), - Password: utils.String(password), - }, + CertificateCreateOrUpdateProperties: &apimanagement.CertificateCreateOrUpdateProperties{}, + } + + if keyVaultSecretId != "" { + parsedSecretId, err := keyVaultParse.ParseOptionallyVersionedNestedItemID(keyVaultSecretId) + if err != nil { + return err + } + + parameters.KeyVault = &apimanagement.KeyVaultContractCreateProperties{ + SecretIdentifier: utils.String(parsedSecretId.ID()), + } + + if keyVaultIdentity != "" { + parameters.KeyVault.IdentityClientID = utils.String(keyVaultIdentity) + } + } + + if data != "" { + parameters.Data = utils.String(data) + parameters.Password = utils.String(password) } if _, err := client.CreateOrUpdate(ctx, resourceGroup, serviceName, name, parameters, ""); err != nil { @@ -113,7 +154,7 @@ func resourceApiManagementCertificateCreateUpdate(d *schema.ResourceData, meta i return fmt.Errorf("retrieving Certificate %q (Resource Group %q / API Management Service %q): %+v", name, resourceGroup, serviceName, err) } if resp.ID == nil { - return fmt.Errorf("Cannot read ID for Certificate %q (Resource Group %q / API Management Service %q)", name, resourceGroup, serviceName) + return fmt.Errorf("cannot read ID for Certificate %q (Resource Group %q / API Management Service %q)", name, resourceGroup, serviceName) } d.SetId(*resp.ID) @@ -156,6 +197,8 @@ func resourceApiManagementCertificateRead(d *schema.ResourceData, meta interface d.Set("subject", props.Thumbprint) d.Set("thumbprint", props.Thumbprint) + d.Set("key_vault_secret_id", props.KeyVault.SecretIdentifier) + d.Set("key_vault_identity_client_id", props.KeyVault.IdentityClientID) } return nil diff --git a/azurerm/internal/services/apimanagement/api_management_certificate_resource_test.go b/azurerm/internal/services/apimanagement/api_management_certificate_resource_test.go index bcb09b8a53d5..ff7f477bdf59 100644 --- a/azurerm/internal/services/apimanagement/api_management_certificate_resource_test.go +++ b/azurerm/internal/services/apimanagement/api_management_certificate_resource_test.go @@ -3,6 +3,7 @@ package apimanagement_test import ( "context" "fmt" + "regexp" "testing" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" @@ -45,6 +46,81 @@ func TestAccApiManagementCertificate_basic(t *testing.T) { }) } +func TestAccApiManagementCertificate_basicKeyVaultSystemIdentity(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_api_management_certificate", "test") + r := ApiManagementCertificateResource{} + + data.ResourceTest(t, r, []resource.TestStep{ + { + Config: r.basicKeyVaultSystemIdentity(data, "cert1"), + Check: resource.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("key_vault_secret_id").Exists(), + check.That(data.ResourceName).Key("expiration").Exists(), + check.That(data.ResourceName).Key("subject").Exists(), + check.That(data.ResourceName).Key("thumbprint").Exists(), + ), + }, + { + ResourceName: data.ResourceName, + ImportState: true, + ImportStateVerify: true, + }, + }) +} + +func TestAccApiManagementCertificate_basicKeyVaultUserIdentity(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_api_management_certificate", "test") + r := ApiManagementCertificateResource{} + + data.ResourceTest(t, r, []resource.TestStep{ + { + Config: r.basicKeyVaultUserIdentity(data, "cert1"), + Check: resource.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("key_vault_secret_id").Exists(), + check.That(data.ResourceName).Key("key_vault_identity_client_id").Exists(), + check.That(data.ResourceName).Key("expiration").Exists(), + check.That(data.ResourceName).Key("subject").Exists(), + check.That(data.ResourceName).Key("thumbprint").Exists(), + ), + }, + { + ResourceName: data.ResourceName, + ImportState: true, + ImportStateVerify: true, + }, + }) +} + +func TestAccApiManagementCertificate_basicKeyVaultUpdate(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_api_management_certificate", "test") + r := ApiManagementCertificateResource{} + + certUpdatedRegex := regexp.MustCompile(fmt.Sprintf(`https://acct%d\.vault\.azure\.net/secrets/cert2/[a-z0-9]{32}`, data.RandomInteger)) + + data.ResourceTest(t, r, []resource.TestStep{ + { + Config: r.basicKeyVaultSystemIdentity(data, "cert1"), + Check: resource.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("key_vault_secret_id").Exists(), + check.That(data.ResourceName).Key("expiration").Exists(), + check.That(data.ResourceName).Key("subject").Exists(), + check.That(data.ResourceName).Key("thumbprint").Exists(), + ), + }, + { + Config: r.basicKeyVaultSystemIdentity(data, "cert2"), + Check: resource.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("key_vault_secret_id").MatchesRegex(certUpdatedRegex), + ), + }, + data.ImportStep(), + }) +} + func TestAccApiManagementCertificate_requiresImport(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_api_management_certificate", "test") r := ApiManagementCertificateResource{} @@ -107,6 +183,203 @@ resource "azurerm_api_management_certificate" "test" { `, data.RandomInteger, data.Locations.Primary, data.RandomInteger) } +func (r ApiManagementCertificateResource) basicKeyVaultSystemIdentity(data acceptance.TestData, certificate string) string { + return fmt.Sprintf(` +%s + +resource "azurerm_api_management" "test" { + name = "acctestAM-%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + publisher_name = "pub1" + publisher_email = "pub1@email.com" + sku_name = "Developer_1" + + identity { + type = "SystemAssigned" + } +} + +resource "azurerm_key_vault_access_policy" "test" { + key_vault_id = azurerm_key_vault.test.id + tenant_id = azurerm_api_management.test.identity.0.tenant_id + object_id = azurerm_api_management.test.identity.0.principal_id + + secret_permissions = [ + "get", + ] + + certificate_permissions = [ + "get", + ] +} + +resource "azurerm_api_management_certificate" "test" { + name = "example-cert" + api_management_name = azurerm_api_management.test.name + resource_group_name = azurerm_resource_group.test.name + + key_vault_secret_id = azurerm_key_vault_certificate.%s.secret_id +} +`, r.templateKeyVault(data), data.RandomInteger, certificate) +} + +func (r ApiManagementCertificateResource) basicKeyVaultUserIdentity(data acceptance.TestData, certificate string) string { + return fmt.Sprintf(` +%s + +resource "azurerm_user_assigned_identity" "test" { + name = "acctestUAI-%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name +} + +resource "azurerm_api_management" "test" { + name = "acctestAM-%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + publisher_name = "pub1" + publisher_email = "pub1@email.com" + sku_name = "Developer_1" + + identity { + type = "UserAssigned" + identity_ids = [ + azurerm_user_assigned_identity.test.id + ] + } +} + +resource "azurerm_key_vault_access_policy" "test" { + key_vault_id = azurerm_key_vault.test.id + tenant_id = data.azurerm_client_config.test.tenant_id + object_id = azurerm_user_assigned_identity.test.principal_id + + secret_permissions = [ + "get", + ] + + certificate_permissions = [ + "get", + ] +} + +resource "azurerm_api_management_certificate" "test" { + name = "example-cert" + api_management_name = azurerm_api_management.test.name + resource_group_name = azurerm_resource_group.test.name + + key_vault_secret_id = azurerm_key_vault_certificate.%s.secret_id + key_vault_identity_client_id = azurerm_user_assigned_identity.test.client_id +} +`, r.templateKeyVault(data), data.RandomInteger, data.RandomInteger, certificate) +} + +func (ApiManagementCertificateResource) templateKeyVault(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +data "azurerm_client_config" "test" {} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_key_vault" "test" { + name = "acct%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + soft_delete_enabled = true + + tenant_id = data.azurerm_client_config.test.tenant_id + + sku_name = "standard" +} + +resource "azurerm_key_vault_access_policy" "sptest" { + key_vault_id = azurerm_key_vault.test.id + tenant_id = data.azurerm_client_config.test.tenant_id + object_id = data.azurerm_client_config.test.object_id + + secret_permissions = [ + "delete", + "get", + "purge", + "set", + ] + + certificate_permissions = [ + "create", + "delete", + "get", + "purge", + "import", + ] +} + +resource "azurerm_key_vault_certificate" "cert1" { + name = "cert1" + key_vault_id = azurerm_key_vault.test.id + + depends_on = [azurerm_key_vault_access_policy.sptest] + + certificate { + contents = filebase64("testdata/api_management_api_test.pfx") + password = "terraform" + } + + certificate_policy { + issuer_parameters { + name = "Self" + } + + key_properties { + exportable = true + key_size = 2048 + key_type = "RSA" + reuse_key = false + } + + secret_properties { + content_type = "application/x-pkcs12" + } + } +} + +resource "azurerm_key_vault_certificate" "cert2" { + name = "cert2" + key_vault_id = azurerm_key_vault.test.id + + depends_on = [azurerm_key_vault_access_policy.sptest] + + certificate { + contents = filebase64("testdata/api_management_api2_test.pfx") + password = "terraform" + } + + certificate_policy { + issuer_parameters { + name = "Self" + } + + key_properties { + exportable = true + key_size = 2048 + key_type = "RSA" + reuse_key = false + } + + secret_properties { + content_type = "application/x-pkcs12" + } + } +} +`, data.RandomInteger, data.Locations.Primary, data.RandomInteger) +} + func (r ApiManagementCertificateResource) requiresImport(data acceptance.TestData) string { return fmt.Sprintf(` %s diff --git a/azurerm/internal/services/apimanagement/api_management_resource_test.go b/azurerm/internal/services/apimanagement/api_management_resource_test.go index 1b2bdc8b91c4..2d6ad6666ddd 100644 --- a/azurerm/internal/services/apimanagement/api_management_resource_test.go +++ b/azurerm/internal/services/apimanagement/api_management_resource_test.go @@ -1059,7 +1059,7 @@ resource "azurerm_api_management" "test" { identity { type = "UserAssigned" identity_ids = [ - azurerm_user_assigned_identity.test.id, + azurerm_user_assigned_identity.test.principal_id, ] } } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/deletedservices.go b/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/deletedservices.go index ccdf2dbb01a9..c0b75a35574d 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/deletedservices.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/deletedservices.go @@ -8,11 +8,12 @@ package apimanagement import ( "context" + "net/http" + "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/autorest/validation" "github.com/Azure/go-autorest/tracing" - "net/http" ) // DeletedServicesClient is the apiManagement Client diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/gatewaycertificateauthority.go b/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/gatewaycertificateauthority.go index e254096de278..2edf87a1c50b 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/gatewaycertificateauthority.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/gatewaycertificateauthority.go @@ -8,11 +8,12 @@ package apimanagement import ( "context" + "net/http" + "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/autorest/validation" "github.com/Azure/go-autorest/tracing" - "net/http" ) // GatewayCertificateAuthorityClient is the apiManagement Client diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/models.go index 04e4ca695bfa..b254ce4eca03 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/models.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/models.go @@ -9,13 +9,14 @@ package apimanagement import ( "context" "encoding/json" + "net/http" + "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/autorest/date" "github.com/Azure/go-autorest/autorest/to" "github.com/Azure/go-autorest/tracing" "github.com/gofrs/uuid" - "net/http" ) // The package's fully qualified name. @@ -5559,6 +5560,255 @@ func (gc GatewayCollection) hasNextLink() bool { return gc.NextLink != nil && len(*gc.NextLink) != 0 } +// gatewayCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (gc GatewayCollection) gatewayCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !gc.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(gcac.NextLink))) +} + +// GatewayCertificateAuthorityCollectionPage contains a page of GatewayCertificateAuthorityContract values. +type GatewayCertificateAuthorityCollectionPage struct { + fn func(context.Context, GatewayCertificateAuthorityCollection) (GatewayCertificateAuthorityCollection, error) + gcac GatewayCertificateAuthorityCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *GatewayCertificateAuthorityCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayCertificateAuthorityCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.gcac) + if err != nil { + return err + } + page.gcac = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *GatewayCertificateAuthorityCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page GatewayCertificateAuthorityCollectionPage) NotDone() bool { + return !page.gcac.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page GatewayCertificateAuthorityCollectionPage) Response() GatewayCertificateAuthorityCollection { + return page.gcac +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page GatewayCertificateAuthorityCollectionPage) Values() []GatewayCertificateAuthorityContract { + if page.gcac.IsEmpty() { + return nil + } + return *page.gcac.Value +} + +// Creates a new instance of the GatewayCertificateAuthorityCollectionPage type. +func NewGatewayCertificateAuthorityCollectionPage(cur GatewayCertificateAuthorityCollection, getNextPage func(context.Context, GatewayCertificateAuthorityCollection) (GatewayCertificateAuthorityCollection, error)) GatewayCertificateAuthorityCollectionPage { + return GatewayCertificateAuthorityCollectionPage{ + fn: getNextPage, + gcac: cur, + } +} + +// GatewayCertificateAuthorityContract gateway certificate authority details. +type GatewayCertificateAuthorityContract struct { + autorest.Response `json:"-"` + // GatewayCertificateAuthorityContractProperties - Gateway certificate authority details. + *GatewayCertificateAuthorityContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for GatewayCertificateAuthorityContract. +func (gcac GatewayCertificateAuthorityContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if gcac.GatewayCertificateAuthorityContractProperties != nil { + objectMap["properties"] = gcac.GatewayCertificateAuthorityContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for GatewayCertificateAuthorityContract struct. +func (gcac *GatewayCertificateAuthorityContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var gatewayCertificateAuthorityContractProperties GatewayCertificateAuthorityContractProperties + err = json.Unmarshal(*v, &gatewayCertificateAuthorityContractProperties) + if err != nil { + return err + } + gcac.GatewayCertificateAuthorityContractProperties = &gatewayCertificateAuthorityContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + gcac.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + gcac.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + gcac.Type = &typeVar + } + } + } + + return nil +} + +// GatewayCertificateAuthorityContractProperties gateway certificate authority details. +type GatewayCertificateAuthorityContractProperties struct { + // IsTrusted - Determines whether certificate authority is trusted. + IsTrusted *bool `json:"isTrusted,omitempty"` +} + +// GatewayCollection paged Gateway list representation. +type GatewayCollection struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Page values. + Value *[]GatewayContract `json:"value,omitempty"` + // Count - Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + // NextLink - READ-ONLY; Next page link if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for GatewayCollection. +func (gc GatewayCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if gc.Count != nil { + objectMap["count"] = gc.Count + } + return json.Marshal(objectMap) +} + +// GatewayCollectionIterator provides access to a complete listing of GatewayContract values. +type GatewayCollectionIterator struct { + i int + page GatewayCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *GatewayCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *GatewayCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter GatewayCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter GatewayCollectionIterator) Response() GatewayCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter GatewayCollectionIterator) Value() GatewayContract { + if !iter.page.NotDone() { + return GatewayContract{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the GatewayCollectionIterator type. +func NewGatewayCollectionIterator(page GatewayCollectionPage) GatewayCollectionIterator { + return GatewayCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (gc GatewayCollection) IsEmpty() bool { + return gc.Value == nil || len(*gc.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (gc GatewayCollection) hasNextLink() bool { + return gc.NextLink != nil && len(*gc.NextLink) != 0 +} + // gatewayCollectionPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. func (gc GatewayCollection) gatewayCollectionPreparer(ctx context.Context) (*http.Request, error) { @@ -10290,10 +10540,377 @@ func (prc *PortalRevisionContract) UnmarshalJSON(body []byte) error { type PortalRevisionContractProperties struct { // Description - Portal revision description. Description *string `json:"description,omitempty"` - // StatusDetails - READ-ONLY; Portal revision publishing status details. - StatusDetails *string `json:"statusDetails,omitempty"` - // Status - READ-ONLY; Portal revision publishing status. Possible values include: 'PortalRevisionStatusPending', 'PortalRevisionStatusPublishing', 'PortalRevisionStatusCompleted', 'PortalRevisionStatusFailed' - Status PortalRevisionStatus `json:"status,omitempty"` + // Scope - READ-ONLY; Binary OR value of the Snippet scope. + Scope *int64 `json:"scope,omitempty"` +} + +// MarshalJSON is the custom marshaler for PortalRevisionContractProperties. +func (prcp PortalRevisionContractProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if prcp.Description != nil { + objectMap["description"] = prcp.Description + } + if prcp.IsCurrent != nil { + objectMap["isCurrent"] = prcp.IsCurrent + } + return json.Marshal(objectMap) +} + +// PortalRevisionCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type PortalRevisionCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PortalRevisionClient) (PortalRevisionContract, error) +} + +// PortalRevisionUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type PortalRevisionUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PortalRevisionClient) (PortalRevisionContract, error) +} + +// PortalSettingsCollection descriptions of APIM policies. +type PortalSettingsCollection struct { + autorest.Response `json:"-"` + // Value - Descriptions of APIM policies. + Value *[]PortalSettingsContract `json:"value,omitempty"` + // Count - Total record count number. + Count *int64 `json:"count,omitempty"` +} + +// PortalSettingsContract portal Settings for the Developer Portal. +type PortalSettingsContract struct { + // PortalSettingsContractProperties - Portal Settings contract properties. + *PortalSettingsContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for PortalSettingsContract. +func (psc PortalSettingsContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if psc.PortalSettingsContractProperties != nil { + objectMap["properties"] = psc.PortalSettingsContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PortalSettingsContract struct. +func (psc *PortalSettingsContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var portalSettingsContractProperties PortalSettingsContractProperties + err = json.Unmarshal(*v, &portalSettingsContractProperties) + if err != nil { + return err + } + psc.PortalSettingsContractProperties = &portalSettingsContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + psc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + psc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + psc.Type = &typeVar + } + } + } + + return nil +} + +// PortalSettingsContractProperties sign-in settings contract properties. +type PortalSettingsContractProperties struct { + // URL - A delegation Url. + URL *string `json:"url,omitempty"` + // ValidationKey - A base64-encoded validation key to validate, that a request is coming from Azure API Management. + ValidationKey *string `json:"validationKey,omitempty"` + // Subscriptions - Subscriptions delegation settings. + Subscriptions *SubscriptionsDelegationSettingsProperties `json:"subscriptions,omitempty"` + // UserRegistration - User registration delegation settings. + UserRegistration *RegistrationDelegationSettingsProperties `json:"userRegistration,omitempty"` + // Enabled - Redirect Anonymous users to the Sign-In page. + Enabled *bool `json:"enabled,omitempty"` + // TermsOfService - Terms of service contract properties. + TermsOfService *TermsOfServiceProperties `json:"termsOfService,omitempty"` +} + +// PortalRevisionCollection paged list of portal revisions. +type PortalRevisionCollection struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Collection of portal revisions. + Value *[]PortalRevisionContract `json:"value,omitempty"` + // NextLink - READ-ONLY; Next page link, if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// PortalRevisionCollectionIterator provides access to a complete listing of PortalRevisionContract values. +type PortalRevisionCollectionIterator struct { + i int + page PortalRevisionCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *PortalRevisionCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PortalRevisionCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *PortalRevisionCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter PortalRevisionCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter PortalRevisionCollectionIterator) Response() PortalRevisionCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter PortalRevisionCollectionIterator) Value() PortalRevisionContract { + if !iter.page.NotDone() { + return PortalRevisionContract{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the PortalRevisionCollectionIterator type. +func NewPortalRevisionCollectionIterator(page PortalRevisionCollectionPage) PortalRevisionCollectionIterator { + return PortalRevisionCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (prc PortalRevisionCollection) IsEmpty() bool { + return prc.Value == nil || len(*prc.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (prc PortalRevisionCollection) hasNextLink() bool { + return prc.NextLink != nil && len(*prc.NextLink) != 0 +} + +// portalRevisionCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (prc PortalRevisionCollection) portalRevisionCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !prc.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(prc.NextLink))) +} + +// PortalRevisionCollectionPage contains a page of PortalRevisionContract values. +type PortalRevisionCollectionPage struct { + fn func(context.Context, PortalRevisionCollection) (PortalRevisionCollection, error) + prc PortalRevisionCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *PortalRevisionCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PortalRevisionCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.prc) + if err != nil { + return err + } + page.prc = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *PortalRevisionCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page PortalRevisionCollectionPage) NotDone() bool { + return !page.prc.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page PortalRevisionCollectionPage) Response() PortalRevisionCollection { + return page.prc +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page PortalRevisionCollectionPage) Values() []PortalRevisionContract { + if page.prc.IsEmpty() { + return nil + } + return *page.prc.Value +} + +// Creates a new instance of the PortalRevisionCollectionPage type. +func NewPortalRevisionCollectionPage(cur PortalRevisionCollection, getNextPage func(context.Context, PortalRevisionCollection) (PortalRevisionCollection, error)) PortalRevisionCollectionPage { + return PortalRevisionCollectionPage{ + fn: getNextPage, + prc: cur, + } +} + +// PortalRevisionContract portal revisions contract details. +type PortalRevisionContract struct { + autorest.Response `json:"-"` + // PortalRevisionContractProperties - Properties of the portal revisions. + *PortalRevisionContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for PortalRevisionContract. +func (prc PortalRevisionContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if prc.PortalRevisionContractProperties != nil { + objectMap["properties"] = prc.PortalRevisionContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PortalRevisionContract struct. +func (prc *PortalRevisionContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var portalRevisionContractProperties PortalRevisionContractProperties + err = json.Unmarshal(*v, &portalRevisionContractProperties) + if err != nil { + return err + } + prc.PortalRevisionContractProperties = &portalRevisionContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + prc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + prc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + prc.Type = &typeVar + } + } + } + + return nil +} + +// PortalRevisionContractProperties ... +type PortalRevisionContractProperties struct { + // Description - Portal revision description. + Description *string `json:"description,omitempty"` + // StatusDetails - READ-ONLY; Portal revision publishing status details. + StatusDetails *string `json:"statusDetails,omitempty"` + // Status - READ-ONLY; Portal revision publishing status. Possible values include: 'PortalRevisionStatusPending', 'PortalRevisionStatusPublishing', 'PortalRevisionStatusCompleted', 'PortalRevisionStatusFailed' + Status PortalRevisionStatus `json:"status,omitempty"` // IsCurrent - Indicates if the Portal Revision is public. IsCurrent *bool `json:"isCurrent,omitempty"` // CreatedDateTime - READ-ONLY; Portal revision creation date and time. @@ -13840,6 +14457,164 @@ type SkuZoneDetails struct { Capabilities *[]SkuCapabilities `json:"capabilities,omitempty"` } +// SkusResultIterator provides access to a complete listing of Sku values. +type SkusResultIterator struct { + i int + page SkusResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SkusResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SkusResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SkusResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SkusResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter SkusResultIterator) Response() SkusResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter SkusResultIterator) Value() Sku { + if !iter.page.NotDone() { + return Sku{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SkusResultIterator type. +func NewSkusResultIterator(page SkusResultPage) SkusResultIterator { + return SkusResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sr SkusResult) IsEmpty() bool { + return sr.Value == nil || len(*sr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sr SkusResult) hasNextLink() bool { + return sr.NextLink != nil && len(*sr.NextLink) != 0 +} + +// skusResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sr SkusResult) skusResultPreparer(ctx context.Context) (*http.Request, error) { + if !sr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sr.NextLink))) +} + +// SkusResultPage contains a page of Sku values. +type SkusResultPage struct { + fn func(context.Context, SkusResult) (SkusResult, error) + sr SkusResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SkusResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SkusResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.sr) + if err != nil { + return err + } + page.sr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *SkusResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SkusResultPage) NotDone() bool { + return !page.sr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SkusResultPage) Response() SkusResult { + return page.sr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SkusResultPage) Values() []Sku { + if page.sr.IsEmpty() { + return nil + } + return *page.sr.Value +} + +// Creates a new instance of the SkusResultPage type. +func NewSkusResultPage(cur SkusResult, getNextPage func(context.Context, SkusResult) (SkusResult, error)) SkusResultPage { + return SkusResultPage{ + fn: getNextPage, + sr: cur, + } +} + +// SkuZoneDetails describes The zonal capabilities of a SKU. +type SkuZoneDetails struct { + // Name - READ-ONLY; The set of zones that the SKU is available in with the specified capabilities. + Name *[]string `json:"name,omitempty"` + // Capabilities - READ-ONLY; A list of capabilities that are available for the SKU in the specified list of zones. + Capabilities *[]SkuCapabilities `json:"capabilities,omitempty"` +} + // SubscriptionCollection paged Subscriptions list representation. type SubscriptionCollection struct { autorest.Response `json:"-"` diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/namedvalue.go b/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/namedvalue.go index d6a60cc63cbe..ee69f201b1f4 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/namedvalue.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/namedvalue.go @@ -8,11 +8,12 @@ package apimanagement import ( "context" + "net/http" + "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/autorest/validation" "github.com/Azure/go-autorest/tracing" - "net/http" ) // NamedValueClient is the apiManagement Client diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/portalrevision.go b/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/portalrevision.go index 523ddad7ab1a..2f55c00ada7b 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/portalrevision.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/portalrevision.go @@ -8,11 +8,12 @@ package apimanagement import ( "context" + "net/http" + "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/autorest/validation" "github.com/Azure/go-autorest/tracing" - "net/http" ) // PortalRevisionClient is the apiManagement Client diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/skus.go b/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/skus.go index 0254d3764b0f..fe86498ca177 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/skus.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/skus.go @@ -8,10 +8,11 @@ package apimanagement import ( "context" + "net/http" + "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/tracing" - "net/http" ) // SkusClient is the apiManagement Client diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/tenantsettings.go b/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/tenantsettings.go index 6b1835d532ff..b2a215e82d65 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/tenantsettings.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/tenantsettings.go @@ -8,11 +8,12 @@ package apimanagement import ( "context" + "net/http" + "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/autorest/validation" "github.com/Azure/go-autorest/tracing" - "net/http" ) // TenantSettingsClient is the apiManagement Client diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2020-04-01-preview/authorization/CHANGELOG.md b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2020-04-01-preview/authorization/CHANGELOG.md index 52911e4cc5e4..e9a47f4363f6 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2020-04-01-preview/authorization/CHANGELOG.md +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2020-04-01-preview/authorization/CHANGELOG.md @@ -1,2 +1,22 @@ # Change History +### New Funcs + +1. NewRoleAssignmentMetricsClient(string) RoleAssignmentMetricsClient +1. NewRoleAssignmentMetricsClientWithBaseURI(string, string) RoleAssignmentMetricsClient +1. RoleAssignmentMetricsClient.GetMetricsForSubscription(context.Context) (RoleAssignmentMetricsResult, error) +1. RoleAssignmentMetricsClient.GetMetricsForSubscriptionPreparer(context.Context) (*http.Request, error) +1. RoleAssignmentMetricsClient.GetMetricsForSubscriptionResponder(*http.Response) (RoleAssignmentMetricsResult, error) +1. RoleAssignmentMetricsClient.GetMetricsForSubscriptionSender(*http.Request) (*http.Response, error) + +## Struct Changes + +### New Structs + +1. CustomErrorResponse +1. RoleAssignmentMetricsClient +1. RoleAssignmentMetricsResult + +### New Struct Fields + +1. RoleAssignmentProperties.DelegatedManagedIdentityResourceID diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2020-04-01-preview/authorization/roleassignmentmetrics.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2020-04-01-preview/authorization/roleassignmentmetrics.go index 5059d51a01e5..f26c34492822 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2020-04-01-preview/authorization/roleassignmentmetrics.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2020-04-01-preview/authorization/roleassignmentmetrics.go @@ -8,11 +8,12 @@ package authorization import ( "context" + "net/http" + "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/autorest/validation" "github.com/Azure/go-autorest/tracing" - "net/http" ) // RoleAssignmentMetricsClient is the client for the RoleAssignmentMetrics methods of the Authorization service. diff --git a/website/docs/r/api_management_certificate.html.markdown b/website/docs/r/api_management_certificate.html.markdown index 9130e4b52977..9503aed98795 100644 --- a/website/docs/r/api_management_certificate.html.markdown +++ b/website/docs/r/api_management_certificate.html.markdown @@ -10,7 +10,7 @@ description: |- Manages an Certificate within an API Management Service. -## Example Usage +## Example Usage (with Base64 Certificate) ```hcl resource "azurerm_resource_group" "example" { @@ -36,6 +36,91 @@ resource "azurerm_api_management_certificate" "example" { } ``` +## Example Usage (with Key Vault Certificate) + +```hcl +data "azurerm_client_config" "current" {} + +resource "azurerm_resource_group" "example" { + name = "example-resources" + location = "West Europe" +} + +resource "azurerm_api_management" "example" { + name = "example-apim" + location = azurerm_resource_group.example.location + resource_group_name = azurerm_resource_group.example.name + publisher_name = "My Company" + publisher_email = "company@terraform.io" + + sku_name = "Developer_1" + + identity { + type = "SystemAssigned" + } +} + +resource "azurerm_key_vault" "example" { + name = "examplekeyvault" + location = azurerm_resource_group.example.location + resource_group_name = azurerm_resource_group.example.name + soft_delete_enabled = true + + tenant_id = data.azurerm_client_config.example.tenant_id + + sku_name = "standard" +} + +resource "azurerm_key_vault_access_policy" "example" { + key_vault_id = azurerm_key_vault.example.id + tenant_id = azurerm_api_management.example.identity.0.tenant_id + object_id = azurerm_api_management.example.identity.0.principal_id + + secret_permissions = [ + "get", + ] + + certificate_permissions = [ + "get", + ] +} + +resource "azurerm_key_vault_certificate" "example" { + name = "example-cert" + key_vault_id = azurerm_key_vault.example.id + + certificate { + contents = filebase64("example_cert.pfx") + password = "terraform" + } + + certificate_policy { + issuer_parameters { + name = "Self" + } + + key_properties { + exportable = true + key_size = 2048 + key_type = "RSA" + reuse_key = false + } + + secret_properties { + content_type = "application/x-pkcs12" + } + } +} + +resource "azurerm_api_management_certificate" "example" { + name = "example-cert" + api_management_name = azurerm_api_management.example.name + resource_group_name = azurerm_resource_group.example.name + + key_vault_secret_id = azurerm_key_vault_certificate.example.secret_id +} +``` + ## Argument Reference The following arguments are supported: @@ -46,10 +131,20 @@ The following arguments are supported: * `resource_group_name` - (Required) The Name of the Resource Group where the API Management Service exists. Changing this forces a new resource to be created. -* `data` - (Required) The base-64 encoded certificate data, which must be a PFX file. Changing this forces a new resource to be created. +-> **NOTE:** Either `data` or `key_vault_secret_id` must be specified - but not both. + +* `data` - (Optional) The base-64 encoded certificate data, which must be a PFX file. Changing this forces a new resource to be created. * `password` - (Optional) The password used for this certificate. Changing this forces a new resource to be created. +* `key_vault_secret_id` - (Optional) The ID of the Key Vault Secret containing the SSL Certificate, which must be of the type `application/x-pkcs12`. + +-> **NOTE:** Setting this field requires the `identity` block to be specified in API Management Service, since this identity is used to retrieve the Key Vault Certificate. Auto-updating the Certificate from the Key Vault requires that Secret version isn't specified. + +* `key_vault_identity_client_id` - (Optional) The Client ID of the User Assigned Managed Identity to use for retrieving certificate. + +-> **NOTE:** If not specified, will use System Assigned identity of the API Management Service. + --- ## Attributes Reference From b416c65bc5f7421240d3ee352252f8a2d79a5114 Mon Sep 17 00:00:00 2001 From: Mattias Date: Thu, 29 Apr 2021 15:31:06 +0200 Subject: [PATCH 2/6] go mod vendor --- .../apimanagement/deletedservices.go | 3 +- .../gatewaycertificateauthority.go | 3 +- .../mgmt/2020-12-01/apimanagement/models.go | 777 +----------------- .../2020-12-01/apimanagement/namedvalue.go | 3 +- .../apimanagement/portalrevision.go | 3 +- .../mgmt/2020-12-01/apimanagement/skus.go | 3 +- .../apimanagement/tenantsettings.go | 3 +- .../authorization/CHANGELOG.md | 20 - .../authorization/roleassignmentmetrics.go | 3 +- 9 files changed, 8 insertions(+), 810 deletions(-) diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/deletedservices.go b/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/deletedservices.go index c0b75a35574d..ccdf2dbb01a9 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/deletedservices.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/deletedservices.go @@ -8,12 +8,11 @@ package apimanagement import ( "context" - "net/http" - "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/autorest/validation" "github.com/Azure/go-autorest/tracing" + "net/http" ) // DeletedServicesClient is the apiManagement Client diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/gatewaycertificateauthority.go b/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/gatewaycertificateauthority.go index 2edf87a1c50b..e254096de278 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/gatewaycertificateauthority.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/gatewaycertificateauthority.go @@ -8,12 +8,11 @@ package apimanagement import ( "context" - "net/http" - "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/autorest/validation" "github.com/Azure/go-autorest/tracing" + "net/http" ) // GatewayCertificateAuthorityClient is the apiManagement Client diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/models.go index b254ce4eca03..04e4ca695bfa 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/models.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/models.go @@ -9,14 +9,13 @@ package apimanagement import ( "context" "encoding/json" - "net/http" - "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/autorest/date" "github.com/Azure/go-autorest/autorest/to" "github.com/Azure/go-autorest/tracing" "github.com/gofrs/uuid" + "net/http" ) // The package's fully qualified name. @@ -5560,255 +5559,6 @@ func (gc GatewayCollection) hasNextLink() bool { return gc.NextLink != nil && len(*gc.NextLink) != 0 } -// gatewayCollectionPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (gc GatewayCollection) gatewayCollectionPreparer(ctx context.Context) (*http.Request, error) { - if !gc.hasNextLink() { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(gcac.NextLink))) -} - -// GatewayCertificateAuthorityCollectionPage contains a page of GatewayCertificateAuthorityContract values. -type GatewayCertificateAuthorityCollectionPage struct { - fn func(context.Context, GatewayCertificateAuthorityCollection) (GatewayCertificateAuthorityCollection, error) - gcac GatewayCertificateAuthorityCollection -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *GatewayCertificateAuthorityCollectionPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/GatewayCertificateAuthorityCollectionPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - for { - next, err := page.fn(ctx, page.gcac) - if err != nil { - return err - } - page.gcac = next - if !next.hasNextLink() || !next.IsEmpty() { - break - } - } - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *GatewayCertificateAuthorityCollectionPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page GatewayCertificateAuthorityCollectionPage) NotDone() bool { - return !page.gcac.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page GatewayCertificateAuthorityCollectionPage) Response() GatewayCertificateAuthorityCollection { - return page.gcac -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page GatewayCertificateAuthorityCollectionPage) Values() []GatewayCertificateAuthorityContract { - if page.gcac.IsEmpty() { - return nil - } - return *page.gcac.Value -} - -// Creates a new instance of the GatewayCertificateAuthorityCollectionPage type. -func NewGatewayCertificateAuthorityCollectionPage(cur GatewayCertificateAuthorityCollection, getNextPage func(context.Context, GatewayCertificateAuthorityCollection) (GatewayCertificateAuthorityCollection, error)) GatewayCertificateAuthorityCollectionPage { - return GatewayCertificateAuthorityCollectionPage{ - fn: getNextPage, - gcac: cur, - } -} - -// GatewayCertificateAuthorityContract gateway certificate authority details. -type GatewayCertificateAuthorityContract struct { - autorest.Response `json:"-"` - // GatewayCertificateAuthorityContractProperties - Gateway certificate authority details. - *GatewayCertificateAuthorityContractProperties `json:"properties,omitempty"` - // ID - READ-ONLY; Resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type for API Management resource. - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for GatewayCertificateAuthorityContract. -func (gcac GatewayCertificateAuthorityContract) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if gcac.GatewayCertificateAuthorityContractProperties != nil { - objectMap["properties"] = gcac.GatewayCertificateAuthorityContractProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for GatewayCertificateAuthorityContract struct. -func (gcac *GatewayCertificateAuthorityContract) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var gatewayCertificateAuthorityContractProperties GatewayCertificateAuthorityContractProperties - err = json.Unmarshal(*v, &gatewayCertificateAuthorityContractProperties) - if err != nil { - return err - } - gcac.GatewayCertificateAuthorityContractProperties = &gatewayCertificateAuthorityContractProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - gcac.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - gcac.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - gcac.Type = &typeVar - } - } - } - - return nil -} - -// GatewayCertificateAuthorityContractProperties gateway certificate authority details. -type GatewayCertificateAuthorityContractProperties struct { - // IsTrusted - Determines whether certificate authority is trusted. - IsTrusted *bool `json:"isTrusted,omitempty"` -} - -// GatewayCollection paged Gateway list representation. -type GatewayCollection struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; Page values. - Value *[]GatewayContract `json:"value,omitempty"` - // Count - Total record count number across all pages. - Count *int64 `json:"count,omitempty"` - // NextLink - READ-ONLY; Next page link if any. - NextLink *string `json:"nextLink,omitempty"` -} - -// MarshalJSON is the custom marshaler for GatewayCollection. -func (gc GatewayCollection) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if gc.Count != nil { - objectMap["count"] = gc.Count - } - return json.Marshal(objectMap) -} - -// GatewayCollectionIterator provides access to a complete listing of GatewayContract values. -type GatewayCollectionIterator struct { - i int - page GatewayCollectionPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *GatewayCollectionIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/GatewayCollectionIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *GatewayCollectionIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter GatewayCollectionIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter GatewayCollectionIterator) Response() GatewayCollection { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter GatewayCollectionIterator) Value() GatewayContract { - if !iter.page.NotDone() { - return GatewayContract{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the GatewayCollectionIterator type. -func NewGatewayCollectionIterator(page GatewayCollectionPage) GatewayCollectionIterator { - return GatewayCollectionIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (gc GatewayCollection) IsEmpty() bool { - return gc.Value == nil || len(*gc.Value) == 0 -} - -// hasNextLink returns true if the NextLink is not empty. -func (gc GatewayCollection) hasNextLink() bool { - return gc.NextLink != nil && len(*gc.NextLink) != 0 -} - // gatewayCollectionPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. func (gc GatewayCollection) gatewayCollectionPreparer(ctx context.Context) (*http.Request, error) { @@ -10536,373 +10286,6 @@ func (prc *PortalRevisionContract) UnmarshalJSON(body []byte) error { return nil } -// PortalRevisionContractProperties ... -type PortalRevisionContractProperties struct { - // Description - Portal revision description. - Description *string `json:"description,omitempty"` - // Scope - READ-ONLY; Binary OR value of the Snippet scope. - Scope *int64 `json:"scope,omitempty"` -} - -// MarshalJSON is the custom marshaler for PortalRevisionContractProperties. -func (prcp PortalRevisionContractProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if prcp.Description != nil { - objectMap["description"] = prcp.Description - } - if prcp.IsCurrent != nil { - objectMap["isCurrent"] = prcp.IsCurrent - } - return json.Marshal(objectMap) -} - -// PortalRevisionCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type PortalRevisionCreateOrUpdateFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(PortalRevisionClient) (PortalRevisionContract, error) -} - -// PortalRevisionUpdateFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type PortalRevisionUpdateFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(PortalRevisionClient) (PortalRevisionContract, error) -} - -// PortalSettingsCollection descriptions of APIM policies. -type PortalSettingsCollection struct { - autorest.Response `json:"-"` - // Value - Descriptions of APIM policies. - Value *[]PortalSettingsContract `json:"value,omitempty"` - // Count - Total record count number. - Count *int64 `json:"count,omitempty"` -} - -// PortalSettingsContract portal Settings for the Developer Portal. -type PortalSettingsContract struct { - // PortalSettingsContractProperties - Portal Settings contract properties. - *PortalSettingsContractProperties `json:"properties,omitempty"` - // ID - READ-ONLY; Resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type for API Management resource. - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for PortalSettingsContract. -func (psc PortalSettingsContract) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if psc.PortalSettingsContractProperties != nil { - objectMap["properties"] = psc.PortalSettingsContractProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for PortalSettingsContract struct. -func (psc *PortalSettingsContract) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var portalSettingsContractProperties PortalSettingsContractProperties - err = json.Unmarshal(*v, &portalSettingsContractProperties) - if err != nil { - return err - } - psc.PortalSettingsContractProperties = &portalSettingsContractProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - psc.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - psc.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - psc.Type = &typeVar - } - } - } - - return nil -} - -// PortalSettingsContractProperties sign-in settings contract properties. -type PortalSettingsContractProperties struct { - // URL - A delegation Url. - URL *string `json:"url,omitempty"` - // ValidationKey - A base64-encoded validation key to validate, that a request is coming from Azure API Management. - ValidationKey *string `json:"validationKey,omitempty"` - // Subscriptions - Subscriptions delegation settings. - Subscriptions *SubscriptionsDelegationSettingsProperties `json:"subscriptions,omitempty"` - // UserRegistration - User registration delegation settings. - UserRegistration *RegistrationDelegationSettingsProperties `json:"userRegistration,omitempty"` - // Enabled - Redirect Anonymous users to the Sign-In page. - Enabled *bool `json:"enabled,omitempty"` - // TermsOfService - Terms of service contract properties. - TermsOfService *TermsOfServiceProperties `json:"termsOfService,omitempty"` -} - -// PortalRevisionCollection paged list of portal revisions. -type PortalRevisionCollection struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; Collection of portal revisions. - Value *[]PortalRevisionContract `json:"value,omitempty"` - // NextLink - READ-ONLY; Next page link, if any. - NextLink *string `json:"nextLink,omitempty"` -} - -// PortalRevisionCollectionIterator provides access to a complete listing of PortalRevisionContract values. -type PortalRevisionCollectionIterator struct { - i int - page PortalRevisionCollectionPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *PortalRevisionCollectionIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PortalRevisionCollectionIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *PortalRevisionCollectionIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter PortalRevisionCollectionIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter PortalRevisionCollectionIterator) Response() PortalRevisionCollection { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter PortalRevisionCollectionIterator) Value() PortalRevisionContract { - if !iter.page.NotDone() { - return PortalRevisionContract{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the PortalRevisionCollectionIterator type. -func NewPortalRevisionCollectionIterator(page PortalRevisionCollectionPage) PortalRevisionCollectionIterator { - return PortalRevisionCollectionIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (prc PortalRevisionCollection) IsEmpty() bool { - return prc.Value == nil || len(*prc.Value) == 0 -} - -// hasNextLink returns true if the NextLink is not empty. -func (prc PortalRevisionCollection) hasNextLink() bool { - return prc.NextLink != nil && len(*prc.NextLink) != 0 -} - -// portalRevisionCollectionPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (prc PortalRevisionCollection) portalRevisionCollectionPreparer(ctx context.Context) (*http.Request, error) { - if !prc.hasNextLink() { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(prc.NextLink))) -} - -// PortalRevisionCollectionPage contains a page of PortalRevisionContract values. -type PortalRevisionCollectionPage struct { - fn func(context.Context, PortalRevisionCollection) (PortalRevisionCollection, error) - prc PortalRevisionCollection -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *PortalRevisionCollectionPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PortalRevisionCollectionPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - for { - next, err := page.fn(ctx, page.prc) - if err != nil { - return err - } - page.prc = next - if !next.hasNextLink() || !next.IsEmpty() { - break - } - } - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *PortalRevisionCollectionPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page PortalRevisionCollectionPage) NotDone() bool { - return !page.prc.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page PortalRevisionCollectionPage) Response() PortalRevisionCollection { - return page.prc -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page PortalRevisionCollectionPage) Values() []PortalRevisionContract { - if page.prc.IsEmpty() { - return nil - } - return *page.prc.Value -} - -// Creates a new instance of the PortalRevisionCollectionPage type. -func NewPortalRevisionCollectionPage(cur PortalRevisionCollection, getNextPage func(context.Context, PortalRevisionCollection) (PortalRevisionCollection, error)) PortalRevisionCollectionPage { - return PortalRevisionCollectionPage{ - fn: getNextPage, - prc: cur, - } -} - -// PortalRevisionContract portal revisions contract details. -type PortalRevisionContract struct { - autorest.Response `json:"-"` - // PortalRevisionContractProperties - Properties of the portal revisions. - *PortalRevisionContractProperties `json:"properties,omitempty"` - // ID - READ-ONLY; Resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type for API Management resource. - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for PortalRevisionContract. -func (prc PortalRevisionContract) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if prc.PortalRevisionContractProperties != nil { - objectMap["properties"] = prc.PortalRevisionContractProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for PortalRevisionContract struct. -func (prc *PortalRevisionContract) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var portalRevisionContractProperties PortalRevisionContractProperties - err = json.Unmarshal(*v, &portalRevisionContractProperties) - if err != nil { - return err - } - prc.PortalRevisionContractProperties = &portalRevisionContractProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - prc.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - prc.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - prc.Type = &typeVar - } - } - } - - return nil -} - // PortalRevisionContractProperties ... type PortalRevisionContractProperties struct { // Description - Portal revision description. @@ -14457,164 +13840,6 @@ type SkuZoneDetails struct { Capabilities *[]SkuCapabilities `json:"capabilities,omitempty"` } -// SkusResultIterator provides access to a complete listing of Sku values. -type SkusResultIterator struct { - i int - page SkusResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *SkusResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SkusResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *SkusResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter SkusResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter SkusResultIterator) Response() SkusResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter SkusResultIterator) Value() Sku { - if !iter.page.NotDone() { - return Sku{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the SkusResultIterator type. -func NewSkusResultIterator(page SkusResultPage) SkusResultIterator { - return SkusResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (sr SkusResult) IsEmpty() bool { - return sr.Value == nil || len(*sr.Value) == 0 -} - -// hasNextLink returns true if the NextLink is not empty. -func (sr SkusResult) hasNextLink() bool { - return sr.NextLink != nil && len(*sr.NextLink) != 0 -} - -// skusResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (sr SkusResult) skusResultPreparer(ctx context.Context) (*http.Request, error) { - if !sr.hasNextLink() { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(sr.NextLink))) -} - -// SkusResultPage contains a page of Sku values. -type SkusResultPage struct { - fn func(context.Context, SkusResult) (SkusResult, error) - sr SkusResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *SkusResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SkusResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - for { - next, err := page.fn(ctx, page.sr) - if err != nil { - return err - } - page.sr = next - if !next.hasNextLink() || !next.IsEmpty() { - break - } - } - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *SkusResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page SkusResultPage) NotDone() bool { - return !page.sr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page SkusResultPage) Response() SkusResult { - return page.sr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page SkusResultPage) Values() []Sku { - if page.sr.IsEmpty() { - return nil - } - return *page.sr.Value -} - -// Creates a new instance of the SkusResultPage type. -func NewSkusResultPage(cur SkusResult, getNextPage func(context.Context, SkusResult) (SkusResult, error)) SkusResultPage { - return SkusResultPage{ - fn: getNextPage, - sr: cur, - } -} - -// SkuZoneDetails describes The zonal capabilities of a SKU. -type SkuZoneDetails struct { - // Name - READ-ONLY; The set of zones that the SKU is available in with the specified capabilities. - Name *[]string `json:"name,omitempty"` - // Capabilities - READ-ONLY; A list of capabilities that are available for the SKU in the specified list of zones. - Capabilities *[]SkuCapabilities `json:"capabilities,omitempty"` -} - // SubscriptionCollection paged Subscriptions list representation. type SubscriptionCollection struct { autorest.Response `json:"-"` diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/namedvalue.go b/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/namedvalue.go index ee69f201b1f4..d6a60cc63cbe 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/namedvalue.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/namedvalue.go @@ -8,12 +8,11 @@ package apimanagement import ( "context" - "net/http" - "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/autorest/validation" "github.com/Azure/go-autorest/tracing" + "net/http" ) // NamedValueClient is the apiManagement Client diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/portalrevision.go b/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/portalrevision.go index 2f55c00ada7b..523ddad7ab1a 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/portalrevision.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/portalrevision.go @@ -8,12 +8,11 @@ package apimanagement import ( "context" - "net/http" - "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/autorest/validation" "github.com/Azure/go-autorest/tracing" + "net/http" ) // PortalRevisionClient is the apiManagement Client diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/skus.go b/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/skus.go index fe86498ca177..0254d3764b0f 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/skus.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/skus.go @@ -8,11 +8,10 @@ package apimanagement import ( "context" - "net/http" - "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/tracing" + "net/http" ) // SkusClient is the apiManagement Client diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/tenantsettings.go b/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/tenantsettings.go index b2a215e82d65..6b1835d532ff 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/tenantsettings.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2020-12-01/apimanagement/tenantsettings.go @@ -8,12 +8,11 @@ package apimanagement import ( "context" - "net/http" - "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/autorest/validation" "github.com/Azure/go-autorest/tracing" + "net/http" ) // TenantSettingsClient is the apiManagement Client diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2020-04-01-preview/authorization/CHANGELOG.md b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2020-04-01-preview/authorization/CHANGELOG.md index e9a47f4363f6..52911e4cc5e4 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2020-04-01-preview/authorization/CHANGELOG.md +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2020-04-01-preview/authorization/CHANGELOG.md @@ -1,22 +1,2 @@ # Change History -### New Funcs - -1. NewRoleAssignmentMetricsClient(string) RoleAssignmentMetricsClient -1. NewRoleAssignmentMetricsClientWithBaseURI(string, string) RoleAssignmentMetricsClient -1. RoleAssignmentMetricsClient.GetMetricsForSubscription(context.Context) (RoleAssignmentMetricsResult, error) -1. RoleAssignmentMetricsClient.GetMetricsForSubscriptionPreparer(context.Context) (*http.Request, error) -1. RoleAssignmentMetricsClient.GetMetricsForSubscriptionResponder(*http.Response) (RoleAssignmentMetricsResult, error) -1. RoleAssignmentMetricsClient.GetMetricsForSubscriptionSender(*http.Request) (*http.Response, error) - -## Struct Changes - -### New Structs - -1. CustomErrorResponse -1. RoleAssignmentMetricsClient -1. RoleAssignmentMetricsResult - -### New Struct Fields - -1. RoleAssignmentProperties.DelegatedManagedIdentityResourceID diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2020-04-01-preview/authorization/roleassignmentmetrics.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2020-04-01-preview/authorization/roleassignmentmetrics.go index f26c34492822..5059d51a01e5 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2020-04-01-preview/authorization/roleassignmentmetrics.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2020-04-01-preview/authorization/roleassignmentmetrics.go @@ -8,12 +8,11 @@ package authorization import ( "context" - "net/http" - "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/autorest/validation" "github.com/Azure/go-autorest/tracing" + "net/http" ) // RoleAssignmentMetricsClient is the client for the RoleAssignmentMetrics methods of the Authorization service. From 39073a6f3ab5571b49cf4883cfd8c39f06d984c7 Mon Sep 17 00:00:00 2001 From: Mattias Date: Thu, 29 Apr 2021 15:34:54 +0200 Subject: [PATCH 3/6] don't remember changing this :) --- .../services/apimanagement/api_management_api_data_source.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azurerm/internal/services/apimanagement/api_management_api_data_source.go b/azurerm/internal/services/apimanagement/api_management_api_data_source.go index 5d5ea7795109..acd72605acf6 100644 --- a/azurerm/internal/services/apimanagement/api_management_api_data_source.go +++ b/azurerm/internal/services/apimanagement/api_management_api_data_source.go @@ -132,7 +132,7 @@ func dataSourceApiManagementApiRead(d *schema.ResourceData, meta interface{}) er resp, err := client.Get(ctx, resourceGroup, serviceName, apiId) if err != nil { if utils.ResponseWasNotFound(resp.Response) { - return fmt.Errorf("API %q Revision %q (API Management Service %q / Resource Group %q) does not exist", name, revision, serviceName, resourceGroup) + return fmt.Errorf("API %q Revision %q (API Management Service %q / Resource Group %q) does not exist!", name, revision, serviceName, resourceGroup) } return fmt.Errorf("retrieving API %q / Revision %q (API Management Service %q / Resource Group %q): %+v", name, revision, serviceName, resourceGroup, err) From 0fb41964514553249a9e7e1596659fbf176f6bff Mon Sep 17 00:00:00 2001 From: Mattias Date: Fri, 30 Apr 2021 14:30:27 +0200 Subject: [PATCH 4/6] check if keyvault properties exist before setting --- .../apimanagement/api_management_certificate_resource.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/azurerm/internal/services/apimanagement/api_management_certificate_resource.go b/azurerm/internal/services/apimanagement/api_management_certificate_resource.go index a56ba7fd35f4..f9f998e0c373 100644 --- a/azurerm/internal/services/apimanagement/api_management_certificate_resource.go +++ b/azurerm/internal/services/apimanagement/api_management_certificate_resource.go @@ -194,11 +194,13 @@ func resourceApiManagementCertificateRead(d *schema.ResourceData, meta interface formatted := expiration.Format(time.RFC3339) d.Set("expiration", formatted) } - d.Set("subject", props.Thumbprint) d.Set("thumbprint", props.Thumbprint) - d.Set("key_vault_secret_id", props.KeyVault.SecretIdentifier) - d.Set("key_vault_identity_client_id", props.KeyVault.IdentityClientID) + + if keyvault := props.KeyVault; keyvault != nil { + d.Set("key_vault_secret_id", keyvault.SecretIdentifier) + d.Set("key_vault_identity_client_id", keyvault.IdentityClientID) + } } return nil From 1d5a0bcab31c90c6114404f2033f2ee0bf7871fe Mon Sep 17 00:00:00 2001 From: Mattias Date: Fri, 30 Apr 2021 14:35:08 +0200 Subject: [PATCH 5/6] use atleastoneof and importstep function --- .../api_management_certificate_resource.go | 2 ++ .../api_management_certificate_resource_test.go | 12 ++---------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/azurerm/internal/services/apimanagement/api_management_certificate_resource.go b/azurerm/internal/services/apimanagement/api_management_certificate_resource.go index f9f998e0c373..fd2fa5d99e70 100644 --- a/azurerm/internal/services/apimanagement/api_management_certificate_resource.go +++ b/azurerm/internal/services/apimanagement/api_management_certificate_resource.go @@ -49,6 +49,7 @@ func resourceApiManagementCertificate() *schema.Resource { Optional: true, Sensitive: true, ValidateFunc: validation.StringIsBase64, + AtLeastOneOf: []string{"data", "key_vault_secret_id"}, ConflictsWith: []string{"key_vault_secret_id", "key_vault_identity_client_id"}, }, @@ -63,6 +64,7 @@ func resourceApiManagementCertificate() *schema.Resource { Type: schema.TypeString, Optional: true, ValidateFunc: keyVaultValidate.NestedItemIdWithOptionalVersion, + AtLeastOneOf: []string{"data", "key_vault_secret_id"}, ConflictsWith: []string{"data", "password"}, }, diff --git a/azurerm/internal/services/apimanagement/api_management_certificate_resource_test.go b/azurerm/internal/services/apimanagement/api_management_certificate_resource_test.go index ff7f477bdf59..3d88e524cfb2 100644 --- a/azurerm/internal/services/apimanagement/api_management_certificate_resource_test.go +++ b/azurerm/internal/services/apimanagement/api_management_certificate_resource_test.go @@ -61,11 +61,7 @@ func TestAccApiManagementCertificate_basicKeyVaultSystemIdentity(t *testing.T) { check.That(data.ResourceName).Key("thumbprint").Exists(), ), }, - { - ResourceName: data.ResourceName, - ImportState: true, - ImportStateVerify: true, - }, + data.ImportStep(), }) } @@ -85,11 +81,7 @@ func TestAccApiManagementCertificate_basicKeyVaultUserIdentity(t *testing.T) { check.That(data.ResourceName).Key("thumbprint").Exists(), ), }, - { - ResourceName: data.ResourceName, - ImportState: true, - ImportStateVerify: true, - }, + data.ImportStep(), }) } From 0eafa89a1dd36ef95f91865e2949360857959975 Mon Sep 17 00:00:00 2001 From: Mattias Date: Fri, 30 Apr 2021 14:36:55 +0200 Subject: [PATCH 6/6] remove unncessary check --- .../apimanagement/api_management_certificate_resource.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/azurerm/internal/services/apimanagement/api_management_certificate_resource.go b/azurerm/internal/services/apimanagement/api_management_certificate_resource.go index fd2fa5d99e70..2935e7e8af7b 100644 --- a/azurerm/internal/services/apimanagement/api_management_certificate_resource.go +++ b/azurerm/internal/services/apimanagement/api_management_certificate_resource.go @@ -106,10 +106,6 @@ func resourceApiManagementCertificateCreateUpdate(d *schema.ResourceData, meta i keyVaultSecretId := d.Get("key_vault_secret_id").(string) keyVaultIdentity := d.Get("key_vault_identity_client_id").(string) - if data == "" && keyVaultSecretId == "" { - return fmt.Errorf("either `data` or `key_vault_secret_id` must be set") - } - if d.IsNewResource() { existing, err := client.Get(ctx, resourceGroup, serviceName, name) if err != nil {