/
integration.go
204 lines (171 loc) · 5.24 KB
/
integration.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
package option
import (
"github.com/rockset/rockset-go-client/openapi"
)
type AWSCredentials struct {
*openapi.AwsAccessKey
*openapi.AwsRole
}
type AWSCredentialsFn func(o *AWSCredentials)
func AWSKeys(accessKey, secretKey string) AWSCredentialsFn {
return func(o *AWSCredentials) {
o.AwsAccessKey = &openapi.AwsAccessKey{
AwsAccessKeyId: accessKey,
AwsSecretAccessKey: secretKey,
}
}
}
func AWSRole(roleARN string) AWSCredentialsFn {
return func(o *AWSCredentials) {
o.AwsRole = &openapi.AwsRole{
AwsRoleArn: roleARN,
}
}
}
type S3Integration struct {
openapi.S3Integration
Description *string
}
type S3IntegrationOption func(request *S3Integration)
func WithS3IntegrationDescription(desc string) S3IntegrationOption {
return func(o *S3Integration) {
o.Description = &desc
}
}
type KinesisIntegration struct {
openapi.KinesisIntegration
Description *string
}
type KinesisIntegrationOption func(request *KinesisIntegration)
func WithKinesisIntegrationDescription(desc string) KinesisIntegrationOption {
return func(o *KinesisIntegration) {
o.Description = &desc
}
}
type DynamoDBIntegration struct {
openapi.DynamodbIntegration
Description *string
}
type DynamoDBIntegrationOption func(request *DynamoDBIntegration)
func WithDynamoDBIntegrationDescription(desc string) DynamoDBIntegrationOption {
return func(o *DynamoDBIntegration) {
o.Description = &desc
}
}
type GCSIntegration struct {
Description *string
}
type GCSIntegrationOption func(request *GCSIntegration)
func WithGCSIntegrationDescription(desc string) GCSIntegrationOption {
return func(o *GCSIntegration) {
o.Description = &desc
}
}
type SegmentIntegration struct {
Description *string
}
type SegmentIntegrationOption func(request *SegmentIntegration)
func WithSegmentIntegrationDescription(desc string) SegmentIntegrationOption {
return func(o *SegmentIntegration) {
o.Description = &desc
}
}
// KafkaFormat is the definition of the Kafka format
type KafkaFormat string
// String returns the string representation of the Kafka format
func (f KafkaFormat) String() string {
return string(f)
}
const (
// KafkaFormatJSON is the JSON format for Kafka.
KafkaFormatJSON KafkaFormat = "JSON"
// KafkaFormatAVRO is the AVRO format for Kafka. If used, the option.WithKafkaSchemaRegistryConfig()
// must be used when creating the integration.
KafkaFormatAVRO KafkaFormat = "AVRO"
)
// KafkaIntegrationTopicState is the definition of topic states for a Kafka integration.
type KafkaIntegrationTopicState string
const (
KafkaIntegrationActive KafkaIntegrationTopicState = "ACTIVE"
KafkaIntegrationNoDocsYet KafkaIntegrationTopicState = "NO_DOCS_YET"
KafkaIntegrationDormant KafkaIntegrationTopicState = "DORMANT"
)
type KafkaIntegration struct {
Description *string
Config openapi.KafkaIntegration
}
type KafkaIntegrationOption func(request *KafkaIntegration)
func WithKafkaIntegrationDescription(desc string) KafkaIntegrationOption {
return func(o *KafkaIntegration) {
o.Description = &desc
}
}
// WithKafkaIntegrationTopic adds a topic name to the integration. Can be specified multiple times.
func WithKafkaIntegrationTopic(topic string) KafkaIntegrationOption {
return func(o *KafkaIntegration) {
o.Config.KafkaTopicNames = append(o.Config.KafkaTopicNames, topic)
}
}
func WithKafkaConnectionString(s string) KafkaIntegrationOption {
return func(o *KafkaIntegration) {
o.Config.ConnectionString = &s
}
}
func WithKafkaIntegrationConfig(config openapi.KafkaIntegration) KafkaIntegrationOption {
return func(o *KafkaIntegration) {
o.Config = config
}
}
func WithKafkaDataFormat(format KafkaFormat) KafkaIntegrationOption {
return func(o *KafkaIntegration) {
o.Config.KafkaDataFormat = openapi.PtrString(string(format))
}
}
func WithKafkaV3() KafkaIntegrationOption {
return func(o *KafkaIntegration) {
o.Config.UseV3 = openapi.PtrBool(true)
}
}
func WithKafkaBootstrapServers(servers string) KafkaIntegrationOption {
return func(o *KafkaIntegration) {
o.Config.BootstrapServers = &servers
}
}
func WithKafkaSecurityConfig(apiKey, secret string) KafkaIntegrationOption {
return func(o *KafkaIntegration) {
o.Config.SecurityConfig = &openapi.KafkaV3SecurityConfig{
ApiKey: &apiKey,
Secret: &secret,
}
}
}
// WithKafkaSchemaRegistryConfig is required when the Kafka format is rockset.KafkaFormatJSON.
// A Kafka integration without schema registry configured can only be used to ingest from topics
// serving JSON messages.
func WithKafkaSchemaRegistryConfig(url, apiKey, secret string) KafkaIntegrationOption {
return func(o *KafkaIntegration) {
o.Config.SchemaRegistryConfig = &openapi.SchemaRegistryConfig{
Url: &url,
Key: &apiKey,
Secret: &secret,
}
}
}
func WithKafkaStatusByTopic(topic string, status openapi.StatusKafka) KafkaIntegrationOption {
return func(o *KafkaIntegration) {
if o.Config.SourceStatusByTopic == nil {
m := make(map[string]openapi.StatusKafka)
o.Config.SourceStatusByTopic = &m
}
(*o.Config.SourceStatusByTopic)[topic] = status
}
}
type MongoDBIntegration struct {
Description *string
}
type MongoDBIntegrationOption func(request *MongoDBIntegration)
func WithMongoDBIntegrationDescription(desc string) MongoDBIntegrationOption {
return func(o *MongoDBIntegration) {
o.Description = &desc
}
}