Skip to content

Commit

Permalink
Merge pull request #84 from signalsciences/requestlogging
Browse files Browse the repository at this point in the history
add requestlogging attribute to site rule
  • Loading branch information
shawnps authored Nov 29, 2022
2 parents 2040d86 + 26d6a8d commit 9a98bb6
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 17 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.17
require (
github.com/davecgh/go-spew v1.1.1
github.com/hashicorp/terraform-plugin-sdk v1.14.0
github.com/signalsciences/go-sigsci v0.1.7
github.com/signalsciences/go-sigsci v0.1.8
)

require (
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,8 @@ github.com/posener/complete v1.2.1/go.mod h1:6gapUrK/U1TAN7ciCoNRIdVC5sbdBTUh1DK
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/signalsciences/go-sigsci v0.1.6 h1:O3v1kQOA00d+HO4pD8ykymouojBe02bYy0gj15ow8jA=
github.com/signalsciences/go-sigsci v0.1.6/go.mod h1:9eUL/FIXlslxnqtsf0yk67CSBiYdL4ToYjYybzWQ77A=
github.com/signalsciences/go-sigsci v0.1.7 h1:86Avjmn5Kg5QZIqR9LBqvSHr7sUpR07c59GSTG4AocQ=
github.com/signalsciences/go-sigsci v0.1.7/go.mod h1:9eUL/FIXlslxnqtsf0yk67CSBiYdL4ToYjYybzWQ77A=
github.com/signalsciences/go-sigsci v0.1.8 h1:vTWe3beT9lsaWnvoPsItPspk/9tKriDjeAJTruC4oo4=
github.com/signalsciences/go-sigsci v0.1.8/go.mod h1:9eUL/FIXlslxnqtsf0yk67CSBiYdL4ToYjYybzWQ77A=
github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc=
github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
Expand Down
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ resource "sigsci_site_rule" "test" {
reason = "Example site rule update"
signal = "SQLI"
expiration = ""
requestlogging = "sampled"

conditions {
type = "single"
Expand Down
35 changes: 23 additions & 12 deletions provider/resource_site_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ func resourceSiteRule() *schema.Resource {
Description: "Date the rule will automatically be disabled. If rule is always enabled, will return empty string",
Required: true,
},
"requestlogging": {
Type: schema.TypeString,
Description: "Indicates whether to store the logs for requests that match the rule's conditions (sampled) or not store them (none). This field is only available for request rules that have a block or allow action.",
Required: false,
},
"actions": {
Type: schema.TypeSet,
Description: "Actions",
Expand Down Expand Up @@ -224,12 +229,13 @@ func resourceSiteRuleCreate(d *schema.ResourceData, m interface{}) error {
site := d.Get("site_short_name").(string)

siteRulesBody := sigsci.CreateSiteRuleBody{
Type: d.Get("type").(string),
GroupOperator: d.Get("group_operator").(string),
Enabled: d.Get("enabled").(bool),
Reason: d.Get("reason").(string),
Signal: d.Get("signal").(string),
Expiration: d.Get("expiration").(string),
Type: d.Get("type").(string),
GroupOperator: d.Get("group_operator").(string),
Enabled: d.Get("enabled").(bool),
Reason: d.Get("reason").(string),
Signal: d.Get("signal").(string),
Expiration: d.Get("expiration").(string),
RequestLogging: d.Get("requestlogging").(string),
}

siteRulesBody.Conditions = expandRuleConditions(d.Get("conditions").(*schema.Set))
Expand Down Expand Up @@ -290,6 +296,10 @@ func resourceSiteRuleRead(d *schema.ResourceData, m interface{}) error {
if err != nil {
return err
}
err = d.Set("requestlogging", rule.RequestLogging)
if err != nil {
return err
}
err = d.Set("actions", flattenRuleActions(rule.Actions, true))
if err != nil {
return err
Expand All @@ -313,12 +323,13 @@ func resourceSiteRuleUpdate(d *schema.ResourceData, m interface{}) error {
site := d.Get("site_short_name").(string)

updateSiteRuleBody := sigsci.CreateSiteRuleBody{
Type: d.Get("type").(string),
GroupOperator: d.Get("group_operator").(string),
Enabled: d.Get("enabled").(bool),
Reason: d.Get("reason").(string),
Signal: d.Get("signal").(string),
Expiration: d.Get("expiration").(string),
Type: d.Get("type").(string),
GroupOperator: d.Get("group_operator").(string),
Enabled: d.Get("enabled").(bool),
Reason: d.Get("reason").(string),
Signal: d.Get("signal").(string),
Expiration: d.Get("expiration").(string),
RequestLogging: d.Get("requestlogging").(string),
}

updateSiteRuleBody.Conditions = expandRuleConditions(d.Get("conditions").(*schema.Set))
Expand Down

0 comments on commit 9a98bb6

Please sign in to comment.