/
models.go
235 lines (206 loc) · 8.47 KB
/
models.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
package ably_control
import (
ably_control_go "github.com/ably/ably-control-go"
"github.com/hashicorp/terraform-plugin-framework/types"
)
// Ably App
type AblyApp struct {
AccountID types.String `tfsdk:"account_id"`
ID types.String `tfsdk:"id"`
Name types.String `tfsdk:"name"`
Status types.String `tfsdk:"status"`
TLSOnly types.Bool `tfsdk:"tls_only"`
FcmKey types.String `tfsdk:"fcm_key"`
ApnsCertificate types.String `tfsdk:"apns_certificate"`
ApnsPrivateKey types.String `tfsdk:"apns_private_key"`
ApnsUseSandboxEndpoint types.Bool `tfsdk:"apns_use_sandbox_endpoint"`
}
// Ably Namespace
type AblyNamespace struct {
AppID types.String `tfsdk:"app_id"`
ID types.String `tfsdk:"id"`
Authenticated types.Bool `tfsdk:"authenticated"`
Persisted types.Bool `tfsdk:"persisted"`
PersistLast types.Bool `tfsdk:"persist_last"`
PushEnabled types.Bool `tfsdk:"push_enabled"`
TlsOnly types.Bool `tfsdk:"tls_only"`
ExposeTimeserial types.Bool `tfsdk:"expose_timeserial"`
}
// Ably Key
type AblyKey struct {
ID types.String `tfsdk:"id"`
AppID types.String `tfsdk:"app_id"`
Name types.String `tfsdk:"name"`
RevocableTokens types.Bool `tfsdk:"revocable_tokens"`
Capability map[string][]string `tfsdk:"capabilities"`
Status types.Int64 `tfsdk:"status"`
Key types.String `tfsdk:"key"`
Created types.Int64 `tfsdk:"created"`
Modified types.Int64 `tfsdk:"modified"`
}
// Ably Queue
type AblyQueue struct {
AppID types.String `tfsdk:"app_id"`
ID types.String `tfsdk:"id"`
Name types.String `tfsdk:"name"`
Ttl types.Int64 `tfsdk:"ttl"`
MaxLength types.Int64 `tfsdk:"max_length"`
Region types.String `tfsdk:"region"`
AmqpUri types.String `tfsdk:"amqp_uri"`
AmqpQueueName types.String `tfsdk:"amqp_queue_name"`
StompURI types.String `tfsdk:"stomp_uri"`
StompHost types.String `tfsdk:"stomp_host"`
StompDestination types.String `tfsdk:"stomp_destination"`
State types.String `tfsdk:"state"`
MessagesReady types.Int64 `tfsdk:"messages_ready"`
MessagesUnacknowledged types.Int64 `tfsdk:"messages_unacknowledged"`
MessagesTotal types.Int64 `tfsdk:"messages_total"`
StatsPublishRate types.Float64 `tfsdk:"stats_publish_rate"`
StatsDeliveryRate types.Float64 `tfsdk:"stats_delivery_rate"`
StatsAcknowledgementRate types.Float64 `tfsdk:"stats_acknowledgement_rate"`
Deadletter types.Bool `tfsdk:"deadletter"`
DeadletterID types.String `tfsdk:"deadletter_id"`
}
func emptyStringToNull(v *types.String) {
if v.ValueString() == "" {
*v = types.StringNull()
}
}
// Ably Rule
type AblyRuleSource struct {
ChannelFilter types.String `tfsdk:"channel_filter"`
Type ably_control_go.SourceType `tfsdk:"type"`
}
func (r *AblyRuleDecoder[_]) Rule() AblyRule {
return AblyRule{
ID: r.ID,
AppID: r.AppID,
Status: r.Status,
RequestMode: r.RequestMode,
Source: r.Source,
Target: r.Target,
}
}
type AblyRuleDecoder[T any] struct {
ID types.String `tfsdk:"id"`
AppID types.String `tfsdk:"app_id"`
Status types.String `tfsdk:"status"`
RequestMode types.String `tfsdk:"request_mode"`
Source *AblyRuleSource `tfsdk:"source"`
Target T `tfsdk:"target"`
}
type AblyRule AblyRuleDecoder[any]
type AblyRuleTargetKinesis struct {
Region string `tfsdk:"region"`
StreamName string `tfsdk:"stream_name"`
PartitionKey string `tfsdk:"partition_key"`
AwsAuth AwsAuth `tfsdk:"authentication"`
Enveloped bool `tfsdk:"enveloped"`
Format ably_control_go.Format `tfsdk:"format"`
}
type AwsAuth struct {
AuthenticationMode types.String `tfsdk:"mode"`
RoleArn types.String `tfsdk:"role_arn"`
AccessKeyId types.String `tfsdk:"access_key_id"`
SecretAccessKey types.String `tfsdk:"secret_access_key"`
}
type AblyRuleTargetSqs struct {
Region string `tfsdk:"region"`
AwsAccountID string `tfsdk:"aws_account_id"`
QueueName string `tfsdk:"queue_name"`
AwsAuth AwsAuth `tfsdk:"authentication"`
Enveloped bool `tfsdk:"enveloped"`
Format ably_control_go.Format `tfsdk:"format"`
}
type AblyRuleTargetLambda struct {
Region string `tfsdk:"region"`
FunctionName string `tfsdk:"function_name"`
AwsAuth AwsAuth `tfsdk:"authentication"`
Enveloped bool `tfsdk:"enveloped"`
}
type AblyRuleTargetGoogleFunction struct {
Region string `tfsdk:"region"`
ProjectID string `tfsdk:"project_id"`
FunctionName string `tfsdk:"function_name"`
Headers []AblyRuleHeaders `tfsdk:"headers"`
SigningKeyId string `tfsdk:"signing_key_id"`
Enveloped bool `tfsdk:"enveloped"`
Format ably_control_go.Format `tfsdk:"format"`
}
type AblyRuleTargetCloudflareWorker struct {
Url string `tfsdk:"url"`
Headers []AblyRuleHeaders `tfsdk:"headers"`
SigningKeyId string `tfsdk:"signing_key_id"`
}
type AblyRuleTargetHTTP struct {
Url string `tfsdk:"url"`
Headers []AblyRuleHeaders `tfsdk:"headers"`
SigningKeyId string `tfsdk:"signing_key_id"`
Format ably_control_go.Format `tfsdk:"format"`
Enveloped bool `tfsdk:"enveloped"`
}
type AblyRuleTargetPulsar struct {
RoutingKey string `tfsdk:"routing_key"`
Topic string `tfsdk:"topic"`
ServiceURL string `tfsdk:"service_url"`
TlsTrustCerts []string `tfsdk:"tls_trust_certs"`
Authentication PulsarAuthentication `tfsdk:"authentication"`
Enveloped bool `tfsdk:"enveloped"`
Format ably_control_go.Format `tfsdk:"format"`
}
type PulsarAuthentication struct {
Mode string `tfsdk:"mode"`
Token string `tfsdk:"token"`
}
type AblyRuleTargetZapier struct {
Url string `tfsdk:"url"`
Headers []AblyRuleHeaders `tfsdk:"headers"`
SigningKeyId string `tfsdk:"signing_key_id"`
}
type AblyRuleTargetIFTTT struct {
WebhookKey string `tfsdk:"webhook_key"`
EventName string `tfsdk:"event_name"`
}
type AblyRuleTargetAzureFunction struct {
AzureAppID string `tfsdk:"azure_app_id"`
AzureFunctionName string `tfsdk:"function_name"`
Headers []AblyRuleHeaders `tfsdk:"headers"`
SigningKeyID string `tfsdk:"signing_key_id"`
Format ably_control_go.Format `tfsdk:"format"`
}
type AblyRuleHeaders struct {
Name types.String `tfsdk:"name"`
Value types.String `tfsdk:"value"`
}
type AblyRuleTargetKafka struct {
RoutingKey string `tfsdk:"routing_key"`
Brokers []string `tfsdk:"brokers"`
KafkaAuthentication KafkaAuthentication `tfsdk:"auth"`
Enveloped bool `tfsdk:"enveloped"`
Format ably_control_go.Format `tfsdk:"format"`
}
type AblyRuleTargetAmqp struct {
QueueID string `tfsdk:"queue_id"`
Headers []AblyRuleHeaders `tfsdk:"headers"`
Enveloped bool `tfsdk:"enveloped"`
Format ably_control_go.Format `tfsdk:"format"`
}
type AblyRuleTargetAmqpExternal struct {
Url string `tfsdk:"url"`
RoutingKey string `tfsdk:"routing_key"`
Exchange string `tfsdk:"exchange"`
MandatoryRoute bool `tfsdk:"mandatory_route"`
PersistentMessages bool `tfsdk:"persistent_messages"`
MessageTtl types.Int64 `tfsdk:"message_ttl"`
Headers []AblyRuleHeaders `tfsdk:"headers"`
Enveloped bool `tfsdk:"enveloped"`
Format ably_control_go.Format `tfsdk:"format"`
}
type KafkaAuthentication struct {
Sasl Sasl `tfsdk:"sasl"`
}
type Sasl struct {
Mechanism string `tfsdk:"mechanism"`
Username string `tfsdk:"username"`
Password string `tfsdk:"password"`
}