Skip to content

Commit

Permalink
feature: add tenant ids to webhook (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
Allen-Ning authored and robotdan committed Oct 26, 2022
1 parent 97b6c0f commit 968eab6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
7 changes: 6 additions & 1 deletion docs/resources/webhook.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ A FusionAuth Webhook is intended to consume JSON events emitted by FusionAuth. C

```hcl
resource "fusionauth_webhook" "example" {
tenant_ids = [
"00000000-0000-0000-0000-000000000003",
fusionauth_tenant.example.id
]
connect_timeout = 1000
description = "The standard game Webhook"
events_enabled {
Expand All @@ -27,6 +31,7 @@ resource "fusionauth_webhook" "example" {
```

## Argument Reference
* `tenant_ids` - (Optional) The Ids of the tenants that this Webhook should be associated with. If no Ids are specified and the global field is false, this Webhook will not be used.
* `connect_timeout` - (Required) The connection timeout in milliseconds used when FusionAuth sends events to the Webhook.
* `description` - (Optional) A description of the Webhook. This is used for display purposes only.
* `events_enabled` - (Optional) A mapping for the events that are enabled for this Webhook.
Expand Down Expand Up @@ -76,4 +81,4 @@ resource "fusionauth_webhook" "example" {
* `http_authentication_username` -(Optional) The HTTP basic authentication username that is sent as part of the HTTP request for the events.
* `read_timeout` - (Required) The read timeout in milliseconds used when FusionAuth sends events to the Webhook.
* `ssl_certificate` - (Optional) An SSL certificate in PEM format that is used to establish the a SSL (TLS specifically) connection to the Webhook.
* `url` - (Required) The fully qualified URL of the Webhook’s endpoint that will accept the event requests from FusionAuth.
* `url` - (Required) The fully qualified URL of the Webhook’s endpoint that will accept the event requests from FusionAuth.
10 changes: 10 additions & 0 deletions fusionauth/resource_fusionauth_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ func newWebhook() *schema.Resource {
UpdateContext: updateWebhook,
DeleteContext: deleteWebhook,
Schema: map[string]*schema.Schema{
"tenant_ids": {
Type: schema.TypeSet,
Elem: &schema.Schema{Type: schema.TypeString},
Optional: true,
Description: "The Ids of the Tenants that this Webhook should be associated with. If no Ids are specified and the global field is false, this Webhook will not be used.",
},
"connect_timeout": {
Type: schema.TypeInt,
Required: true,
Expand Down Expand Up @@ -282,6 +288,7 @@ func newWebhook() *schema.Resource {

func buildWebhook(data *schema.ResourceData) fusionauth.Webhook {
wh := fusionauth.Webhook{
TenantIds: handleStringSlice("tenant_ids", data),
ConnectTimeout: data.Get("connect_timeout").(int),
Description: data.Get("description").(string),
EventsEnabled: buildEventsEnabled("events_enabled", data),
Expand Down Expand Up @@ -380,6 +387,9 @@ func readWebhook(_ context.Context, data *schema.ResourceData, i interface{}) di
}

l := resp.Webhook
if err := data.Set("tenant_ids", l.TenantIds); err != nil {
return diag.Errorf("webhook.tenant_ids: %s", err.Error())
}
if err := data.Set("connect_timeout", l.ConnectTimeout); err != nil {
return diag.Errorf("webhook.connect_timeout: %s", err.Error())
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/gpsinsight/terraform-provider-fusionauth
go 1.18

require (
github.com/FusionAuth/go-client v0.0.0-20220927000356-028dacca67f0
github.com/FusionAuth/go-client v0.0.0-20220928202602-4f85e4f2101f
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
github.com/hashicorp/go-uuid v1.0.3
github.com/hashicorp/terraform-plugin-sdk/v2 v2.14.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/FusionAuth/go-client v0.0.0-20220429153148-63e95adfac4e h1:1GkB6QE01BlB7+OCwWBBiUM/xBqMA5vpFgr7C/fF2ck=
github.com/FusionAuth/go-client v0.0.0-20220429153148-63e95adfac4e/go.mod h1:SyRrXMJAzMVQLiJjKfQUR59dRI3jPyZv+BXIZ//HwE4=
github.com/FusionAuth/go-client v0.0.0-20220927000356-028dacca67f0 h1:gV0qAy8Su8r4pOJxj6uZ/qqycVhW6uU8tUMSkOcgr+s=
github.com/FusionAuth/go-client v0.0.0-20220927000356-028dacca67f0/go.mod h1:SyRrXMJAzMVQLiJjKfQUR59dRI3jPyZv+BXIZ//HwE4=
github.com/FusionAuth/go-client v0.0.0-20220928202602-4f85e4f2101f h1:a7M72XffsaShvWiJVyCMEXzXJWVU9GzkUrDxVaxlFnQ=
github.com/FusionAuth/go-client v0.0.0-20220928202602-4f85e4f2101f/go.mod h1:SyRrXMJAzMVQLiJjKfQUR59dRI3jPyZv+BXIZ//HwE4=
github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA=
github.com/Microsoft/go-winio v0.4.16 h1:FtSW/jqD+l4ba5iPBj9CODVtgfYAD8w2wS923g/cFDk=
github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0=
Expand Down

0 comments on commit 968eab6

Please sign in to comment.