-
Notifications
You must be signed in to change notification settings - Fork 16
/
sourcemongodbv2.go
365 lines (306 loc) · 11.4 KB
/
sourcemongodbv2.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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
package shared
import (
"encoding/json"
"errors"
"fmt"
"github.com/airbytehq/terraform-provider-airbyte/internal/sdk/pkg/utils"
)
type SourceMongodbV2SchemasDatabaseConfigClusterType string
const (
SourceMongodbV2SchemasDatabaseConfigClusterTypeSelfManagedReplicaSet SourceMongodbV2SchemasDatabaseConfigClusterType = "SELF_MANAGED_REPLICA_SET"
)
func (e SourceMongodbV2SchemasDatabaseConfigClusterType) ToPointer() *SourceMongodbV2SchemasDatabaseConfigClusterType {
return &e
}
func (e *SourceMongodbV2SchemasDatabaseConfigClusterType) UnmarshalJSON(data []byte) error {
var v string
if err := json.Unmarshal(data, &v); err != nil {
return err
}
switch v {
case "SELF_MANAGED_REPLICA_SET":
*e = SourceMongodbV2SchemasDatabaseConfigClusterType(v)
return nil
default:
return fmt.Errorf("invalid value for SourceMongodbV2SchemasDatabaseConfigClusterType: %v", v)
}
}
// SourceMongodbV2SelfManagedReplicaSet - MongoDB self-hosted cluster configured as a replica set
type SourceMongodbV2SelfManagedReplicaSet struct {
AdditionalProperties interface{} `additionalProperties:"true" json:"-"`
// The authentication source where the user information is stored.
AuthSource *string `default:"admin" json:"auth_source"`
clusterType SourceMongodbV2SchemasDatabaseConfigClusterType `const:"SELF_MANAGED_REPLICA_SET" json:"cluster_type"`
// The connection string of the cluster that you want to replicate. https://www.mongodb.com/docs/manual/reference/connection-string/#find-your-self-hosted-deployment-s-connection-string for more information.
ConnectionString string `json:"connection_string"`
// The name of the MongoDB database that contains the collection(s) to replicate.
Database string `json:"database"`
// The password associated with this username.
Password *string `json:"password,omitempty"`
// When enabled, syncs will validate and structure records against the stream's schema.
SchemaEnforced *bool `default:"true" json:"schema_enforced"`
// The username which is used to access the database.
Username *string `json:"username,omitempty"`
}
func (s SourceMongodbV2SelfManagedReplicaSet) MarshalJSON() ([]byte, error) {
return utils.MarshalJSON(s, "", false)
}
func (s *SourceMongodbV2SelfManagedReplicaSet) UnmarshalJSON(data []byte) error {
if err := utils.UnmarshalJSON(data, &s, "", false, true); err != nil {
return err
}
return nil
}
func (o *SourceMongodbV2SelfManagedReplicaSet) GetAdditionalProperties() interface{} {
if o == nil {
return nil
}
return o.AdditionalProperties
}
func (o *SourceMongodbV2SelfManagedReplicaSet) GetAuthSource() *string {
if o == nil {
return nil
}
return o.AuthSource
}
func (o *SourceMongodbV2SelfManagedReplicaSet) GetClusterType() SourceMongodbV2SchemasDatabaseConfigClusterType {
return SourceMongodbV2SchemasDatabaseConfigClusterTypeSelfManagedReplicaSet
}
func (o *SourceMongodbV2SelfManagedReplicaSet) GetConnectionString() string {
if o == nil {
return ""
}
return o.ConnectionString
}
func (o *SourceMongodbV2SelfManagedReplicaSet) GetDatabase() string {
if o == nil {
return ""
}
return o.Database
}
func (o *SourceMongodbV2SelfManagedReplicaSet) GetPassword() *string {
if o == nil {
return nil
}
return o.Password
}
func (o *SourceMongodbV2SelfManagedReplicaSet) GetSchemaEnforced() *bool {
if o == nil {
return nil
}
return o.SchemaEnforced
}
func (o *SourceMongodbV2SelfManagedReplicaSet) GetUsername() *string {
if o == nil {
return nil
}
return o.Username
}
type SourceMongodbV2SchemasClusterType string
const (
SourceMongodbV2SchemasClusterTypeAtlasReplicaSet SourceMongodbV2SchemasClusterType = "ATLAS_REPLICA_SET"
)
func (e SourceMongodbV2SchemasClusterType) ToPointer() *SourceMongodbV2SchemasClusterType {
return &e
}
func (e *SourceMongodbV2SchemasClusterType) UnmarshalJSON(data []byte) error {
var v string
if err := json.Unmarshal(data, &v); err != nil {
return err
}
switch v {
case "ATLAS_REPLICA_SET":
*e = SourceMongodbV2SchemasClusterType(v)
return nil
default:
return fmt.Errorf("invalid value for SourceMongodbV2SchemasClusterType: %v", v)
}
}
// SourceMongodbV2MongoDBAtlasReplicaSet - MongoDB Atlas-hosted cluster configured as a replica set
type SourceMongodbV2MongoDBAtlasReplicaSet struct {
AdditionalProperties interface{} `additionalProperties:"true" json:"-"`
// The authentication source where the user information is stored. See https://www.mongodb.com/docs/manual/reference/connection-string/#mongodb-urioption-urioption.authSource for more details.
AuthSource *string `default:"admin" json:"auth_source"`
clusterType SourceMongodbV2SchemasClusterType `const:"ATLAS_REPLICA_SET" json:"cluster_type"`
// The connection string of the cluster that you want to replicate.
ConnectionString string `json:"connection_string"`
// The name of the MongoDB database that contains the collection(s) to replicate.
Database string `json:"database"`
// The password associated with this username.
Password string `json:"password"`
// When enabled, syncs will validate and structure records against the stream's schema.
SchemaEnforced *bool `default:"true" json:"schema_enforced"`
// The username which is used to access the database.
Username string `json:"username"`
}
func (s SourceMongodbV2MongoDBAtlasReplicaSet) MarshalJSON() ([]byte, error) {
return utils.MarshalJSON(s, "", false)
}
func (s *SourceMongodbV2MongoDBAtlasReplicaSet) UnmarshalJSON(data []byte) error {
if err := utils.UnmarshalJSON(data, &s, "", false, true); err != nil {
return err
}
return nil
}
func (o *SourceMongodbV2MongoDBAtlasReplicaSet) GetAdditionalProperties() interface{} {
if o == nil {
return nil
}
return o.AdditionalProperties
}
func (o *SourceMongodbV2MongoDBAtlasReplicaSet) GetAuthSource() *string {
if o == nil {
return nil
}
return o.AuthSource
}
func (o *SourceMongodbV2MongoDBAtlasReplicaSet) GetClusterType() SourceMongodbV2SchemasClusterType {
return SourceMongodbV2SchemasClusterTypeAtlasReplicaSet
}
func (o *SourceMongodbV2MongoDBAtlasReplicaSet) GetConnectionString() string {
if o == nil {
return ""
}
return o.ConnectionString
}
func (o *SourceMongodbV2MongoDBAtlasReplicaSet) GetDatabase() string {
if o == nil {
return ""
}
return o.Database
}
func (o *SourceMongodbV2MongoDBAtlasReplicaSet) GetPassword() string {
if o == nil {
return ""
}
return o.Password
}
func (o *SourceMongodbV2MongoDBAtlasReplicaSet) GetSchemaEnforced() *bool {
if o == nil {
return nil
}
return o.SchemaEnforced
}
func (o *SourceMongodbV2MongoDBAtlasReplicaSet) GetUsername() string {
if o == nil {
return ""
}
return o.Username
}
type SourceMongodbV2ClusterTypeType string
const (
SourceMongodbV2ClusterTypeTypeSourceMongodbV2MongoDBAtlasReplicaSet SourceMongodbV2ClusterTypeType = "source-mongodb-v2_MongoDB Atlas Replica Set"
SourceMongodbV2ClusterTypeTypeSourceMongodbV2SelfManagedReplicaSet SourceMongodbV2ClusterTypeType = "source-mongodb-v2_Self-Managed Replica Set"
)
// SourceMongodbV2ClusterType - Configures the MongoDB cluster type.
type SourceMongodbV2ClusterType struct {
SourceMongodbV2MongoDBAtlasReplicaSet *SourceMongodbV2MongoDBAtlasReplicaSet
SourceMongodbV2SelfManagedReplicaSet *SourceMongodbV2SelfManagedReplicaSet
Type SourceMongodbV2ClusterTypeType
}
func CreateSourceMongodbV2ClusterTypeSourceMongodbV2MongoDBAtlasReplicaSet(sourceMongodbV2MongoDBAtlasReplicaSet SourceMongodbV2MongoDBAtlasReplicaSet) SourceMongodbV2ClusterType {
typ := SourceMongodbV2ClusterTypeTypeSourceMongodbV2MongoDBAtlasReplicaSet
return SourceMongodbV2ClusterType{
SourceMongodbV2MongoDBAtlasReplicaSet: &sourceMongodbV2MongoDBAtlasReplicaSet,
Type: typ,
}
}
func CreateSourceMongodbV2ClusterTypeSourceMongodbV2SelfManagedReplicaSet(sourceMongodbV2SelfManagedReplicaSet SourceMongodbV2SelfManagedReplicaSet) SourceMongodbV2ClusterType {
typ := SourceMongodbV2ClusterTypeTypeSourceMongodbV2SelfManagedReplicaSet
return SourceMongodbV2ClusterType{
SourceMongodbV2SelfManagedReplicaSet: &sourceMongodbV2SelfManagedReplicaSet,
Type: typ,
}
}
func (u *SourceMongodbV2ClusterType) UnmarshalJSON(data []byte) error {
sourceMongodbV2MongoDBAtlasReplicaSet := new(SourceMongodbV2MongoDBAtlasReplicaSet)
if err := utils.UnmarshalJSON(data, &sourceMongodbV2MongoDBAtlasReplicaSet, "", true, true); err == nil {
u.SourceMongodbV2MongoDBAtlasReplicaSet = sourceMongodbV2MongoDBAtlasReplicaSet
u.Type = SourceMongodbV2ClusterTypeTypeSourceMongodbV2MongoDBAtlasReplicaSet
return nil
}
sourceMongodbV2SelfManagedReplicaSet := new(SourceMongodbV2SelfManagedReplicaSet)
if err := utils.UnmarshalJSON(data, &sourceMongodbV2SelfManagedReplicaSet, "", true, true); err == nil {
u.SourceMongodbV2SelfManagedReplicaSet = sourceMongodbV2SelfManagedReplicaSet
u.Type = SourceMongodbV2ClusterTypeTypeSourceMongodbV2SelfManagedReplicaSet
return nil
}
return errors.New("could not unmarshal into supported union types")
}
func (u SourceMongodbV2ClusterType) MarshalJSON() ([]byte, error) {
if u.SourceMongodbV2MongoDBAtlasReplicaSet != nil {
return utils.MarshalJSON(u.SourceMongodbV2MongoDBAtlasReplicaSet, "", true)
}
if u.SourceMongodbV2SelfManagedReplicaSet != nil {
return utils.MarshalJSON(u.SourceMongodbV2SelfManagedReplicaSet, "", true)
}
return nil, errors.New("could not marshal union type: all fields are null")
}
type MongodbV2 string
const (
MongodbV2MongodbV2 MongodbV2 = "mongodb-v2"
)
func (e MongodbV2) ToPointer() *MongodbV2 {
return &e
}
func (e *MongodbV2) UnmarshalJSON(data []byte) error {
var v string
if err := json.Unmarshal(data, &v); err != nil {
return err
}
switch v {
case "mongodb-v2":
*e = MongodbV2(v)
return nil
default:
return fmt.Errorf("invalid value for MongodbV2: %v", v)
}
}
type SourceMongodbV2 struct {
// Configures the MongoDB cluster type.
DatabaseConfig SourceMongodbV2ClusterType `json:"database_config"`
// The maximum number of documents to sample when attempting to discover the unique fields for a collection.
DiscoverSampleSize *int64 `default:"10000" json:"discover_sample_size"`
// The amount of time the connector will wait when it launches to determine if there is new data to sync or not. Defaults to 300 seconds. Valid range: 120 seconds to 1200 seconds.
InitialWaitingSeconds *int64 `default:"300" json:"initial_waiting_seconds"`
// The size of the internal queue. This may interfere with memory consumption and efficiency of the connector, please be careful.
QueueSize *int64 `default:"10000" json:"queue_size"`
sourceType MongodbV2 `const:"mongodb-v2" json:"sourceType"`
}
func (s SourceMongodbV2) MarshalJSON() ([]byte, error) {
return utils.MarshalJSON(s, "", false)
}
func (s *SourceMongodbV2) UnmarshalJSON(data []byte) error {
if err := utils.UnmarshalJSON(data, &s, "", false, false); err != nil {
return err
}
return nil
}
func (o *SourceMongodbV2) GetDatabaseConfig() SourceMongodbV2ClusterType {
if o == nil {
return SourceMongodbV2ClusterType{}
}
return o.DatabaseConfig
}
func (o *SourceMongodbV2) GetDiscoverSampleSize() *int64 {
if o == nil {
return nil
}
return o.DiscoverSampleSize
}
func (o *SourceMongodbV2) GetInitialWaitingSeconds() *int64 {
if o == nil {
return nil
}
return o.InitialWaitingSeconds
}
func (o *SourceMongodbV2) GetQueueSize() *int64 {
if o == nil {
return nil
}
return o.QueueSize
}
func (o *SourceMongodbV2) GetSourceType() MongodbV2 {
return MongodbV2MongodbV2
}