/
kafkaSchema.go
369 lines (316 loc) · 15.7 KB
/
kafkaSchema.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
366
367
368
369
// Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
// *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
package aiven
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi-aiven/sdk/v6/go/aiven/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// The Kafka Schema resource allows the creation and management of Aiven Kafka Schemas.
//
// ## Example Usage
//
// <!--Start PulumiCodeChooser -->
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-aiven/sdk/v6/go/aiven"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := aiven.NewKafkaSchema(ctx, "kafka-schema1", &aiven.KafkaSchemaArgs{
// Project: pulumi.Any(aiven_project.KafkaSchemasProject1.Project),
// ServiceName: pulumi.Any(aiven_kafka.KafkaService1.Service_name),
// SubjectName: pulumi.String("kafka-schema1"),
// CompatibilityLevel: pulumi.String("FORWARD"),
// Schema: pulumi.String(` {
// "doc": "example",
// "fields": [
// {
// "default": 5,
// "doc": "my test number",
// "name": "test",
// "namespace": "test",
// "type": "int"
// }
// ],
// "name": "example",
// "namespace": "example",
// "type": "record"
// }
//
// `),
//
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
// <!--End PulumiCodeChooser -->
//
// ## Import
//
// ```sh
// $ pulumi import aiven:index/kafkaSchema:KafkaSchema kafka-schema1 project/service_name/subject_name
// ```
type KafkaSchema struct {
pulumi.CustomResourceState
// Kafka Schemas compatibility level. The possible values are `BACKWARD`, `BACKWARD_TRANSITIVE`, `FORWARD`, `FORWARD_TRANSITIVE`, `FULL`, `FULL_TRANSITIVE` and `NONE`.
CompatibilityLevel pulumi.StringPtrOutput `pulumi:"compatibilityLevel"`
// Identifies the project this resource belongs to. To set up proper dependencies please refer to this variable as a reference. Changing this property forces recreation of the resource.
Project pulumi.StringOutput `pulumi:"project"`
// Kafka Schema configuration. Should be a valid Avro, JSON, or Protobuf schema, depending on the schema type.
Schema pulumi.StringOutput `pulumi:"schema"`
// Kafka Schema configuration type. Defaults to AVRO. Possible values are AVRO, JSON, and PROTOBUF.
SchemaType pulumi.StringPtrOutput `pulumi:"schemaType"`
// Specifies the name of the service that this resource belongs to. To set up proper dependencies please refer to this variable as a reference. Changing this property forces recreation of the resource.
ServiceName pulumi.StringOutput `pulumi:"serviceName"`
// The Kafka Schema Subject name. Changing this property forces recreation of the resource.
SubjectName pulumi.StringOutput `pulumi:"subjectName"`
// Kafka Schema configuration version.
Version pulumi.IntOutput `pulumi:"version"`
}
// NewKafkaSchema registers a new resource with the given unique name, arguments, and options.
func NewKafkaSchema(ctx *pulumi.Context,
name string, args *KafkaSchemaArgs, opts ...pulumi.ResourceOption) (*KafkaSchema, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.Project == nil {
return nil, errors.New("invalid value for required argument 'Project'")
}
if args.Schema == nil {
return nil, errors.New("invalid value for required argument 'Schema'")
}
if args.ServiceName == nil {
return nil, errors.New("invalid value for required argument 'ServiceName'")
}
if args.SubjectName == nil {
return nil, errors.New("invalid value for required argument 'SubjectName'")
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource KafkaSchema
err := ctx.RegisterResource("aiven:index/kafkaSchema:KafkaSchema", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetKafkaSchema gets an existing KafkaSchema resource's state with the given name, ID, and optional
// state properties that are used to uniquely qualify the lookup (nil if not required).
func GetKafkaSchema(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *KafkaSchemaState, opts ...pulumi.ResourceOption) (*KafkaSchema, error) {
var resource KafkaSchema
err := ctx.ReadResource("aiven:index/kafkaSchema:KafkaSchema", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering KafkaSchema resources.
type kafkaSchemaState struct {
// Kafka Schemas compatibility level. The possible values are `BACKWARD`, `BACKWARD_TRANSITIVE`, `FORWARD`, `FORWARD_TRANSITIVE`, `FULL`, `FULL_TRANSITIVE` and `NONE`.
CompatibilityLevel *string `pulumi:"compatibilityLevel"`
// Identifies the project this resource belongs to. To set up proper dependencies please refer to this variable as a reference. Changing this property forces recreation of the resource.
Project *string `pulumi:"project"`
// Kafka Schema configuration. Should be a valid Avro, JSON, or Protobuf schema, depending on the schema type.
Schema *string `pulumi:"schema"`
// Kafka Schema configuration type. Defaults to AVRO. Possible values are AVRO, JSON, and PROTOBUF.
SchemaType *string `pulumi:"schemaType"`
// Specifies the name of the service that this resource belongs to. To set up proper dependencies please refer to this variable as a reference. Changing this property forces recreation of the resource.
ServiceName *string `pulumi:"serviceName"`
// The Kafka Schema Subject name. Changing this property forces recreation of the resource.
SubjectName *string `pulumi:"subjectName"`
// Kafka Schema configuration version.
Version *int `pulumi:"version"`
}
type KafkaSchemaState struct {
// Kafka Schemas compatibility level. The possible values are `BACKWARD`, `BACKWARD_TRANSITIVE`, `FORWARD`, `FORWARD_TRANSITIVE`, `FULL`, `FULL_TRANSITIVE` and `NONE`.
CompatibilityLevel pulumi.StringPtrInput
// Identifies the project this resource belongs to. To set up proper dependencies please refer to this variable as a reference. Changing this property forces recreation of the resource.
Project pulumi.StringPtrInput
// Kafka Schema configuration. Should be a valid Avro, JSON, or Protobuf schema, depending on the schema type.
Schema pulumi.StringPtrInput
// Kafka Schema configuration type. Defaults to AVRO. Possible values are AVRO, JSON, and PROTOBUF.
SchemaType pulumi.StringPtrInput
// Specifies the name of the service that this resource belongs to. To set up proper dependencies please refer to this variable as a reference. Changing this property forces recreation of the resource.
ServiceName pulumi.StringPtrInput
// The Kafka Schema Subject name. Changing this property forces recreation of the resource.
SubjectName pulumi.StringPtrInput
// Kafka Schema configuration version.
Version pulumi.IntPtrInput
}
func (KafkaSchemaState) ElementType() reflect.Type {
return reflect.TypeOf((*kafkaSchemaState)(nil)).Elem()
}
type kafkaSchemaArgs struct {
// Kafka Schemas compatibility level. The possible values are `BACKWARD`, `BACKWARD_TRANSITIVE`, `FORWARD`, `FORWARD_TRANSITIVE`, `FULL`, `FULL_TRANSITIVE` and `NONE`.
CompatibilityLevel *string `pulumi:"compatibilityLevel"`
// Identifies the project this resource belongs to. To set up proper dependencies please refer to this variable as a reference. Changing this property forces recreation of the resource.
Project string `pulumi:"project"`
// Kafka Schema configuration. Should be a valid Avro, JSON, or Protobuf schema, depending on the schema type.
Schema string `pulumi:"schema"`
// Kafka Schema configuration type. Defaults to AVRO. Possible values are AVRO, JSON, and PROTOBUF.
SchemaType *string `pulumi:"schemaType"`
// Specifies the name of the service that this resource belongs to. To set up proper dependencies please refer to this variable as a reference. Changing this property forces recreation of the resource.
ServiceName string `pulumi:"serviceName"`
// The Kafka Schema Subject name. Changing this property forces recreation of the resource.
SubjectName string `pulumi:"subjectName"`
}
// The set of arguments for constructing a KafkaSchema resource.
type KafkaSchemaArgs struct {
// Kafka Schemas compatibility level. The possible values are `BACKWARD`, `BACKWARD_TRANSITIVE`, `FORWARD`, `FORWARD_TRANSITIVE`, `FULL`, `FULL_TRANSITIVE` and `NONE`.
CompatibilityLevel pulumi.StringPtrInput
// Identifies the project this resource belongs to. To set up proper dependencies please refer to this variable as a reference. Changing this property forces recreation of the resource.
Project pulumi.StringInput
// Kafka Schema configuration. Should be a valid Avro, JSON, or Protobuf schema, depending on the schema type.
Schema pulumi.StringInput
// Kafka Schema configuration type. Defaults to AVRO. Possible values are AVRO, JSON, and PROTOBUF.
SchemaType pulumi.StringPtrInput
// Specifies the name of the service that this resource belongs to. To set up proper dependencies please refer to this variable as a reference. Changing this property forces recreation of the resource.
ServiceName pulumi.StringInput
// The Kafka Schema Subject name. Changing this property forces recreation of the resource.
SubjectName pulumi.StringInput
}
func (KafkaSchemaArgs) ElementType() reflect.Type {
return reflect.TypeOf((*kafkaSchemaArgs)(nil)).Elem()
}
type KafkaSchemaInput interface {
pulumi.Input
ToKafkaSchemaOutput() KafkaSchemaOutput
ToKafkaSchemaOutputWithContext(ctx context.Context) KafkaSchemaOutput
}
func (*KafkaSchema) ElementType() reflect.Type {
return reflect.TypeOf((**KafkaSchema)(nil)).Elem()
}
func (i *KafkaSchema) ToKafkaSchemaOutput() KafkaSchemaOutput {
return i.ToKafkaSchemaOutputWithContext(context.Background())
}
func (i *KafkaSchema) ToKafkaSchemaOutputWithContext(ctx context.Context) KafkaSchemaOutput {
return pulumi.ToOutputWithContext(ctx, i).(KafkaSchemaOutput)
}
// KafkaSchemaArrayInput is an input type that accepts KafkaSchemaArray and KafkaSchemaArrayOutput values.
// You can construct a concrete instance of `KafkaSchemaArrayInput` via:
//
// KafkaSchemaArray{ KafkaSchemaArgs{...} }
type KafkaSchemaArrayInput interface {
pulumi.Input
ToKafkaSchemaArrayOutput() KafkaSchemaArrayOutput
ToKafkaSchemaArrayOutputWithContext(context.Context) KafkaSchemaArrayOutput
}
type KafkaSchemaArray []KafkaSchemaInput
func (KafkaSchemaArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*KafkaSchema)(nil)).Elem()
}
func (i KafkaSchemaArray) ToKafkaSchemaArrayOutput() KafkaSchemaArrayOutput {
return i.ToKafkaSchemaArrayOutputWithContext(context.Background())
}
func (i KafkaSchemaArray) ToKafkaSchemaArrayOutputWithContext(ctx context.Context) KafkaSchemaArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(KafkaSchemaArrayOutput)
}
// KafkaSchemaMapInput is an input type that accepts KafkaSchemaMap and KafkaSchemaMapOutput values.
// You can construct a concrete instance of `KafkaSchemaMapInput` via:
//
// KafkaSchemaMap{ "key": KafkaSchemaArgs{...} }
type KafkaSchemaMapInput interface {
pulumi.Input
ToKafkaSchemaMapOutput() KafkaSchemaMapOutput
ToKafkaSchemaMapOutputWithContext(context.Context) KafkaSchemaMapOutput
}
type KafkaSchemaMap map[string]KafkaSchemaInput
func (KafkaSchemaMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*KafkaSchema)(nil)).Elem()
}
func (i KafkaSchemaMap) ToKafkaSchemaMapOutput() KafkaSchemaMapOutput {
return i.ToKafkaSchemaMapOutputWithContext(context.Background())
}
func (i KafkaSchemaMap) ToKafkaSchemaMapOutputWithContext(ctx context.Context) KafkaSchemaMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(KafkaSchemaMapOutput)
}
type KafkaSchemaOutput struct{ *pulumi.OutputState }
func (KafkaSchemaOutput) ElementType() reflect.Type {
return reflect.TypeOf((**KafkaSchema)(nil)).Elem()
}
func (o KafkaSchemaOutput) ToKafkaSchemaOutput() KafkaSchemaOutput {
return o
}
func (o KafkaSchemaOutput) ToKafkaSchemaOutputWithContext(ctx context.Context) KafkaSchemaOutput {
return o
}
// Kafka Schemas compatibility level. The possible values are `BACKWARD`, `BACKWARD_TRANSITIVE`, `FORWARD`, `FORWARD_TRANSITIVE`, `FULL`, `FULL_TRANSITIVE` and `NONE`.
func (o KafkaSchemaOutput) CompatibilityLevel() pulumi.StringPtrOutput {
return o.ApplyT(func(v *KafkaSchema) pulumi.StringPtrOutput { return v.CompatibilityLevel }).(pulumi.StringPtrOutput)
}
// Identifies the project this resource belongs to. To set up proper dependencies please refer to this variable as a reference. Changing this property forces recreation of the resource.
func (o KafkaSchemaOutput) Project() pulumi.StringOutput {
return o.ApplyT(func(v *KafkaSchema) pulumi.StringOutput { return v.Project }).(pulumi.StringOutput)
}
// Kafka Schema configuration. Should be a valid Avro, JSON, or Protobuf schema, depending on the schema type.
func (o KafkaSchemaOutput) Schema() pulumi.StringOutput {
return o.ApplyT(func(v *KafkaSchema) pulumi.StringOutput { return v.Schema }).(pulumi.StringOutput)
}
// Kafka Schema configuration type. Defaults to AVRO. Possible values are AVRO, JSON, and PROTOBUF.
func (o KafkaSchemaOutput) SchemaType() pulumi.StringPtrOutput {
return o.ApplyT(func(v *KafkaSchema) pulumi.StringPtrOutput { return v.SchemaType }).(pulumi.StringPtrOutput)
}
// Specifies the name of the service that this resource belongs to. To set up proper dependencies please refer to this variable as a reference. Changing this property forces recreation of the resource.
func (o KafkaSchemaOutput) ServiceName() pulumi.StringOutput {
return o.ApplyT(func(v *KafkaSchema) pulumi.StringOutput { return v.ServiceName }).(pulumi.StringOutput)
}
// The Kafka Schema Subject name. Changing this property forces recreation of the resource.
func (o KafkaSchemaOutput) SubjectName() pulumi.StringOutput {
return o.ApplyT(func(v *KafkaSchema) pulumi.StringOutput { return v.SubjectName }).(pulumi.StringOutput)
}
// Kafka Schema configuration version.
func (o KafkaSchemaOutput) Version() pulumi.IntOutput {
return o.ApplyT(func(v *KafkaSchema) pulumi.IntOutput { return v.Version }).(pulumi.IntOutput)
}
type KafkaSchemaArrayOutput struct{ *pulumi.OutputState }
func (KafkaSchemaArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*KafkaSchema)(nil)).Elem()
}
func (o KafkaSchemaArrayOutput) ToKafkaSchemaArrayOutput() KafkaSchemaArrayOutput {
return o
}
func (o KafkaSchemaArrayOutput) ToKafkaSchemaArrayOutputWithContext(ctx context.Context) KafkaSchemaArrayOutput {
return o
}
func (o KafkaSchemaArrayOutput) Index(i pulumi.IntInput) KafkaSchemaOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *KafkaSchema {
return vs[0].([]*KafkaSchema)[vs[1].(int)]
}).(KafkaSchemaOutput)
}
type KafkaSchemaMapOutput struct{ *pulumi.OutputState }
func (KafkaSchemaMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*KafkaSchema)(nil)).Elem()
}
func (o KafkaSchemaMapOutput) ToKafkaSchemaMapOutput() KafkaSchemaMapOutput {
return o
}
func (o KafkaSchemaMapOutput) ToKafkaSchemaMapOutputWithContext(ctx context.Context) KafkaSchemaMapOutput {
return o
}
func (o KafkaSchemaMapOutput) MapIndex(k pulumi.StringInput) KafkaSchemaOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *KafkaSchema {
return vs[0].(map[string]*KafkaSchema)[vs[1].(string)]
}).(KafkaSchemaOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*KafkaSchemaInput)(nil)).Elem(), &KafkaSchema{})
pulumi.RegisterInputType(reflect.TypeOf((*KafkaSchemaArrayInput)(nil)).Elem(), KafkaSchemaArray{})
pulumi.RegisterInputType(reflect.TypeOf((*KafkaSchemaMapInput)(nil)).Elem(), KafkaSchemaMap{})
pulumi.RegisterOutputType(KafkaSchemaOutput{})
pulumi.RegisterOutputType(KafkaSchemaArrayOutput{})
pulumi.RegisterOutputType(KafkaSchemaMapOutput{})
}