forked from aws/aws-sdk-go-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.go
641 lines (530 loc) · 19.3 KB
/
api.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
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
package costandusagereportservice
import (
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/internal/awsutil"
)
const opDeleteReportDefinition = "DeleteReportDefinition"
// DeleteReportDefinitionRequest is a API request type for the DeleteReportDefinition API operation.
type DeleteReportDefinitionRequest struct {
*aws.Request
Input *DeleteReportDefinitionInput
}
// Send marshals and sends the DeleteReportDefinition API request.
func (r DeleteReportDefinitionRequest) Send() (*DeleteReportDefinitionOutput, error) {
err := r.Request.Send()
if err != nil {
return nil, err
}
return r.Request.Data.(*DeleteReportDefinitionOutput), nil
}
// DeleteReportDefinitionRequest returns a request value for making API operation for
// AWS Cost and Usage Report Service.
//
// Delete a specified report definition
//
// // Example sending a request using the DeleteReportDefinitionRequest method.
// req := client.DeleteReportDefinitionRequest(params)
// resp, err := req.Send()
// if err == nil {
// fmt.Println(resp)
// }
//
// Please also see https://docs.aws.amazon.com/goto/WebAPI/cur-2017-01-06/DeleteReportDefinition
func (c *CostAndUsageReportService) DeleteReportDefinitionRequest(input *DeleteReportDefinitionInput) DeleteReportDefinitionRequest {
op := &aws.Operation{
Name: opDeleteReportDefinition,
HTTPMethod: "POST",
HTTPPath: "/",
}
if input == nil {
input = &DeleteReportDefinitionInput{}
}
output := &DeleteReportDefinitionOutput{}
req := c.newRequest(op, input, output)
output.responseMetadata = aws.Response{Request: req}
return DeleteReportDefinitionRequest{Request: req, Input: input}
}
const opDescribeReportDefinitions = "DescribeReportDefinitions"
// DescribeReportDefinitionsRequest is a API request type for the DescribeReportDefinitions API operation.
type DescribeReportDefinitionsRequest struct {
*aws.Request
Input *DescribeReportDefinitionsInput
}
// Send marshals and sends the DescribeReportDefinitions API request.
func (r DescribeReportDefinitionsRequest) Send() (*DescribeReportDefinitionsOutput, error) {
err := r.Request.Send()
if err != nil {
return nil, err
}
return r.Request.Data.(*DescribeReportDefinitionsOutput), nil
}
// DescribeReportDefinitionsRequest returns a request value for making API operation for
// AWS Cost and Usage Report Service.
//
// Describe a list of report definitions owned by the account
//
// // Example sending a request using the DescribeReportDefinitionsRequest method.
// req := client.DescribeReportDefinitionsRequest(params)
// resp, err := req.Send()
// if err == nil {
// fmt.Println(resp)
// }
//
// Please also see https://docs.aws.amazon.com/goto/WebAPI/cur-2017-01-06/DescribeReportDefinitions
func (c *CostAndUsageReportService) DescribeReportDefinitionsRequest(input *DescribeReportDefinitionsInput) DescribeReportDefinitionsRequest {
op := &aws.Operation{
Name: opDescribeReportDefinitions,
HTTPMethod: "POST",
HTTPPath: "/",
Paginator: &aws.Paginator{
InputTokens: []string{"NextToken"},
OutputTokens: []string{"NextToken"},
LimitToken: "MaxResults",
TruncationToken: "",
},
}
if input == nil {
input = &DescribeReportDefinitionsInput{}
}
output := &DescribeReportDefinitionsOutput{}
req := c.newRequest(op, input, output)
output.responseMetadata = aws.Response{Request: req}
return DescribeReportDefinitionsRequest{Request: req, Input: input}
}
// DescribeReportDefinitionsPages iterates over the pages of a DescribeReportDefinitions operation,
// calling the "fn" function with the response data for each page. To stop
// iterating, return false from the fn function.
//
// See DescribeReportDefinitions method for more information on how to use this operation.
//
// Note: This operation can generate multiple requests to a service.
//
// // Example iterating over at most 3 pages of a DescribeReportDefinitions operation.
// pageNum := 0
// err := client.DescribeReportDefinitionsPages(params,
// func(page *DescribeReportDefinitionsOutput, lastPage bool) bool {
// pageNum++
// fmt.Println(page)
// return pageNum <= 3
// })
//
func (c *CostAndUsageReportService) DescribeReportDefinitionsPages(input *DescribeReportDefinitionsInput, fn func(*DescribeReportDefinitionsOutput, bool) bool) error {
return c.DescribeReportDefinitionsPagesWithContext(aws.BackgroundContext(), input, fn)
}
// DescribeReportDefinitionsPagesWithContext same as DescribeReportDefinitionsPages except
// it takes a Context and allows setting request options on the pages.
//
// The context must be non-nil and will be used for request cancellation. If
// the context is nil a panic will occur. In the future the SDK may create
// sub-contexts for http.Requests. See https://golang.org/pkg/context/
// for more information on using Contexts.
func (c *CostAndUsageReportService) DescribeReportDefinitionsPagesWithContext(ctx aws.Context, input *DescribeReportDefinitionsInput, fn func(*DescribeReportDefinitionsOutput, bool) bool, opts ...aws.Option) error {
p := aws.Pagination{
NewRequest: func() (*aws.Request, error) {
var inCpy *DescribeReportDefinitionsInput
if input != nil {
tmp := *input
inCpy = &tmp
}
req := c.DescribeReportDefinitionsRequest(inCpy)
req.SetContext(ctx)
req.ApplyOptions(opts...)
return req.Request, nil
},
}
cont := true
for p.Next() && cont {
cont = fn(p.Page().(*DescribeReportDefinitionsOutput), !p.HasNextPage())
}
return p.Err()
}
const opPutReportDefinition = "PutReportDefinition"
// PutReportDefinitionRequest is a API request type for the PutReportDefinition API operation.
type PutReportDefinitionRequest struct {
*aws.Request
Input *PutReportDefinitionInput
}
// Send marshals and sends the PutReportDefinition API request.
func (r PutReportDefinitionRequest) Send() (*PutReportDefinitionOutput, error) {
err := r.Request.Send()
if err != nil {
return nil, err
}
return r.Request.Data.(*PutReportDefinitionOutput), nil
}
// PutReportDefinitionRequest returns a request value for making API operation for
// AWS Cost and Usage Report Service.
//
// Create a new report definition
//
// // Example sending a request using the PutReportDefinitionRequest method.
// req := client.PutReportDefinitionRequest(params)
// resp, err := req.Send()
// if err == nil {
// fmt.Println(resp)
// }
//
// Please also see https://docs.aws.amazon.com/goto/WebAPI/cur-2017-01-06/PutReportDefinition
func (c *CostAndUsageReportService) PutReportDefinitionRequest(input *PutReportDefinitionInput) PutReportDefinitionRequest {
op := &aws.Operation{
Name: opPutReportDefinition,
HTTPMethod: "POST",
HTTPPath: "/",
}
if input == nil {
input = &PutReportDefinitionInput{}
}
output := &PutReportDefinitionOutput{}
req := c.newRequest(op, input, output)
output.responseMetadata = aws.Response{Request: req}
return PutReportDefinitionRequest{Request: req, Input: input}
}
// Request of DeleteReportDefinition
// Please also see https://docs.aws.amazon.com/goto/WebAPI/cur-2017-01-06/DeleteReportDefinitionRequest
type DeleteReportDefinitionInput struct {
_ struct{} `type:"structure"`
// Preferred name for a report, it has to be unique. Must starts with a number/letter,
// case sensitive. Limited to 256 characters.
ReportName *string `type:"string"`
}
// String returns the string representation
func (s DeleteReportDefinitionInput) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation
func (s DeleteReportDefinitionInput) GoString() string {
return s.String()
}
// SetReportName sets the ReportName field's value.
func (s *DeleteReportDefinitionInput) SetReportName(v string) *DeleteReportDefinitionInput {
s.ReportName = &v
return s
}
// Response of DeleteReportDefinition
// Please also see https://docs.aws.amazon.com/goto/WebAPI/cur-2017-01-06/DeleteReportDefinitionResponse
type DeleteReportDefinitionOutput struct {
_ struct{} `type:"structure"`
responseMetadata aws.Response
// A message indicates if the deletion is successful.
ResponseMessage *string `type:"string"`
}
// String returns the string representation
func (s DeleteReportDefinitionOutput) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation
func (s DeleteReportDefinitionOutput) GoString() string {
return s.String()
}
// SDKResponseMetdata return sthe response metadata for the API.
func (s DeleteReportDefinitionOutput) SDKResponseMetadata() aws.Response {
return s.responseMetadata
}
// SetResponseMessage sets the ResponseMessage field's value.
func (s *DeleteReportDefinitionOutput) SetResponseMessage(v string) *DeleteReportDefinitionOutput {
s.ResponseMessage = &v
return s
}
// Request of DescribeReportDefinitions
// Please also see https://docs.aws.amazon.com/goto/WebAPI/cur-2017-01-06/DescribeReportDefinitionsRequest
type DescribeReportDefinitionsInput struct {
_ struct{} `type:"structure"`
// The max number of results returned by the operation.
MaxResults *int64 `min:"5" type:"integer"`
// A generic string.
NextToken *string `type:"string"`
}
// String returns the string representation
func (s DescribeReportDefinitionsInput) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation
func (s DescribeReportDefinitionsInput) GoString() string {
return s.String()
}
// Validate inspects the fields of the type to determine if they are valid.
func (s *DescribeReportDefinitionsInput) Validate() error {
invalidParams := aws.ErrInvalidParams{Context: "DescribeReportDefinitionsInput"}
if s.MaxResults != nil && *s.MaxResults < 5 {
invalidParams.Add(aws.NewErrParamMinValue("MaxResults", 5))
}
if invalidParams.Len() > 0 {
return invalidParams
}
return nil
}
// SetMaxResults sets the MaxResults field's value.
func (s *DescribeReportDefinitionsInput) SetMaxResults(v int64) *DescribeReportDefinitionsInput {
s.MaxResults = &v
return s
}
// SetNextToken sets the NextToken field's value.
func (s *DescribeReportDefinitionsInput) SetNextToken(v string) *DescribeReportDefinitionsInput {
s.NextToken = &v
return s
}
// Response of DescribeReportDefinitions
// Please also see https://docs.aws.amazon.com/goto/WebAPI/cur-2017-01-06/DescribeReportDefinitionsResponse
type DescribeReportDefinitionsOutput struct {
_ struct{} `type:"structure"`
responseMetadata aws.Response
// A generic string.
NextToken *string `type:"string"`
// A list of report definitions.
ReportDefinitions []ReportDefinition `type:"list"`
}
// String returns the string representation
func (s DescribeReportDefinitionsOutput) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation
func (s DescribeReportDefinitionsOutput) GoString() string {
return s.String()
}
// SDKResponseMetdata return sthe response metadata for the API.
func (s DescribeReportDefinitionsOutput) SDKResponseMetadata() aws.Response {
return s.responseMetadata
}
// SetNextToken sets the NextToken field's value.
func (s *DescribeReportDefinitionsOutput) SetNextToken(v string) *DescribeReportDefinitionsOutput {
s.NextToken = &v
return s
}
// SetReportDefinitions sets the ReportDefinitions field's value.
func (s *DescribeReportDefinitionsOutput) SetReportDefinitions(v []ReportDefinition) *DescribeReportDefinitionsOutput {
s.ReportDefinitions = v
return s
}
// Request of PutReportDefinition
// Please also see https://docs.aws.amazon.com/goto/WebAPI/cur-2017-01-06/PutReportDefinitionRequest
type PutReportDefinitionInput struct {
_ struct{} `type:"structure"`
// The definition of AWS Cost and Usage Report. Customer can specify the report
// name, time unit, report format, compression format, S3 bucket and additional
// artifacts and schema elements in the definition.
//
// ReportDefinition is a required field
ReportDefinition *ReportDefinition `type:"structure" required:"true"`
}
// String returns the string representation
func (s PutReportDefinitionInput) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation
func (s PutReportDefinitionInput) GoString() string {
return s.String()
}
// Validate inspects the fields of the type to determine if they are valid.
func (s *PutReportDefinitionInput) Validate() error {
invalidParams := aws.ErrInvalidParams{Context: "PutReportDefinitionInput"}
if s.ReportDefinition == nil {
invalidParams.Add(aws.NewErrParamRequired("ReportDefinition"))
}
if s.ReportDefinition != nil {
if err := s.ReportDefinition.Validate(); err != nil {
invalidParams.AddNested("ReportDefinition", err.(aws.ErrInvalidParams))
}
}
if invalidParams.Len() > 0 {
return invalidParams
}
return nil
}
// SetReportDefinition sets the ReportDefinition field's value.
func (s *PutReportDefinitionInput) SetReportDefinition(v *ReportDefinition) *PutReportDefinitionInput {
s.ReportDefinition = v
return s
}
// Response of PutReportDefinition
// Please also see https://docs.aws.amazon.com/goto/WebAPI/cur-2017-01-06/PutReportDefinitionResponse
type PutReportDefinitionOutput struct {
_ struct{} `type:"structure"`
responseMetadata aws.Response
}
// String returns the string representation
func (s PutReportDefinitionOutput) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation
func (s PutReportDefinitionOutput) GoString() string {
return s.String()
}
// SDKResponseMetdata return sthe response metadata for the API.
func (s PutReportDefinitionOutput) SDKResponseMetadata() aws.Response {
return s.responseMetadata
}
// The definition of AWS Cost and Usage Report. Customer can specify the report
// name, time unit, report format, compression format, S3 bucket and additional
// artifacts and schema elements in the definition.
// Please also see https://docs.aws.amazon.com/goto/WebAPI/cur-2017-01-06/ReportDefinition
type ReportDefinition struct {
_ struct{} `type:"structure"`
// A list of additional artifacts.
AdditionalArtifacts []AdditionalArtifact `type:"list"`
// A list of schema elements.
//
// AdditionalSchemaElements is a required field
AdditionalSchemaElements []SchemaElement `type:"list" required:"true"`
// Preferred compression format for report.
//
// Compression is a required field
Compression CompressionFormat `type:"string" required:"true" enum:"true"`
// Preferred format for report.
//
// Format is a required field
Format ReportFormat `type:"string" required:"true" enum:"true"`
// Preferred name for a report, it has to be unique. Must starts with a number/letter,
// case sensitive. Limited to 256 characters.
//
// ReportName is a required field
ReportName *string `type:"string" required:"true"`
// Name of customer S3 bucket.
//
// S3Bucket is a required field
S3Bucket *string `type:"string" required:"true"`
// Preferred report path prefix. Limited to 256 characters.
//
// S3Prefix is a required field
S3Prefix *string `type:"string" required:"true"`
// Region of customer S3 bucket.
//
// S3Region is a required field
S3Region AWSRegion `type:"string" required:"true" enum:"true"`
// The frequency on which report data are measured and displayed.
//
// TimeUnit is a required field
TimeUnit TimeUnit `type:"string" required:"true" enum:"true"`
}
// String returns the string representation
func (s ReportDefinition) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation
func (s ReportDefinition) GoString() string {
return s.String()
}
// Validate inspects the fields of the type to determine if they are valid.
func (s *ReportDefinition) Validate() error {
invalidParams := aws.ErrInvalidParams{Context: "ReportDefinition"}
if s.AdditionalSchemaElements == nil {
invalidParams.Add(aws.NewErrParamRequired("AdditionalSchemaElements"))
}
if len(s.Compression) == 0 {
invalidParams.Add(aws.NewErrParamRequired("Compression"))
}
if len(s.Format) == 0 {
invalidParams.Add(aws.NewErrParamRequired("Format"))
}
if s.ReportName == nil {
invalidParams.Add(aws.NewErrParamRequired("ReportName"))
}
if s.S3Bucket == nil {
invalidParams.Add(aws.NewErrParamRequired("S3Bucket"))
}
if s.S3Prefix == nil {
invalidParams.Add(aws.NewErrParamRequired("S3Prefix"))
}
if len(s.S3Region) == 0 {
invalidParams.Add(aws.NewErrParamRequired("S3Region"))
}
if len(s.TimeUnit) == 0 {
invalidParams.Add(aws.NewErrParamRequired("TimeUnit"))
}
if invalidParams.Len() > 0 {
return invalidParams
}
return nil
}
// SetAdditionalArtifacts sets the AdditionalArtifacts field's value.
func (s *ReportDefinition) SetAdditionalArtifacts(v []AdditionalArtifact) *ReportDefinition {
s.AdditionalArtifacts = v
return s
}
// SetAdditionalSchemaElements sets the AdditionalSchemaElements field's value.
func (s *ReportDefinition) SetAdditionalSchemaElements(v []SchemaElement) *ReportDefinition {
s.AdditionalSchemaElements = v
return s
}
// SetCompression sets the Compression field's value.
func (s *ReportDefinition) SetCompression(v CompressionFormat) *ReportDefinition {
s.Compression = v
return s
}
// SetFormat sets the Format field's value.
func (s *ReportDefinition) SetFormat(v ReportFormat) *ReportDefinition {
s.Format = v
return s
}
// SetReportName sets the ReportName field's value.
func (s *ReportDefinition) SetReportName(v string) *ReportDefinition {
s.ReportName = &v
return s
}
// SetS3Bucket sets the S3Bucket field's value.
func (s *ReportDefinition) SetS3Bucket(v string) *ReportDefinition {
s.S3Bucket = &v
return s
}
// SetS3Prefix sets the S3Prefix field's value.
func (s *ReportDefinition) SetS3Prefix(v string) *ReportDefinition {
s.S3Prefix = &v
return s
}
// SetS3Region sets the S3Region field's value.
func (s *ReportDefinition) SetS3Region(v AWSRegion) *ReportDefinition {
s.S3Region = v
return s
}
// SetTimeUnit sets the TimeUnit field's value.
func (s *ReportDefinition) SetTimeUnit(v TimeUnit) *ReportDefinition {
s.TimeUnit = v
return s
}
// Region of customer S3 bucket.
type AWSRegion string
// Enum values for AWSRegion
const (
AWSRegionUsEast1 AWSRegion = "us-east-1"
AWSRegionUsWest1 AWSRegion = "us-west-1"
AWSRegionUsWest2 AWSRegion = "us-west-2"
AWSRegionEuCentral1 AWSRegion = "eu-central-1"
AWSRegionEuWest1 AWSRegion = "eu-west-1"
AWSRegionApSoutheast1 AWSRegion = "ap-southeast-1"
AWSRegionApSoutheast2 AWSRegion = "ap-southeast-2"
AWSRegionApNortheast1 AWSRegion = "ap-northeast-1"
)
// Enable support for Redshift and/or QuickSight.
type AdditionalArtifact string
// Enum values for AdditionalArtifact
const (
AdditionalArtifactRedshift AdditionalArtifact = "REDSHIFT"
AdditionalArtifactQuicksight AdditionalArtifact = "QUICKSIGHT"
)
// Preferred compression format for report.
type CompressionFormat string
// Enum values for CompressionFormat
const (
CompressionFormatZip CompressionFormat = "ZIP"
CompressionFormatGzip CompressionFormat = "GZIP"
)
// Preferred format for report.
type ReportFormat string
// Enum values for ReportFormat
const (
ReportFormatTextOrcsv ReportFormat = "textORcsv"
)
// Preference of including Resource IDs. You can include additional details
// about individual resource IDs in your report.
type SchemaElement string
// Enum values for SchemaElement
const (
SchemaElementResources SchemaElement = "RESOURCES"
)
// The frequency on which report data are measured and displayed.
type TimeUnit string
// Enum values for TimeUnit
const (
TimeUnitHourly TimeUnit = "HOURLY"
TimeUnitDaily TimeUnit = "DAILY"
)