forked from aws/aws-sdk-go-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.go
696 lines (578 loc) · 20.4 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
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
package pricing
import (
"fmt"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/internal/awsutil"
)
const opDescribeServices = "DescribeServices"
// DescribeServicesRequest is a API request type for the DescribeServices API operation.
type DescribeServicesRequest struct {
*aws.Request
Input *DescribeServicesInput
Copy func(*DescribeServicesInput) DescribeServicesRequest
}
// Send marshals and sends the DescribeServices API request.
func (r DescribeServicesRequest) Send() (*DescribeServicesOutput, error) {
err := r.Request.Send()
if err != nil {
return nil, err
}
return r.Request.Data.(*DescribeServicesOutput), nil
}
// DescribeServicesRequest returns a request value for making API operation for
// AWS Price List Service.
//
// Returns the metadata for one service or a list of the metadata for all services.
// Use this without a service code to get the service codes for all services.
// Use it with a service code, such as AmazonEC2, to get information specific
// to that service, such as the attribute names available for that service.
// For example, some of the attribute names available for EC2 are volumeType,
// maxIopsVolume, operation, locationType, and instanceCapacity10xlarge.
//
// // Example sending a request using the DescribeServicesRequest method.
// req := client.DescribeServicesRequest(params)
// resp, err := req.Send()
// if err == nil {
// fmt.Println(resp)
// }
//
// Please also see https://docs.aws.amazon.com/goto/WebAPI/pricing-2017-10-15/DescribeServices
func (c *Pricing) DescribeServicesRequest(input *DescribeServicesInput) DescribeServicesRequest {
op := &aws.Operation{
Name: opDescribeServices,
HTTPMethod: "POST",
HTTPPath: "/",
Paginator: &aws.Paginator{
InputTokens: []string{"NextToken"},
OutputTokens: []string{"NextToken"},
LimitToken: "MaxResults",
TruncationToken: "",
},
}
if input == nil {
input = &DescribeServicesInput{}
}
output := &DescribeServicesOutput{}
req := c.newRequest(op, input, output)
output.responseMetadata = aws.Response{Request: req}
return DescribeServicesRequest{Request: req, Input: input, Copy: c.DescribeServicesRequest}
}
// Paginate pages iterates over the pages of a DescribeServicesRequest operation,
// calling the Next method for each page. Using the paginators Next
// method will depict whether or not there are more pages.
//
// Note: This operation can generate multiple requests to a service.
//
// // Example iterating over at most 3 pages of a DescribeServices operation.
// req := client.DescribeServicesRequest(input)
// p := req.Paginate()
// for p.Next() {
// page := p.CurrentPage()
// }
//
// if err := p.Err(); err != nil {
// return err
// }
//
func (p *DescribeServicesRequest) Paginate(opts ...aws.Option) DescribeServicesPager {
return DescribeServicesPager{
Pager: aws.Pager{
NewRequest: func() (*aws.Request, error) {
var inCpy *DescribeServicesInput
if p.Input != nil {
tmp := *p.Input
inCpy = &tmp
}
req := p.Copy(inCpy)
req.ApplyOptions(opts...)
return req.Request, nil
},
},
}
}
// DescribeServicesPager is used to paginate the request. This can be done by
// calling Next and CurrentPage.
type DescribeServicesPager struct {
aws.Pager
}
func (p *DescribeServicesPager) CurrentPage() *DescribeServicesOutput {
return p.Pager.CurrentPage().(*DescribeServicesOutput)
}
const opGetAttributeValues = "GetAttributeValues"
// GetAttributeValuesRequest is a API request type for the GetAttributeValues API operation.
type GetAttributeValuesRequest struct {
*aws.Request
Input *GetAttributeValuesInput
Copy func(*GetAttributeValuesInput) GetAttributeValuesRequest
}
// Send marshals and sends the GetAttributeValues API request.
func (r GetAttributeValuesRequest) Send() (*GetAttributeValuesOutput, error) {
err := r.Request.Send()
if err != nil {
return nil, err
}
return r.Request.Data.(*GetAttributeValuesOutput), nil
}
// GetAttributeValuesRequest returns a request value for making API operation for
// AWS Price List Service.
//
// Returns a list of attribute values. Attibutes are similar to the details
// in a Price List API offer file. For a list of available attributes, see Offer
// File Definitions (http://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/reading-an-offer.html#pps-defs)
// in the AWS Billing and Cost Management User Guide (http://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/billing-what-is.html).
//
// // Example sending a request using the GetAttributeValuesRequest method.
// req := client.GetAttributeValuesRequest(params)
// resp, err := req.Send()
// if err == nil {
// fmt.Println(resp)
// }
//
// Please also see https://docs.aws.amazon.com/goto/WebAPI/pricing-2017-10-15/GetAttributeValues
func (c *Pricing) GetAttributeValuesRequest(input *GetAttributeValuesInput) GetAttributeValuesRequest {
op := &aws.Operation{
Name: opGetAttributeValues,
HTTPMethod: "POST",
HTTPPath: "/",
Paginator: &aws.Paginator{
InputTokens: []string{"NextToken"},
OutputTokens: []string{"NextToken"},
LimitToken: "MaxResults",
TruncationToken: "",
},
}
if input == nil {
input = &GetAttributeValuesInput{}
}
output := &GetAttributeValuesOutput{}
req := c.newRequest(op, input, output)
output.responseMetadata = aws.Response{Request: req}
return GetAttributeValuesRequest{Request: req, Input: input, Copy: c.GetAttributeValuesRequest}
}
// Paginate pages iterates over the pages of a GetAttributeValuesRequest operation,
// calling the Next method for each page. Using the paginators Next
// method will depict whether or not there are more pages.
//
// Note: This operation can generate multiple requests to a service.
//
// // Example iterating over at most 3 pages of a GetAttributeValues operation.
// req := client.GetAttributeValuesRequest(input)
// p := req.Paginate()
// for p.Next() {
// page := p.CurrentPage()
// }
//
// if err := p.Err(); err != nil {
// return err
// }
//
func (p *GetAttributeValuesRequest) Paginate(opts ...aws.Option) GetAttributeValuesPager {
return GetAttributeValuesPager{
Pager: aws.Pager{
NewRequest: func() (*aws.Request, error) {
var inCpy *GetAttributeValuesInput
if p.Input != nil {
tmp := *p.Input
inCpy = &tmp
}
req := p.Copy(inCpy)
req.ApplyOptions(opts...)
return req.Request, nil
},
},
}
}
// GetAttributeValuesPager is used to paginate the request. This can be done by
// calling Next and CurrentPage.
type GetAttributeValuesPager struct {
aws.Pager
}
func (p *GetAttributeValuesPager) CurrentPage() *GetAttributeValuesOutput {
return p.Pager.CurrentPage().(*GetAttributeValuesOutput)
}
const opGetProducts = "GetProducts"
// GetProductsRequest is a API request type for the GetProducts API operation.
type GetProductsRequest struct {
*aws.Request
Input *GetProductsInput
Copy func(*GetProductsInput) GetProductsRequest
}
// Send marshals and sends the GetProducts API request.
func (r GetProductsRequest) Send() (*GetProductsOutput, error) {
err := r.Request.Send()
if err != nil {
return nil, err
}
return r.Request.Data.(*GetProductsOutput), nil
}
// GetProductsRequest returns a request value for making API operation for
// AWS Price List Service.
//
// Returns a list of all products that match the filter criteria.
//
// // Example sending a request using the GetProductsRequest method.
// req := client.GetProductsRequest(params)
// resp, err := req.Send()
// if err == nil {
// fmt.Println(resp)
// }
//
// Please also see https://docs.aws.amazon.com/goto/WebAPI/pricing-2017-10-15/GetProducts
func (c *Pricing) GetProductsRequest(input *GetProductsInput) GetProductsRequest {
op := &aws.Operation{
Name: opGetProducts,
HTTPMethod: "POST",
HTTPPath: "/",
Paginator: &aws.Paginator{
InputTokens: []string{"NextToken"},
OutputTokens: []string{"NextToken"},
LimitToken: "MaxResults",
TruncationToken: "",
},
}
if input == nil {
input = &GetProductsInput{}
}
output := &GetProductsOutput{}
req := c.newRequest(op, input, output)
output.responseMetadata = aws.Response{Request: req}
return GetProductsRequest{Request: req, Input: input, Copy: c.GetProductsRequest}
}
// Paginate pages iterates over the pages of a GetProductsRequest operation,
// calling the Next method for each page. Using the paginators Next
// method will depict whether or not there are more pages.
//
// Note: This operation can generate multiple requests to a service.
//
// // Example iterating over at most 3 pages of a GetProducts operation.
// req := client.GetProductsRequest(input)
// p := req.Paginate()
// for p.Next() {
// page := p.CurrentPage()
// }
//
// if err := p.Err(); err != nil {
// return err
// }
//
func (p *GetProductsRequest) Paginate(opts ...aws.Option) GetProductsPager {
return GetProductsPager{
Pager: aws.Pager{
NewRequest: func() (*aws.Request, error) {
var inCpy *GetProductsInput
if p.Input != nil {
tmp := *p.Input
inCpy = &tmp
}
req := p.Copy(inCpy)
req.ApplyOptions(opts...)
return req.Request, nil
},
},
}
}
// GetProductsPager is used to paginate the request. This can be done by
// calling Next and CurrentPage.
type GetProductsPager struct {
aws.Pager
}
func (p *GetProductsPager) CurrentPage() *GetProductsOutput {
return p.Pager.CurrentPage().(*GetProductsOutput)
}
// The values of a given attribute, such as Throughput Optimized HDD or Provisioned
// IOPS for the Amazon EC2volumeType attribute.
// Please also see https://docs.aws.amazon.com/goto/WebAPI/pricing-2017-10-15/AttributeValue
type AttributeValue struct {
_ struct{} `type:"structure"`
// The specific value of an attributeName.
Value *string `type:"string"`
}
// String returns the string representation
func (s AttributeValue) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation
func (s AttributeValue) GoString() string {
return s.String()
}
// Please also see https://docs.aws.amazon.com/goto/WebAPI/pricing-2017-10-15/DescribeServicesRequest
type DescribeServicesInput struct {
_ struct{} `type:"structure"`
// The format version that you want the response to be in.
//
// Valid values are: aws_v1
FormatVersion *string `type:"string"`
// The maximum number of results that you want returned in the response.
MaxResults *int64 `min:"1" type:"integer"`
// The pagination token that indicates the next set of results that you want
// to retrieve.
NextToken *string `type:"string"`
// The code for the service whose information you want to retrieve, such as
// AmazonEC2. You can use the ServiceCode to filter the results in a GetProducts
// call. To retrieve a list of all services, leave this blank.
ServiceCode *string `type:"string"`
}
// String returns the string representation
func (s DescribeServicesInput) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation
func (s DescribeServicesInput) GoString() string {
return s.String()
}
// Validate inspects the fields of the type to determine if they are valid.
func (s *DescribeServicesInput) Validate() error {
invalidParams := aws.ErrInvalidParams{Context: "DescribeServicesInput"}
if s.MaxResults != nil && *s.MaxResults < 1 {
invalidParams.Add(aws.NewErrParamMinValue("MaxResults", 1))
}
if invalidParams.Len() > 0 {
return invalidParams
}
return nil
}
// Please also see https://docs.aws.amazon.com/goto/WebAPI/pricing-2017-10-15/DescribeServicesResponse
type DescribeServicesOutput struct {
_ struct{} `type:"structure"`
responseMetadata aws.Response
// The format version of the response. For example, aws_v1.
FormatVersion *string `type:"string"`
// The pagination token for the next set of retreivable results.
NextToken *string `type:"string"`
// The service metadata for the service or services in the response.
Services []Service `type:"list"`
}
// String returns the string representation
func (s DescribeServicesOutput) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation
func (s DescribeServicesOutput) GoString() string {
return s.String()
}
// SDKResponseMetdata return sthe response metadata for the API.
func (s DescribeServicesOutput) SDKResponseMetadata() aws.Response {
return s.responseMetadata
}
// The constraints that you want all returned products to match.
// Please also see https://docs.aws.amazon.com/goto/WebAPI/pricing-2017-10-15/Filter
type Filter struct {
_ struct{} `type:"structure"`
// The product metadata field that you want to filter on. You can filter by
// just the service code to see all products for a specific service, filter
// by just the attribute name to see a specific attribute for multiple services,
// or use both a service code and an attribute name to retrieve only products
// that match both fields.
//
// Valid values include: ServiceCode, and all attribute names
//
// For example, you can filter by the AmazonEC2 service code and the volumeType
// attribute name to get the prices for only Amazon EC2 volumes.
//
// Field is a required field
Field *string `type:"string" required:"true"`
// The type of filter that you want to use.
//
// Valid values are: TERM_MATCH. TERM_MATCH returns only products that match
// both the given filter field and the given value.
//
// Type is a required field
Type FilterType `type:"string" required:"true" enum:"true"`
// The service code or attribute value that you want to filter by. If you are
// filtering by service code this is the actual service code, such as AmazonEC2.
// If you are filtering by attribute name, this is the attribute value that
// you want the returned products to match, such as a Provisioned IOPS volume.
//
// Value is a required field
Value *string `type:"string" required:"true"`
}
// String returns the string representation
func (s Filter) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation
func (s Filter) GoString() string {
return s.String()
}
// Validate inspects the fields of the type to determine if they are valid.
func (s *Filter) Validate() error {
invalidParams := aws.ErrInvalidParams{Context: "Filter"}
if s.Field == nil {
invalidParams.Add(aws.NewErrParamRequired("Field"))
}
if len(s.Type) == 0 {
invalidParams.Add(aws.NewErrParamRequired("Type"))
}
if s.Value == nil {
invalidParams.Add(aws.NewErrParamRequired("Value"))
}
if invalidParams.Len() > 0 {
return invalidParams
}
return nil
}
// Please also see https://docs.aws.amazon.com/goto/WebAPI/pricing-2017-10-15/GetAttributeValuesRequest
type GetAttributeValuesInput struct {
_ struct{} `type:"structure"`
// The name of the attribute that you want to retrieve the values for, such
// as volumeType.
//
// AttributeName is a required field
AttributeName *string `type:"string" required:"true"`
// The maximum number of results to return in response.
MaxResults *int64 `min:"1" type:"integer"`
// The pagination token that indicates the next set of results that you want
// to retrieve.
NextToken *string `type:"string"`
// The service code for the service whose attributes you want to retrieve. For
// example, if you want the retrieve an EC2 attribute, use AmazonEC2.
//
// ServiceCode is a required field
ServiceCode *string `type:"string" required:"true"`
}
// String returns the string representation
func (s GetAttributeValuesInput) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation
func (s GetAttributeValuesInput) GoString() string {
return s.String()
}
// Validate inspects the fields of the type to determine if they are valid.
func (s *GetAttributeValuesInput) Validate() error {
invalidParams := aws.ErrInvalidParams{Context: "GetAttributeValuesInput"}
if s.AttributeName == nil {
invalidParams.Add(aws.NewErrParamRequired("AttributeName"))
}
if s.MaxResults != nil && *s.MaxResults < 1 {
invalidParams.Add(aws.NewErrParamMinValue("MaxResults", 1))
}
if s.ServiceCode == nil {
invalidParams.Add(aws.NewErrParamRequired("ServiceCode"))
}
if invalidParams.Len() > 0 {
return invalidParams
}
return nil
}
// Please also see https://docs.aws.amazon.com/goto/WebAPI/pricing-2017-10-15/GetAttributeValuesResponse
type GetAttributeValuesOutput struct {
_ struct{} `type:"structure"`
responseMetadata aws.Response
// The list of values for an attribute. For example, Throughput Optimized HDD
// and Provisioned IOPS are two available values for the AmazonEC2volumeType.
AttributeValues []AttributeValue `type:"list"`
// The pagination token that indicates the next set of results to retrieve.
NextToken *string `type:"string"`
}
// String returns the string representation
func (s GetAttributeValuesOutput) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation
func (s GetAttributeValuesOutput) GoString() string {
return s.String()
}
// SDKResponseMetdata return sthe response metadata for the API.
func (s GetAttributeValuesOutput) SDKResponseMetadata() aws.Response {
return s.responseMetadata
}
// Please also see https://docs.aws.amazon.com/goto/WebAPI/pricing-2017-10-15/GetProductsRequest
type GetProductsInput struct {
_ struct{} `type:"structure"`
// The list of filters that limit the returned products. only products that
// match all filters are returned.
Filters []Filter `type:"list"`
// The format version that you want the response to be in.
//
// Valid values are: aws_v1
FormatVersion *string `type:"string"`
// The maximum number of results to return in the response.
MaxResults *int64 `min:"1" type:"integer"`
// The pagination token that indicates the next set of results that you want
// to retrieve.
NextToken *string `type:"string"`
// The code for the service whose products you want to retrieve.
ServiceCode *string `type:"string"`
}
// String returns the string representation
func (s GetProductsInput) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation
func (s GetProductsInput) GoString() string {
return s.String()
}
// Validate inspects the fields of the type to determine if they are valid.
func (s *GetProductsInput) Validate() error {
invalidParams := aws.ErrInvalidParams{Context: "GetProductsInput"}
if s.MaxResults != nil && *s.MaxResults < 1 {
invalidParams.Add(aws.NewErrParamMinValue("MaxResults", 1))
}
if s.Filters != nil {
for i, v := range s.Filters {
if err := v.Validate(); err != nil {
invalidParams.AddNested(fmt.Sprintf("%s[%v]", "Filters", i), err.(aws.ErrInvalidParams))
}
}
}
if invalidParams.Len() > 0 {
return invalidParams
}
return nil
}
// Please also see https://docs.aws.amazon.com/goto/WebAPI/pricing-2017-10-15/GetProductsResponse
type GetProductsOutput struct {
_ struct{} `type:"structure"`
responseMetadata aws.Response
// The format version of the response. For example, aws_v1.
FormatVersion *string `type:"string"`
// The pagination token that indicates the next set of results to retrieve.
NextToken *string `type:"string"`
// The list of products that match your filters. The list contains both the
// product metadata and the price information.
PriceList []aws.JSONValue `type:"list"`
}
// String returns the string representation
func (s GetProductsOutput) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation
func (s GetProductsOutput) GoString() string {
return s.String()
}
// SDKResponseMetdata return sthe response metadata for the API.
func (s GetProductsOutput) SDKResponseMetadata() aws.Response {
return s.responseMetadata
}
// The metadata for a service, such as the service code and available attribute
// names.
// Please also see https://docs.aws.amazon.com/goto/WebAPI/pricing-2017-10-15/Service
type Service struct {
_ struct{} `type:"structure"`
// The attributes that are available for this service.
AttributeNames []string `type:"list"`
// The code for the AWS service.
ServiceCode *string `type:"string"`
}
// String returns the string representation
func (s Service) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation
func (s Service) GoString() string {
return s.String()
}
type FilterType string
// Enum values for FilterType
const (
FilterTypeTermMatch FilterType = "TERM_MATCH"
)
func (enum FilterType) MarshalValue() (string, error) {
return string(enum), nil
}
func (enum FilterType) MarshalValueBuf(b []byte) ([]byte, error) {
b = b[0:0]
return append(b, enum...), nil
}