Skip to content

Commit

Permalink
feat: Update to Hookdeck Go SDK v0.0.37 and support more source verif…
Browse files Browse the repository at this point in the history
…ications (#28)

* chore: Update Hookdeck Go SDK to v0.0.37

* fix: Rename "archived" to "disabled"

* fix: Update source verification change in SDK

* fix: Update source verification config naming convention

* fix: Remove default API base URL

For some reason, the default api.hookdeck.com URL without versioning is running into an issue. I'm removing that from the provider and instead use the latest version from the SDK instead. If people wants to override this value, it's recommended that they include the versioning in their base URL as well.

* chore: Add optional to disabled_at field

* fix: Include type to Verification payload

* fix: Recharge source verification

* feat: Add new source verifications

* docs: Generate docs

* feat: Add JSON source verification

* docs: Generate docs

* lint: Add error handling around JSON unmarshalling
  • Loading branch information
alexluong authored Apr 22, 2024
1 parent 5f7ce30 commit 4f8f6f6
Show file tree
Hide file tree
Showing 71 changed files with 631 additions and 107 deletions.
2 changes: 1 addition & 1 deletion docs/guides/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ Terraform will perform the following actions:
+ "PATCH",
+ "DELETE",
]
+ archived_at = (known after apply)
+ created_at = (known after apply)
+ disabled_at = (known after apply)
+ id = (known after apply)
+ name = "my_source"
+ team_id = (known after apply)
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ resource "hookdeck_connection" "connection" {

### Optional

- `api_base` (String) Hookdeck API Base URL. Alternatively, can be configured using the `HOOKDECK_API_BASE` environment variable. (default: https://api.hookdeck.com)
- `api_base` (String) Hookdeck API Base URL. Alternatively, can be configured using the `HOOKDECK_API_BASE` environment variable.
- `api_key` (String, Sensitive) Hookdeck API Key. Alternatively, can be configured using the `HOOKDECK_API_KEY` environment variable.
2 changes: 1 addition & 1 deletion docs/resources/connection.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ resource "hookdeck_connection" "connection_example" {
### Optional

- `description` (String) Description for the connection
- `disabled_at` (String) Date the connection was disabled
- `name` (String) A unique, human-friendly name for the connection
- `rules` (Attributes List) (see [below for nested schema](#nestedatt--rules))

### Read-Only

- `archived_at` (String) Date the connection was archived
- `created_at` (String) Date the connection was created
- `id` (String) ID of the connection
- `paused_at` (String) Date the connection was paused
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/destination.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ resource "hookdeck_destination" "example" {
- `auth_method` (Attributes) Config for the destination's auth method (see [below for nested schema](#nestedatt--auth_method))
- `cli_path` (String) Path for the CLI destination
- `description` (String) Description for the destination
- `disabled_at` (String) Date the destination was disabled
- `http_method` (String) must be one of ["GET", "POST", "PUT", "PATCH", "DELETE"]
HTTP method used on requests sent to the destination, overrides the method used on requests sent to the source.
- `path_forwarding_disabled` (Boolean)
Expand All @@ -51,7 +52,6 @@ HTTP method used on requests sent to the destination, overrides the method used

### Read-Only

- `archived_at` (String) Date the destination was archived
- `created_at` (String) Date the destination was created
- `id` (String) ID of the destination
- `team_id` (String) ID of the workspace
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/source.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ resource "hookdeck_source" "example" {
- `allowed_http_methods` (List of String) List of allowed HTTP methods. Defaults to PUT, POST, PATCH, DELETE.
- `custom_response` (Attributes) Custom response object (see [below for nested schema](#nestedatt--custom_response))
- `description` (String) Description for the source
- `disabled_at` (String) Date the source was disabled

### Read-Only

- `archived_at` (String) Date the source was archived
- `created_at` (String) Date the source was created
- `id` (String) ID of the source
- `team_id` (String) ID of the workspace
Expand Down
89 changes: 89 additions & 0 deletions docs/resources/source_verification.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,38 @@ Optional:
- `cloudsignal` (Attributes) (see [below for nested schema](#nestedatt--verification--cloudsignal))
- `commercelayer` (Attributes) (see [below for nested schema](#nestedatt--verification--commercelayer))
- `courier` (Attributes) (see [below for nested schema](#nestedatt--verification--courier))
- `ebay` (Attributes) (see [below for nested schema](#nestedatt--verification--ebay))
- `enode` (Attributes) (see [below for nested schema](#nestedatt--verification--enode))
- `favro` (Attributes) (see [below for nested schema](#nestedatt--verification--favro))
- `frontapp` (Attributes) (see [below for nested schema](#nestedatt--verification--frontapp))
- `github` (Attributes) (see [below for nested schema](#nestedatt--verification--github))
- `gitlab` (Attributes) (see [below for nested schema](#nestedatt--verification--gitlab))
- `hmac` (Attributes) (see [below for nested schema](#nestedatt--verification--hmac))
- `json` (String)
- `linear` (Attributes) (see [below for nested schema](#nestedatt--verification--linear))
- `mailgun` (Attributes) (see [below for nested schema](#nestedatt--verification--mailgun))
- `nmi` (Attributes) (see [below for nested schema](#nestedatt--verification--nmi))
- `orb` (Attributes) (see [below for nested schema](#nestedatt--verification--orb))
- `oura` (Attributes) (see [below for nested schema](#nestedatt--verification--oura))
- `persona` (Attributes) (see [below for nested schema](#nestedatt--verification--persona))
- `pipedrive` (Attributes) (see [below for nested schema](#nestedatt--verification--pipedrive))
- `postmark` (Attributes) (see [below for nested schema](#nestedatt--verification--postmark))
- `property_finder` (Attributes) (see [below for nested schema](#nestedatt--verification--property_finder))
- `pylon` (Attributes) (see [below for nested schema](#nestedatt--verification--pylon))
- `recharge` (Attributes) (see [below for nested schema](#nestedatt--verification--recharge))
- `repay` (Attributes) (see [below for nested schema](#nestedatt--verification--repay))
- `sanity` (Attributes) (see [below for nested schema](#nestedatt--verification--sanity))
- `sendgrid` (Attributes) (see [below for nested schema](#nestedatt--verification--sendgrid))
- `shopify` (Attributes) (see [below for nested schema](#nestedatt--verification--shopify))
- `shopline` (Attributes) (see [below for nested schema](#nestedatt--verification--shopline))
- `solidgate` (Attributes) (see [below for nested schema](#nestedatt--verification--solidgate))
- `square` (Attributes) (see [below for nested schema](#nestedatt--verification--square))
- `stripe` (Attributes) (see [below for nested schema](#nestedatt--verification--stripe))
- `svix` (Attributes) (see [below for nested schema](#nestedatt--verification--svix))
- `synctera` (Attributes) (see [below for nested schema](#nestedatt--verification--synctera))
- `telnyx` (Attributes) (see [below for nested schema](#nestedatt--verification--telnyx))
- `threedeye` (Attributes) (see [below for nested schema](#nestedatt--verification--threedeye))
- `tokenio` (Attributes) (see [below for nested schema](#nestedatt--verification--tokenio))
- `trello` (Attributes) (see [below for nested schema](#nestedatt--verification--trello))
- `twitch` (Attributes) (see [below for nested schema](#nestedatt--verification--twitch))
- `twitter` (Attributes) (see [below for nested schema](#nestedatt--verification--twitter))
Expand Down Expand Up @@ -138,6 +148,26 @@ Required:
- `webhook_secret_key` (String, Sensitive)


<a id="nestedatt--verification--ebay"></a>
### Nested Schema for `verification.ebay`

Required:

- `client_id` (String, Sensitive)
- `client_secret` (String, Sensitive)
- `dev_id` (String, Sensitive)
- `environment` (String, Sensitive)
- `verification_token` (String, Sensitive)


<a id="nestedatt--verification--enode"></a>
### Nested Schema for `verification.enode`

Required:

- `webhook_secret_key` (String, Sensitive)


<a id="nestedatt--verification--favro"></a>
### Nested Schema for `verification.favro`

Expand All @@ -146,6 +176,14 @@ Required:
- `webhook_secret_key` (String, Sensitive)


<a id="nestedatt--verification--frontapp"></a>
### Nested Schema for `verification.frontapp`

Required:

- `webhook_secret_key` (String, Sensitive)


<a id="nestedatt--verification--github"></a>
### Nested Schema for `verification.github`

Expand Down Expand Up @@ -173,6 +211,14 @@ Required:
- `webhook_secret_key` (String, Sensitive)


<a id="nestedatt--verification--linear"></a>
### Nested Schema for `verification.linear`

Required:

- `webhook_secret_key` (String, Sensitive)


<a id="nestedatt--verification--mailgun"></a>
### Nested Schema for `verification.mailgun`

Expand All @@ -189,6 +235,14 @@ Required:
- `webhook_secret_key` (String, Sensitive)


<a id="nestedatt--verification--orb"></a>
### Nested Schema for `verification.orb`

Required:

- `webhook_secret_key` (String, Sensitive)


<a id="nestedatt--verification--oura"></a>
### Nested Schema for `verification.oura`

Expand Down Expand Up @@ -230,11 +284,22 @@ Required:
- `webhook_secret_key` (String, Sensitive)


<a id="nestedatt--verification--pylon"></a>
### Nested Schema for `verification.pylon`

Required:

- `webhook_secret_key` (String, Sensitive)


<a id="nestedatt--verification--recharge"></a>
### Nested Schema for `verification.recharge`

Required:

- `algorithm` (String)
- `encoding` (String)
- `header_key` (String)
- `webhook_secret_key` (String, Sensitive)


Expand Down Expand Up @@ -270,6 +335,14 @@ Required:
- `webhook_secret_key` (String, Sensitive)


<a id="nestedatt--verification--shopline"></a>
### Nested Schema for `verification.shopline`

Required:

- `webhook_secret_key` (String, Sensitive)


<a id="nestedatt--verification--solidgate"></a>
### Nested Schema for `verification.solidgate`

Expand Down Expand Up @@ -310,6 +383,14 @@ Required:
- `webhook_secret_key` (String, Sensitive)


<a id="nestedatt--verification--telnyx"></a>
### Nested Schema for `verification.telnyx`

Required:

- `public_key` (String, Sensitive)


<a id="nestedatt--verification--threedeye"></a>
### Nested Schema for `verification.threedeye`

Expand All @@ -318,6 +399,14 @@ Required:
- `webhook_secret_key` (String, Sensitive)


<a id="nestedatt--verification--tokenio"></a>
### Nested Schema for `verification.tokenio`

Required:

- `public_key` (String, Sensitive)


<a id="nestedatt--verification--trello"></a>
### Nested Schema for `verification.trello`

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/hashicorp/terraform-plugin-framework v1.5.0
github.com/hashicorp/terraform-plugin-framework-validators v0.12.0
github.com/hashicorp/terraform-plugin-log v0.9.0
github.com/hookdeck/hookdeck-go-sdk v0.0.36
github.com/hookdeck/hookdeck-go-sdk v0.0.37
)

require (
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE
github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ=
github.com/hookdeck/hookdeck-go-sdk v0.0.36 h1:ux0RKjTIUYV+83lQ1N2zA3mtU35OfD+WMna6H5RKceQ=
github.com/hookdeck/hookdeck-go-sdk v0.0.36/go.mod h1:kfFn3/WEGcxuPkaaf8lAq9L+3nYg45GwGy4utH/Tnmg=
github.com/hookdeck/hookdeck-go-sdk v0.0.37 h1:Y+QnwsWuJ6KMkpY2qJZDeGzcKc4GkzBrRaEnIb8zimc=
github.com/hookdeck/hookdeck-go-sdk v0.0.37/go.mod h1:kfFn3/WEGcxuPkaaf8lAq9L+3nYg45GwGy4utH/Tnmg=
github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/huandu/xstrings v1.3.2 h1:L18LIDzqlW6xN2rEkpdV8+oL/IXWJ1APd+vsdYy4Wdw=
github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/connection/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package connection
import "github.com/hashicorp/terraform-plugin-framework/types"

type connectionResourceModel struct {
ArchivedAt types.String `tfsdk:"archived_at"`
CreatedAt types.String `tfsdk:"created_at"`
Description types.String `tfsdk:"description"`
DestinationID types.String `tfsdk:"destination_id"`
DisabledAt types.String `tfsdk:"disabled_at"`
ID types.String `tfsdk:"id"`
Name types.String `tfsdk:"name"`
PausedAt types.String `tfsdk:"paused_at"`
Expand Down
15 changes: 8 additions & 7 deletions internal/provider/connection/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,6 @@ func (r *connectionResource) Schema(_ context.Context, _ resource.SchemaRequest,
MarkdownDescription: "Connection Resource",

Attributes: map[string]schema.Attribute{
"archived_at": schema.StringAttribute{
Computed: true,
Validators: []validator.String{
validators.IsRFC3339(),
},
Description: "Date the connection was archived",
},
"created_at": schema.StringAttribute{
Computed: true,
Validators: []validator.String{
Expand All @@ -68,6 +61,14 @@ func (r *connectionResource) Schema(_ context.Context, _ resource.SchemaRequest,
},
Description: "ID of a destination to bind to the connection",
},
"disabled_at": schema.StringAttribute{
Computed: true,
Optional: true,
Validators: []validator.String{
validators.IsRFC3339(),
},
Description: "Date the connection was disabled",
},
"id": schema.StringAttribute{
Computed: true,
Description: `ID of the connection`,
Expand Down
10 changes: 5 additions & 5 deletions internal/provider/connection/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import (
)

func (m *connectionResourceModel) Refresh(connection *hookdeck.Connection) {
if connection.ArchivedAt != nil {
m.ArchivedAt = types.StringValue(connection.ArchivedAt.Format(time.RFC3339))
} else {
m.ArchivedAt = types.StringNull()
}
m.CreatedAt = types.StringValue(connection.CreatedAt.Format(time.RFC3339))
m.DestinationID = types.StringValue(connection.Destination.Id)
if connection.DisabledAt != nil {
m.DisabledAt = types.StringValue(connection.DisabledAt.Format(time.RFC3339))
} else {
m.DisabledAt = types.StringNull()
}
m.ID = types.StringValue(connection.Id)
if connection.Name != nil {
m.Name = types.StringValue(*connection.Name)
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/destination/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
)

type destinationResourceModel struct {
ArchivedAt types.String `tfsdk:"archived_at"`
AuthMethod *destinationAuthMethodConfig `tfsdk:"auth_method"`
CliPath types.String `tfsdk:"cli_path"`
CreatedAt types.String `tfsdk:"created_at"`
Description types.String `tfsdk:"description"`
DisabledAt types.String `tfsdk:"disabled_at"`
HTTPMethod types.String `tfsdk:"http_method"`
ID types.String `tfsdk:"id"`
Name types.String `tfsdk:"name"`
Expand Down
15 changes: 8 additions & 7 deletions internal/provider/destination/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@ func (r *destinationResource) Schema(_ context.Context, _ resource.SchemaRequest
MarkdownDescription: "Destination Resource",

Attributes: map[string]schema.Attribute{
"archived_at": schema.StringAttribute{
Computed: true,
Validators: []validator.String{
validators.IsRFC3339(),
},
Description: `Date the destination was archived`,
},
"auth_method": schema.SingleNestedAttribute{
Computed: true,
Optional: true,
Expand Down Expand Up @@ -137,6 +130,14 @@ func (r *destinationResource) Schema(_ context.Context, _ resource.SchemaRequest
},
Description: "Description for the destination",
},
"disabled_at": schema.StringAttribute{
Computed: true,
Optional: true,
Validators: []validator.String{
validators.IsRFC3339(),
},
Description: `Date the destination was disabled`,
},
"http_method": schema.StringAttribute{
// Computed: true,
Optional: true,
Expand Down
10 changes: 5 additions & 5 deletions internal/provider/destination/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ import (
)

func (m *destinationResourceModel) Refresh(destination *hookdeck.Destination) {
if destination.ArchivedAt != nil {
m.ArchivedAt = types.StringValue(destination.ArchivedAt.Format(time.RFC3339))
} else {
m.ArchivedAt = types.StringNull()
}
if destination.AuthMethod != nil {
m.refreshAuthMethod(destination)
}
Expand All @@ -23,6 +18,11 @@ func (m *destinationResourceModel) Refresh(destination *hookdeck.Destination) {
m.CliPath = types.StringNull()
}
m.CreatedAt = types.StringValue(destination.CreatedAt.Format(time.RFC3339))
if destination.DisabledAt != nil {
m.DisabledAt = types.StringValue(destination.DisabledAt.Format(time.RFC3339))
} else {
m.DisabledAt = types.StringNull()
}
if destination.HttpMethod != nil {
m.HTTPMethod = types.StringValue(string(*destination.HttpMethod))
} else {
Expand Down
Loading

0 comments on commit 4f8f6f6

Please sign in to comment.