api.go 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. // Package mobileanalytics provides a client for Amazon Mobile Analytics.
  3. package mobileanalytics
  4. import (
  5. "fmt"
  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 can be used to capture response data after the request's "Send" method
  15. // is called.
  16. //
  17. // See PutEvents for usage and error information.
  18. //
  19. // Creating a request object using this method should be used when you want to inject
  20. // custom logic into the request's lifecycle using a custom handler, or if you want to
  21. // access properties on the request object before or after sending the request. If
  22. // you just want the service response, call the PutEvents method directly
  23. // instead.
  24. //
  25. // Note: You must call the "Send" method on the returned request object in order
  26. // to execute the request.
  27. //
  28. // // Example sending a request using the PutEventsRequest method.
  29. // req, resp := client.PutEventsRequest(params)
  30. //
  31. // err := req.Send()
  32. // if err == nil { // resp is now filled
  33. // fmt.Println(resp)
  34. // }
  35. //
  36. func (c *MobileAnalytics) PutEventsRequest(input *PutEventsInput) (req *request.Request, output *PutEventsOutput) {
  37. op := &request.Operation{
  38. Name: opPutEvents,
  39. HTTPMethod: "POST",
  40. HTTPPath: "/2014-06-05/events",
  41. }
  42. if input == nil {
  43. input = &PutEventsInput{}
  44. }
  45. req = c.newRequest(op, input, output)
  46. req.Handlers.Unmarshal.Remove(restjson.UnmarshalHandler)
  47. req.Handlers.Unmarshal.PushBackNamed(protocol.UnmarshalDiscardBodyHandler)
  48. output = &PutEventsOutput{}
  49. req.Data = output
  50. return
  51. }
  52. // PutEvents API operation for Amazon Mobile Analytics.
  53. //
  54. // The PutEvents operation records one or more events. You can have up to 1,500
  55. // unique custom events per app, any combination of up to 40 attributes and
  56. // metrics per custom event, and any number of attribute or metric values.
  57. //
  58. // Returns awserr.Error for service API and SDK errors. Use runtime type assertions
  59. // with awserr.Error's Code and Message methods to get detailed information about
  60. // the error.
  61. //
  62. // See the AWS API reference guide for Amazon Mobile Analytics's
  63. // API operation PutEvents for usage and error information.
  64. //
  65. // Returned Error Codes:
  66. // * BadRequestException
  67. // An exception object returned when a request fails.
  68. //
  69. func (c *MobileAnalytics) PutEvents(input *PutEventsInput) (*PutEventsOutput, error) {
  70. req, out := c.PutEventsRequest(input)
  71. err := req.Send()
  72. return out, err
  73. }
  74. // A JSON object representing a batch of unique event occurrences in your app.
  75. type Event struct {
  76. _ struct{} `type:"structure"`
  77. // A collection of key-value pairs that give additional context to the event.
  78. // The key-value pairs are specified by the developer.
  79. //
  80. // This collection can be empty or the attribute object can be omitted.
  81. Attributes map[string]*string `locationName:"attributes" type:"map"`
  82. // A name signifying an event that occurred in your app. This is used for grouping
  83. // and aggregating like events together for reporting purposes.
  84. //
  85. // EventType is a required field
  86. EventType *string `locationName:"eventType" min:"1" type:"string" required:"true"`
  87. // A collection of key-value pairs that gives additional, measurable context
  88. // to the event. The key-value pairs are specified by the developer.
  89. //
  90. // This collection can be empty or the attribute object can be omitted.
  91. Metrics map[string]*float64 `locationName:"metrics" type:"map"`
  92. // The session the event occured within.
  93. Session *Session `locationName:"session" type:"structure"`
  94. // The time the event occurred in ISO 8601 standard date time format. For example,
  95. // 2014-06-30T19:07:47.885Z
  96. //
  97. // Timestamp is a required field
  98. Timestamp *string `locationName:"timestamp" type:"string" required:"true"`
  99. // The version of the event.
  100. Version *string `locationName:"version" min:"1" type:"string"`
  101. }
  102. // String returns the string representation
  103. func (s Event) String() string {
  104. return awsutil.Prettify(s)
  105. }
  106. // GoString returns the string representation
  107. func (s Event) GoString() string {
  108. return s.String()
  109. }
  110. // Validate inspects the fields of the type to determine if they are valid.
  111. func (s *Event) Validate() error {
  112. invalidParams := request.ErrInvalidParams{Context: "Event"}
  113. if s.EventType == nil {
  114. invalidParams.Add(request.NewErrParamRequired("EventType"))
  115. }
  116. if s.EventType != nil && len(*s.EventType) < 1 {
  117. invalidParams.Add(request.NewErrParamMinLen("EventType", 1))
  118. }
  119. if s.Timestamp == nil {
  120. invalidParams.Add(request.NewErrParamRequired("Timestamp"))
  121. }
  122. if s.Version != nil && len(*s.Version) < 1 {
  123. invalidParams.Add(request.NewErrParamMinLen("Version", 1))
  124. }
  125. if s.Session != nil {
  126. if err := s.Session.Validate(); err != nil {
  127. invalidParams.AddNested("Session", err.(request.ErrInvalidParams))
  128. }
  129. }
  130. if invalidParams.Len() > 0 {
  131. return invalidParams
  132. }
  133. return nil
  134. }
  135. // A container for the data needed for a PutEvent operation
  136. type PutEventsInput struct {
  137. _ struct{} `type:"structure"`
  138. // The client context including the client ID, app title, app version and package
  139. // name.
  140. //
  141. // ClientContext is a required field
  142. ClientContext *string `location:"header" locationName:"x-amz-Client-Context" type:"string" required:"true"`
  143. // The encoding used for the client context.
  144. ClientContextEncoding *string `location:"header" locationName:"x-amz-Client-Context-Encoding" type:"string"`
  145. // An array of Event JSON objects
  146. //
  147. // Events is a required field
  148. Events []*Event `locationName:"events" type:"list" required:"true"`
  149. }
  150. // String returns the string representation
  151. func (s PutEventsInput) String() string {
  152. return awsutil.Prettify(s)
  153. }
  154. // GoString returns the string representation
  155. func (s PutEventsInput) GoString() string {
  156. return s.String()
  157. }
  158. // Validate inspects the fields of the type to determine if they are valid.
  159. func (s *PutEventsInput) Validate() error {
  160. invalidParams := request.ErrInvalidParams{Context: "PutEventsInput"}
  161. if s.ClientContext == nil {
  162. invalidParams.Add(request.NewErrParamRequired("ClientContext"))
  163. }
  164. if s.Events == nil {
  165. invalidParams.Add(request.NewErrParamRequired("Events"))
  166. }
  167. if s.Events != nil {
  168. for i, v := range s.Events {
  169. if v == nil {
  170. continue
  171. }
  172. if err := v.Validate(); err != nil {
  173. invalidParams.AddNested(fmt.Sprintf("%s[%v]", "Events", i), err.(request.ErrInvalidParams))
  174. }
  175. }
  176. }
  177. if invalidParams.Len() > 0 {
  178. return invalidParams
  179. }
  180. return nil
  181. }
  182. type PutEventsOutput struct {
  183. _ struct{} `type:"structure"`
  184. }
  185. // String returns the string representation
  186. func (s PutEventsOutput) String() string {
  187. return awsutil.Prettify(s)
  188. }
  189. // GoString returns the string representation
  190. func (s PutEventsOutput) GoString() string {
  191. return s.String()
  192. }
  193. // Describes the session. Session information is required on ALL events.
  194. type Session struct {
  195. _ struct{} `type:"structure"`
  196. // The duration of the session.
  197. Duration *int64 `locationName:"duration" type:"long"`
  198. // A unique identifier for the session
  199. Id *string `locationName:"id" min:"1" type:"string"`
  200. // The time the event started in ISO 8601 standard date time format. For example,
  201. // 2014-06-30T19:07:47.885Z
  202. StartTimestamp *string `locationName:"startTimestamp" type:"string"`
  203. // The time the event terminated in ISO 8601 standard date time format. For
  204. // example, 2014-06-30T19:07:47.885Z
  205. StopTimestamp *string `locationName:"stopTimestamp" type:"string"`
  206. }
  207. // String returns the string representation
  208. func (s Session) String() string {
  209. return awsutil.Prettify(s)
  210. }
  211. // GoString returns the string representation
  212. func (s Session) GoString() string {
  213. return s.String()
  214. }
  215. // Validate inspects the fields of the type to determine if they are valid.
  216. func (s *Session) Validate() error {
  217. invalidParams := request.ErrInvalidParams{Context: "Session"}
  218. if s.Id != nil && len(*s.Id) < 1 {
  219. invalidParams.Add(request.NewErrParamMinLen("Id", 1))
  220. }
  221. if invalidParams.Len() > 0 {
  222. return invalidParams
  223. }
  224. return nil
  225. }