/
resource_ably_rule_http_google_cloud_function.go
83 lines (71 loc) · 3.17 KB
/
resource_ably_rule_http_google_cloud_function.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
72
73
74
75
76
77
78
79
80
81
82
83
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 resourceRuleGoogleFunction struct {
p *provider
}
// Get Rule Resource schema
func (r resourceRuleGoogleFunction) GetSchema(_ context.Context) (tfsdk.Schema, diag.Diagnostics) {
return GetRuleSchema(
map[string]tfsdk.Attribute{
"region": {
Type: types.StringType,
Required: true,
Description: "The region in which your Google Cloud Function is hosted. See the Google documentation for more details.",
},
"function_name": {
Type: types.StringType,
Required: true,
Description: "The name of your Google Cloud Function.",
},
"project_id": {
Type: types.StringType,
Required: true,
Description: "The project ID for your Google Cloud Project that was generated when you created your project.",
},
"headers": GetHeaderSchema(),
"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",
},
"enveloped": GetEnvelopedSchema(),
"format": GetFormatSchema(),
},
"The `ably_rule_google_cloud_function` resource allows you to create and manage an Ably integration rule for Google cloud functions. Read more at https://ably.com/docs/general/webhooks/google-functions",
), nil
}
func (r resourceRuleGoogleFunction) Metadata(ctx context.Context, req tfsdk_resource.MetadataRequest, resp *tfsdk_resource.MetadataResponse) {
resp.TypeName = "ably_rule_google_function"
}
func (r *resourceRuleGoogleFunction) Provider() *provider {
return r.p
}
func (r *resourceRuleGoogleFunction) Name() string {
return "Google Cloud Function"
}
// Create a new resource
func (r resourceRuleGoogleFunction) Create(ctx context.Context, req tfsdk_resource.CreateRequest, resp *tfsdk_resource.CreateResponse) {
CreateRule[AblyRuleTargetGoogleFunction](&r, ctx, req, resp)
}
// Read resource
func (r resourceRuleGoogleFunction) Read(ctx context.Context, req tfsdk_resource.ReadRequest, resp *tfsdk_resource.ReadResponse) {
ReadRule[AblyRuleTargetGoogleFunction](&r, ctx, req, resp)
}
// // Update resource
func (r resourceRuleGoogleFunction) Update(ctx context.Context, req tfsdk_resource.UpdateRequest, resp *tfsdk_resource.UpdateResponse) {
UpdateRule[AblyRuleTargetGoogleFunction](&r, ctx, req, resp)
}
// Delete resource
func (r resourceRuleGoogleFunction) Delete(ctx context.Context, req tfsdk_resource.DeleteRequest, resp *tfsdk_resource.DeleteResponse) {
DeleteRule[AblyRuleTargetGoogleFunction](&r, ctx, req, resp)
}
// Import resource
func (r resourceRuleGoogleFunction) ImportState(ctx context.Context, req tfsdk_resource.ImportStateRequest, resp *tfsdk_resource.ImportStateResponse) {
ImportResource(ctx, req, resp, "app_id", "id")
}