/
resource_ably_rule_zapier.go
71 lines (59 loc) · 2.53 KB
/
resource_ably_rule_zapier.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package ably_control
import (
"context"
"github.com/hashicorp/terraform-plugin-framework/diag"
tfsdk_resource "github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/tfsdk"
"github.com/hashicorp/terraform-plugin-framework/types"
)
type resourceRuleZapier struct {
p *provider
}
// Get Rule Resource schema
func (r resourceRuleZapier) GetSchema(_ context.Context) (tfsdk.Schema, diag.Diagnostics) {
return GetRuleSchema(
map[string]tfsdk.Attribute{
"headers": GetHeaderSchema(),
"url": {
Type: types.StringType,
Required: true,
Description: "The webhook URL that Ably will POST events to",
},
"signing_key_id": {
Type: types.StringType,
Optional: true,
Description: "The signing key ID for use in batch mode. Ably will optionally sign the payload using an API key ensuring your servers can validate the payload using the private API key. See the [webhook security docs](https://ably.com/docs/general/webhooks#security) for more information",
},
},
"The `ably_rule_zapier` resource allows you to create and manage an Ably integration rule for Zapier. Read more at https://ably.com/docs/general/webhooks/zapier",
), nil
}
func (r resourceRuleZapier) Metadata(ctx context.Context, req tfsdk_resource.MetadataRequest, resp *tfsdk_resource.MetadataResponse) {
resp.TypeName = "ably_rule_zapier"
}
func (r *resourceRuleZapier) Provider() *provider {
return r.p
}
func (r *resourceRuleZapier) Name() string {
return "Zapier"
}
// Create a new resource
func (r resourceRuleZapier) Create(ctx context.Context, req tfsdk_resource.CreateRequest, resp *tfsdk_resource.CreateResponse) {
CreateRule[AblyRuleTargetZapier](&r, ctx, req, resp)
}
// Read resource
func (r resourceRuleZapier) Read(ctx context.Context, req tfsdk_resource.ReadRequest, resp *tfsdk_resource.ReadResponse) {
ReadRule[AblyRuleTargetZapier](&r, ctx, req, resp)
}
// // Update resource
func (r resourceRuleZapier) Update(ctx context.Context, req tfsdk_resource.UpdateRequest, resp *tfsdk_resource.UpdateResponse) {
UpdateRule[AblyRuleTargetZapier](&r, ctx, req, resp)
}
// Delete resource
func (r resourceRuleZapier) Delete(ctx context.Context, req tfsdk_resource.DeleteRequest, resp *tfsdk_resource.DeleteResponse) {
DeleteRule[AblyRuleTargetZapier](&r, ctx, req, resp)
}
// Import resource
func (r resourceRuleZapier) ImportState(ctx context.Context, req tfsdk_resource.ImportStateRequest, resp *tfsdk_resource.ImportStateResponse) {
ImportResource(ctx, req, resp, "app_id", "id")
}