-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
api.go
656 lines (560 loc) · 20.1 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
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
package forecastqueryservice
import (
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awsutil"
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/private/protocol"
)
const opQueryForecast = "QueryForecast"
// QueryForecastRequest generates a "aws/request.Request" representing the
// client's request for the QueryForecast operation. The "output" return
// value will be populated with the request's response once the request completes
// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
//
// See QueryForecast for more information on using the QueryForecast
// API call, and error handling.
//
// This method is useful when you want to inject custom logic or configuration
// into the SDK's request lifecycle. Such as custom headers, or retry logic.
//
//
// // Example sending a request using the QueryForecastRequest method.
// req, resp := client.QueryForecastRequest(params)
//
// err := req.Send()
// if err == nil { // resp is now filled
// fmt.Println(resp)
// }
//
// See also, https://docs.aws.amazon.com/goto/WebAPI/forecastquery-2018-06-26/QueryForecast
func (c *ForecastQueryService) QueryForecastRequest(input *QueryForecastInput) (req *request.Request, output *QueryForecastOutput) {
op := &request.Operation{
Name: opQueryForecast,
HTTPMethod: "POST",
HTTPPath: "/",
}
if input == nil {
input = &QueryForecastInput{}
}
output = &QueryForecastOutput{}
req = c.newRequest(op, input, output)
return
}
// QueryForecast API operation for Amazon Forecast Query Service.
//
// Retrieves a forecast for a single item, filtered by the supplied criteria.
//
// The criteria is a key-value pair. The key is either item_id (or the equivalent
// non-timestamp, non-target field) from the TARGET_TIME_SERIES dataset, or
// one of the forecast dimensions specified as part of the FeaturizationConfig
// object.
//
// By default, QueryForecast returns the complete date range for the filtered
// forecast. You can request a specific date range.
//
// To get the full forecast, use the CreateForecastExportJob (https://docs.aws.amazon.com/en_us/forecast/latest/dg/API_CreateForecastExportJob.html)
// operation.
//
// The forecasts generated by Amazon Forecast are in the same timezone as the
// dataset that was used to create the predictor.
//
// Returns awserr.Error for service API and SDK errors. Use runtime type assertions
// with awserr.Error's Code and Message methods to get detailed information about
// the error.
//
// See the AWS API reference guide for Amazon Forecast Query Service's
// API operation QueryForecast for usage and error information.
//
// Returned Error Types:
// * ResourceNotFoundException
// We can't find that resource. Check the information that you've provided and
// try again.
//
// * ResourceInUseException
// The specified resource is in use.
//
// * InvalidInputException
// The value is invalid or is too long.
//
// * LimitExceededException
// The limit on the number of requests per second has been exceeded.
//
// * InvalidNextTokenException
// The token is not valid. Tokens expire after 24 hours.
//
// See also, https://docs.aws.amazon.com/goto/WebAPI/forecastquery-2018-06-26/QueryForecast
func (c *ForecastQueryService) QueryForecast(input *QueryForecastInput) (*QueryForecastOutput, error) {
req, out := c.QueryForecastRequest(input)
return out, req.Send()
}
// QueryForecastWithContext is the same as QueryForecast with the addition of
// the ability to pass a context and additional request options.
//
// See QueryForecast for details on how to use this API operation.
//
// 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 *ForecastQueryService) QueryForecastWithContext(ctx aws.Context, input *QueryForecastInput, opts ...request.Option) (*QueryForecastOutput, error) {
req, out := c.QueryForecastRequest(input)
req.SetContext(ctx)
req.ApplyOptions(opts...)
return out, req.Send()
}
// The forecast value for a specific date. Part of the Forecast object.
type DataPoint struct {
_ struct{} `type:"structure"`
// The timestamp of the specific forecast.
Timestamp *string `type:"string"`
// The forecast value.
Value *float64 `type:"double"`
}
// String returns the string representation.
//
// API parameter values that are decorated as "sensitive" in the API will not
// be included in the string output. The member name will be present, but the
// value will be replaced with "sensitive".
func (s DataPoint) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation.
//
// API parameter values that are decorated as "sensitive" in the API will not
// be included in the string output. The member name will be present, but the
// value will be replaced with "sensitive".
func (s DataPoint) GoString() string {
return s.String()
}
// SetTimestamp sets the Timestamp field's value.
func (s *DataPoint) SetTimestamp(v string) *DataPoint {
s.Timestamp = &v
return s
}
// SetValue sets the Value field's value.
func (s *DataPoint) SetValue(v float64) *DataPoint {
s.Value = &v
return s
}
// Provides information about a forecast. Returned as part of the QueryForecast
// response.
type Forecast struct {
_ struct{} `type:"structure"`
// The forecast.
//
// The string of the string-to-array map is one of the following values:
//
// * p10
//
// * p50
//
// * p90
Predictions map[string][]*DataPoint `type:"map"`
}
// String returns the string representation.
//
// API parameter values that are decorated as "sensitive" in the API will not
// be included in the string output. The member name will be present, but the
// value will be replaced with "sensitive".
func (s Forecast) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation.
//
// API parameter values that are decorated as "sensitive" in the API will not
// be included in the string output. The member name will be present, but the
// value will be replaced with "sensitive".
func (s Forecast) GoString() string {
return s.String()
}
// SetPredictions sets the Predictions field's value.
func (s *Forecast) SetPredictions(v map[string][]*DataPoint) *Forecast {
s.Predictions = v
return s
}
// The value is invalid or is too long.
type InvalidInputException struct {
_ struct{} `type:"structure"`
RespMetadata protocol.ResponseMetadata `json:"-" xml:"-"`
Message_ *string `locationName:"Message" type:"string"`
}
// String returns the string representation.
//
// API parameter values that are decorated as "sensitive" in the API will not
// be included in the string output. The member name will be present, but the
// value will be replaced with "sensitive".
func (s InvalidInputException) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation.
//
// API parameter values that are decorated as "sensitive" in the API will not
// be included in the string output. The member name will be present, but the
// value will be replaced with "sensitive".
func (s InvalidInputException) GoString() string {
return s.String()
}
func newErrorInvalidInputException(v protocol.ResponseMetadata) error {
return &InvalidInputException{
RespMetadata: v,
}
}
// Code returns the exception type name.
func (s *InvalidInputException) Code() string {
return "InvalidInputException"
}
// Message returns the exception's message.
func (s *InvalidInputException) Message() string {
if s.Message_ != nil {
return *s.Message_
}
return ""
}
// OrigErr always returns nil, satisfies awserr.Error interface.
func (s *InvalidInputException) OrigErr() error {
return nil
}
func (s *InvalidInputException) Error() string {
return fmt.Sprintf("%s: %s", s.Code(), s.Message())
}
// Status code returns the HTTP status code for the request's response error.
func (s *InvalidInputException) StatusCode() int {
return s.RespMetadata.StatusCode
}
// RequestID returns the service's response RequestID for request.
func (s *InvalidInputException) RequestID() string {
return s.RespMetadata.RequestID
}
// The token is not valid. Tokens expire after 24 hours.
type InvalidNextTokenException struct {
_ struct{} `type:"structure"`
RespMetadata protocol.ResponseMetadata `json:"-" xml:"-"`
Message_ *string `locationName:"Message" type:"string"`
}
// String returns the string representation.
//
// API parameter values that are decorated as "sensitive" in the API will not
// be included in the string output. The member name will be present, but the
// value will be replaced with "sensitive".
func (s InvalidNextTokenException) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation.
//
// API parameter values that are decorated as "sensitive" in the API will not
// be included in the string output. The member name will be present, but the
// value will be replaced with "sensitive".
func (s InvalidNextTokenException) GoString() string {
return s.String()
}
func newErrorInvalidNextTokenException(v protocol.ResponseMetadata) error {
return &InvalidNextTokenException{
RespMetadata: v,
}
}
// Code returns the exception type name.
func (s *InvalidNextTokenException) Code() string {
return "InvalidNextTokenException"
}
// Message returns the exception's message.
func (s *InvalidNextTokenException) Message() string {
if s.Message_ != nil {
return *s.Message_
}
return ""
}
// OrigErr always returns nil, satisfies awserr.Error interface.
func (s *InvalidNextTokenException) OrigErr() error {
return nil
}
func (s *InvalidNextTokenException) Error() string {
return fmt.Sprintf("%s: %s", s.Code(), s.Message())
}
// Status code returns the HTTP status code for the request's response error.
func (s *InvalidNextTokenException) StatusCode() int {
return s.RespMetadata.StatusCode
}
// RequestID returns the service's response RequestID for request.
func (s *InvalidNextTokenException) RequestID() string {
return s.RespMetadata.RequestID
}
// The limit on the number of requests per second has been exceeded.
type LimitExceededException struct {
_ struct{} `type:"structure"`
RespMetadata protocol.ResponseMetadata `json:"-" xml:"-"`
Message_ *string `locationName:"Message" type:"string"`
}
// String returns the string representation.
//
// API parameter values that are decorated as "sensitive" in the API will not
// be included in the string output. The member name will be present, but the
// value will be replaced with "sensitive".
func (s LimitExceededException) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation.
//
// API parameter values that are decorated as "sensitive" in the API will not
// be included in the string output. The member name will be present, but the
// value will be replaced with "sensitive".
func (s LimitExceededException) GoString() string {
return s.String()
}
func newErrorLimitExceededException(v protocol.ResponseMetadata) error {
return &LimitExceededException{
RespMetadata: v,
}
}
// Code returns the exception type name.
func (s *LimitExceededException) Code() string {
return "LimitExceededException"
}
// Message returns the exception's message.
func (s *LimitExceededException) Message() string {
if s.Message_ != nil {
return *s.Message_
}
return ""
}
// OrigErr always returns nil, satisfies awserr.Error interface.
func (s *LimitExceededException) OrigErr() error {
return nil
}
func (s *LimitExceededException) Error() string {
return fmt.Sprintf("%s: %s", s.Code(), s.Message())
}
// Status code returns the HTTP status code for the request's response error.
func (s *LimitExceededException) StatusCode() int {
return s.RespMetadata.StatusCode
}
// RequestID returns the service's response RequestID for request.
func (s *LimitExceededException) RequestID() string {
return s.RespMetadata.RequestID
}
type QueryForecastInput struct {
_ struct{} `type:"structure"`
// The end date for the forecast. Specify the date using this format: yyyy-MM-dd'T'HH:mm:ss
// (ISO 8601 format). For example, 2015-01-01T20:00:00.
EndDate *string `type:"string"`
// The filtering criteria to apply when retrieving the forecast. For example,
// to get the forecast for client_21 in the electricity usage dataset, specify
// the following:
//
// {"item_id" : "client_21"}
//
// To get the full forecast, use the CreateForecastExportJob (https://docs.aws.amazon.com/en_us/forecast/latest/dg/API_CreateForecastExportJob.html)
// operation.
//
// Filters is a required field
Filters map[string]*string `min:"1" type:"map" required:"true"`
// The Amazon Resource Name (ARN) of the forecast to query.
//
// ForecastArn is a required field
ForecastArn *string `type:"string" required:"true"`
// If the result of the previous request was truncated, the response includes
// a NextToken. To retrieve the next set of results, use the token in the next
// request. Tokens expire after 24 hours.
NextToken *string `min:"1" type:"string"`
// The start date for the forecast. Specify the date using this format: yyyy-MM-dd'T'HH:mm:ss
// (ISO 8601 format). For example, 2015-01-01T08:00:00.
StartDate *string `type:"string"`
}
// String returns the string representation.
//
// API parameter values that are decorated as "sensitive" in the API will not
// be included in the string output. The member name will be present, but the
// value will be replaced with "sensitive".
func (s QueryForecastInput) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation.
//
// API parameter values that are decorated as "sensitive" in the API will not
// be included in the string output. The member name will be present, but the
// value will be replaced with "sensitive".
func (s QueryForecastInput) GoString() string {
return s.String()
}
// Validate inspects the fields of the type to determine if they are valid.
func (s *QueryForecastInput) Validate() error {
invalidParams := request.ErrInvalidParams{Context: "QueryForecastInput"}
if s.Filters == nil {
invalidParams.Add(request.NewErrParamRequired("Filters"))
}
if s.Filters != nil && len(s.Filters) < 1 {
invalidParams.Add(request.NewErrParamMinLen("Filters", 1))
}
if s.ForecastArn == nil {
invalidParams.Add(request.NewErrParamRequired("ForecastArn"))
}
if s.NextToken != nil && len(*s.NextToken) < 1 {
invalidParams.Add(request.NewErrParamMinLen("NextToken", 1))
}
if invalidParams.Len() > 0 {
return invalidParams
}
return nil
}
// SetEndDate sets the EndDate field's value.
func (s *QueryForecastInput) SetEndDate(v string) *QueryForecastInput {
s.EndDate = &v
return s
}
// SetFilters sets the Filters field's value.
func (s *QueryForecastInput) SetFilters(v map[string]*string) *QueryForecastInput {
s.Filters = v
return s
}
// SetForecastArn sets the ForecastArn field's value.
func (s *QueryForecastInput) SetForecastArn(v string) *QueryForecastInput {
s.ForecastArn = &v
return s
}
// SetNextToken sets the NextToken field's value.
func (s *QueryForecastInput) SetNextToken(v string) *QueryForecastInput {
s.NextToken = &v
return s
}
// SetStartDate sets the StartDate field's value.
func (s *QueryForecastInput) SetStartDate(v string) *QueryForecastInput {
s.StartDate = &v
return s
}
type QueryForecastOutput struct {
_ struct{} `type:"structure"`
// The forecast.
Forecast *Forecast `type:"structure"`
}
// String returns the string representation.
//
// API parameter values that are decorated as "sensitive" in the API will not
// be included in the string output. The member name will be present, but the
// value will be replaced with "sensitive".
func (s QueryForecastOutput) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation.
//
// API parameter values that are decorated as "sensitive" in the API will not
// be included in the string output. The member name will be present, but the
// value will be replaced with "sensitive".
func (s QueryForecastOutput) GoString() string {
return s.String()
}
// SetForecast sets the Forecast field's value.
func (s *QueryForecastOutput) SetForecast(v *Forecast) *QueryForecastOutput {
s.Forecast = v
return s
}
// The specified resource is in use.
type ResourceInUseException struct {
_ struct{} `type:"structure"`
RespMetadata protocol.ResponseMetadata `json:"-" xml:"-"`
Message_ *string `locationName:"Message" type:"string"`
}
// String returns the string representation.
//
// API parameter values that are decorated as "sensitive" in the API will not
// be included in the string output. The member name will be present, but the
// value will be replaced with "sensitive".
func (s ResourceInUseException) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation.
//
// API parameter values that are decorated as "sensitive" in the API will not
// be included in the string output. The member name will be present, but the
// value will be replaced with "sensitive".
func (s ResourceInUseException) GoString() string {
return s.String()
}
func newErrorResourceInUseException(v protocol.ResponseMetadata) error {
return &ResourceInUseException{
RespMetadata: v,
}
}
// Code returns the exception type name.
func (s *ResourceInUseException) Code() string {
return "ResourceInUseException"
}
// Message returns the exception's message.
func (s *ResourceInUseException) Message() string {
if s.Message_ != nil {
return *s.Message_
}
return ""
}
// OrigErr always returns nil, satisfies awserr.Error interface.
func (s *ResourceInUseException) OrigErr() error {
return nil
}
func (s *ResourceInUseException) Error() string {
return fmt.Sprintf("%s: %s", s.Code(), s.Message())
}
// Status code returns the HTTP status code for the request's response error.
func (s *ResourceInUseException) StatusCode() int {
return s.RespMetadata.StatusCode
}
// RequestID returns the service's response RequestID for request.
func (s *ResourceInUseException) RequestID() string {
return s.RespMetadata.RequestID
}
// We can't find that resource. Check the information that you've provided and
// try again.
type ResourceNotFoundException struct {
_ struct{} `type:"structure"`
RespMetadata protocol.ResponseMetadata `json:"-" xml:"-"`
Message_ *string `locationName:"Message" type:"string"`
}
// String returns the string representation.
//
// API parameter values that are decorated as "sensitive" in the API will not
// be included in the string output. The member name will be present, but the
// value will be replaced with "sensitive".
func (s ResourceNotFoundException) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation.
//
// API parameter values that are decorated as "sensitive" in the API will not
// be included in the string output. The member name will be present, but the
// value will be replaced with "sensitive".
func (s ResourceNotFoundException) GoString() string {
return s.String()
}
func newErrorResourceNotFoundException(v protocol.ResponseMetadata) error {
return &ResourceNotFoundException{
RespMetadata: v,
}
}
// Code returns the exception type name.
func (s *ResourceNotFoundException) Code() string {
return "ResourceNotFoundException"
}
// Message returns the exception's message.
func (s *ResourceNotFoundException) Message() string {
if s.Message_ != nil {
return *s.Message_
}
return ""
}
// OrigErr always returns nil, satisfies awserr.Error interface.
func (s *ResourceNotFoundException) OrigErr() error {
return nil
}
func (s *ResourceNotFoundException) Error() string {
return fmt.Sprintf("%s: %s", s.Code(), s.Message())
}
// Status code returns the HTTP status code for the request's response error.
func (s *ResourceNotFoundException) StatusCode() int {
return s.RespMetadata.StatusCode
}
// RequestID returns the service's response RequestID for request.
func (s *ResourceNotFoundException) RequestID() string {
return s.RespMetadata.RequestID
}