forked from aws/aws-sdk-go-v2
/
api.go
372 lines (303 loc) · 10.7 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
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
package mobileanalytics
import (
"fmt"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/internal/awsutil"
"github.com/aws/aws-sdk-go-v2/private/protocol"
"github.com/aws/aws-sdk-go-v2/private/protocol/restjson"
)
const opPutEvents = "PutEvents"
// PutEventsRequest is a API request type for the PutEvents API operation.
type PutEventsRequest struct {
*aws.Request
Input *PutEventsInput
Copy func(*PutEventsInput) PutEventsRequest
}
// Send marshals and sends the PutEvents API request.
func (r PutEventsRequest) Send() (*PutEventsOutput, error) {
err := r.Request.Send()
if err != nil {
return nil, err
}
return r.Request.Data.(*PutEventsOutput), nil
}
// PutEventsRequest returns a request value for making API operation for
// Amazon Mobile Analytics.
//
// The PutEvents operation records one or more events. You can have up to 1,500
// unique custom events per app, any combination of up to 40 attributes and
// metrics per custom event, and any number of attribute or metric values.
//
// // Example sending a request using the PutEventsRequest method.
// req := client.PutEventsRequest(params)
// resp, err := req.Send()
// if err == nil {
// fmt.Println(resp)
// }
func (c *MobileAnalytics) PutEventsRequest(input *PutEventsInput) PutEventsRequest {
op := &aws.Operation{
Name: opPutEvents,
HTTPMethod: "POST",
HTTPPath: "/2014-06-05/events",
}
if input == nil {
input = &PutEventsInput{}
}
output := &PutEventsOutput{}
req := c.newRequest(op, input, output)
req.Handlers.Unmarshal.Remove(restjson.UnmarshalHandler)
req.Handlers.Unmarshal.PushBackNamed(protocol.UnmarshalDiscardBodyHandler)
output.responseMetadata = aws.Response{Request: req}
return PutEventsRequest{Request: req, Input: input, Copy: c.PutEventsRequest}
}
// A JSON object representing a batch of unique event occurrences in your app.
type Event struct {
_ struct{} `type:"structure"`
// A collection of key-value pairs that give additional context to the event.
// The key-value pairs are specified by the developer.
//
// This collection can be empty or the attribute object can be omitted.
Attributes map[string]string `locationName:"attributes" type:"map"`
// A name signifying an event that occurred in your app. This is used for grouping
// and aggregating like events together for reporting purposes.
//
// EventType is a required field
EventType *string `locationName:"eventType" min:"1" type:"string" required:"true"`
// A collection of key-value pairs that gives additional, measurable context
// to the event. The key-value pairs are specified by the developer.
//
// This collection can be empty or the attribute object can be omitted.
Metrics map[string]float64 `locationName:"metrics" type:"map"`
// The session the event occured within.
Session *Session `locationName:"session" type:"structure"`
// The time the event occurred in ISO 8601 standard date time format. For example,
// 2014-06-30T19:07:47.885Z
//
// Timestamp is a required field
Timestamp *string `locationName:"timestamp" type:"string" required:"true"`
// The version of the event.
Version *string `locationName:"version" min:"1" type:"string"`
}
// String returns the string representation
func (s Event) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation
func (s Event) GoString() string {
return s.String()
}
// Validate inspects the fields of the type to determine if they are valid.
func (s *Event) Validate() error {
invalidParams := aws.ErrInvalidParams{Context: "Event"}
if s.EventType == nil {
invalidParams.Add(aws.NewErrParamRequired("EventType"))
}
if s.EventType != nil && len(*s.EventType) < 1 {
invalidParams.Add(aws.NewErrParamMinLen("EventType", 1))
}
if s.Timestamp == nil {
invalidParams.Add(aws.NewErrParamRequired("Timestamp"))
}
if s.Version != nil && len(*s.Version) < 1 {
invalidParams.Add(aws.NewErrParamMinLen("Version", 1))
}
if s.Session != nil {
if err := s.Session.Validate(); err != nil {
invalidParams.AddNested("Session", err.(aws.ErrInvalidParams))
}
}
if invalidParams.Len() > 0 {
return invalidParams
}
return nil
}
// MarshalFields encodes the AWS API shape using the passed in protocol encoder.
func (s Event) MarshalFields(e protocol.FieldEncoder) error {
if len(s.Attributes) > 0 {
v := s.Attributes
metadata := protocol.Metadata{}
ms0 := e.Map(protocol.BodyTarget, "attributes", metadata)
ms0.Start()
for k1, v1 := range v {
ms0.MapSetValue(k1, protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v1)})
}
ms0.End()
}
if s.EventType != nil {
v := *s.EventType
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "eventType", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)
}
if len(s.Metrics) > 0 {
v := s.Metrics
metadata := protocol.Metadata{}
ms0 := e.Map(protocol.BodyTarget, "metrics", metadata)
ms0.Start()
for k1, v1 := range v {
ms0.MapSetValue(k1, protocol.Float64Value(v1))
}
ms0.End()
}
if s.Session != nil {
v := s.Session
metadata := protocol.Metadata{}
e.SetFields(protocol.BodyTarget, "session", v, metadata)
}
if s.Timestamp != nil {
v := *s.Timestamp
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "timestamp", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)
}
if s.Version != nil {
v := *s.Version
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "version", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)
}
return nil
}
// A container for the data needed for a PutEvent operation
type PutEventsInput struct {
_ struct{} `type:"structure"`
// The client context including the client ID, app title, app version and package
// name.
//
// ClientContext is a required field
ClientContext *string `location:"header" locationName:"x-amz-Client-Context" type:"string" required:"true"`
// The encoding used for the client context.
ClientContextEncoding *string `location:"header" locationName:"x-amz-Client-Context-Encoding" type:"string"`
// An array of Event JSON objects
//
// Events is a required field
Events []Event `locationName:"events" type:"list" required:"true"`
}
// String returns the string representation
func (s PutEventsInput) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation
func (s PutEventsInput) GoString() string {
return s.String()
}
// Validate inspects the fields of the type to determine if they are valid.
func (s *PutEventsInput) Validate() error {
invalidParams := aws.ErrInvalidParams{Context: "PutEventsInput"}
if s.ClientContext == nil {
invalidParams.Add(aws.NewErrParamRequired("ClientContext"))
}
if s.Events == nil {
invalidParams.Add(aws.NewErrParamRequired("Events"))
}
if s.Events != nil {
for i, v := range s.Events {
if err := v.Validate(); err != nil {
invalidParams.AddNested(fmt.Sprintf("%s[%v]", "Events", i), err.(aws.ErrInvalidParams))
}
}
}
if invalidParams.Len() > 0 {
return invalidParams
}
return nil
}
// MarshalFields encodes the AWS API shape using the passed in protocol encoder.
func (s PutEventsInput) MarshalFields(e protocol.FieldEncoder) error {
if len(s.Events) > 0 {
v := s.Events
metadata := protocol.Metadata{}
ls0 := e.List(protocol.BodyTarget, "events", metadata)
ls0.Start()
for _, v1 := range v {
ls0.ListAddFields(v1)
}
ls0.End()
}
if s.ClientContext != nil {
v := *s.ClientContext
metadata := protocol.Metadata{}
e.SetValue(protocol.HeaderTarget, "x-amz-Client-Context", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)
}
if s.ClientContextEncoding != nil {
v := *s.ClientContextEncoding
metadata := protocol.Metadata{}
e.SetValue(protocol.HeaderTarget, "x-amz-Client-Context-Encoding", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)
}
return nil
}
type PutEventsOutput struct {
_ struct{} `type:"structure"`
responseMetadata aws.Response
}
// String returns the string representation
func (s PutEventsOutput) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation
func (s PutEventsOutput) GoString() string {
return s.String()
}
// SDKResponseMetdata return sthe response metadata for the API.
func (s PutEventsOutput) SDKResponseMetadata() aws.Response {
return s.responseMetadata
}
// MarshalFields encodes the AWS API shape using the passed in protocol encoder.
func (s PutEventsOutput) MarshalFields(e protocol.FieldEncoder) error {
return nil
}
// Describes the session. Session information is required on ALL events.
type Session struct {
_ struct{} `type:"structure"`
// The duration of the session.
Duration *int64 `locationName:"duration" type:"long"`
// A unique identifier for the session
Id *string `locationName:"id" min:"1" type:"string"`
// The time the event started in ISO 8601 standard date time format. For example,
// 2014-06-30T19:07:47.885Z
StartTimestamp *string `locationName:"startTimestamp" type:"string"`
// The time the event terminated in ISO 8601 standard date time format. For
// example, 2014-06-30T19:07:47.885Z
StopTimestamp *string `locationName:"stopTimestamp" type:"string"`
}
// String returns the string representation
func (s Session) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation
func (s Session) GoString() string {
return s.String()
}
// Validate inspects the fields of the type to determine if they are valid.
func (s *Session) Validate() error {
invalidParams := aws.ErrInvalidParams{Context: "Session"}
if s.Id != nil && len(*s.Id) < 1 {
invalidParams.Add(aws.NewErrParamMinLen("Id", 1))
}
if invalidParams.Len() > 0 {
return invalidParams
}
return nil
}
// MarshalFields encodes the AWS API shape using the passed in protocol encoder.
func (s Session) MarshalFields(e protocol.FieldEncoder) error {
if s.Duration != nil {
v := *s.Duration
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "duration", protocol.Int64Value(v), metadata)
}
if s.Id != nil {
v := *s.Id
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "id", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)
}
if s.StartTimestamp != nil {
v := *s.StartTimestamp
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "startTimestamp", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)
}
if s.StopTimestamp != nil {
v := *s.StopTimestamp
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "stopTimestamp", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)
}
return nil
}