From 186e9728fd6ccbb1c0537eb62ad6eb1012ecb73c Mon Sep 17 00:00:00 2001 From: Michael Borkenstein Date: Tue, 21 Dec 2021 12:26:09 -0600 Subject: [PATCH] GATE-2273: Adds support for device posture gateway rules --- cloudflare/resource_cloudflare_teams_rules.go | 43 +++++++++++-------- cloudflare/schema_cloudflare_teams_rules.go | 4 ++ website/docs/r/teams_rule.html.markdown | 1 + 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/cloudflare/resource_cloudflare_teams_rules.go b/cloudflare/resource_cloudflare_teams_rules.go index 2d3153dd88a..0a674c76263 100644 --- a/cloudflare/resource_cloudflare_teams_rules.go +++ b/cloudflare/resource_cloudflare_teams_rules.go @@ -60,6 +60,9 @@ func resourceCloudflareTeamsRuleRead(d *schema.ResourceData, meta interface{}) e if err := d.Set("identity", rule.Identity); err != nil { return fmt.Errorf("error parsing rule identity") } + if err := d.Set("device_posture", rule.DevicePosture); err != nil { + return fmt.Errorf("error parsing rule device_posture") + } if err := d.Set("version", int64(rule.Version)); err != nil { return fmt.Errorf("error parsing rule version") } @@ -81,15 +84,16 @@ func resourceCloudflareTeamsRuleCreate(d *schema.ResourceData, meta interface{}) } newTeamsRule := cloudflare.TeamsRule{ - Name: d.Get("name").(string), - Description: d.Get("description").(string), - Precedence: uint64(d.Get("precedence").(int)), - Enabled: d.Get("enabled").(bool), - Action: cloudflare.TeamsGatewayAction(d.Get("action").(string)), - Filters: filters, - Traffic: d.Get("traffic").(string), - Identity: d.Get("identity").(string), - Version: uint64(d.Get("version").(int)), + Name: d.Get("name").(string), + Description: d.Get("description").(string), + Precedence: uint64(d.Get("precedence").(int)), + Enabled: d.Get("enabled").(bool), + Action: cloudflare.TeamsGatewayAction(d.Get("action").(string)), + Filters: filters, + Traffic: d.Get("traffic").(string), + Identity: d.Get("identity").(string), + DevicePosture: d.Get("device_posture").(string), + Version: uint64(d.Get("version").(int)), } if settings != nil { @@ -118,16 +122,17 @@ func resourceCloudflareTeamsRuleUpdate(d *schema.ResourceData, meta interface{}) } teamsRule := cloudflare.TeamsRule{ - ID: d.Id(), - Name: d.Get("name").(string), - Description: d.Get("description").(string), - Precedence: uint64(d.Get("precedence").(int)), - Enabled: d.Get("enabled").(bool), - Action: cloudflare.TeamsGatewayAction(d.Get("action").(string)), - Filters: filters, - Traffic: d.Get("traffic").(string), - Identity: d.Get("identity").(string), - Version: uint64(d.Get("version").(int)), + ID: d.Id(), + Name: d.Get("name").(string), + Description: d.Get("description").(string), + Precedence: uint64(d.Get("precedence").(int)), + Enabled: d.Get("enabled").(bool), + Action: cloudflare.TeamsGatewayAction(d.Get("action").(string)), + Filters: filters, + Traffic: d.Get("traffic").(string), + Identity: d.Get("identity").(string), + DevicePosture: d.Get("device_posture").(string), + Version: uint64(d.Get("version").(int)), } if settings != nil { diff --git a/cloudflare/schema_cloudflare_teams_rules.go b/cloudflare/schema_cloudflare_teams_rules.go index cdc9620d5cf..ecc30e61726 100644 --- a/cloudflare/schema_cloudflare_teams_rules.go +++ b/cloudflare/schema_cloudflare_teams_rules.go @@ -46,6 +46,10 @@ func resourceCloudflareTeamsRuleSchema() map[string]*schema.Schema { Type: schema.TypeString, Optional: true, }, + "device_posture": { + Type: schema.TypeString, + Optional: true, + }, "version": { Type: schema.TypeInt, Computed: true, diff --git a/website/docs/r/teams_rule.html.markdown b/website/docs/r/teams_rule.html.markdown index c83649ecf78..b51626a7840 100644 --- a/website/docs/r/teams_rule.html.markdown +++ b/website/docs/r/teams_rule.html.markdown @@ -45,6 +45,7 @@ The following arguments are supported: * `filters` - (Optional) The protocol or layer to evaluate the traffic and identity expressions. * `traffic` - (Optional) The wirefilter expression to be used for traffic matching. * `identity` - (Optional) The wirefilter expression to be used for identity matching. +* `device_posture` - (Optional) The wirefilter expression to be used for device_posture check matching. * `rule_settings` - (Optional) Additional rule settings. The **rule_settings** block supports: