generated from pulumi/pulumi-tf-provider-boilerplate
/
customer.go
440 lines (381 loc) · 22.2 KB
/
customer.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
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
// 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 stripe
import (
"context"
"reflect"
"github.com/georgegebbett/pulumi-stripe/sdk/go/stripe/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// With this resource, you can create a customer - [Stripe API customer documentation](https://stripe.com/docs/api/customers).
//
// Customer objects allow you to perform recurring charges, and to track multiple charges,
// that are associated with the same customer.
//
// ## Example Usage
//
// ```go
// package main
//
// import (
//
// "github.com/georgegebbett/pulumi-stripe/sdk/go/stripe"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := stripe.NewCustomer(ctx, "customer", &stripe.CustomerArgs{
// Balance: pulumi.Int(10000),
// InvoicePrefix: pulumi.String("LA000"),
// InvoiceSettings: pulumi.StringMap{
// "customFieldName": pulumi.String("customFieldValue"),
// "footer": pulumi.String("--- Lukas Aron ---"),
// },
// NextInvoiceSequence: pulumi.Int(1001),
// PreferredLocales: pulumi.StringArray{
// pulumi.String("eng"),
// pulumi.String("esp"),
// },
// Shipping: pulumi.StringMap{
// "city": pulumi.String("Sydney"),
// "country": pulumi.String("AU"),
// "line1": pulumi.String("1 The Best Street"),
// "line2": pulumi.String("Apartment 401"),
// "name": pulumi.String("Lukas Aron"),
// "phone": pulumi.String("+610123456789"),
// "postal_code": pulumi.String("2000"),
// "state": pulumi.String("New South Wales"),
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
type Customer struct {
pulumi.CustomResourceState
// Map(String). The customer’s address, for all individual fields see: Address Fields.
Address pulumi.StringMapOutput `pulumi:"address"`
// Int. Current balance, if any, being stored on the customer. If negative, the customer has credit to apply to their next invoice. If positive, the customer has an amount owed that will be added to their next invoice. The balance does not refer to any unpaid invoices; it solely takes into account amounts that have yet to be successfully applied to any invoice. This balance is only taken into account as invoices are finalized.
Balance pulumi.IntPtrOutput `pulumi:"balance"`
// String. The default invoice prefix generated by Stripe when not individual invoice prefix provided.
DefaultInvoicePrefix pulumi.StringOutput `pulumi:"defaultInvoicePrefix"`
// String. An arbitrary string that you can attach to a customer object. It is displayed alongside the customer in the dashboard.
Description pulumi.StringPtrOutput `pulumi:"description"`
// String. Customer’s email address. It’s displayed alongside the customer in your dashboard and can be useful for searching and tracking. This may be up to 512 characters.
Email pulumi.StringPtrOutput `pulumi:"email"`
// String. The prefix for the customer used to generate unique invoice numbers. Must be `3–12 uppercase letters or numbers`.
InvoicePrefix pulumi.StringPtrOutput `pulumi:"invoicePrefix"`
// Map(String). Default invoice settings for this customer. For supported fields see: Invoice Settings Fields.
InvoiceSettings pulumi.StringMapOutput `pulumi:"invoiceSettings"`
// Map(String). Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
Metadata pulumi.StringMapOutput `pulumi:"metadata"`
// String. The customer’s full name or business name.
Name pulumi.StringOutput `pulumi:"name"`
// Int. The sequence to be used on the customer’s next invoice. Defaults to 1.
NextInvoiceSequence pulumi.IntPtrOutput `pulumi:"nextInvoiceSequence"`
// String. The customer’s phone number.
Phone pulumi.StringPtrOutput `pulumi:"phone"`
// List(String). Customer’s preferred languages, ordered by preference.
PreferredLocales pulumi.StringArrayOutput `pulumi:"preferredLocales"`
// Map(String). Mailing and shipping address for the customer. Appears on invoices emailed to this customer. For all individual fields see: Shipping Fields.
Shipping pulumi.StringMapOutput `pulumi:"shipping"`
}
// NewCustomer registers a new resource with the given unique name, arguments, and options.
func NewCustomer(ctx *pulumi.Context,
name string, args *CustomerArgs, opts ...pulumi.ResourceOption) (*Customer, error) {
if args == nil {
args = &CustomerArgs{}
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource Customer
err := ctx.RegisterResource("stripe:index/customer:Customer", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetCustomer gets an existing Customer 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 GetCustomer(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *CustomerState, opts ...pulumi.ResourceOption) (*Customer, error) {
var resource Customer
err := ctx.ReadResource("stripe:index/customer:Customer", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering Customer resources.
type customerState struct {
// Map(String). The customer’s address, for all individual fields see: Address Fields.
Address map[string]string `pulumi:"address"`
// Int. Current balance, if any, being stored on the customer. If negative, the customer has credit to apply to their next invoice. If positive, the customer has an amount owed that will be added to their next invoice. The balance does not refer to any unpaid invoices; it solely takes into account amounts that have yet to be successfully applied to any invoice. This balance is only taken into account as invoices are finalized.
Balance *int `pulumi:"balance"`
// String. The default invoice prefix generated by Stripe when not individual invoice prefix provided.
DefaultInvoicePrefix *string `pulumi:"defaultInvoicePrefix"`
// String. An arbitrary string that you can attach to a customer object. It is displayed alongside the customer in the dashboard.
Description *string `pulumi:"description"`
// String. Customer’s email address. It’s displayed alongside the customer in your dashboard and can be useful for searching and tracking. This may be up to 512 characters.
Email *string `pulumi:"email"`
// String. The prefix for the customer used to generate unique invoice numbers. Must be `3–12 uppercase letters or numbers`.
InvoicePrefix *string `pulumi:"invoicePrefix"`
// Map(String). Default invoice settings for this customer. For supported fields see: Invoice Settings Fields.
InvoiceSettings map[string]string `pulumi:"invoiceSettings"`
// Map(String). Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
Metadata map[string]string `pulumi:"metadata"`
// String. The customer’s full name or business name.
Name *string `pulumi:"name"`
// Int. The sequence to be used on the customer’s next invoice. Defaults to 1.
NextInvoiceSequence *int `pulumi:"nextInvoiceSequence"`
// String. The customer’s phone number.
Phone *string `pulumi:"phone"`
// List(String). Customer’s preferred languages, ordered by preference.
PreferredLocales []string `pulumi:"preferredLocales"`
// Map(String). Mailing and shipping address for the customer. Appears on invoices emailed to this customer. For all individual fields see: Shipping Fields.
Shipping map[string]string `pulumi:"shipping"`
}
type CustomerState struct {
// Map(String). The customer’s address, for all individual fields see: Address Fields.
Address pulumi.StringMapInput
// Int. Current balance, if any, being stored on the customer. If negative, the customer has credit to apply to their next invoice. If positive, the customer has an amount owed that will be added to their next invoice. The balance does not refer to any unpaid invoices; it solely takes into account amounts that have yet to be successfully applied to any invoice. This balance is only taken into account as invoices are finalized.
Balance pulumi.IntPtrInput
// String. The default invoice prefix generated by Stripe when not individual invoice prefix provided.
DefaultInvoicePrefix pulumi.StringPtrInput
// String. An arbitrary string that you can attach to a customer object. It is displayed alongside the customer in the dashboard.
Description pulumi.StringPtrInput
// String. Customer’s email address. It’s displayed alongside the customer in your dashboard and can be useful for searching and tracking. This may be up to 512 characters.
Email pulumi.StringPtrInput
// String. The prefix for the customer used to generate unique invoice numbers. Must be `3–12 uppercase letters or numbers`.
InvoicePrefix pulumi.StringPtrInput
// Map(String). Default invoice settings for this customer. For supported fields see: Invoice Settings Fields.
InvoiceSettings pulumi.StringMapInput
// Map(String). Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
Metadata pulumi.StringMapInput
// String. The customer’s full name or business name.
Name pulumi.StringPtrInput
// Int. The sequence to be used on the customer’s next invoice. Defaults to 1.
NextInvoiceSequence pulumi.IntPtrInput
// String. The customer’s phone number.
Phone pulumi.StringPtrInput
// List(String). Customer’s preferred languages, ordered by preference.
PreferredLocales pulumi.StringArrayInput
// Map(String). Mailing and shipping address for the customer. Appears on invoices emailed to this customer. For all individual fields see: Shipping Fields.
Shipping pulumi.StringMapInput
}
func (CustomerState) ElementType() reflect.Type {
return reflect.TypeOf((*customerState)(nil)).Elem()
}
type customerArgs struct {
// Map(String). The customer’s address, for all individual fields see: Address Fields.
Address map[string]string `pulumi:"address"`
// Int. Current balance, if any, being stored on the customer. If negative, the customer has credit to apply to their next invoice. If positive, the customer has an amount owed that will be added to their next invoice. The balance does not refer to any unpaid invoices; it solely takes into account amounts that have yet to be successfully applied to any invoice. This balance is only taken into account as invoices are finalized.
Balance *int `pulumi:"balance"`
// String. An arbitrary string that you can attach to a customer object. It is displayed alongside the customer in the dashboard.
Description *string `pulumi:"description"`
// String. Customer’s email address. It’s displayed alongside the customer in your dashboard and can be useful for searching and tracking. This may be up to 512 characters.
Email *string `pulumi:"email"`
// String. The prefix for the customer used to generate unique invoice numbers. Must be `3–12 uppercase letters or numbers`.
InvoicePrefix *string `pulumi:"invoicePrefix"`
// Map(String). Default invoice settings for this customer. For supported fields see: Invoice Settings Fields.
InvoiceSettings map[string]string `pulumi:"invoiceSettings"`
// Map(String). Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
Metadata map[string]string `pulumi:"metadata"`
// String. The customer’s full name or business name.
Name *string `pulumi:"name"`
// Int. The sequence to be used on the customer’s next invoice. Defaults to 1.
NextInvoiceSequence *int `pulumi:"nextInvoiceSequence"`
// String. The customer’s phone number.
Phone *string `pulumi:"phone"`
// List(String). Customer’s preferred languages, ordered by preference.
PreferredLocales []string `pulumi:"preferredLocales"`
// Map(String). Mailing and shipping address for the customer. Appears on invoices emailed to this customer. For all individual fields see: Shipping Fields.
Shipping map[string]string `pulumi:"shipping"`
}
// The set of arguments for constructing a Customer resource.
type CustomerArgs struct {
// Map(String). The customer’s address, for all individual fields see: Address Fields.
Address pulumi.StringMapInput
// Int. Current balance, if any, being stored on the customer. If negative, the customer has credit to apply to their next invoice. If positive, the customer has an amount owed that will be added to their next invoice. The balance does not refer to any unpaid invoices; it solely takes into account amounts that have yet to be successfully applied to any invoice. This balance is only taken into account as invoices are finalized.
Balance pulumi.IntPtrInput
// String. An arbitrary string that you can attach to a customer object. It is displayed alongside the customer in the dashboard.
Description pulumi.StringPtrInput
// String. Customer’s email address. It’s displayed alongside the customer in your dashboard and can be useful for searching and tracking. This may be up to 512 characters.
Email pulumi.StringPtrInput
// String. The prefix for the customer used to generate unique invoice numbers. Must be `3–12 uppercase letters or numbers`.
InvoicePrefix pulumi.StringPtrInput
// Map(String). Default invoice settings for this customer. For supported fields see: Invoice Settings Fields.
InvoiceSettings pulumi.StringMapInput
// Map(String). Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
Metadata pulumi.StringMapInput
// String. The customer’s full name or business name.
Name pulumi.StringPtrInput
// Int. The sequence to be used on the customer’s next invoice. Defaults to 1.
NextInvoiceSequence pulumi.IntPtrInput
// String. The customer’s phone number.
Phone pulumi.StringPtrInput
// List(String). Customer’s preferred languages, ordered by preference.
PreferredLocales pulumi.StringArrayInput
// Map(String). Mailing and shipping address for the customer. Appears on invoices emailed to this customer. For all individual fields see: Shipping Fields.
Shipping pulumi.StringMapInput
}
func (CustomerArgs) ElementType() reflect.Type {
return reflect.TypeOf((*customerArgs)(nil)).Elem()
}
type CustomerInput interface {
pulumi.Input
ToCustomerOutput() CustomerOutput
ToCustomerOutputWithContext(ctx context.Context) CustomerOutput
}
func (*Customer) ElementType() reflect.Type {
return reflect.TypeOf((**Customer)(nil)).Elem()
}
func (i *Customer) ToCustomerOutput() CustomerOutput {
return i.ToCustomerOutputWithContext(context.Background())
}
func (i *Customer) ToCustomerOutputWithContext(ctx context.Context) CustomerOutput {
return pulumi.ToOutputWithContext(ctx, i).(CustomerOutput)
}
// CustomerArrayInput is an input type that accepts CustomerArray and CustomerArrayOutput values.
// You can construct a concrete instance of `CustomerArrayInput` via:
//
// CustomerArray{ CustomerArgs{...} }
type CustomerArrayInput interface {
pulumi.Input
ToCustomerArrayOutput() CustomerArrayOutput
ToCustomerArrayOutputWithContext(context.Context) CustomerArrayOutput
}
type CustomerArray []CustomerInput
func (CustomerArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Customer)(nil)).Elem()
}
func (i CustomerArray) ToCustomerArrayOutput() CustomerArrayOutput {
return i.ToCustomerArrayOutputWithContext(context.Background())
}
func (i CustomerArray) ToCustomerArrayOutputWithContext(ctx context.Context) CustomerArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(CustomerArrayOutput)
}
// CustomerMapInput is an input type that accepts CustomerMap and CustomerMapOutput values.
// You can construct a concrete instance of `CustomerMapInput` via:
//
// CustomerMap{ "key": CustomerArgs{...} }
type CustomerMapInput interface {
pulumi.Input
ToCustomerMapOutput() CustomerMapOutput
ToCustomerMapOutputWithContext(context.Context) CustomerMapOutput
}
type CustomerMap map[string]CustomerInput
func (CustomerMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Customer)(nil)).Elem()
}
func (i CustomerMap) ToCustomerMapOutput() CustomerMapOutput {
return i.ToCustomerMapOutputWithContext(context.Background())
}
func (i CustomerMap) ToCustomerMapOutputWithContext(ctx context.Context) CustomerMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(CustomerMapOutput)
}
type CustomerOutput struct{ *pulumi.OutputState }
func (CustomerOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Customer)(nil)).Elem()
}
func (o CustomerOutput) ToCustomerOutput() CustomerOutput {
return o
}
func (o CustomerOutput) ToCustomerOutputWithContext(ctx context.Context) CustomerOutput {
return o
}
// Map(String). The customer’s address, for all individual fields see: Address Fields.
func (o CustomerOutput) Address() pulumi.StringMapOutput {
return o.ApplyT(func(v *Customer) pulumi.StringMapOutput { return v.Address }).(pulumi.StringMapOutput)
}
// Int. Current balance, if any, being stored on the customer. If negative, the customer has credit to apply to their next invoice. If positive, the customer has an amount owed that will be added to their next invoice. The balance does not refer to any unpaid invoices; it solely takes into account amounts that have yet to be successfully applied to any invoice. This balance is only taken into account as invoices are finalized.
func (o CustomerOutput) Balance() pulumi.IntPtrOutput {
return o.ApplyT(func(v *Customer) pulumi.IntPtrOutput { return v.Balance }).(pulumi.IntPtrOutput)
}
// String. The default invoice prefix generated by Stripe when not individual invoice prefix provided.
func (o CustomerOutput) DefaultInvoicePrefix() pulumi.StringOutput {
return o.ApplyT(func(v *Customer) pulumi.StringOutput { return v.DefaultInvoicePrefix }).(pulumi.StringOutput)
}
// String. An arbitrary string that you can attach to a customer object. It is displayed alongside the customer in the dashboard.
func (o CustomerOutput) Description() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Customer) pulumi.StringPtrOutput { return v.Description }).(pulumi.StringPtrOutput)
}
// String. Customer’s email address. It’s displayed alongside the customer in your dashboard and can be useful for searching and tracking. This may be up to 512 characters.
func (o CustomerOutput) Email() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Customer) pulumi.StringPtrOutput { return v.Email }).(pulumi.StringPtrOutput)
}
// String. The prefix for the customer used to generate unique invoice numbers. Must be `3–12 uppercase letters or numbers`.
func (o CustomerOutput) InvoicePrefix() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Customer) pulumi.StringPtrOutput { return v.InvoicePrefix }).(pulumi.StringPtrOutput)
}
// Map(String). Default invoice settings for this customer. For supported fields see: Invoice Settings Fields.
func (o CustomerOutput) InvoiceSettings() pulumi.StringMapOutput {
return o.ApplyT(func(v *Customer) pulumi.StringMapOutput { return v.InvoiceSettings }).(pulumi.StringMapOutput)
}
// Map(String). Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
func (o CustomerOutput) Metadata() pulumi.StringMapOutput {
return o.ApplyT(func(v *Customer) pulumi.StringMapOutput { return v.Metadata }).(pulumi.StringMapOutput)
}
// String. The customer’s full name or business name.
func (o CustomerOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v *Customer) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
}
// Int. The sequence to be used on the customer’s next invoice. Defaults to 1.
func (o CustomerOutput) NextInvoiceSequence() pulumi.IntPtrOutput {
return o.ApplyT(func(v *Customer) pulumi.IntPtrOutput { return v.NextInvoiceSequence }).(pulumi.IntPtrOutput)
}
// String. The customer’s phone number.
func (o CustomerOutput) Phone() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Customer) pulumi.StringPtrOutput { return v.Phone }).(pulumi.StringPtrOutput)
}
// List(String). Customer’s preferred languages, ordered by preference.
func (o CustomerOutput) PreferredLocales() pulumi.StringArrayOutput {
return o.ApplyT(func(v *Customer) pulumi.StringArrayOutput { return v.PreferredLocales }).(pulumi.StringArrayOutput)
}
// Map(String). Mailing and shipping address for the customer. Appears on invoices emailed to this customer. For all individual fields see: Shipping Fields.
func (o CustomerOutput) Shipping() pulumi.StringMapOutput {
return o.ApplyT(func(v *Customer) pulumi.StringMapOutput { return v.Shipping }).(pulumi.StringMapOutput)
}
type CustomerArrayOutput struct{ *pulumi.OutputState }
func (CustomerArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Customer)(nil)).Elem()
}
func (o CustomerArrayOutput) ToCustomerArrayOutput() CustomerArrayOutput {
return o
}
func (o CustomerArrayOutput) ToCustomerArrayOutputWithContext(ctx context.Context) CustomerArrayOutput {
return o
}
func (o CustomerArrayOutput) Index(i pulumi.IntInput) CustomerOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Customer {
return vs[0].([]*Customer)[vs[1].(int)]
}).(CustomerOutput)
}
type CustomerMapOutput struct{ *pulumi.OutputState }
func (CustomerMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Customer)(nil)).Elem()
}
func (o CustomerMapOutput) ToCustomerMapOutput() CustomerMapOutput {
return o
}
func (o CustomerMapOutput) ToCustomerMapOutputWithContext(ctx context.Context) CustomerMapOutput {
return o
}
func (o CustomerMapOutput) MapIndex(k pulumi.StringInput) CustomerOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Customer {
return vs[0].(map[string]*Customer)[vs[1].(string)]
}).(CustomerOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*CustomerInput)(nil)).Elem(), &Customer{})
pulumi.RegisterInputType(reflect.TypeOf((*CustomerArrayInput)(nil)).Elem(), CustomerArray{})
pulumi.RegisterInputType(reflect.TypeOf((*CustomerMapInput)(nil)).Elem(), CustomerMap{})
pulumi.RegisterOutputType(CustomerOutput{})
pulumi.RegisterOutputType(CustomerArrayOutput{})
pulumi.RegisterOutputType(CustomerMapOutput{})
}