api.go 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
  2. package mobileanalytics
  3. import (
  4. "fmt"
  5. "github.com/aws/aws-sdk-go/aws"
  6. "github.com/aws/aws-sdk-go/aws/awsutil"
  7. "github.com/aws/aws-sdk-go/aws/request"
  8. "github.com/aws/aws-sdk-go/private/protocol"
  9. "github.com/aws/aws-sdk-go/private/protocol/restjson"
  10. )
  11. const opPutEvents = "PutEvents"
  12. // PutEventsRequest generates a "aws/request.Request" representing the
  13. // client's request for the PutEvents operation. The "output" return
  14. // value will be populated with the request's response once the request completes
  15. // successfully.
  16. //
  17. // Use "Send" method on the returned Request to send the API call to the service.
  18. // the "output" return value is not valid until after Send returns without error.
  19. //
  20. // See PutEvents for more information on using the PutEvents
  21. // API call, and error handling.
  22. //
  23. // This method is useful when you want to inject custom logic or configuration
  24. // into the SDK's request lifecycle. Such as custom headers, or retry logic.
  25. //
  26. //
  27. // // Example sending a request using the PutEventsRequest method.
  28. // req, resp := client.PutEventsRequest(params)
  29. //
  30. // err := req.Send()
  31. // if err == nil { // resp is now filled
  32. // fmt.Println(resp)
  33. // }
  34. func (c *MobileAnalytics) PutEventsRequest(input *PutEventsInput) (req *request.Request, output *PutEventsOutput) {
  35. op := &request.Operation{
  36. Name: opPutEvents,
  37. HTTPMethod: "POST",
  38. HTTPPath: "/2014-06-05/events",
  39. }
  40. if input == nil {
  41. input = &PutEventsInput{}
  42. }
  43. output = &PutEventsOutput{}
  44. req = c.newRequest(op, input, output)
  45. req.Handlers.Unmarshal.Swap(restjson.UnmarshalHandler.Name, protocol.UnmarshalDiscardBodyHandler)
  46. return
  47. }
  48. // PutEvents API operation for Amazon Mobile Analytics.
  49. //
  50. // The PutEvents operation records one or more events. You can have up to 1,500
  51. // unique custom events per app, any combination of up to 40 attributes and
  52. // metrics per custom event, and any number of attribute or metric values.
  53. //
  54. // Returns awserr.Error for service API and SDK errors. Use runtime type assertions
  55. // with awserr.Error's Code and Message methods to get detailed information about
  56. // the error.
  57. //
  58. // See the AWS API reference guide for Amazon Mobile Analytics's
  59. // API operation PutEvents for usage and error information.
  60. //
  61. // Returned Error Codes:
  62. // * ErrCodeBadRequestException "BadRequestException"
  63. // An exception object returned when a request fails.
  64. //
  65. func (c *MobileAnalytics) PutEvents(input *PutEventsInput) (*PutEventsOutput, error) {
  66. req, out := c.PutEventsRequest(input)
  67. return out, req.Send()
  68. }
  69. // PutEventsWithContext is the same as PutEvents with the addition of
  70. // the ability to pass a context and additional request options.
  71. //
  72. // See PutEvents for details on how to use this API operation.
  73. //
  74. // The context must be non-nil and will be used for request cancellation. If
  75. // the context is nil a panic will occur. In the future the SDK may create
  76. // sub-contexts for http.Requests. See https://golang.org/pkg/context/
  77. // for more information on using Contexts.
  78. func (c *MobileAnalytics) PutEventsWithContext(ctx aws.Context, input *PutEventsInput, opts ...request.Option) (*PutEventsOutput, error) {
  79. req, out := c.PutEventsRequest(input)
  80. req.SetContext(ctx)
  81. req.ApplyOptions(opts...)
  82. return out, req.Send()
  83. }
  84. // A JSON object representing a batch of unique event occurrences in your app.
  85. type Event struct {
  86. _ struct{} `type:"structure"`
  87. // A collection of key-value pairs that give additional context to the event.
  88. // The key-value pairs are specified by the developer.
  89. //
  90. // This collection can be empty or the attribute object can be omitted.
  91. Attributes map[string]*string `locationName:"attributes" type:"map"`
  92. // A name signifying an event that occurred in your app. This is used for grouping
  93. // and aggregating like events together for reporting purposes.
  94. //
  95. // EventType is a required field
  96. EventType *string `locationName:"eventType" min:"1" type:"string" required:"true"`
  97. // A collection of key-value pairs that gives additional, measurable context
  98. // to the event. The key-value pairs are specified by the developer.
  99. //
  100. // This collection can be empty or the attribute object can be omitted.
  101. Metrics map[string]*float64 `locationName:"metrics" type:"map"`
  102. // The session the event occured within.
  103. Session *Session `locationName:"session" type:"structure"`
  104. // The time the event occurred in ISO 8601 standard date time format. For example,
  105. // 2014-06-30T19:07:47.885Z
  106. //
  107. // Timestamp is a required field
  108. Timestamp *string `locationName:"timestamp" type:"string" required:"true"`
  109. // The version of the event.
  110. Version *string `locationName:"version" min:"1" type:"string"`
  111. }
  112. // String returns the string representation
  113. func (s Event) String() string {
  114. return awsutil.Prettify(s)
  115. }
  116. // GoString returns the string representation
  117. func (s Event) GoString() string {
  118. return s.String()
  119. }
  120. // Validate inspects the fields of the type to determine if they are valid.
  121. func (s *Event) Validate() error {
  122. invalidParams := request.ErrInvalidParams{Context: "Event"}
  123. if s.EventType == nil {
  124. invalidParams.Add(request.NewErrParamRequired("EventType"))
  125. }
  126. if s.EventType != nil && len(*s.EventType) < 1 {
  127. invalidParams.Add(request.NewErrParamMinLen("EventType", 1))
  128. }
  129. if s.Timestamp == nil {
  130. invalidParams.Add(request.NewErrParamRequired("Timestamp"))
  131. }
  132. if s.Version != nil && len(*s.Version) < 1 {
  133. invalidParams.Add(request.NewErrParamMinLen("Version", 1))
  134. }
  135. if s.Session != nil {
  136. if err := s.Session.Validate(); err != nil {
  137. invalidParams.AddNested("Session", err.(request.ErrInvalidParams))
  138. }
  139. }
  140. if invalidParams.Len() > 0 {
  141. return invalidParams
  142. }
  143. return nil
  144. }
  145. // SetAttributes sets the Attributes field's value.
  146. func (s *Event) SetAttributes(v map[string]*string) *Event {
  147. s.Attributes = v
  148. return s
  149. }
  150. // SetEventType sets the EventType field's value.
  151. func (s *Event) SetEventType(v string) *Event {
  152. s.EventType = &v
  153. return s
  154. }
  155. // SetMetrics sets the Metrics field's value.
  156. func (s *Event) SetMetrics(v map[string]*float64) *Event {
  157. s.Metrics = v
  158. return s
  159. }
  160. // SetSession sets the Session field's value.
  161. func (s *Event) SetSession(v *Session) *Event {
  162. s.Session = v
  163. return s
  164. }
  165. // SetTimestamp sets the Timestamp field's value.
  166. func (s *Event) SetTimestamp(v string) *Event {
  167. s.Timestamp = &v
  168. return s
  169. }
  170. // SetVersion sets the Version field's value.
  171. func (s *Event) SetVersion(v string) *Event {
  172. s.Version = &v
  173. return s
  174. }
  175. // A container for the data needed for a PutEvent operation
  176. type PutEventsInput struct {
  177. _ struct{} `type:"structure"`
  178. // The client context including the client ID, app title, app version and package
  179. // name.
  180. //
  181. // ClientContext is a required field
  182. ClientContext *string `location:"header" locationName:"x-amz-Client-Context" type:"string" required:"true"`
  183. // The encoding used for the client context.
  184. ClientContextEncoding *string `location:"header" locationName:"x-amz-Client-Context-Encoding" type:"string"`
  185. // An array of Event JSON objects
  186. //
  187. // Events is a required field
  188. Events []*Event `locationName:"events" type:"list" required:"true"`
  189. }
  190. // String returns the string representation
  191. func (s PutEventsInput) String() string {
  192. return awsutil.Prettify(s)
  193. }
  194. // GoString returns the string representation
  195. func (s PutEventsInput) GoString() string {
  196. return s.String()
  197. }
  198. // Validate inspects the fields of the type to determine if they are valid.
  199. func (s *PutEventsInput) Validate() error {
  200. invalidParams := request.ErrInvalidParams{Context: "PutEventsInput"}
  201. if s.ClientContext == nil {
  202. invalidParams.Add(request.NewErrParamRequired("ClientContext"))
  203. }
  204. if s.Events == nil {
  205. invalidParams.Add(request.NewErrParamRequired("Events"))
  206. }
  207. if s.Events != nil {
  208. for i, v := range s.Events {
  209. if v == nil {
  210. continue
  211. }
  212. if err := v.Validate(); err != nil {
  213. invalidParams.AddNested(fmt.Sprintf("%s[%v]", "Events", i), err.(request.ErrInvalidParams))
  214. }
  215. }
  216. }
  217. if invalidParams.Len() > 0 {
  218. return invalidParams
  219. }
  220. return nil
  221. }
  222. // SetClientContext sets the ClientContext field's value.
  223. func (s *PutEventsInput) SetClientContext(v string) *PutEventsInput {
  224. s.ClientContext = &v
  225. return s
  226. }
  227. // SetClientContextEncoding sets the ClientContextEncoding field's value.
  228. func (s *PutEventsInput) SetClientContextEncoding(v string) *PutEventsInput {
  229. s.ClientContextEncoding = &v
  230. return s
  231. }
  232. // SetEvents sets the Events field's value.
  233. func (s *PutEventsInput) SetEvents(v []*Event) *PutEventsInput {
  234. s.Events = v
  235. return s
  236. }
  237. type PutEventsOutput struct {
  238. _ struct{} `type:"structure"`
  239. }
  240. // String returns the string representation
  241. func (s PutEventsOutput) String() string {
  242. return awsutil.Prettify(s)
  243. }
  244. // GoString returns the string representation
  245. func (s PutEventsOutput) GoString() string {
  246. return s.String()
  247. }
  248. // Describes the session. Session information is required on ALL events.
  249. type Session struct {
  250. _ struct{} `type:"structure"`
  251. // The duration of the session.
  252. Duration *int64 `locationName:"duration" type:"long"`
  253. // A unique identifier for the session
  254. Id *string `locationName:"id" min:"1" type:"string"`
  255. // The time the event started in ISO 8601 standard date time format. For example,
  256. // 2014-06-30T19:07:47.885Z
  257. StartTimestamp *string `locationName:"startTimestamp" type:"string"`
  258. // The time the event terminated in ISO 8601 standard date time format. For
  259. // example, 2014-06-30T19:07:47.885Z
  260. StopTimestamp *string `locationName:"stopTimestamp" type:"string"`
  261. }
  262. // String returns the string representation
  263. func (s Session) String() string {
  264. return awsutil.Prettify(s)
  265. }
  266. // GoString returns the string representation
  267. func (s Session) GoString() string {
  268. return s.String()
  269. }
  270. // Validate inspects the fields of the type to determine if they are valid.
  271. func (s *Session) Validate() error {
  272. invalidParams := request.ErrInvalidParams{Context: "Session"}
  273. if s.Id != nil && len(*s.Id) < 1 {
  274. invalidParams.Add(request.NewErrParamMinLen("Id", 1))
  275. }
  276. if invalidParams.Len() > 0 {
  277. return invalidParams
  278. }
  279. return nil
  280. }
  281. // SetDuration sets the Duration field's value.
  282. func (s *Session) SetDuration(v int64) *Session {
  283. s.Duration = &v
  284. return s
  285. }
  286. // SetId sets the Id field's value.
  287. func (s *Session) SetId(v string) *Session {
  288. s.Id = &v
  289. return s
  290. }
  291. // SetStartTimestamp sets the StartTimestamp field's value.
  292. func (s *Session) SetStartTimestamp(v string) *Session {
  293. s.StartTimestamp = &v
  294. return s
  295. }
  296. // SetStopTimestamp sets the StopTimestamp field's value.
  297. func (s *Session) SetStopTimestamp(v string) *Session {
  298. s.StopTimestamp = &v
  299. return s
  300. }