From 43048082314d0929c2671a42711d25b096026186 Mon Sep 17 00:00:00 2001 From: Jeffrey Cline <20408400+WodansSon@users.noreply.github.com> Date: Tue, 3 Dec 2024 02:21:00 -0700 Subject: [PATCH 1/2] Initial check-in... Upgrading API... --- ...n_frontdoor_firewall_policy_data_source.go | 55 +- .../cdn_frontdoor_firewall_policy_resource.go | 484 ++++++------ .../services/cdn/cdn_frontdoor_helpers.go | 27 +- .../cdn/cdn_frontdoor_rule_resource.go | 1 + .../cdn/cdn_frontdoor_shared_schema.go | 72 +- internal/services/cdn/client/client.go | 6 + .../webapplicationfirewallpolicies/README.md | 117 +++ .../webapplicationfirewallpolicies/client.go | 18 + .../constants.go | 697 ++++++++++++++++++ ...d_frontdoorwebapplicationfirewallpolicy.go | 130 ++++ .../method_policiescreateorupdate_autorest.go | 80 ++ .../method_policiesdelete_autorest.go | 78 ++ .../method_policiesget_autorest.go | 68 ++ .../method_policieslist_autorest.go | 187 +++++ ...hod_policieslistbysubscription_autorest.go | 187 +++++ .../method_policiesupdate_autorest.go | 80 ++ .../model_customrule.go | 16 + .../model_customrulelist.go | 8 + .../model_frontendendpointlink.go | 8 + .../model_groupbyvariable.go | 8 + .../model_managedruleexclusion.go | 10 + .../model_managedrulegroupoverride.go | 10 + .../model_managedruleoverride.go | 11 + .../model_managedruleset.go | 12 + .../model_managedrulesetlist.go | 8 + .../model_matchcondition.go | 13 + .../model_policysettings.go | 15 + .../model_policysettingslogscrubbing.go | 9 + .../model_routingrulelink.go | 8 + .../model_securitypolicylink.go | 8 + .../model_sku.go | 8 + .../model_tagsobject.go | 8 + .../model_webapplicationfirewallpolicy.go | 15 + ..._webapplicationfirewallpolicyproperties.go | 15 + ...el_webapplicationfirewallscrubbingrules.go | 11 + .../predicates.go | 37 + .../webapplicationfirewallpolicies/version.go | 10 + vendor/modules.txt | 1 + 38 files changed, 2231 insertions(+), 305 deletions(-) create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/constants.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/id_frontdoorwebapplicationfirewallpolicy.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/method_policiescreateorupdate_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/method_policiesdelete_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/method_policiesget_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/method_policieslist_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/method_policieslistbysubscription_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/method_policiesupdate_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_customrule.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_customrulelist.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_frontendendpointlink.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_groupbyvariable.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_managedruleexclusion.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_managedrulegroupoverride.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_managedruleoverride.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_managedruleset.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_managedrulesetlist.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_matchcondition.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_policysettings.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_policysettingslogscrubbing.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_routingrulelink.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_securitypolicylink.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_sku.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_tagsobject.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_webapplicationfirewallpolicy.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_webapplicationfirewallpolicyproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_webapplicationfirewallscrubbingrules.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/predicates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/version.go diff --git a/internal/services/cdn/cdn_frontdoor_firewall_policy_data_source.go b/internal/services/cdn/cdn_frontdoor_firewall_policy_data_source.go index 4634270d7ca9..6a1ef3aa352b 100644 --- a/internal/services/cdn/cdn_frontdoor_firewall_policy_data_source.go +++ b/internal/services/cdn/cdn_frontdoor_firewall_policy_data_source.go @@ -7,14 +7,14 @@ import ( "fmt" "time" - "github.com/Azure/azure-sdk-for-go/services/frontdoor/mgmt/2020-11-01/frontdoor" // nolint: staticcheck + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + waf "github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cdn/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cdn/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func dataSourceCdnFrontDoorFirewallPolicy() *pluginsdk.Resource { @@ -66,42 +66,59 @@ func dataSourceCdnFrontDoorFirewallPolicy() *pluginsdk.Resource { } func dataSourceCdnFrontDoorFirewallPolicyRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cdn.FrontDoorLegacyFirewallPoliciesClient + client := meta.(*clients.Client).Cdn.FrontDoorFirewallPoliciesClient subscriptionId := meta.(*clients.Client).Account.SubscriptionId ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id := parse.NewFrontDoorFirewallPolicyID(subscriptionId, d.Get("resource_group_name").(string), d.Get("name").(string)) + name := d.Get("name").(string) + resourceGroup := d.Get("resource_group_name").(string) - resp, err := client.Get(ctx, id.ResourceGroup, id.FrontDoorWebApplicationFirewallPolicyName) + id := waf.NewFrontDoorWebApplicationFirewallPolicyID(subscriptionId, resourceGroup, name) + + result, err := client.PoliciesGet(ctx, id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if !response.WasNotFound(result.HttpResponse) { return fmt.Errorf("%s was not found", id) } return fmt.Errorf("retrieving %s: %+v", id, err) } + model := result.Model + + if model == nil { + return fmt.Errorf("retrieving %s: 'model' was nil", id) + } + + if model.Sku == nil { + return fmt.Errorf("retrieving %s: 'model.Sku' was nil", id) + } + + if model.Properties == nil { + return fmt.Errorf("retrieving %s: 'model.Properties' was nil", id) + } + + props := model.Properties + skuName := "" - if sku := resp.Sku; sku != nil { - skuName = string(sku.Name) + if sku := model.Sku; sku != nil { + skuName = string(pointer.From(model.Sku.Name)) } d.SetId(id.ID()) d.Set("name", id.FrontDoorWebApplicationFirewallPolicyName) - d.Set("resource_group_name", id.ResourceGroup) + d.Set("resource_group_name", id.ResourceGroupName) d.Set("sku_name", skuName) - if properties := resp.WebApplicationFirewallPolicyProperties; properties != nil { - if policy := properties.PolicySettings; policy != nil { - d.Set("enabled", policy.EnabledState == frontdoor.PolicyEnabledStateEnabled) - d.Set("mode", string(policy.Mode)) - d.Set("redirect_url", policy.RedirectURL) - } + if policy := props.PolicySettings; policy != nil { + d.Set("enabled", pointer.From(policy.EnabledState) == waf.PolicyEnabledStateEnabled) + d.Set("mode", pointer.From(policy.Mode)) + d.Set("redirect_url", policy.RedirectURL) + } - if err := d.Set("frontend_endpoint_ids", flattenFrontendEndpointLinkSlice(properties.FrontendEndpointLinks)); err != nil { - return fmt.Errorf("flattening 'frontend_endpoint_ids': %+v", err) - } + if err := d.Set("frontend_endpoint_ids", flattenFrontendEndpointLinkSlice(props.FrontendEndpointLinks)); err != nil { + return fmt.Errorf("flattening 'frontend_endpoint_ids': %+v", err) } return nil diff --git a/internal/services/cdn/cdn_frontdoor_firewall_policy_resource.go b/internal/services/cdn/cdn_frontdoor_firewall_policy_resource.go index 20071a4b5ef4..b8dbbacd8a56 100644 --- a/internal/services/cdn/cdn_frontdoor_firewall_policy_resource.go +++ b/internal/services/cdn/cdn_frontdoor_firewall_policy_resource.go @@ -5,14 +5,15 @@ package cdn import ( "fmt" - "log" "strconv" "time" - "github.com/Azure/azure-sdk-for-go/services/frontdoor/mgmt/2020-11-01/frontdoor" // nolint: staticcheck + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" "github.com/hashicorp/go-azure-helpers/resourcemanager/location" "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" + waf "github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cdn/parse" @@ -57,8 +58,8 @@ func resourceCdnFrontDoorFirewallPolicy() *pluginsdk.Resource { Required: true, ForceNew: true, ValidateFunc: validation.StringInSlice([]string{ - string(frontdoor.SkuNameStandardAzureFrontDoor), - string(frontdoor.SkuNamePremiumAzureFrontDoor), + string(waf.SkuNameStandardAzureFrontDoor), + string(waf.SkuNamePremiumAzureFrontDoor), }, false), }, @@ -66,8 +67,8 @@ func resourceCdnFrontDoorFirewallPolicy() *pluginsdk.Resource { Type: pluginsdk.TypeString, Required: true, ValidateFunc: validation.StringInSlice([]string{ - string(frontdoor.PolicyModeDetection), - string(frontdoor.PolicyModePrevention), + string(waf.PolicyModeDetection), + string(waf.PolicyModePrevention), }, false), }, @@ -135,8 +136,8 @@ func resourceCdnFrontDoorFirewallPolicy() *pluginsdk.Resource { Type: pluginsdk.TypeString, Required: true, ValidateFunc: validation.StringInSlice([]string{ - string(frontdoor.RuleTypeMatchRule), - string(frontdoor.RuleTypeRateLimitRule), + string(waf.RuleTypeMatchRule), + string(waf.RuleTypeRateLimitRule), }, false), }, @@ -156,10 +157,10 @@ func resourceCdnFrontDoorFirewallPolicy() *pluginsdk.Resource { Type: pluginsdk.TypeString, Required: true, ValidateFunc: validation.StringInSlice([]string{ - string(frontdoor.ActionTypeAllow), - string(frontdoor.ActionTypeBlock), - string(frontdoor.ActionTypeLog), - string(frontdoor.ActionTypeRedirect), + string(waf.ActionTypeAllow), + string(waf.ActionTypeBlock), + string(waf.ActionTypeLog), + string(waf.ActionTypeRedirect), }, false), }, @@ -173,15 +174,15 @@ func resourceCdnFrontDoorFirewallPolicy() *pluginsdk.Resource { Type: pluginsdk.TypeString, Required: true, ValidateFunc: validation.StringInSlice([]string{ - string(frontdoor.MatchVariableCookies), - string(frontdoor.MatchVariablePostArgs), - string(frontdoor.MatchVariableQueryString), - string(frontdoor.MatchVariableRemoteAddr), - string(frontdoor.MatchVariableRequestBody), - string(frontdoor.MatchVariableRequestHeader), - string(frontdoor.MatchVariableRequestMethod), - string(frontdoor.MatchVariableRequestURI), - string(frontdoor.MatchVariableSocketAddr), + string(waf.MatchVariableCookies), + string(waf.MatchVariablePostArgs), + string(waf.MatchVariableQueryString), + string(waf.MatchVariableRemoteAddr), + string(waf.MatchVariableRequestBody), + string(waf.MatchVariableRequestHeader), + string(waf.MatchVariableRequestMethod), + string(waf.MatchVariableRequestUri), + string(waf.MatchVariableSocketAddr), }, false), }, @@ -199,18 +200,18 @@ func resourceCdnFrontDoorFirewallPolicy() *pluginsdk.Resource { Type: pluginsdk.TypeString, Required: true, ValidateFunc: validation.StringInSlice([]string{ - string(frontdoor.OperatorAny), - string(frontdoor.OperatorBeginsWith), - string(frontdoor.OperatorContains), - string(frontdoor.OperatorEndsWith), - string(frontdoor.OperatorEqual), - string(frontdoor.OperatorGeoMatch), - string(frontdoor.OperatorGreaterThan), - string(frontdoor.OperatorGreaterThanOrEqual), - string(frontdoor.OperatorIPMatch), - string(frontdoor.OperatorLessThan), - string(frontdoor.OperatorLessThanOrEqual), - string(frontdoor.OperatorRegEx), + string(waf.OperatorAny), + string(waf.OperatorBeginsWith), + string(waf.OperatorContains), + string(waf.OperatorEndsWith), + string(waf.OperatorEqual), + string(waf.OperatorGeoMatch), + string(waf.OperatorGreaterThan), + string(waf.OperatorGreaterThanOrEqual), + string(waf.OperatorIPMatch), + string(waf.OperatorLessThan), + string(waf.OperatorLessThanOrEqual), + string(waf.OperatorRegEx), }, false), }, @@ -233,12 +234,12 @@ func resourceCdnFrontDoorFirewallPolicy() *pluginsdk.Resource { Elem: &pluginsdk.Schema{ Type: pluginsdk.TypeString, ValidateFunc: validation.StringInSlice([]string{ - string(frontdoor.TransformTypeLowercase), - string(frontdoor.TransformTypeRemoveNulls), - string(frontdoor.TransformTypeTrim), - string(frontdoor.TransformTypeUppercase), - string(frontdoor.TransformTypeURLDecode), - string(frontdoor.TransformTypeURLEncode), + string(waf.TransformTypeLowercase), + string(waf.TransformTypeRemoveNulls), + string(waf.TransformTypeTrim), + string(waf.TransformTypeUppercase), + string(waf.TransformTypeURLDecode), + string(waf.TransformTypeURLEncode), }, false), }, }, @@ -271,10 +272,10 @@ func resourceCdnFrontDoorFirewallPolicy() *pluginsdk.Resource { Type: pluginsdk.TypeString, Required: true, ValidateFunc: validation.StringInSlice([]string{ - string(frontdoor.ActionTypeAllow), - string(frontdoor.ActionTypeLog), - string(frontdoor.ActionTypeBlock), - string(frontdoor.ActionTypeRedirect), + string(waf.ActionTypeAllow), + string(waf.ActionTypeLog), + string(waf.ActionTypeBlock), + string(waf.ActionTypeRedirect), }, false), }, @@ -288,22 +289,22 @@ func resourceCdnFrontDoorFirewallPolicy() *pluginsdk.Resource { Type: pluginsdk.TypeString, Required: true, ValidateFunc: validation.StringInSlice([]string{ - string(frontdoor.ManagedRuleExclusionMatchVariableQueryStringArgNames), - string(frontdoor.ManagedRuleExclusionMatchVariableRequestBodyPostArgNames), - string(frontdoor.ManagedRuleExclusionMatchVariableRequestCookieNames), - string(frontdoor.ManagedRuleExclusionMatchVariableRequestHeaderNames), - string(frontdoor.ManagedRuleExclusionMatchVariableRequestBodyJSONArgNames), + string(waf.ManagedRuleExclusionMatchVariableQueryStringArgNames), + string(waf.ManagedRuleExclusionMatchVariableRequestBodyPostArgNames), + string(waf.ManagedRuleExclusionMatchVariableRequestCookieNames), + string(waf.ManagedRuleExclusionMatchVariableRequestHeaderNames), + string(waf.ManagedRuleExclusionMatchVariableRequestBodyJsonArgNames), }, false), }, "operator": { Type: pluginsdk.TypeString, Required: true, ValidateFunc: validation.StringInSlice([]string{ - string(frontdoor.ManagedRuleExclusionSelectorMatchOperatorContains), - string(frontdoor.ManagedRuleExclusionSelectorMatchOperatorEndsWith), - string(frontdoor.ManagedRuleExclusionSelectorMatchOperatorEquals), - string(frontdoor.ManagedRuleExclusionSelectorMatchOperatorEqualsAny), - string(frontdoor.ManagedRuleExclusionSelectorMatchOperatorStartsWith), + string(waf.ManagedRuleExclusionSelectorMatchOperatorContains), + string(waf.ManagedRuleExclusionSelectorMatchOperatorEndsWith), + string(waf.ManagedRuleExclusionSelectorMatchOperatorEquals), + string(waf.ManagedRuleExclusionSelectorMatchOperatorEqualsAny), + string(waf.ManagedRuleExclusionSelectorMatchOperatorStartsWith), }, false), }, "selector": { @@ -337,22 +338,22 @@ func resourceCdnFrontDoorFirewallPolicy() *pluginsdk.Resource { Type: pluginsdk.TypeString, Required: true, ValidateFunc: validation.StringInSlice([]string{ - string(frontdoor.ManagedRuleExclusionMatchVariableQueryStringArgNames), - string(frontdoor.ManagedRuleExclusionMatchVariableRequestBodyPostArgNames), - string(frontdoor.ManagedRuleExclusionMatchVariableRequestCookieNames), - string(frontdoor.ManagedRuleExclusionMatchVariableRequestHeaderNames), - string(frontdoor.ManagedRuleExclusionMatchVariableRequestBodyJSONArgNames), + string(waf.ManagedRuleExclusionMatchVariableQueryStringArgNames), + string(waf.ManagedRuleExclusionMatchVariableRequestBodyPostArgNames), + string(waf.ManagedRuleExclusionMatchVariableRequestCookieNames), + string(waf.ManagedRuleExclusionMatchVariableRequestHeaderNames), + string(waf.ManagedRuleExclusionMatchVariableRequestBodyJsonArgNames), }, false), }, "operator": { Type: pluginsdk.TypeString, Required: true, ValidateFunc: validation.StringInSlice([]string{ - string(frontdoor.ManagedRuleExclusionSelectorMatchOperatorContains), - string(frontdoor.ManagedRuleExclusionSelectorMatchOperatorEndsWith), - string(frontdoor.ManagedRuleExclusionSelectorMatchOperatorEquals), - string(frontdoor.ManagedRuleExclusionSelectorMatchOperatorEqualsAny), - string(frontdoor.ManagedRuleExclusionSelectorMatchOperatorStartsWith), + string(waf.ManagedRuleExclusionSelectorMatchOperatorContains), + string(waf.ManagedRuleExclusionSelectorMatchOperatorEndsWith), + string(waf.ManagedRuleExclusionSelectorMatchOperatorEquals), + string(waf.ManagedRuleExclusionSelectorMatchOperatorEqualsAny), + string(waf.ManagedRuleExclusionSelectorMatchOperatorStartsWith), }, false), }, "selector": { @@ -392,22 +393,22 @@ func resourceCdnFrontDoorFirewallPolicy() *pluginsdk.Resource { Type: pluginsdk.TypeString, Required: true, ValidateFunc: validation.StringInSlice([]string{ - string(frontdoor.ManagedRuleExclusionMatchVariableQueryStringArgNames), - string(frontdoor.ManagedRuleExclusionMatchVariableRequestBodyPostArgNames), - string(frontdoor.ManagedRuleExclusionMatchVariableRequestCookieNames), - string(frontdoor.ManagedRuleExclusionMatchVariableRequestHeaderNames), - string(frontdoor.ManagedRuleExclusionMatchVariableRequestBodyJSONArgNames), + string(waf.ManagedRuleExclusionMatchVariableQueryStringArgNames), + string(waf.ManagedRuleExclusionMatchVariableRequestBodyPostArgNames), + string(waf.ManagedRuleExclusionMatchVariableRequestCookieNames), + string(waf.ManagedRuleExclusionMatchVariableRequestHeaderNames), + string(waf.ManagedRuleExclusionMatchVariableRequestBodyJsonArgNames), }, false), }, "operator": { Type: pluginsdk.TypeString, Required: true, ValidateFunc: validation.StringInSlice([]string{ - string(frontdoor.ManagedRuleExclusionSelectorMatchOperatorContains), - string(frontdoor.ManagedRuleExclusionSelectorMatchOperatorEndsWith), - string(frontdoor.ManagedRuleExclusionSelectorMatchOperatorEquals), - string(frontdoor.ManagedRuleExclusionSelectorMatchOperatorEqualsAny), - string(frontdoor.ManagedRuleExclusionSelectorMatchOperatorStartsWith), + string(waf.ManagedRuleExclusionSelectorMatchOperatorContains), + string(waf.ManagedRuleExclusionSelectorMatchOperatorEndsWith), + string(waf.ManagedRuleExclusionSelectorMatchOperatorEquals), + string(waf.ManagedRuleExclusionSelectorMatchOperatorEqualsAny), + string(waf.ManagedRuleExclusionSelectorMatchOperatorStartsWith), }, false), }, "selector": { @@ -423,11 +424,11 @@ func resourceCdnFrontDoorFirewallPolicy() *pluginsdk.Resource { Type: pluginsdk.TypeString, Required: true, ValidateFunc: validation.StringInSlice([]string{ - string(frontdoor.ActionTypeAllow), - string(frontdoor.ActionTypeLog), - string(frontdoor.ActionTypeBlock), - string(frontdoor.ActionTypeRedirect), - "AnomalyScoring", // Only valid with 2.0 and above + string(waf.ActionTypeAllow), + string(waf.ActionTypeLog), + string(waf.ActionTypeBlock), + string(waf.ActionTypeRedirect), + string(waf.ActionTypeAnomalyScoring), // Only valid with 2.0 and above }, false), }, }, @@ -454,7 +455,7 @@ func resourceCdnFrontDoorFirewallPolicy() *pluginsdk.Resource { } func resourceCdnFrontDoorFirewallPolicyCreate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cdn.FrontDoorLegacyFirewallPoliciesClient + client := meta.(*clients.Client).Cdn.FrontDoorFirewallPoliciesClient subscriptionId := meta.(*clients.Client).Account.SubscriptionId ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() @@ -462,33 +463,33 @@ func resourceCdnFrontDoorFirewallPolicyCreate(d *pluginsdk.ResourceData, meta in name := d.Get("name").(string) resourceGroup := d.Get("resource_group_name").(string) - id := parse.NewFrontDoorFirewallPolicyID(subscriptionId, resourceGroup, name) + id := waf.NewFrontDoorWebApplicationFirewallPolicyID(subscriptionId, resourceGroup, name) - existing, err := client.Get(ctx, id.ResourceGroup, id.FrontDoorWebApplicationFirewallPolicyName) + result, err := client.PoliciesGet(ctx, id) if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { + if !response.WasNotFound(result.HttpResponse) { return fmt.Errorf("checking for existing %s: %+v", id, err) } } - if !utils.ResponseWasNotFound(existing.Response) { + if !response.WasNotFound(result.HttpResponse) { return tf.ImportAsExistsError("azurerm_cdn_frontdoor_firewall_policy", id.ID()) } - enabled := frontdoor.PolicyEnabledStateDisabled + enabled := waf.PolicyEnabledStateDisabled if d.Get("enabled").(bool) { - enabled = frontdoor.PolicyEnabledStateEnabled + enabled = waf.PolicyEnabledStateEnabled } - requestBodyCheck := frontdoor.PolicyRequestBodyCheckDisabled + requestBodyCheck := waf.PolicyRequestBodyCheckDisabled if d.Get("request_body_check_enabled").(bool) { - requestBodyCheck = frontdoor.PolicyRequestBodyCheckEnabled + requestBodyCheck = waf.PolicyRequestBodyCheckEnabled } sku := d.Get("sku_name").(string) - mode := frontdoor.PolicyMode(d.Get("mode").(string)) + mode := waf.PolicyMode(d.Get("mode").(string)) redirectUrl := d.Get("redirect_url").(string) customBlockResponseStatusCode := d.Get("custom_block_response_status_code").(int) customBlockResponseBody := d.Get("custom_block_response_body").(string) @@ -498,96 +499,100 @@ func resourceCdnFrontDoorFirewallPolicyCreate(d *pluginsdk.ResourceData, meta in return fmt.Errorf("expanding managed_rule: %+v", err) } - if sku != string(frontdoor.SkuNamePremiumAzureFrontDoor) && managedRules != nil { + if sku != string(waf.SkuNamePremiumAzureFrontDoor) && managedRules != nil { return fmt.Errorf("the 'managed_rule' field is only supported with the 'Premium_AzureFrontDoor' sku, got %q", sku) } t := d.Get("tags").(map[string]interface{}) - payload := frontdoor.WebApplicationFirewallPolicy{ + payload := waf.WebApplicationFirewallPolicy{ Location: utils.String(location.Normalize("Global")), - Sku: &frontdoor.Sku{ - Name: frontdoor.SkuName(sku), + Sku: &waf.Sku{ + Name: pointer.To(waf.SkuName(sku)), }, - WebApplicationFirewallPolicyProperties: &frontdoor.WebApplicationFirewallPolicyProperties{ - PolicySettings: &frontdoor.PolicySettings{ - EnabledState: enabled, - Mode: mode, - RequestBodyCheck: requestBodyCheck, + Properties: &waf.WebApplicationFirewallPolicyProperties{ + PolicySettings: &waf.PolicySettings{ + EnabledState: pointer.To(enabled), + Mode: pointer.To(mode), + RequestBodyCheck: pointer.To(requestBodyCheck), + // NOTE: Add 'javascript_challenge_expiration_in_minutes' here... }, CustomRules: expandCdnFrontDoorFirewallCustomRules(customRules), }, - Tags: expandFrontDoorTags(tags.Expand(t)), + Tags: tags.Expand(t), } if managedRules != nil { - payload.WebApplicationFirewallPolicyProperties.ManagedRules = managedRules + payload.Properties.ManagedRules = managedRules } if redirectUrl != "" { - payload.WebApplicationFirewallPolicyProperties.PolicySettings.RedirectURL = utils.String(redirectUrl) + payload.Properties.PolicySettings.RedirectURL = utils.String(redirectUrl) } if customBlockResponseBody != "" { - payload.WebApplicationFirewallPolicyProperties.PolicySettings.CustomBlockResponseBody = utils.String(customBlockResponseBody) + payload.Properties.PolicySettings.CustomBlockResponseBody = utils.String(customBlockResponseBody) } if customBlockResponseStatusCode > 0 { - payload.WebApplicationFirewallPolicyProperties.PolicySettings.CustomBlockResponseStatusCode = utils.Int32(int32(customBlockResponseStatusCode)) + payload.Properties.PolicySettings.CustomBlockResponseStatusCode = utils.Int64(int64(customBlockResponseStatusCode)) } - future, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.FrontDoorWebApplicationFirewallPolicyName, payload) + err = client.PoliciesCreateOrUpdateThenPoll(ctx, id, payload) if err != nil { return fmt.Errorf("creating %s: %+v", id, err) } - if err := future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting for the creation of %s: %+v", id, err) - } - d.SetId(id.ID()) return resourceCdnFrontDoorFirewallPolicyRead(d, meta) } func resourceCdnFrontDoorFirewallPolicyUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cdn.FrontDoorLegacyFirewallPoliciesClient + client := meta.(*clients.Client).Cdn.FrontDoorFirewallPoliciesClient ctx, cancel := timeouts.ForUpdate(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.FrontDoorFirewallPolicyID(d.Id()) + id, err := waf.ParseFrontDoorWebApplicationFirewallPolicyID(d.Id()) if err != nil { return err } - existing, err := client.Get(ctx, id.ResourceGroup, id.FrontDoorWebApplicationFirewallPolicyName) + result, err := client.PoliciesGet(ctx, pointer.From(id)) if err != nil { return fmt.Errorf("retrieving %s: %+v", *id, err) } - if existing.Sku == nil { - return fmt.Errorf("retrieving %s: 'sku' was nil", *id) + model := result.Model + + if model == nil { + return fmt.Errorf("retrieving %s: 'model' was nil", *id) + } + + if model.Sku == nil { + return fmt.Errorf("retrieving %s: 'model.Sku' was nil", *id) } - if existing.WebApplicationFirewallPolicyProperties == nil { - return fmt.Errorf("retrieving %s: 'properties' was nil", *id) + if model.Properties == nil { + return fmt.Errorf("retrieving %s: 'model.Properties' was nil", *id) } - props := *existing.WebApplicationFirewallPolicyProperties + props := *model.Properties if d.HasChanges("custom_block_response_body", "custom_block_response_status_code", "enabled", "mode", "redirect_url", "request_body_check_enabled") { - enabled := frontdoor.PolicyEnabledStateDisabled + enabled := waf.PolicyEnabledStateDisabled if d.Get("enabled").(bool) { - enabled = frontdoor.PolicyEnabledStateEnabled + enabled = waf.PolicyEnabledStateEnabled } - requestBodyCheck := frontdoor.PolicyRequestBodyCheckDisabled + + requestBodyCheck := waf.PolicyRequestBodyCheckDisabled if d.Get("request_body_check_enabled").(bool) { - requestBodyCheck = frontdoor.PolicyRequestBodyCheckEnabled - } - props.PolicySettings = &frontdoor.PolicySettings{ - EnabledState: enabled, - Mode: frontdoor.PolicyMode(d.Get("mode").(string)), - RequestBodyCheck: requestBodyCheck, + requestBodyCheck = waf.PolicyRequestBodyCheckEnabled } + props.PolicySettings = pointer.To(waf.PolicySettings{ + EnabledState: pointer.To(enabled), + Mode: pointer.To(waf.PolicyMode(d.Get("mode").(string))), + RequestBodyCheck: pointer.To(requestBodyCheck), + }) if redirectUrl := d.Get("redirect_url").(string); redirectUrl != "" { props.PolicySettings.RedirectURL = utils.String(redirectUrl) @@ -597,8 +602,8 @@ func resourceCdnFrontDoorFirewallPolicyUpdate(d *pluginsdk.ResourceData, meta in props.PolicySettings.CustomBlockResponseBody = utils.String(body) } - if statusCode := d.Get("custom_block_response_status_code").(int); statusCode > 0 { - props.PolicySettings.CustomBlockResponseStatusCode = utils.Int32(int32(statusCode)) + if statusCode := d.Get("custom_block_response_status_code").(int64); statusCode > 0 { + props.PolicySettings.CustomBlockResponseStatusCode = utils.Int64(int64(statusCode)) } } @@ -612,8 +617,8 @@ func resourceCdnFrontDoorFirewallPolicyUpdate(d *pluginsdk.ResourceData, meta in return fmt.Errorf("expanding managed_rule: %+v", err) } - if existing.Sku.Name != frontdoor.SkuNamePremiumAzureFrontDoor && managedRules != nil { - return fmt.Errorf("the 'managed_rule' field is only supported when using the sku 'Premium_AzureFrontDoor', got %q", existing.Sku.Name) + if pointer.From(model.Sku.Name) != waf.SkuNamePremiumAzureFrontDoor && managedRules != nil { + return fmt.Errorf("the 'managed_rule' field is only supported when using the sku 'Premium_AzureFrontDoor', got %q", pointer.From(model.Sku.Name)) } if managedRules != nil { @@ -623,74 +628,81 @@ func resourceCdnFrontDoorFirewallPolicyUpdate(d *pluginsdk.ResourceData, meta in if d.HasChange("tags") { t := d.Get("tags").(map[string]interface{}) - existing.Tags = expandFrontDoorTags(tags.Expand(t)) + model.Tags = tags.Expand(t) } - existing.WebApplicationFirewallPolicyProperties = &props - future, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.FrontDoorWebApplicationFirewallPolicyName, existing) + model.Properties = pointer.To(props) + + err = client.PoliciesCreateOrUpdateThenPoll(ctx, pointer.From(id), pointer.From(model)) if err != nil { return fmt.Errorf("updating %s: %+v", *id, err) } - if err := future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting for the update of %s: %+v", *id, err) - } return resourceCdnFrontDoorFirewallPolicyRead(d, meta) } func resourceCdnFrontDoorFirewallPolicyRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cdn.FrontDoorLegacyFirewallPoliciesClient + client := meta.(*clients.Client).Cdn.FrontDoorFirewallPoliciesClient ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.FrontDoorFirewallPolicyID(d.Id()) + id, err := waf.ParseFrontDoorWebApplicationFirewallPolicyID(d.Id()) if err != nil { return err } - resp, err := client.Get(ctx, id.ResourceGroup, id.FrontDoorWebApplicationFirewallPolicyName) + result, err := client.PoliciesGet(ctx, pointer.From(id)) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - log.Printf("[INFO] Cdn Frontdoor Firewall Policy %q does not exist - removing from state", d.Id()) - d.SetId("") - return nil - } return fmt.Errorf("retrieving %s: %+v", *id, err) } + model := result.Model + + if model == nil { + return fmt.Errorf("retrieving %s: 'model' was nil", *id) + } + + if model.Sku == nil { + return fmt.Errorf("retrieving %s: 'model.Sku' was nil", *id) + } + + if model.Properties == nil { + return fmt.Errorf("retrieving %s: 'model.Properties' was nil", *id) + } + d.Set("name", id.FrontDoorWebApplicationFirewallPolicyName) - d.Set("resource_group_name", id.ResourceGroup) + d.Set("resource_group_name", id.ResourceGroupName) skuName := "" - if sku := resp.Sku; sku != nil { - skuName = string(sku.Name) + if sku := model.Sku; sku != nil { + skuName = string(pointer.From(sku.Name)) } d.Set("sku_name", skuName) - if properties := resp.WebApplicationFirewallPolicyProperties; properties != nil { - if policy := properties.PolicySettings; policy != nil { - d.Set("enabled", policy.EnabledState == frontdoor.PolicyEnabledStateEnabled) - d.Set("mode", string(policy.Mode)) - d.Set("request_body_check_enabled", policy.RequestBodyCheck == frontdoor.PolicyRequestBodyCheckEnabled) + if props := model.Properties; props != nil { + if policy := props.PolicySettings; policy != nil { + d.Set("enabled", pointer.From(policy.EnabledState) == waf.PolicyEnabledStateEnabled) + d.Set("mode", string(pointer.From(policy.Mode))) + d.Set("request_body_check_enabled", pointer.From(policy.RequestBodyCheck) == waf.PolicyRequestBodyCheckEnabled) d.Set("redirect_url", policy.RedirectURL) d.Set("custom_block_response_status_code", policy.CustomBlockResponseStatusCode) d.Set("custom_block_response_body", policy.CustomBlockResponseBody) } - if err := d.Set("custom_rule", flattenCdnFrontDoorFirewallCustomRules(properties.CustomRules)); err != nil { + if err := d.Set("custom_rule", flattenCdnFrontDoorFirewallCustomRules(props.CustomRules)); err != nil { return fmt.Errorf("flattening 'custom_rule': %+v", err) } - if err := d.Set("frontend_endpoint_ids", flattenFrontendEndpointLinkSlice(properties.FrontendEndpointLinks)); err != nil { + if err := d.Set("frontend_endpoint_ids", flattenFrontendEndpointLinkSlice(props.FrontendEndpointLinks)); err != nil { return fmt.Errorf("flattening 'frontend_endpoint_ids': %+v", err) } - if err := d.Set("managed_rule", flattenCdnFrontDoorFirewallManagedRules(properties.ManagedRules)); err != nil { + if err := d.Set("managed_rule", flattenCdnFrontDoorFirewallManagedRules(props.ManagedRules)); err != nil { return fmt.Errorf("flattening 'managed_rule': %+v", err) } } - if err := tags.FlattenAndSet(d, flattenFrontDoorTags(resp.Tags)); err != nil { + if err := tags.FlattenAndSet(d, model.Tags); err != nil { return err } @@ -719,48 +731,48 @@ func resourceCdnFrontDoorFirewallPolicyDelete(d *pluginsdk.ResourceData, meta in return nil } -func expandCdnFrontDoorFirewallCustomRules(input []interface{}) *frontdoor.CustomRuleList { +func expandCdnFrontDoorFirewallCustomRules(input []interface{}) *waf.CustomRuleList { if len(input) == 0 { return nil } - output := make([]frontdoor.CustomRule, 0) + output := make([]waf.CustomRule, 0) for _, cr := range input { custom := cr.(map[string]interface{}) - enabled := frontdoor.CustomRuleEnabledStateDisabled + enabled := waf.CustomRuleEnabledStateDisabled if custom["enabled"].(bool) { - enabled = frontdoor.CustomRuleEnabledStateEnabled + enabled = waf.CustomRuleEnabledStateEnabled } name := custom["name"].(string) - priority := int32(custom["priority"].(int)) + priority := int64(custom["priority"].(int)) ruleType := custom["type"].(string) - rateLimitDurationInMinutes := int32(custom["rate_limit_duration_in_minutes"].(int)) - rateLimitThreshold := int32(custom["rate_limit_threshold"].(int)) + rateLimitDurationInMinutes := int64(custom["rate_limit_duration_in_minutes"].(int)) + rateLimitThreshold := int64(custom["rate_limit_threshold"].(int)) matchConditions := expandCdnFrontDoorFirewallMatchConditions(custom["match_condition"].([]interface{})) action := custom["action"].(string) - output = append(output, frontdoor.CustomRule{ + output = append(output, waf.CustomRule{ Name: utils.String(name), - Priority: &priority, - EnabledState: enabled, - RuleType: frontdoor.RuleType(ruleType), - RateLimitDurationInMinutes: utils.Int32(rateLimitDurationInMinutes), - RateLimitThreshold: utils.Int32(rateLimitThreshold), - MatchConditions: &matchConditions, - Action: frontdoor.ActionType(action), + Priority: priority, + EnabledState: pointer.To(enabled), + RuleType: waf.RuleType(ruleType), + RateLimitDurationInMinutes: utils.Int64(rateLimitDurationInMinutes), + RateLimitThreshold: utils.Int64(rateLimitThreshold), + MatchConditions: matchConditions, + Action: waf.ActionType(action), }) } - return &frontdoor.CustomRuleList{ + return &waf.CustomRuleList{ Rules: &output, } } -func expandCdnFrontDoorFirewallMatchConditions(input []interface{}) []frontdoor.MatchCondition { - result := make([]frontdoor.MatchCondition, 0) +func expandCdnFrontDoorFirewallMatchConditions(input []interface{}) []waf.MatchCondition { + result := make([]waf.MatchCondition, 0) if len(input) == 0 { return nil } @@ -772,18 +784,18 @@ func expandCdnFrontDoorFirewallMatchConditions(input []interface{}) []frontdoor. selector := match["selector"].(string) operator := match["operator"].(string) negateCondition := match["negation_condition"].(bool) - matchValues := match["match_values"].([]interface{}) + matchValues := match["match_values"].([]string) transforms := match["transforms"].([]interface{}) - matchCondition := frontdoor.MatchCondition{ - Operator: frontdoor.Operator(operator), + matchCondition := waf.MatchCondition{ + Operator: waf.Operator(operator), NegateCondition: &negateCondition, - MatchValue: utils.ExpandStringSlice(matchValues), + MatchValue: matchValues, Transforms: expandCdnFrontDoorFirewallTransforms(transforms), } if matchVariable != "" { - matchCondition.MatchVariable = frontdoor.MatchVariable(matchVariable) + matchCondition.MatchVariable = waf.MatchVariable(matchVariable) } if selector != "" { matchCondition.Selector = utils.String(selector) @@ -795,25 +807,25 @@ func expandCdnFrontDoorFirewallMatchConditions(input []interface{}) []frontdoor. return result } -func expandCdnFrontDoorFirewallTransforms(input []interface{}) *[]frontdoor.TransformType { - result := make([]frontdoor.TransformType, 0) +func expandCdnFrontDoorFirewallTransforms(input []interface{}) *[]waf.TransformType { + result := make([]waf.TransformType, 0) if len(input) == 0 { return nil } for _, v := range input { - result = append(result, frontdoor.TransformType(v.(string))) + result = append(result, waf.TransformType(v.(string))) } return &result } -func expandCdnFrontDoorFirewallManagedRules(input []interface{}) (*frontdoor.ManagedRuleSetList, error) { +func expandCdnFrontDoorFirewallManagedRules(input []interface{}) (*waf.ManagedRuleSetList, error) { if len(input) == 0 { return nil, nil } - result := make([]frontdoor.ManagedRuleSet, 0) + result := make([]waf.ManagedRuleSet, 0) for _, mr := range input { managedRule := mr.(map[string]interface{}) @@ -842,27 +854,27 @@ func expandCdnFrontDoorFirewallManagedRules(input []interface{}) (*frontdoor.Man return nil, err } - managedRuleSet := frontdoor.ManagedRuleSet{ + managedRuleSet := waf.ManagedRuleSet{ Exclusions: exclusions, - RuleSetVersion: &version, + RuleSetVersion: version, RuleGroupOverrides: ruleGroupOverrides, - RuleSetType: &ruleType, + RuleSetType: ruleType, } if action != "" { - managedRuleSet.RuleSetAction = frontdoor.ManagedRuleSetActionType(action) + managedRuleSet.RuleSetAction = pointer.To(waf.ManagedRuleSetActionType(action)) } result = append(result, managedRuleSet) } - return &frontdoor.ManagedRuleSetList{ + return &waf.ManagedRuleSetList{ ManagedRuleSets: &result, }, nil } -func expandCdnFrontDoorFirewallManagedRuleGroupExclusion(input []interface{}) *[]frontdoor.ManagedRuleExclusion { - results := make([]frontdoor.ManagedRuleExclusion, 0) +func expandCdnFrontDoorFirewallManagedRuleGroupExclusion(input []interface{}) *[]waf.ManagedRuleExclusion { + results := make([]waf.ManagedRuleExclusion, 0) if len(input) == 0 { return nil } @@ -874,18 +886,18 @@ func expandCdnFrontDoorFirewallManagedRuleGroupExclusion(input []interface{}) *[ operator := exclusion["operator"].(string) selector := exclusion["selector"].(string) - results = append(results, frontdoor.ManagedRuleExclusion{ - MatchVariable: frontdoor.ManagedRuleExclusionMatchVariable(matchVariable), - SelectorMatchOperator: frontdoor.ManagedRuleExclusionSelectorMatchOperator(operator), - Selector: &selector, + results = append(results, waf.ManagedRuleExclusion{ + MatchVariable: waf.ManagedRuleExclusionMatchVariable(matchVariable), + SelectorMatchOperator: waf.ManagedRuleExclusionSelectorMatchOperator(operator), + Selector: selector, }) } return &results } -func expandCdnFrontDoorFirewallManagedRuleGroupOverride(input []interface{}, versionRaw string, version float64) (*[]frontdoor.ManagedRuleGroupOverride, error) { - result := make([]frontdoor.ManagedRuleGroupOverride, 0) +func expandCdnFrontDoorFirewallManagedRuleGroupOverride(input []interface{}, versionRaw string, version float64) (*[]waf.ManagedRuleGroupOverride, error) { + result := make([]waf.ManagedRuleGroupOverride, 0) if len(input) == 0 { return nil, nil } @@ -900,9 +912,9 @@ func expandCdnFrontDoorFirewallManagedRuleGroupOverride(input []interface{}, ver return nil, err } - result = append(result, frontdoor.ManagedRuleGroupOverride{ + result = append(result, waf.ManagedRuleGroupOverride{ Exclusions: exclusions, - RuleGroupName: &ruleGroupName, + RuleGroupName: ruleGroupName, Rules: rules, }) } @@ -910,8 +922,8 @@ func expandCdnFrontDoorFirewallManagedRuleGroupOverride(input []interface{}, ver return &result, nil } -func expandCdnFrontDoorFirewallRuleOverride(input []interface{}, versionRaw string, version float64) (*[]frontdoor.ManagedRuleOverride, error) { - result := make([]frontdoor.ManagedRuleOverride, 0) +func expandCdnFrontDoorFirewallRuleOverride(input []interface{}, versionRaw string, version float64) (*[]waf.ManagedRuleOverride, error) { + result := make([]waf.ManagedRuleOverride, 0) if len(input) == 0 { return nil, nil } @@ -919,29 +931,29 @@ func expandCdnFrontDoorFirewallRuleOverride(input []interface{}, versionRaw stri for _, v := range input { rule := v.(map[string]interface{}) - enabled := frontdoor.ManagedRuleEnabledStateDisabled + enabled := waf.ManagedRuleEnabledStateDisabled if rule["enabled"].(bool) { - enabled = frontdoor.ManagedRuleEnabledStateEnabled + enabled = waf.ManagedRuleEnabledStateEnabled } ruleId := rule["rule_id"].(string) actionTypeRaw := rule["action"].(string) - action := frontdoor.ActionType(actionTypeRaw) + action := waf.ActionType(actionTypeRaw) // NOTE: Default Rule Sets(DRS) 2.0 and above rules only use action type of 'AnomalyScoring' or 'Log'. Issues 19088 and 19561 // This will still work for bot rules as well since it will be the default value of 1.0 - if version < 2.0 && actionTypeRaw == "AnomalyScoring" { + if version < 2.0 && actionTypeRaw == string(waf.ActionTypeAnomalyScoring) { return nil, fmt.Errorf("'AnomalyScoring' is only valid in managed rules that are DRS 2.0 and above, got %q", versionRaw) - } else if version >= 2.0 && actionTypeRaw != "AnomalyScoring" && actionTypeRaw != "Log" { + } else if version >= 2.0 && actionTypeRaw != string(waf.ActionTypeAnomalyScoring) && actionTypeRaw != "Log" { return nil, fmt.Errorf("the managed rules 'action' field must be set to 'AnomalyScoring' or 'Log' if the managed rule is DRS 2.0 or above, got %q", action) } exclusions := expandCdnFrontDoorFirewallManagedRuleGroupExclusion(rule["exclusion"].([]interface{})) - result = append(result, frontdoor.ManagedRuleOverride{ - RuleID: &ruleId, - EnabledState: enabled, - Action: action, + result = append(result, waf.ManagedRuleOverride{ + RuleId: ruleId, + EnabledState: pointer.To(enabled), + Action: pointer.To(action), Exclusions: exclusions, }) } @@ -949,7 +961,7 @@ func expandCdnFrontDoorFirewallRuleOverride(input []interface{}, versionRaw stri return &result, nil } -func flattenCdnFrontDoorFirewallCustomRules(input *frontdoor.CustomRuleList) []interface{} { +func flattenCdnFrontDoorFirewallCustomRules(input *waf.CustomRuleList) []interface{} { if input == nil || input.Rules == nil { return []interface{}{} } @@ -962,8 +974,8 @@ func flattenCdnFrontDoorFirewallCustomRules(input *frontdoor.CustomRuleList) []i } enabled := false - if v.EnabledState != "" { - enabled = v.EnabledState == frontdoor.CustomRuleEnabledStateEnabled + if v.EnabledState != nil { + enabled = pointer.From(v.EnabledState) == waf.CustomRuleEnabledStateEnabled } name := "" @@ -972,8 +984,8 @@ func flattenCdnFrontDoorFirewallCustomRules(input *frontdoor.CustomRuleList) []i } priority := 0 - if v.Priority != nil { - priority = int(*v.Priority) + if v.Priority != 0 { + priority = int(int(v.Priority)) } rateLimitDurationInMinutes := 0 @@ -994,7 +1006,7 @@ func flattenCdnFrontDoorFirewallCustomRules(input *frontdoor.CustomRuleList) []i results = append(results, map[string]interface{}{ "action": action, "enabled": enabled, - "match_condition": flattenCdnFrontDoorFirewallMatchConditions(v.MatchConditions), + "match_condition": flattenCdnFrontDoorFirewallMatchConditions(pointer.To(v.MatchConditions)), "rate_limit_duration_in_minutes": rateLimitDurationInMinutes, "rate_limit_threshold": rateLimitThreshold, "priority": priority, @@ -1006,7 +1018,7 @@ func flattenCdnFrontDoorFirewallCustomRules(input *frontdoor.CustomRuleList) []i return results } -func flattenCdnFrontDoorFirewallMatchConditions(input *[]frontdoor.MatchCondition) []interface{} { +func flattenCdnFrontDoorFirewallMatchConditions(input *[]waf.MatchCondition) []interface{} { if input == nil { return []interface{}{} } @@ -1036,7 +1048,7 @@ func flattenCdnFrontDoorFirewallMatchConditions(input *[]frontdoor.MatchConditio return results } -func flattenCdnFrontDoorFirewallManagedRules(input *frontdoor.ManagedRuleSetList) []interface{} { +func flattenCdnFrontDoorFirewallManagedRules(input *waf.ManagedRuleSetList) []interface{} { if input == nil || input.ManagedRuleSets == nil { return []interface{}{} } @@ -1044,18 +1056,18 @@ func flattenCdnFrontDoorFirewallManagedRules(input *frontdoor.ManagedRuleSetList results := make([]interface{}, 0) for _, r := range *input.ManagedRuleSets { ruleSetType := "" - if r.RuleSetType != nil { - ruleSetType = *r.RuleSetType + if r.RuleSetType != "" { + ruleSetType = r.RuleSetType } ruleSetVersion := "" - if r.RuleSetVersion != nil { - ruleSetVersion = *r.RuleSetVersion + if r.RuleSetVersion != "" { + ruleSetVersion = r.RuleSetVersion } ruleSetAction := "" - if r.RuleSetAction != "" { - ruleSetAction = string(r.RuleSetAction) + if r.RuleSetAction != nil { + ruleSetAction = string(pointer.From(r.RuleSetAction)) } results = append(results, map[string]interface{}{ @@ -1070,7 +1082,7 @@ func flattenCdnFrontDoorFirewallManagedRules(input *frontdoor.ManagedRuleSetList return results } -func flattenCdnFrontDoorFirewallExclusions(input *[]frontdoor.ManagedRuleExclusion) []interface{} { +func flattenCdnFrontDoorFirewallExclusions(input *[]waf.ManagedRuleExclusion) []interface{} { if input == nil { return []interface{}{} } @@ -1088,8 +1100,8 @@ func flattenCdnFrontDoorFirewallExclusions(input *[]frontdoor.ManagedRuleExclusi } selector := "" - if v.Selector != nil { - selector = *v.Selector + if v.Selector != "" { + selector = v.Selector } results = append(results, map[string]interface{}{ @@ -1102,7 +1114,7 @@ func flattenCdnFrontDoorFirewallExclusions(input *[]frontdoor.ManagedRuleExclusi return results } -func flattenCdnFrontDoorFirewallOverrides(input *[]frontdoor.ManagedRuleGroupOverride) []interface{} { +func flattenCdnFrontDoorFirewallOverrides(input *[]waf.ManagedRuleGroupOverride) []interface{} { if input == nil { return []interface{}{} } @@ -1110,8 +1122,8 @@ func flattenCdnFrontDoorFirewallOverrides(input *[]frontdoor.ManagedRuleGroupOve results := make([]interface{}, 0) for _, v := range *input { ruleGroupName := "" - if v.RuleGroupName != nil { - ruleGroupName = *v.RuleGroupName + if v.RuleGroupName != "" { + ruleGroupName = v.RuleGroupName } results = append(results, map[string]interface{}{ @@ -1124,26 +1136,26 @@ func flattenCdnFrontDoorFirewallOverrides(input *[]frontdoor.ManagedRuleGroupOve return results } -func flattenCdnFrontDoorFirewallRules(input *[]frontdoor.ManagedRuleOverride) []interface{} { +func flattenCdnFrontDoorFirewallRules(input *[]waf.ManagedRuleOverride) []interface{} { if input == nil { return []interface{}{} } results := make([]interface{}, 0) for _, v := range *input { - action := "AnomalyScoring" - if v.Action != "" { - action = string(v.Action) + action := waf.ActionTypeAnomalyScoring + if v.Action != nil { + action = pointer.From(v.Action) } enabled := false - if v.EnabledState != "" { - enabled = v.EnabledState == frontdoor.ManagedRuleEnabledStateEnabled + if v.EnabledState != nil { + enabled = pointer.From(v.EnabledState) == waf.ManagedRuleEnabledStateEnabled } ruleId := "" - if v.RuleID != nil { - ruleId = *v.RuleID + if v.RuleId != "" { + ruleId = v.RuleId } results = append(results, map[string]interface{}{ diff --git a/internal/services/cdn/cdn_frontdoor_helpers.go b/internal/services/cdn/cdn_frontdoor_helpers.go index 24298240ba3f..0eabbd7fc0a8 100644 --- a/internal/services/cdn/cdn_frontdoor_helpers.go +++ b/internal/services/cdn/cdn_frontdoor_helpers.go @@ -7,9 +7,10 @@ import ( "fmt" "strings" - "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2021-06-01/cdn" // nolint: staticcheck - "github.com/Azure/azure-sdk-for-go/services/frontdoor/mgmt/2020-11-01/frontdoor" // nolint: staticcheck + "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2021-06-01/cdn" // nolint: staticcheck + // nolint: staticcheck dnsValidate "github.com/hashicorp/go-azure-sdk/resource-manager/dns/2018-05-01/zones" + waf "github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/locks" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cdn/azuresdkhacks" @@ -137,35 +138,31 @@ func flattenFrontDoorTags(tagMap map[string]*string) *map[string]string { return &t } -func flattenTransformSlice(input *[]frontdoor.TransformType) []interface{} { +func flattenTransformSlice(input *[]waf.TransformType) []interface{} { result := make([]interface{}, 0) if input == nil || len(*input) == 0 { return result } - if input != nil { - for _, item := range *input { - result = append(result, string(item)) - } + for _, item := range *input { + result = append(result, string(item)) } return result } -func flattenFrontendEndpointLinkSlice(input *[]frontdoor.FrontendEndpointLink) []interface{} { +func flattenFrontendEndpointLinkSlice(input *[]waf.FrontendEndpointLink) []interface{} { result := make([]interface{}, 0) if input == nil || len(*input) == 0 { return result } - if input != nil { - for _, item := range *input { - if item.ID == nil { - continue - } - - result = append(result, *item.ID) + for _, item := range *input { + if item.Id == nil { + continue } + + result = append(result, *item.Id) } return result diff --git a/internal/services/cdn/cdn_frontdoor_rule_resource.go b/internal/services/cdn/cdn_frontdoor_rule_resource.go index 03acdc252a4a..fc682e5be377 100644 --- a/internal/services/cdn/cdn_frontdoor_rule_resource.go +++ b/internal/services/cdn/cdn_frontdoor_rule_resource.go @@ -7,6 +7,7 @@ import ( "fmt" "time" + // wafwrs "github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallmanagedrulesets" cdn "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2021-06-01/cdn" // nolint: staticcheck "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" diff --git a/internal/services/cdn/cdn_frontdoor_shared_schema.go b/internal/services/cdn/cdn_frontdoor_shared_schema.go index a25030278b99..fe7bb8c2e793 100644 --- a/internal/services/cdn/cdn_frontdoor_shared_schema.go +++ b/internal/services/cdn/cdn_frontdoor_shared_schema.go @@ -4,28 +4,39 @@ package cdn import ( - "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2021-06-01/cdn" // nolint: staticcheck + waf "github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cdn/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" ) +// SslProtocol enumerates the values for ssl protocol. +type SslProtocol string + +const ( + // SslProtocolTLSv1 ... + SslProtocolTLSv1 SslProtocol = "TLSv1" + // SslProtocolTLSv11 ... + SslProtocolTLSv11 SslProtocol = "TLSv1.1" + // SslProtocolTLSv12 ... + SslProtocolTLSv12 SslProtocol = "TLSv1.2" +) + +// PossibleSslProtocolValues returns an array of possible values for the SslProtocol const type. +func PossibleSslProtocolValues() []string { + return []string{ + string(SslProtocolTLSv1), + string(SslProtocolTLSv11), + string(SslProtocolTLSv12), + } +} + func schemaCdnFrontDoorOperator() *pluginsdk.Schema { return &pluginsdk.Schema{ Type: pluginsdk.TypeString, Required: true, - ValidateFunc: validation.StringInSlice([]string{ - string(cdn.OperatorAny), - string(cdn.OperatorEqual), - string(cdn.OperatorContains), - string(cdn.OperatorBeginsWith), - string(cdn.OperatorEndsWith), - string(cdn.OperatorLessThan), - string(cdn.OperatorLessThanOrEqual), - string(cdn.OperatorGreaterThan), - string(cdn.OperatorGreaterThanOrEqual), - string(cdn.OperatorRegEx), - }, false), + ValidateFunc: validation.StringInSlice(waf.PossibleValuesForOperator(), + false), } } @@ -33,9 +44,9 @@ func schemaCdnFrontDoorOperatorEqualOnly() *pluginsdk.Schema { return &pluginsdk.Schema{ Type: pluginsdk.TypeString, Optional: true, - Default: string(cdn.OperatorEqual), + Default: string(waf.OperatorEqual), ValidateFunc: validation.StringInSlice([]string{ - string(cdn.OperatorEqual), + string(waf.OperatorEqual), }, false), } } @@ -44,11 +55,11 @@ func schemaCdnFrontDoorOperatorRemoteAddress() *pluginsdk.Schema { return &pluginsdk.Schema{ Type: pluginsdk.TypeString, Optional: true, - Default: string(cdn.OperatorIPMatch), + Default: string(waf.OperatorIPMatch), ValidateFunc: validation.StringInSlice([]string{ - string(cdn.OperatorAny), - string(cdn.OperatorIPMatch), - string(cdn.OperatorGeoMatch), + string(waf.OperatorAny), + string(waf.OperatorIPMatch), + string(waf.OperatorGeoMatch), }, false), } } @@ -57,10 +68,10 @@ func schemaCdnFrontDoorOperatorSocketAddress() *pluginsdk.Schema { return &pluginsdk.Schema{ Type: pluginsdk.TypeString, Optional: true, - Default: string(cdn.OperatorIPMatch), + Default: string(waf.OperatorIPMatch), ValidateFunc: validation.StringInSlice([]string{ - string(cdn.OperatorAny), - string(cdn.OperatorIPMatch), + string(waf.OperatorAny), + string(waf.OperatorIPMatch), }, false), } } @@ -110,11 +121,8 @@ func schemaCdnFrontDoorSslProtocolMatchValues() *pluginsdk.Schema { Elem: &pluginsdk.Schema{ Type: pluginsdk.TypeString, - ValidateFunc: validation.StringInSlice([]string{ - string(cdn.SslProtocolTLSv1), - string(cdn.SslProtocolTLSv11), - string(cdn.SslProtocolTLSv12), - }, false), + ValidateFunc: validation.StringInSlice(PossibleSslProtocolValues(), + false), }, } } @@ -225,14 +233,8 @@ func schemaCdnFrontDoorRuleTransforms() *pluginsdk.Schema { Elem: &pluginsdk.Schema{ Type: pluginsdk.TypeString, - ValidateFunc: validation.StringInSlice([]string{ - string(cdn.TransformLowercase), - string(cdn.TransformRemoveNulls), - string(cdn.TransformTrim), - string(cdn.TransformUppercase), - string(cdn.TransformURLDecode), - string(cdn.TransformURLEncode), - }, false), + ValidateFunc: validation.StringInSlice(waf.PossibleValuesForTransformType(), + false), }, } } diff --git a/internal/services/cdn/client/client.go b/internal/services/cdn/client/client.go index fa144b1b2c3f..f17c09dc1a20 100644 --- a/internal/services/cdn/client/client.go +++ b/internal/services/cdn/client/client.go @@ -7,6 +7,7 @@ import ( cdnSdk "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2020-09-01/cdn" // nolint: staticcheck cdnFrontDoorSdk "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2021-06-01/cdn" // nolint: staticcheck "github.com/Azure/azure-sdk-for-go/services/frontdoor/mgmt/2020-11-01/frontdoor" // nolint: staticcheck + waf "github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies" "github.com/hashicorp/terraform-provider-azurerm/internal/common" ) @@ -22,6 +23,7 @@ type Client struct { FrontDoorSecretsClient *cdnFrontDoorSdk.SecretsClient FrontDoorRuleSetsClient *cdnFrontDoorSdk.RuleSetsClient FrontDoorLegacyFirewallPoliciesClient *frontdoor.PoliciesClient + FrontDoorFirewallPoliciesClient *waf.WebApplicationFirewallPoliciesClient CustomDomainsClient *cdnSdk.CustomDomainsClient EndpointsClient *cdnSdk.EndpointsClient ProfilesClient *cdnSdk.ProfilesClient @@ -46,6 +48,9 @@ func NewClient(o *common.ClientOptions) *Client { frontDoorLegacyFirewallPoliciesClient := frontdoor.NewPoliciesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) o.ConfigureClient(&frontDoorLegacyFirewallPoliciesClient.Client, o.ResourceManagerAuthorizer) + frontDoorFirewallPoliciesClient := waf.NewWebApplicationFirewallPoliciesClientWithBaseURI(o.ResourceManagerEndpoint) + o.ConfigureClient(&frontDoorFirewallPoliciesClient.Client, o.ResourceManagerAuthorizer) + frontDoorRoutesClient := cdnFrontDoorSdk.NewRoutesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) o.ConfigureClient(&frontDoorRoutesClient.Client, o.ResourceManagerAuthorizer) @@ -82,6 +87,7 @@ func NewClient(o *common.ClientOptions) *Client { FrontDoorSecretsClient: &frontDoorPolicySecretsClient, FrontDoorRuleSetsClient: &frontDoorRuleSetsClient, FrontDoorLegacyFirewallPoliciesClient: &frontDoorLegacyFirewallPoliciesClient, + FrontDoorFirewallPoliciesClient: &frontDoorFirewallPoliciesClient, CustomDomainsClient: &customDomainsClient, EndpointsClient: &endpointsClient, ProfilesClient: &profilesClient, diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/README.md new file mode 100644 index 000000000000..92bdbcf5cc18 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/README.md @@ -0,0 +1,117 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies` Documentation + +The `webapplicationfirewallpolicies` SDK allows for interaction with Azure Resource Manager `frontdoor` (API Version `2024-02-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies" +``` + + +### Client Initialization + +```go +client := webapplicationfirewallpolicies.NewWebApplicationFirewallPoliciesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `WebApplicationFirewallPoliciesClient.PoliciesCreateOrUpdate` + +```go +ctx := context.TODO() +id := webapplicationfirewallpolicies.NewFrontDoorWebApplicationFirewallPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "frontDoorWebApplicationFirewallPolicyName") + +payload := webapplicationfirewallpolicies.WebApplicationFirewallPolicy{ + // ... +} + + +if err := client.PoliciesCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebApplicationFirewallPoliciesClient.PoliciesDelete` + +```go +ctx := context.TODO() +id := webapplicationfirewallpolicies.NewFrontDoorWebApplicationFirewallPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "frontDoorWebApplicationFirewallPolicyName") + +if err := client.PoliciesDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebApplicationFirewallPoliciesClient.PoliciesGet` + +```go +ctx := context.TODO() +id := webapplicationfirewallpolicies.NewFrontDoorWebApplicationFirewallPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "frontDoorWebApplicationFirewallPolicyName") + +read, err := client.PoliciesGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebApplicationFirewallPoliciesClient.PoliciesList` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.PoliciesList(ctx, id)` can be used to do batched pagination +items, err := client.PoliciesListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebApplicationFirewallPoliciesClient.PoliciesListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.PoliciesListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.PoliciesListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebApplicationFirewallPoliciesClient.PoliciesUpdate` + +```go +ctx := context.TODO() +id := webapplicationfirewallpolicies.NewFrontDoorWebApplicationFirewallPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "frontDoorWebApplicationFirewallPolicyName") + +payload := webapplicationfirewallpolicies.TagsObject{ + // ... +} + + +if err := client.PoliciesUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/client.go new file mode 100644 index 000000000000..490f50430c43 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/client.go @@ -0,0 +1,18 @@ +package webapplicationfirewallpolicies + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebApplicationFirewallPoliciesClient struct { + Client autorest.Client + baseUri string +} + +func NewWebApplicationFirewallPoliciesClientWithBaseURI(endpoint string) WebApplicationFirewallPoliciesClient { + return WebApplicationFirewallPoliciesClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/constants.go new file mode 100644 index 000000000000..30ee141cf426 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/constants.go @@ -0,0 +1,697 @@ +package webapplicationfirewallpolicies + +import ( + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ActionType string + +const ( + ActionTypeAllow ActionType = "Allow" + ActionTypeAnomalyScoring ActionType = "AnomalyScoring" + ActionTypeBlock ActionType = "Block" + ActionTypeJSChallenge ActionType = "JSChallenge" + ActionTypeLog ActionType = "Log" + ActionTypeRedirect ActionType = "Redirect" +) + +func PossibleValuesForActionType() []string { + return []string{ + string(ActionTypeAllow), + string(ActionTypeAnomalyScoring), + string(ActionTypeBlock), + string(ActionTypeJSChallenge), + string(ActionTypeLog), + string(ActionTypeRedirect), + } +} + +func parseActionType(input string) (*ActionType, error) { + vals := map[string]ActionType{ + "allow": ActionTypeAllow, + "anomalyscoring": ActionTypeAnomalyScoring, + "block": ActionTypeBlock, + "jschallenge": ActionTypeJSChallenge, + "log": ActionTypeLog, + "redirect": ActionTypeRedirect, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ActionType(input) + return &out, nil +} + +type CustomRuleEnabledState string + +const ( + CustomRuleEnabledStateDisabled CustomRuleEnabledState = "Disabled" + CustomRuleEnabledStateEnabled CustomRuleEnabledState = "Enabled" +) + +func PossibleValuesForCustomRuleEnabledState() []string { + return []string{ + string(CustomRuleEnabledStateDisabled), + string(CustomRuleEnabledStateEnabled), + } +} + +func parseCustomRuleEnabledState(input string) (*CustomRuleEnabledState, error) { + vals := map[string]CustomRuleEnabledState{ + "disabled": CustomRuleEnabledStateDisabled, + "enabled": CustomRuleEnabledStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CustomRuleEnabledState(input) + return &out, nil +} + +type ManagedRuleEnabledState string + +const ( + ManagedRuleEnabledStateDisabled ManagedRuleEnabledState = "Disabled" + ManagedRuleEnabledStateEnabled ManagedRuleEnabledState = "Enabled" +) + +func PossibleValuesForManagedRuleEnabledState() []string { + return []string{ + string(ManagedRuleEnabledStateDisabled), + string(ManagedRuleEnabledStateEnabled), + } +} + +func parseManagedRuleEnabledState(input string) (*ManagedRuleEnabledState, error) { + vals := map[string]ManagedRuleEnabledState{ + "disabled": ManagedRuleEnabledStateDisabled, + "enabled": ManagedRuleEnabledStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedRuleEnabledState(input) + return &out, nil +} + +type ManagedRuleExclusionMatchVariable string + +const ( + ManagedRuleExclusionMatchVariableQueryStringArgNames ManagedRuleExclusionMatchVariable = "QueryStringArgNames" + ManagedRuleExclusionMatchVariableRequestBodyJsonArgNames ManagedRuleExclusionMatchVariable = "RequestBodyJsonArgNames" + ManagedRuleExclusionMatchVariableRequestBodyPostArgNames ManagedRuleExclusionMatchVariable = "RequestBodyPostArgNames" + ManagedRuleExclusionMatchVariableRequestCookieNames ManagedRuleExclusionMatchVariable = "RequestCookieNames" + ManagedRuleExclusionMatchVariableRequestHeaderNames ManagedRuleExclusionMatchVariable = "RequestHeaderNames" +) + +func PossibleValuesForManagedRuleExclusionMatchVariable() []string { + return []string{ + string(ManagedRuleExclusionMatchVariableQueryStringArgNames), + string(ManagedRuleExclusionMatchVariableRequestBodyJsonArgNames), + string(ManagedRuleExclusionMatchVariableRequestBodyPostArgNames), + string(ManagedRuleExclusionMatchVariableRequestCookieNames), + string(ManagedRuleExclusionMatchVariableRequestHeaderNames), + } +} + +func parseManagedRuleExclusionMatchVariable(input string) (*ManagedRuleExclusionMatchVariable, error) { + vals := map[string]ManagedRuleExclusionMatchVariable{ + "querystringargnames": ManagedRuleExclusionMatchVariableQueryStringArgNames, + "requestbodyjsonargnames": ManagedRuleExclusionMatchVariableRequestBodyJsonArgNames, + "requestbodypostargnames": ManagedRuleExclusionMatchVariableRequestBodyPostArgNames, + "requestcookienames": ManagedRuleExclusionMatchVariableRequestCookieNames, + "requestheadernames": ManagedRuleExclusionMatchVariableRequestHeaderNames, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedRuleExclusionMatchVariable(input) + return &out, nil +} + +type ManagedRuleExclusionSelectorMatchOperator string + +const ( + ManagedRuleExclusionSelectorMatchOperatorContains ManagedRuleExclusionSelectorMatchOperator = "Contains" + ManagedRuleExclusionSelectorMatchOperatorEndsWith ManagedRuleExclusionSelectorMatchOperator = "EndsWith" + ManagedRuleExclusionSelectorMatchOperatorEquals ManagedRuleExclusionSelectorMatchOperator = "Equals" + ManagedRuleExclusionSelectorMatchOperatorEqualsAny ManagedRuleExclusionSelectorMatchOperator = "EqualsAny" + ManagedRuleExclusionSelectorMatchOperatorStartsWith ManagedRuleExclusionSelectorMatchOperator = "StartsWith" +) + +func PossibleValuesForManagedRuleExclusionSelectorMatchOperator() []string { + return []string{ + string(ManagedRuleExclusionSelectorMatchOperatorContains), + string(ManagedRuleExclusionSelectorMatchOperatorEndsWith), + string(ManagedRuleExclusionSelectorMatchOperatorEquals), + string(ManagedRuleExclusionSelectorMatchOperatorEqualsAny), + string(ManagedRuleExclusionSelectorMatchOperatorStartsWith), + } +} + +func parseManagedRuleExclusionSelectorMatchOperator(input string) (*ManagedRuleExclusionSelectorMatchOperator, error) { + vals := map[string]ManagedRuleExclusionSelectorMatchOperator{ + "contains": ManagedRuleExclusionSelectorMatchOperatorContains, + "endswith": ManagedRuleExclusionSelectorMatchOperatorEndsWith, + "equals": ManagedRuleExclusionSelectorMatchOperatorEquals, + "equalsany": ManagedRuleExclusionSelectorMatchOperatorEqualsAny, + "startswith": ManagedRuleExclusionSelectorMatchOperatorStartsWith, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedRuleExclusionSelectorMatchOperator(input) + return &out, nil +} + +type ManagedRuleSetActionType string + +const ( + ManagedRuleSetActionTypeBlock ManagedRuleSetActionType = "Block" + ManagedRuleSetActionTypeLog ManagedRuleSetActionType = "Log" + ManagedRuleSetActionTypeRedirect ManagedRuleSetActionType = "Redirect" +) + +func PossibleValuesForManagedRuleSetActionType() []string { + return []string{ + string(ManagedRuleSetActionTypeBlock), + string(ManagedRuleSetActionTypeLog), + string(ManagedRuleSetActionTypeRedirect), + } +} + +func parseManagedRuleSetActionType(input string) (*ManagedRuleSetActionType, error) { + vals := map[string]ManagedRuleSetActionType{ + "block": ManagedRuleSetActionTypeBlock, + "log": ManagedRuleSetActionTypeLog, + "redirect": ManagedRuleSetActionTypeRedirect, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedRuleSetActionType(input) + return &out, nil +} + +type MatchVariable string + +const ( + MatchVariableCookies MatchVariable = "Cookies" + MatchVariablePostArgs MatchVariable = "PostArgs" + MatchVariableQueryString MatchVariable = "QueryString" + MatchVariableRemoteAddr MatchVariable = "RemoteAddr" + MatchVariableRequestBody MatchVariable = "RequestBody" + MatchVariableRequestHeader MatchVariable = "RequestHeader" + MatchVariableRequestMethod MatchVariable = "RequestMethod" + MatchVariableRequestUri MatchVariable = "RequestUri" + MatchVariableSocketAddr MatchVariable = "SocketAddr" +) + +func PossibleValuesForMatchVariable() []string { + return []string{ + string(MatchVariableCookies), + string(MatchVariablePostArgs), + string(MatchVariableQueryString), + string(MatchVariableRemoteAddr), + string(MatchVariableRequestBody), + string(MatchVariableRequestHeader), + string(MatchVariableRequestMethod), + string(MatchVariableRequestUri), + string(MatchVariableSocketAddr), + } +} + +func parseMatchVariable(input string) (*MatchVariable, error) { + vals := map[string]MatchVariable{ + "cookies": MatchVariableCookies, + "postargs": MatchVariablePostArgs, + "querystring": MatchVariableQueryString, + "remoteaddr": MatchVariableRemoteAddr, + "requestbody": MatchVariableRequestBody, + "requestheader": MatchVariableRequestHeader, + "requestmethod": MatchVariableRequestMethod, + "requesturi": MatchVariableRequestUri, + "socketaddr": MatchVariableSocketAddr, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MatchVariable(input) + return &out, nil +} + +type Operator string + +const ( + OperatorAny Operator = "Any" + OperatorBeginsWith Operator = "BeginsWith" + OperatorContains Operator = "Contains" + OperatorEndsWith Operator = "EndsWith" + OperatorEqual Operator = "Equal" + OperatorGeoMatch Operator = "GeoMatch" + OperatorGreaterThan Operator = "GreaterThan" + OperatorGreaterThanOrEqual Operator = "GreaterThanOrEqual" + OperatorIPMatch Operator = "IPMatch" + OperatorLessThan Operator = "LessThan" + OperatorLessThanOrEqual Operator = "LessThanOrEqual" + OperatorRegEx Operator = "RegEx" +) + +func PossibleValuesForOperator() []string { + return []string{ + string(OperatorAny), + string(OperatorBeginsWith), + string(OperatorContains), + string(OperatorEndsWith), + string(OperatorEqual), + string(OperatorGeoMatch), + string(OperatorGreaterThan), + string(OperatorGreaterThanOrEqual), + string(OperatorIPMatch), + string(OperatorLessThan), + string(OperatorLessThanOrEqual), + string(OperatorRegEx), + } +} + +func parseOperator(input string) (*Operator, error) { + vals := map[string]Operator{ + "any": OperatorAny, + "beginswith": OperatorBeginsWith, + "contains": OperatorContains, + "endswith": OperatorEndsWith, + "equal": OperatorEqual, + "geomatch": OperatorGeoMatch, + "greaterthan": OperatorGreaterThan, + "greaterthanorequal": OperatorGreaterThanOrEqual, + "ipmatch": OperatorIPMatch, + "lessthan": OperatorLessThan, + "lessthanorequal": OperatorLessThanOrEqual, + "regex": OperatorRegEx, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Operator(input) + return &out, nil +} + +type PolicyEnabledState string + +const ( + PolicyEnabledStateDisabled PolicyEnabledState = "Disabled" + PolicyEnabledStateEnabled PolicyEnabledState = "Enabled" +) + +func PossibleValuesForPolicyEnabledState() []string { + return []string{ + string(PolicyEnabledStateDisabled), + string(PolicyEnabledStateEnabled), + } +} + +func parsePolicyEnabledState(input string) (*PolicyEnabledState, error) { + vals := map[string]PolicyEnabledState{ + "disabled": PolicyEnabledStateDisabled, + "enabled": PolicyEnabledStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PolicyEnabledState(input) + return &out, nil +} + +type PolicyMode string + +const ( + PolicyModeDetection PolicyMode = "Detection" + PolicyModePrevention PolicyMode = "Prevention" +) + +func PossibleValuesForPolicyMode() []string { + return []string{ + string(PolicyModeDetection), + string(PolicyModePrevention), + } +} + +func parsePolicyMode(input string) (*PolicyMode, error) { + vals := map[string]PolicyMode{ + "detection": PolicyModeDetection, + "prevention": PolicyModePrevention, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PolicyMode(input) + return &out, nil +} + +type PolicyRequestBodyCheck string + +const ( + PolicyRequestBodyCheckDisabled PolicyRequestBodyCheck = "Disabled" + PolicyRequestBodyCheckEnabled PolicyRequestBodyCheck = "Enabled" +) + +func PossibleValuesForPolicyRequestBodyCheck() []string { + return []string{ + string(PolicyRequestBodyCheckDisabled), + string(PolicyRequestBodyCheckEnabled), + } +} + +func parsePolicyRequestBodyCheck(input string) (*PolicyRequestBodyCheck, error) { + vals := map[string]PolicyRequestBodyCheck{ + "disabled": PolicyRequestBodyCheckDisabled, + "enabled": PolicyRequestBodyCheckEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PolicyRequestBodyCheck(input) + return &out, nil +} + +type PolicyResourceState string + +const ( + PolicyResourceStateCreating PolicyResourceState = "Creating" + PolicyResourceStateDeleting PolicyResourceState = "Deleting" + PolicyResourceStateDisabled PolicyResourceState = "Disabled" + PolicyResourceStateDisabling PolicyResourceState = "Disabling" + PolicyResourceStateEnabled PolicyResourceState = "Enabled" + PolicyResourceStateEnabling PolicyResourceState = "Enabling" +) + +func PossibleValuesForPolicyResourceState() []string { + return []string{ + string(PolicyResourceStateCreating), + string(PolicyResourceStateDeleting), + string(PolicyResourceStateDisabled), + string(PolicyResourceStateDisabling), + string(PolicyResourceStateEnabled), + string(PolicyResourceStateEnabling), + } +} + +func parsePolicyResourceState(input string) (*PolicyResourceState, error) { + vals := map[string]PolicyResourceState{ + "creating": PolicyResourceStateCreating, + "deleting": PolicyResourceStateDeleting, + "disabled": PolicyResourceStateDisabled, + "disabling": PolicyResourceStateDisabling, + "enabled": PolicyResourceStateEnabled, + "enabling": PolicyResourceStateEnabling, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PolicyResourceState(input) + return &out, nil +} + +type RuleType string + +const ( + RuleTypeMatchRule RuleType = "MatchRule" + RuleTypeRateLimitRule RuleType = "RateLimitRule" +) + +func PossibleValuesForRuleType() []string { + return []string{ + string(RuleTypeMatchRule), + string(RuleTypeRateLimitRule), + } +} + +func parseRuleType(input string) (*RuleType, error) { + vals := map[string]RuleType{ + "matchrule": RuleTypeMatchRule, + "ratelimitrule": RuleTypeRateLimitRule, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RuleType(input) + return &out, nil +} + +type ScrubbingRuleEntryMatchOperator string + +const ( + ScrubbingRuleEntryMatchOperatorEquals ScrubbingRuleEntryMatchOperator = "Equals" + ScrubbingRuleEntryMatchOperatorEqualsAny ScrubbingRuleEntryMatchOperator = "EqualsAny" +) + +func PossibleValuesForScrubbingRuleEntryMatchOperator() []string { + return []string{ + string(ScrubbingRuleEntryMatchOperatorEquals), + string(ScrubbingRuleEntryMatchOperatorEqualsAny), + } +} + +func parseScrubbingRuleEntryMatchOperator(input string) (*ScrubbingRuleEntryMatchOperator, error) { + vals := map[string]ScrubbingRuleEntryMatchOperator{ + "equals": ScrubbingRuleEntryMatchOperatorEquals, + "equalsany": ScrubbingRuleEntryMatchOperatorEqualsAny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScrubbingRuleEntryMatchOperator(input) + return &out, nil +} + +type ScrubbingRuleEntryMatchVariable string + +const ( + ScrubbingRuleEntryMatchVariableQueryStringArgNames ScrubbingRuleEntryMatchVariable = "QueryStringArgNames" + ScrubbingRuleEntryMatchVariableRequestBodyJsonArgNames ScrubbingRuleEntryMatchVariable = "RequestBodyJsonArgNames" + ScrubbingRuleEntryMatchVariableRequestBodyPostArgNames ScrubbingRuleEntryMatchVariable = "RequestBodyPostArgNames" + ScrubbingRuleEntryMatchVariableRequestCookieNames ScrubbingRuleEntryMatchVariable = "RequestCookieNames" + ScrubbingRuleEntryMatchVariableRequestHeaderNames ScrubbingRuleEntryMatchVariable = "RequestHeaderNames" + ScrubbingRuleEntryMatchVariableRequestIPAddress ScrubbingRuleEntryMatchVariable = "RequestIPAddress" + ScrubbingRuleEntryMatchVariableRequestUri ScrubbingRuleEntryMatchVariable = "RequestUri" +) + +func PossibleValuesForScrubbingRuleEntryMatchVariable() []string { + return []string{ + string(ScrubbingRuleEntryMatchVariableQueryStringArgNames), + string(ScrubbingRuleEntryMatchVariableRequestBodyJsonArgNames), + string(ScrubbingRuleEntryMatchVariableRequestBodyPostArgNames), + string(ScrubbingRuleEntryMatchVariableRequestCookieNames), + string(ScrubbingRuleEntryMatchVariableRequestHeaderNames), + string(ScrubbingRuleEntryMatchVariableRequestIPAddress), + string(ScrubbingRuleEntryMatchVariableRequestUri), + } +} + +func parseScrubbingRuleEntryMatchVariable(input string) (*ScrubbingRuleEntryMatchVariable, error) { + vals := map[string]ScrubbingRuleEntryMatchVariable{ + "querystringargnames": ScrubbingRuleEntryMatchVariableQueryStringArgNames, + "requestbodyjsonargnames": ScrubbingRuleEntryMatchVariableRequestBodyJsonArgNames, + "requestbodypostargnames": ScrubbingRuleEntryMatchVariableRequestBodyPostArgNames, + "requestcookienames": ScrubbingRuleEntryMatchVariableRequestCookieNames, + "requestheadernames": ScrubbingRuleEntryMatchVariableRequestHeaderNames, + "requestipaddress": ScrubbingRuleEntryMatchVariableRequestIPAddress, + "requesturi": ScrubbingRuleEntryMatchVariableRequestUri, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScrubbingRuleEntryMatchVariable(input) + return &out, nil +} + +type ScrubbingRuleEntryState string + +const ( + ScrubbingRuleEntryStateDisabled ScrubbingRuleEntryState = "Disabled" + ScrubbingRuleEntryStateEnabled ScrubbingRuleEntryState = "Enabled" +) + +func PossibleValuesForScrubbingRuleEntryState() []string { + return []string{ + string(ScrubbingRuleEntryStateDisabled), + string(ScrubbingRuleEntryStateEnabled), + } +} + +func parseScrubbingRuleEntryState(input string) (*ScrubbingRuleEntryState, error) { + vals := map[string]ScrubbingRuleEntryState{ + "disabled": ScrubbingRuleEntryStateDisabled, + "enabled": ScrubbingRuleEntryStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScrubbingRuleEntryState(input) + return &out, nil +} + +type SkuName string + +const ( + SkuNameClassicAzureFrontDoor SkuName = "Classic_AzureFrontDoor" + SkuNamePremiumAzureFrontDoor SkuName = "Premium_AzureFrontDoor" + SkuNameStandardAzureFrontDoor SkuName = "Standard_AzureFrontDoor" +) + +func PossibleValuesForSkuName() []string { + return []string{ + string(SkuNameClassicAzureFrontDoor), + string(SkuNamePremiumAzureFrontDoor), + string(SkuNameStandardAzureFrontDoor), + } +} + +func parseSkuName(input string) (*SkuName, error) { + vals := map[string]SkuName{ + "classic_azurefrontdoor": SkuNameClassicAzureFrontDoor, + "premium_azurefrontdoor": SkuNamePremiumAzureFrontDoor, + "standard_azurefrontdoor": SkuNameStandardAzureFrontDoor, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SkuName(input) + return &out, nil +} + +type TransformType string + +const ( + TransformTypeLowercase TransformType = "Lowercase" + TransformTypeRemoveNulls TransformType = "RemoveNulls" + TransformTypeTrim TransformType = "Trim" + TransformTypeURLDecode TransformType = "UrlDecode" + TransformTypeURLEncode TransformType = "UrlEncode" + TransformTypeUppercase TransformType = "Uppercase" +) + +func PossibleValuesForTransformType() []string { + return []string{ + string(TransformTypeLowercase), + string(TransformTypeRemoveNulls), + string(TransformTypeTrim), + string(TransformTypeURLDecode), + string(TransformTypeURLEncode), + string(TransformTypeUppercase), + } +} + +func parseTransformType(input string) (*TransformType, error) { + vals := map[string]TransformType{ + "lowercase": TransformTypeLowercase, + "removenulls": TransformTypeRemoveNulls, + "trim": TransformTypeTrim, + "urldecode": TransformTypeURLDecode, + "urlencode": TransformTypeURLEncode, + "uppercase": TransformTypeUppercase, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TransformType(input) + return &out, nil +} + +type VariableName string + +const ( + VariableNameGeoLocation VariableName = "GeoLocation" + VariableNameNone VariableName = "None" + VariableNameSocketAddr VariableName = "SocketAddr" +) + +func PossibleValuesForVariableName() []string { + return []string{ + string(VariableNameGeoLocation), + string(VariableNameNone), + string(VariableNameSocketAddr), + } +} + +func parseVariableName(input string) (*VariableName, error) { + vals := map[string]VariableName{ + "geolocation": VariableNameGeoLocation, + "none": VariableNameNone, + "socketaddr": VariableNameSocketAddr, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VariableName(input) + return &out, nil +} + +type WebApplicationFirewallScrubbingState string + +const ( + WebApplicationFirewallScrubbingStateDisabled WebApplicationFirewallScrubbingState = "Disabled" + WebApplicationFirewallScrubbingStateEnabled WebApplicationFirewallScrubbingState = "Enabled" +) + +func PossibleValuesForWebApplicationFirewallScrubbingState() []string { + return []string{ + string(WebApplicationFirewallScrubbingStateDisabled), + string(WebApplicationFirewallScrubbingStateEnabled), + } +} + +func parseWebApplicationFirewallScrubbingState(input string) (*WebApplicationFirewallScrubbingState, error) { + vals := map[string]WebApplicationFirewallScrubbingState{ + "disabled": WebApplicationFirewallScrubbingStateDisabled, + "enabled": WebApplicationFirewallScrubbingStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WebApplicationFirewallScrubbingState(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/id_frontdoorwebapplicationfirewallpolicy.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/id_frontdoorwebapplicationfirewallpolicy.go new file mode 100644 index 000000000000..ea2136522571 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/id_frontdoorwebapplicationfirewallpolicy.go @@ -0,0 +1,130 @@ +package webapplicationfirewallpolicies + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&FrontDoorWebApplicationFirewallPolicyId{}) +} + +var _ resourceids.ResourceId = &FrontDoorWebApplicationFirewallPolicyId{} + +// FrontDoorWebApplicationFirewallPolicyId is a struct representing the Resource ID for a Front Door Web Application Firewall Policy +type FrontDoorWebApplicationFirewallPolicyId struct { + SubscriptionId string + ResourceGroupName string + FrontDoorWebApplicationFirewallPolicyName string +} + +// NewFrontDoorWebApplicationFirewallPolicyID returns a new FrontDoorWebApplicationFirewallPolicyId struct +func NewFrontDoorWebApplicationFirewallPolicyID(subscriptionId string, resourceGroupName string, frontDoorWebApplicationFirewallPolicyName string) FrontDoorWebApplicationFirewallPolicyId { + return FrontDoorWebApplicationFirewallPolicyId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + FrontDoorWebApplicationFirewallPolicyName: frontDoorWebApplicationFirewallPolicyName, + } +} + +// ParseFrontDoorWebApplicationFirewallPolicyID parses 'input' into a FrontDoorWebApplicationFirewallPolicyId +func ParseFrontDoorWebApplicationFirewallPolicyID(input string) (*FrontDoorWebApplicationFirewallPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(&FrontDoorWebApplicationFirewallPolicyId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FrontDoorWebApplicationFirewallPolicyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseFrontDoorWebApplicationFirewallPolicyIDInsensitively parses 'input' case-insensitively into a FrontDoorWebApplicationFirewallPolicyId +// note: this method should only be used for API response data and not user input +func ParseFrontDoorWebApplicationFirewallPolicyIDInsensitively(input string) (*FrontDoorWebApplicationFirewallPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(&FrontDoorWebApplicationFirewallPolicyId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FrontDoorWebApplicationFirewallPolicyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *FrontDoorWebApplicationFirewallPolicyId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.FrontDoorWebApplicationFirewallPolicyName, ok = input.Parsed["frontDoorWebApplicationFirewallPolicyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "frontDoorWebApplicationFirewallPolicyName", input) + } + + return nil +} + +// ValidateFrontDoorWebApplicationFirewallPolicyID checks that 'input' can be parsed as a Front Door Web Application Firewall Policy ID +func ValidateFrontDoorWebApplicationFirewallPolicyID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseFrontDoorWebApplicationFirewallPolicyID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Front Door Web Application Firewall Policy ID +func (id FrontDoorWebApplicationFirewallPolicyId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/frontDoorWebApplicationFirewallPolicies/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.FrontDoorWebApplicationFirewallPolicyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Front Door Web Application Firewall Policy ID +func (id FrontDoorWebApplicationFirewallPolicyId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticFrontDoorWebApplicationFirewallPolicies", "frontDoorWebApplicationFirewallPolicies", "frontDoorWebApplicationFirewallPolicies"), + resourceids.UserSpecifiedSegment("frontDoorWebApplicationFirewallPolicyName", "frontDoorWebApplicationFirewallPolicyName"), + } +} + +// String returns a human-readable description of this Front Door Web Application Firewall Policy ID +func (id FrontDoorWebApplicationFirewallPolicyId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Front Door Web Application Firewall Policy Name: %q", id.FrontDoorWebApplicationFirewallPolicyName), + } + return fmt.Sprintf("Front Door Web Application Firewall Policy (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/method_policiescreateorupdate_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/method_policiescreateorupdate_autorest.go new file mode 100644 index 000000000000..e03605ddf6b9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/method_policiescreateorupdate_autorest.go @@ -0,0 +1,80 @@ +package webapplicationfirewallpolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/polling" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PoliciesCreateOrUpdateOperationResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response + Model *WebApplicationFirewallPolicy +} + +// PoliciesCreateOrUpdate ... +func (c WebApplicationFirewallPoliciesClient) PoliciesCreateOrUpdate(ctx context.Context, id FrontDoorWebApplicationFirewallPolicyId, input WebApplicationFirewallPolicy) (result PoliciesCreateOrUpdateOperationResponse, err error) { + req, err := c.preparerForPoliciesCreateOrUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "webapplicationfirewallpolicies.WebApplicationFirewallPoliciesClient", "PoliciesCreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = c.senderForPoliciesCreateOrUpdate(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "webapplicationfirewallpolicies.WebApplicationFirewallPoliciesClient", "PoliciesCreateOrUpdate", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// PoliciesCreateOrUpdateThenPoll performs PoliciesCreateOrUpdate then polls until it's completed +func (c WebApplicationFirewallPoliciesClient) PoliciesCreateOrUpdateThenPoll(ctx context.Context, id FrontDoorWebApplicationFirewallPolicyId, input WebApplicationFirewallPolicy) error { + result, err := c.PoliciesCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing PoliciesCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after PoliciesCreateOrUpdate: %+v", err) + } + + return nil +} + +// preparerForPoliciesCreateOrUpdate prepares the PoliciesCreateOrUpdate request. +func (c WebApplicationFirewallPoliciesClient) preparerForPoliciesCreateOrUpdate(ctx context.Context, id FrontDoorWebApplicationFirewallPolicyId, input WebApplicationFirewallPolicy) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// senderForPoliciesCreateOrUpdate sends the PoliciesCreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (c WebApplicationFirewallPoliciesClient) senderForPoliciesCreateOrUpdate(ctx context.Context, req *http.Request) (future PoliciesCreateOrUpdateOperationResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + + future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/method_policiesdelete_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/method_policiesdelete_autorest.go new file mode 100644 index 000000000000..bc80949a54aa --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/method_policiesdelete_autorest.go @@ -0,0 +1,78 @@ +package webapplicationfirewallpolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/polling" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PoliciesDeleteOperationResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// PoliciesDelete ... +func (c WebApplicationFirewallPoliciesClient) PoliciesDelete(ctx context.Context, id FrontDoorWebApplicationFirewallPolicyId) (result PoliciesDeleteOperationResponse, err error) { + req, err := c.preparerForPoliciesDelete(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "webapplicationfirewallpolicies.WebApplicationFirewallPoliciesClient", "PoliciesDelete", nil, "Failure preparing request") + return + } + + result, err = c.senderForPoliciesDelete(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "webapplicationfirewallpolicies.WebApplicationFirewallPoliciesClient", "PoliciesDelete", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// PoliciesDeleteThenPoll performs PoliciesDelete then polls until it's completed +func (c WebApplicationFirewallPoliciesClient) PoliciesDeleteThenPoll(ctx context.Context, id FrontDoorWebApplicationFirewallPolicyId) error { + result, err := c.PoliciesDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing PoliciesDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after PoliciesDelete: %+v", err) + } + + return nil +} + +// preparerForPoliciesDelete prepares the PoliciesDelete request. +func (c WebApplicationFirewallPoliciesClient) preparerForPoliciesDelete(ctx context.Context, id FrontDoorWebApplicationFirewallPolicyId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsDelete(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// senderForPoliciesDelete sends the PoliciesDelete request. The method will close the +// http.Response Body if it receives an error. +func (c WebApplicationFirewallPoliciesClient) senderForPoliciesDelete(ctx context.Context, req *http.Request) (future PoliciesDeleteOperationResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + + future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/method_policiesget_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/method_policiesget_autorest.go new file mode 100644 index 000000000000..c1fa84824e4c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/method_policiesget_autorest.go @@ -0,0 +1,68 @@ +package webapplicationfirewallpolicies + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PoliciesGetOperationResponse struct { + HttpResponse *http.Response + Model *WebApplicationFirewallPolicy +} + +// PoliciesGet ... +func (c WebApplicationFirewallPoliciesClient) PoliciesGet(ctx context.Context, id FrontDoorWebApplicationFirewallPolicyId) (result PoliciesGetOperationResponse, err error) { + req, err := c.preparerForPoliciesGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "webapplicationfirewallpolicies.WebApplicationFirewallPoliciesClient", "PoliciesGet", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "webapplicationfirewallpolicies.WebApplicationFirewallPoliciesClient", "PoliciesGet", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForPoliciesGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "webapplicationfirewallpolicies.WebApplicationFirewallPoliciesClient", "PoliciesGet", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForPoliciesGet prepares the PoliciesGet request. +func (c WebApplicationFirewallPoliciesClient) preparerForPoliciesGet(ctx context.Context, id FrontDoorWebApplicationFirewallPolicyId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForPoliciesGet handles the response to the PoliciesGet request. The method always +// closes the http.Response Body. +func (c WebApplicationFirewallPoliciesClient) responderForPoliciesGet(resp *http.Response) (result PoliciesGetOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/method_policieslist_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/method_policieslist_autorest.go new file mode 100644 index 000000000000..45a893e1f6af --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/method_policieslist_autorest.go @@ -0,0 +1,187 @@ +package webapplicationfirewallpolicies + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PoliciesListOperationResponse struct { + HttpResponse *http.Response + Model *[]WebApplicationFirewallPolicy + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (PoliciesListOperationResponse, error) +} + +type PoliciesListCompleteResult struct { + Items []WebApplicationFirewallPolicy +} + +func (r PoliciesListOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r PoliciesListOperationResponse) LoadMore(ctx context.Context) (resp PoliciesListOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +// PoliciesList ... +func (c WebApplicationFirewallPoliciesClient) PoliciesList(ctx context.Context, id commonids.ResourceGroupId) (resp PoliciesListOperationResponse, err error) { + req, err := c.preparerForPoliciesList(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "webapplicationfirewallpolicies.WebApplicationFirewallPoliciesClient", "PoliciesList", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "webapplicationfirewallpolicies.WebApplicationFirewallPoliciesClient", "PoliciesList", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForPoliciesList(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "webapplicationfirewallpolicies.WebApplicationFirewallPoliciesClient", "PoliciesList", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForPoliciesList prepares the PoliciesList request. +func (c WebApplicationFirewallPoliciesClient) preparerForPoliciesList(ctx context.Context, id commonids.ResourceGroupId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Network/frontDoorWebApplicationFirewallPolicies", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForPoliciesListWithNextLink prepares the PoliciesList request with the given nextLink token. +func (c WebApplicationFirewallPoliciesClient) preparerForPoliciesListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForPoliciesList handles the response to the PoliciesList request. The method always +// closes the http.Response Body. +func (c WebApplicationFirewallPoliciesClient) responderForPoliciesList(resp *http.Response) (result PoliciesListOperationResponse, err error) { + type page struct { + Values []WebApplicationFirewallPolicy `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result PoliciesListOperationResponse, err error) { + req, err := c.preparerForPoliciesListWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "webapplicationfirewallpolicies.WebApplicationFirewallPoliciesClient", "PoliciesList", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "webapplicationfirewallpolicies.WebApplicationFirewallPoliciesClient", "PoliciesList", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForPoliciesList(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "webapplicationfirewallpolicies.WebApplicationFirewallPoliciesClient", "PoliciesList", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// PoliciesListComplete retrieves all of the results into a single object +func (c WebApplicationFirewallPoliciesClient) PoliciesListComplete(ctx context.Context, id commonids.ResourceGroupId) (PoliciesListCompleteResult, error) { + return c.PoliciesListCompleteMatchingPredicate(ctx, id, WebApplicationFirewallPolicyOperationPredicate{}) +} + +// PoliciesListCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c WebApplicationFirewallPoliciesClient) PoliciesListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate WebApplicationFirewallPolicyOperationPredicate) (resp PoliciesListCompleteResult, err error) { + items := make([]WebApplicationFirewallPolicy, 0) + + page, err := c.PoliciesList(ctx, id) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := PoliciesListCompleteResult{ + Items: items, + } + return out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/method_policieslistbysubscription_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/method_policieslistbysubscription_autorest.go new file mode 100644 index 000000000000..041f3f7e811a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/method_policieslistbysubscription_autorest.go @@ -0,0 +1,187 @@ +package webapplicationfirewallpolicies + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PoliciesListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + Model *[]WebApplicationFirewallPolicy + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (PoliciesListBySubscriptionOperationResponse, error) +} + +type PoliciesListBySubscriptionCompleteResult struct { + Items []WebApplicationFirewallPolicy +} + +func (r PoliciesListBySubscriptionOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r PoliciesListBySubscriptionOperationResponse) LoadMore(ctx context.Context) (resp PoliciesListBySubscriptionOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +// PoliciesListBySubscription ... +func (c WebApplicationFirewallPoliciesClient) PoliciesListBySubscription(ctx context.Context, id commonids.SubscriptionId) (resp PoliciesListBySubscriptionOperationResponse, err error) { + req, err := c.preparerForPoliciesListBySubscription(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "webapplicationfirewallpolicies.WebApplicationFirewallPoliciesClient", "PoliciesListBySubscription", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "webapplicationfirewallpolicies.WebApplicationFirewallPoliciesClient", "PoliciesListBySubscription", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForPoliciesListBySubscription(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "webapplicationfirewallpolicies.WebApplicationFirewallPoliciesClient", "PoliciesListBySubscription", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForPoliciesListBySubscription prepares the PoliciesListBySubscription request. +func (c WebApplicationFirewallPoliciesClient) preparerForPoliciesListBySubscription(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Network/frontDoorWebApplicationFirewallPolicies", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForPoliciesListBySubscriptionWithNextLink prepares the PoliciesListBySubscription request with the given nextLink token. +func (c WebApplicationFirewallPoliciesClient) preparerForPoliciesListBySubscriptionWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForPoliciesListBySubscription handles the response to the PoliciesListBySubscription request. The method always +// closes the http.Response Body. +func (c WebApplicationFirewallPoliciesClient) responderForPoliciesListBySubscription(resp *http.Response) (result PoliciesListBySubscriptionOperationResponse, err error) { + type page struct { + Values []WebApplicationFirewallPolicy `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result PoliciesListBySubscriptionOperationResponse, err error) { + req, err := c.preparerForPoliciesListBySubscriptionWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "webapplicationfirewallpolicies.WebApplicationFirewallPoliciesClient", "PoliciesListBySubscription", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "webapplicationfirewallpolicies.WebApplicationFirewallPoliciesClient", "PoliciesListBySubscription", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForPoliciesListBySubscription(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "webapplicationfirewallpolicies.WebApplicationFirewallPoliciesClient", "PoliciesListBySubscription", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// PoliciesListBySubscriptionComplete retrieves all of the results into a single object +func (c WebApplicationFirewallPoliciesClient) PoliciesListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (PoliciesListBySubscriptionCompleteResult, error) { + return c.PoliciesListBySubscriptionCompleteMatchingPredicate(ctx, id, WebApplicationFirewallPolicyOperationPredicate{}) +} + +// PoliciesListBySubscriptionCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c WebApplicationFirewallPoliciesClient) PoliciesListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate WebApplicationFirewallPolicyOperationPredicate) (resp PoliciesListBySubscriptionCompleteResult, err error) { + items := make([]WebApplicationFirewallPolicy, 0) + + page, err := c.PoliciesListBySubscription(ctx, id) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := PoliciesListBySubscriptionCompleteResult{ + Items: items, + } + return out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/method_policiesupdate_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/method_policiesupdate_autorest.go new file mode 100644 index 000000000000..c871f5c4f3d0 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/method_policiesupdate_autorest.go @@ -0,0 +1,80 @@ +package webapplicationfirewallpolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/polling" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PoliciesUpdateOperationResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response + Model *WebApplicationFirewallPolicy +} + +// PoliciesUpdate ... +func (c WebApplicationFirewallPoliciesClient) PoliciesUpdate(ctx context.Context, id FrontDoorWebApplicationFirewallPolicyId, input TagsObject) (result PoliciesUpdateOperationResponse, err error) { + req, err := c.preparerForPoliciesUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "webapplicationfirewallpolicies.WebApplicationFirewallPoliciesClient", "PoliciesUpdate", nil, "Failure preparing request") + return + } + + result, err = c.senderForPoliciesUpdate(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "webapplicationfirewallpolicies.WebApplicationFirewallPoliciesClient", "PoliciesUpdate", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// PoliciesUpdateThenPoll performs PoliciesUpdate then polls until it's completed +func (c WebApplicationFirewallPoliciesClient) PoliciesUpdateThenPoll(ctx context.Context, id FrontDoorWebApplicationFirewallPolicyId, input TagsObject) error { + result, err := c.PoliciesUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing PoliciesUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after PoliciesUpdate: %+v", err) + } + + return nil +} + +// preparerForPoliciesUpdate prepares the PoliciesUpdate request. +func (c WebApplicationFirewallPoliciesClient) preparerForPoliciesUpdate(ctx context.Context, id FrontDoorWebApplicationFirewallPolicyId, input TagsObject) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// senderForPoliciesUpdate sends the PoliciesUpdate request. The method will close the +// http.Response Body if it receives an error. +func (c WebApplicationFirewallPoliciesClient) senderForPoliciesUpdate(ctx context.Context, req *http.Request) (future PoliciesUpdateOperationResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + + future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_customrule.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_customrule.go new file mode 100644 index 000000000000..48503e8600a0 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_customrule.go @@ -0,0 +1,16 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomRule struct { + Action ActionType `json:"action"` + EnabledState *CustomRuleEnabledState `json:"enabledState,omitempty"` + GroupBy *[]GroupByVariable `json:"groupBy,omitempty"` + MatchConditions []MatchCondition `json:"matchConditions"` + Name *string `json:"name,omitempty"` + Priority int64 `json:"priority"` + RateLimitDurationInMinutes *int64 `json:"rateLimitDurationInMinutes,omitempty"` + RateLimitThreshold *int64 `json:"rateLimitThreshold,omitempty"` + RuleType RuleType `json:"ruleType"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_customrulelist.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_customrulelist.go new file mode 100644 index 000000000000..4af1175aedfa --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_customrulelist.go @@ -0,0 +1,8 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomRuleList struct { + Rules *[]CustomRule `json:"rules,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_frontendendpointlink.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_frontendendpointlink.go new file mode 100644 index 000000000000..4912c45c4479 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_frontendendpointlink.go @@ -0,0 +1,8 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendEndpointLink struct { + Id *string `json:"id,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_groupbyvariable.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_groupbyvariable.go new file mode 100644 index 000000000000..914c2ffb2b6f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_groupbyvariable.go @@ -0,0 +1,8 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GroupByVariable struct { + VariableName VariableName `json:"variableName"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_managedruleexclusion.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_managedruleexclusion.go new file mode 100644 index 000000000000..61fe93748f11 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_managedruleexclusion.go @@ -0,0 +1,10 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedRuleExclusion struct { + MatchVariable ManagedRuleExclusionMatchVariable `json:"matchVariable"` + Selector string `json:"selector"` + SelectorMatchOperator ManagedRuleExclusionSelectorMatchOperator `json:"selectorMatchOperator"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_managedrulegroupoverride.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_managedrulegroupoverride.go new file mode 100644 index 000000000000..b6fb2b34e9e0 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_managedrulegroupoverride.go @@ -0,0 +1,10 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedRuleGroupOverride struct { + Exclusions *[]ManagedRuleExclusion `json:"exclusions,omitempty"` + RuleGroupName string `json:"ruleGroupName"` + Rules *[]ManagedRuleOverride `json:"rules,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_managedruleoverride.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_managedruleoverride.go new file mode 100644 index 000000000000..0161ef1d4614 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_managedruleoverride.go @@ -0,0 +1,11 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedRuleOverride struct { + Action *ActionType `json:"action,omitempty"` + EnabledState *ManagedRuleEnabledState `json:"enabledState,omitempty"` + Exclusions *[]ManagedRuleExclusion `json:"exclusions,omitempty"` + RuleId string `json:"ruleId"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_managedruleset.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_managedruleset.go new file mode 100644 index 000000000000..52b00b82e6a2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_managedruleset.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedRuleSet struct { + Exclusions *[]ManagedRuleExclusion `json:"exclusions,omitempty"` + RuleGroupOverrides *[]ManagedRuleGroupOverride `json:"ruleGroupOverrides,omitempty"` + RuleSetAction *ManagedRuleSetActionType `json:"ruleSetAction,omitempty"` + RuleSetType string `json:"ruleSetType"` + RuleSetVersion string `json:"ruleSetVersion"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_managedrulesetlist.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_managedrulesetlist.go new file mode 100644 index 000000000000..f15de67cc0c2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_managedrulesetlist.go @@ -0,0 +1,8 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedRuleSetList struct { + ManagedRuleSets *[]ManagedRuleSet `json:"managedRuleSets,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_matchcondition.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_matchcondition.go new file mode 100644 index 000000000000..b39cb7d4f89b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_matchcondition.go @@ -0,0 +1,13 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MatchCondition struct { + MatchValue []string `json:"matchValue"` + MatchVariable MatchVariable `json:"matchVariable"` + NegateCondition *bool `json:"negateCondition,omitempty"` + Operator Operator `json:"operator"` + Selector *string `json:"selector,omitempty"` + Transforms *[]TransformType `json:"transforms,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_policysettings.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_policysettings.go new file mode 100644 index 000000000000..ed2343a24c72 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_policysettings.go @@ -0,0 +1,15 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicySettings struct { + CustomBlockResponseBody *string `json:"customBlockResponseBody,omitempty"` + CustomBlockResponseStatusCode *int64 `json:"customBlockResponseStatusCode,omitempty"` + EnabledState *PolicyEnabledState `json:"enabledState,omitempty"` + JavascriptChallengeExpirationInMinutes *int64 `json:"javascriptChallengeExpirationInMinutes,omitempty"` + LogScrubbing *PolicySettingsLogScrubbing `json:"logScrubbing,omitempty"` + Mode *PolicyMode `json:"mode,omitempty"` + RedirectURL *string `json:"redirectUrl,omitempty"` + RequestBodyCheck *PolicyRequestBodyCheck `json:"requestBodyCheck,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_policysettingslogscrubbing.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_policysettingslogscrubbing.go new file mode 100644 index 000000000000..a97418be8671 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_policysettingslogscrubbing.go @@ -0,0 +1,9 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicySettingsLogScrubbing struct { + ScrubbingRules *[]WebApplicationFirewallScrubbingRules `json:"scrubbingRules,omitempty"` + State *WebApplicationFirewallScrubbingState `json:"state,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_routingrulelink.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_routingrulelink.go new file mode 100644 index 000000000000..4f63c00b70ce --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_routingrulelink.go @@ -0,0 +1,8 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutingRuleLink struct { + Id *string `json:"id,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_securitypolicylink.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_securitypolicylink.go new file mode 100644 index 000000000000..81251da5f8cb --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_securitypolicylink.go @@ -0,0 +1,8 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityPolicyLink struct { + Id *string `json:"id,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_sku.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_sku.go new file mode 100644 index 000000000000..2a73ceadea6a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_sku.go @@ -0,0 +1,8 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Sku struct { + Name *SkuName `json:"name,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_tagsobject.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_tagsobject.go new file mode 100644 index 000000000000..6ebacbb7cf10 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_tagsobject.go @@ -0,0 +1,8 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_webapplicationfirewallpolicy.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_webapplicationfirewallpolicy.go new file mode 100644 index 000000000000..bbfecce16c96 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_webapplicationfirewallpolicy.go @@ -0,0 +1,15 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebApplicationFirewallPolicy struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *WebApplicationFirewallPolicyProperties `json:"properties,omitempty"` + Sku *Sku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_webapplicationfirewallpolicyproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_webapplicationfirewallpolicyproperties.go new file mode 100644 index 000000000000..1d45210a4c00 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_webapplicationfirewallpolicyproperties.go @@ -0,0 +1,15 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebApplicationFirewallPolicyProperties struct { + CustomRules *CustomRuleList `json:"customRules,omitempty"` + FrontendEndpointLinks *[]FrontendEndpointLink `json:"frontendEndpointLinks,omitempty"` + ManagedRules *ManagedRuleSetList `json:"managedRules,omitempty"` + PolicySettings *PolicySettings `json:"policySettings,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + ResourceState *PolicyResourceState `json:"resourceState,omitempty"` + RoutingRuleLinks *[]RoutingRuleLink `json:"routingRuleLinks,omitempty"` + SecurityPolicyLinks *[]SecurityPolicyLink `json:"securityPolicyLinks,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_webapplicationfirewallscrubbingrules.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_webapplicationfirewallscrubbingrules.go new file mode 100644 index 000000000000..b3d3f6dd209d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/model_webapplicationfirewallscrubbingrules.go @@ -0,0 +1,11 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebApplicationFirewallScrubbingRules struct { + MatchVariable ScrubbingRuleEntryMatchVariable `json:"matchVariable"` + Selector *string `json:"selector,omitempty"` + SelectorMatchOperator ScrubbingRuleEntryMatchOperator `json:"selectorMatchOperator"` + State *ScrubbingRuleEntryState `json:"state,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/predicates.go new file mode 100644 index 000000000000..a7973b0a14fb --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/predicates.go @@ -0,0 +1,37 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebApplicationFirewallPolicyOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p WebApplicationFirewallPolicyOperationPredicate) Matches(input WebApplicationFirewallPolicy) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/version.go new file mode 100644 index 000000000000..be660aa76002 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies/version.go @@ -0,0 +1,10 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-02-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/webapplicationfirewallpolicies/2024-02-01" +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 3b8df9023da3..11a629819387 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -544,6 +544,7 @@ github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidre github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2020-04-01/webapplicationfirewallpolicies github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2020-05-01/frontdoors +github.com/hashicorp/go-azure-sdk/resource-manager/frontdoor/2024-02-01/webapplicationfirewallpolicies github.com/hashicorp/go-azure-sdk/resource-manager/graphservices/2023-04-13 github.com/hashicorp/go-azure-sdk/resource-manager/graphservices/2023-04-13/graphservicesprods github.com/hashicorp/go-azure-sdk/resource-manager/guestconfiguration/2020-06-25/guestconfigurationassignments From 9c8e9a080eac95d4f9fd2965a7cf19773f4b87d0 Mon Sep 17 00:00:00 2001 From: Jeffrey Cline <20408400+WodansSon@users.noreply.github.com> Date: Tue, 3 Dec 2024 02:46:01 -0700 Subject: [PATCH 2/2] Fix lint errors and remove dependencies on utils package... --- .../cdn_frontdoor_firewall_policy_resource.go | 25 ++++++++-------- .../services/cdn/cdn_frontdoor_helpers.go | 29 ------------------- 2 files changed, 12 insertions(+), 42 deletions(-) diff --git a/internal/services/cdn/cdn_frontdoor_firewall_policy_resource.go b/internal/services/cdn/cdn_frontdoor_firewall_policy_resource.go index b8dbbacd8a56..2abae70611d7 100644 --- a/internal/services/cdn/cdn_frontdoor_firewall_policy_resource.go +++ b/internal/services/cdn/cdn_frontdoor_firewall_policy_resource.go @@ -21,7 +21,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func resourceCdnFrontDoorFirewallPolicy() *pluginsdk.Resource { @@ -506,7 +505,7 @@ func resourceCdnFrontDoorFirewallPolicyCreate(d *pluginsdk.ResourceData, meta in t := d.Get("tags").(map[string]interface{}) payload := waf.WebApplicationFirewallPolicy{ - Location: utils.String(location.Normalize("Global")), + Location: pointer.To(location.Normalize("Global")), Sku: &waf.Sku{ Name: pointer.To(waf.SkuName(sku)), }, @@ -527,15 +526,15 @@ func resourceCdnFrontDoorFirewallPolicyCreate(d *pluginsdk.ResourceData, meta in } if redirectUrl != "" { - payload.Properties.PolicySettings.RedirectURL = utils.String(redirectUrl) + payload.Properties.PolicySettings.RedirectURL = pointer.To(redirectUrl) } if customBlockResponseBody != "" { - payload.Properties.PolicySettings.CustomBlockResponseBody = utils.String(customBlockResponseBody) + payload.Properties.PolicySettings.CustomBlockResponseBody = pointer.To(customBlockResponseBody) } if customBlockResponseStatusCode > 0 { - payload.Properties.PolicySettings.CustomBlockResponseStatusCode = utils.Int64(int64(customBlockResponseStatusCode)) + payload.Properties.PolicySettings.CustomBlockResponseStatusCode = pointer.To(int64(customBlockResponseStatusCode)) } err = client.PoliciesCreateOrUpdateThenPoll(ctx, id, payload) @@ -595,15 +594,15 @@ func resourceCdnFrontDoorFirewallPolicyUpdate(d *pluginsdk.ResourceData, meta in }) if redirectUrl := d.Get("redirect_url").(string); redirectUrl != "" { - props.PolicySettings.RedirectURL = utils.String(redirectUrl) + props.PolicySettings.RedirectURL = pointer.To(redirectUrl) } if body := d.Get("custom_block_response_body").(string); body != "" { - props.PolicySettings.CustomBlockResponseBody = utils.String(body) + props.PolicySettings.CustomBlockResponseBody = pointer.To(body) } if statusCode := d.Get("custom_block_response_status_code").(int64); statusCode > 0 { - props.PolicySettings.CustomBlockResponseStatusCode = utils.Int64(int64(statusCode)) + props.PolicySettings.CustomBlockResponseStatusCode = pointer.To(statusCode) } } @@ -755,12 +754,12 @@ func expandCdnFrontDoorFirewallCustomRules(input []interface{}) *waf.CustomRuleL action := custom["action"].(string) output = append(output, waf.CustomRule{ - Name: utils.String(name), + Name: pointer.To(name), Priority: priority, EnabledState: pointer.To(enabled), RuleType: waf.RuleType(ruleType), - RateLimitDurationInMinutes: utils.Int64(rateLimitDurationInMinutes), - RateLimitThreshold: utils.Int64(rateLimitThreshold), + RateLimitDurationInMinutes: pointer.To(rateLimitDurationInMinutes), + RateLimitThreshold: pointer.To(rateLimitThreshold), MatchConditions: matchConditions, Action: waf.ActionType(action), }) @@ -798,7 +797,7 @@ func expandCdnFrontDoorFirewallMatchConditions(input []interface{}) []waf.MatchC matchCondition.MatchVariable = waf.MatchVariable(matchVariable) } if selector != "" { - matchCondition.Selector = utils.String(selector) + matchCondition.Selector = pointer.To(selector) } result = append(result, matchCondition) @@ -985,7 +984,7 @@ func flattenCdnFrontDoorFirewallCustomRules(input *waf.CustomRuleList) []interfa priority := 0 if v.Priority != 0 { - priority = int(int(v.Priority)) + priority = int(v.Priority) } rateLimitDurationInMinutes := 0 diff --git a/internal/services/cdn/cdn_frontdoor_helpers.go b/internal/services/cdn/cdn_frontdoor_helpers.go index 0eabbd7fc0a8..fb2870744e8b 100644 --- a/internal/services/cdn/cdn_frontdoor_helpers.go +++ b/internal/services/cdn/cdn_frontdoor_helpers.go @@ -109,35 +109,6 @@ func flattenHttpsRedirectToBool(input cdn.HTTPSRedirect) bool { return input == cdn.HTTPSRedirectEnabled } -func expandFrontDoorTags(tagMap *map[string]string) map[string]*string { - t := make(map[string]*string) - - if tagMap != nil { - for k, v := range *tagMap { - tagKey := k - tagValue := v - t[tagKey] = &tagValue - } - } - - return t -} - -func flattenFrontDoorTags(tagMap map[string]*string) *map[string]string { - t := make(map[string]string) - - for k, v := range tagMap { - tagKey := k - tagValue := v - if tagValue == nil { - continue - } - t[tagKey] = *tagValue - } - - return &t -} - func flattenTransformSlice(input *[]waf.TransformType) []interface{} { result := make([]interface{}, 0) if input == nil || len(*input) == 0 {