Skip to content

Commit

Permalink
Update resources to match latest SDK.
Browse files Browse the repository at this point in the history
  • Loading branch information
steveworley committed Dec 13, 2024
1 parent 5253ac3 commit a84e35a
Show file tree
Hide file tree
Showing 12 changed files with 643 additions and 312 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ _testmain.go
*.test
*.prof
terraform.tfstate*

openapi.yaml
spec.json
28 changes: 28 additions & 0 deletions docs/resources/crawler.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Crawler Resource

Provides a crawler resource to manage crawlers in Quant.

## Example Usage

```hcl
resource "quant_crawler" "crawler" {
project = quant_project.test.machine_name
name = "test-crawler"
domain = "example.com"
urls = ["/"]
browser_mode = false
exclude = ["/admin"]
headers = {
"X-Header" = "value"
}
}
```

## Argument Reference

- `project` - (Required) The machine name of the project.
- `name` - (Required) The name of the crawler.
- `domain` - (Required) The domain to apply the crawler to.
- `urls` - (Required) The URLs to apply the crawler to.
- `browser_mode` - (Required) Whether to use browser mode.
- `exclude` - (Required) The URLs to exclude from the crawler.
28 changes: 28 additions & 0 deletions docs/resources/crawler_schedule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Crawler Schedule Resource

Manages a Quant crawler schedule.

## Example Usage

```hcl
resource "quant_crawler_schedule" "crawler_schedule" {
project = quant_project.test.machine_name
crawler = quant_crawler.crawler.uuid
schedule_cron_string = "0 0 * * *"
}
```

## Argument Reference

- `project` - (Required) The machine name of the project.
- `crawler` - (Required) The UUID of the crawler.
- `schedule_cron_string` - (Required) The cron string to schedule the crawler.

## Attributes Reference

- `id` - The ID of the crawler schedule.
- `crawler_config_id` - The ID of the crawler configuration.
- `project_id` - The ID of the project.
- `crawler_last_run_id` - The ID of the last crawler run.
- `schedule_cron_string` - The cron string to schedule the crawler.
- `created_at` - The date and time the crawler schedule was created.
41 changes: 41 additions & 0 deletions docs/resources/rule_proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,21 @@ resource "quant_rule_proxy" "test" {
project = quant_project.test.machine_name
domain = ["any"]
url = ["/proxy"]
country = "country_is"
country_is = ["US", "CA"]
method = "method_is"
method_is = ["GET", "POST"]
ip = "ip_is"
ip_is = ["192.168.1.1", "192.168.1.2"]
proxy = {
to = "https://backend.example.com"
host = "backend.example.com"
}
failover = {
failover_mode = "true"
failover_lifetime = "1h"
failover_origin_status_codes = ["200", "201"]
}
waf_enabled = true
waf_config = {
mode = "report"
Expand All @@ -27,9 +38,39 @@ resource "quant_rule_proxy" "test" {
enabled = false
}
}
notify = "slack"
notify_config = {
origin_status_codes = ["200", "201"]
period = "60"
slack_webhook = "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"
}
thresholds = [{
cooldown = 60
hits = 10
minutes = 1
mode = "block"
notify_slack = "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"
rps = 1000
type = "block"
value = "192.168.1.1"
}]
}
```

## Rule Selection Criteria

The following parameters are used to inspect the request and determine if the rule should be applied.

- `country` - Should be `country_is` or `country_is_not`. This tells the rules engine which variable to inspect when applying the rule.
- `country_is` - A list of country codes to match.
- `country_is_not` - A list of country codes to not match.
- `ip` - Should be `ip_is` or `ip_is_not`. This tells the rules engine which variable to inspect when applying the rule.
- `ip_is` - A list of IP addresses to match.
- `ip_is_not` - A list of IP addresses to not match.
- `method` - AnyOf `method_is` or `method_is_not`. This tells the rules engine which variable to inspect when applying the rule.
- `method_is` - A list of HTTP methods to match.
- `method_is_not` - A list of HTTP methods to not match.

## Argument Reference

- `name` - (Required) The name of the rule.
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/hashicorp/terraform-plugin-go v0.25.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.35.0
github.com/hashicorp/terraform-plugin-testing v1.11.0
github.com/quantcdn/quant-admin-go v0.0.0-20241115034118-d5bee8cc24e8
github.com/quantcdn/quant-admin-go v0.0.0-20241213023303-ad9791a191a1
github.com/stretchr/testify v1.9.0
)

Expand Down Expand Up @@ -66,5 +66,6 @@ require (
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect
google.golang.org/grpc v1.67.1 // indirect
google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit a84e35a

Please sign in to comment.