api.go 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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. // Creating a request object using this method should be used when you want to inject
  18. // custom logic into the request's lifecycle using a custom handler, or if you want to
  19. // access properties on the request object before or after sending the request. If
  20. // you just want the service response, call the PutEvents method directly
  21. // instead.
  22. //
  23. // Note: You must call the "Send" method on the returned request object in order
  24. // to execute the request.
  25. //
  26. // // Example sending a request using the PutEventsRequest method.
  27. // req, resp := client.PutEventsRequest(params)
  28. //
  29. // err := req.Send()
  30. // if err == nil { // resp is now filled
  31. // fmt.Println(resp)
  32. // }
  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. req = c.newRequest(op, input, output)
  44. req.Handlers.Unmarshal.Remove(restjson.UnmarshalHandler)
  45. req.Handlers.Unmarshal.PushBackNamed(protocol.UnmarshalDiscardBodyHandler)
  46. output = &PutEventsOutput{}
  47. req.Data = output
  48. return
  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. func (c *MobileAnalytics) PutEvents(input *PutEventsInput) (*PutEventsOutput, error) {
  54. req, out := c.PutEventsRequest(input)
  55. err := req.Send()
  56. return out, err
  57. }
  58. // A JSON object representing a batch of unique event occurrences in your app.
  59. type Event struct {
  60. _ struct{} `type:"structure"`
  61. // A collection of key-value pairs that give additional context to the event.
  62. // The key-value pairs are specified by the developer.
  63. //
  64. // This collection can be empty or the attribute object can be omitted.
  65. Attributes map[string]*string `locationName:"attributes" type:"map"`
  66. // A name signifying an event that occurred in your app. This is used for grouping
  67. // and aggregating like events together for reporting purposes.
  68. EventType *string `locationName:"eventType" min:"1" type:"string" required:"true"`
  69. // A collection of key-value pairs that gives additional, measurable context
  70. // to the event. The key-value pairs are specified by the developer.
  71. //
  72. // This collection can be empty or the attribute object can be omitted.
  73. Metrics map[string]*float64 `locationName:"metrics" type:"map"`
  74. // The session the event occured within.
  75. Session *Session `locationName:"session" type:"structure"`
  76. // The time the event occurred in ISO 8601 standard date time format. For example,
  77. // 2014-06-30T19:07:47.885Z
  78. Timestamp *string `locationName:"timestamp" type:"string" required:"true"`
  79. // The version of the event.
  80. Version *string `locationName:"version" min:"1" type:"string"`
  81. }
  82. // String returns the string representation
  83. func (s Event) String() string {
  84. return awsutil.Prettify(s)
  85. }
  86. // GoString returns the string representation
  87. func (s Event) GoString() string {
  88. return s.String()
  89. }
  90. // Validate inspects the fields of the type to determine if they are valid.
  91. func (s *Event) Validate() error {
  92. invalidParams := request.ErrInvalidParams{Context: "Event"}
  93. if s.EventType == nil {
  94. invalidParams.Add(request.NewErrParamRequired("EventType"))
  95. }
  96. if s.EventType != nil && len(*s.EventType) < 1 {
  97. invalidParams.Add(request.NewErrParamMinLen("EventType", 1))
  98. }
  99. if s.Timestamp == nil {
  100. invalidParams.Add(request.NewErrParamRequired("Timestamp"))
  101. }
  102. if s.Version != nil && len(*s.Version) < 1 {
  103. invalidParams.Add(request.NewErrParamMinLen("Version", 1))
  104. }
  105. if s.Session != nil {
  106. if err := s.Session.Validate(); err != nil {
  107. invalidParams.AddNested("Session", err.(request.ErrInvalidParams))
  108. }
  109. }
  110. if invalidParams.Len() > 0 {
  111. return invalidParams
  112. }
  113. return nil
  114. }
  115. // A container for the data needed for a PutEvent operation
  116. type PutEventsInput struct {
  117. _ struct{} `type:"structure"`
  118. // The client context including the client ID, app title, app version and package
  119. // name.
  120. ClientContext *string `location:"header" locationName:"x-amz-Client-Context" type:"string" required:"true"`
  121. // The encoding used for the client context.
  122. ClientContextEncoding *string `location:"header" locationName:"x-amz-Client-Context-Encoding" type:"string"`
  123. // An array of Event JSON objects
  124. Events []*Event `locationName:"events" type:"list" required:"true"`
  125. }
  126. // String returns the string representation
  127. func (s PutEventsInput) String() string {
  128. return awsutil.Prettify(s)
  129. }
  130. // GoString returns the string representation
  131. func (s PutEventsInput) GoString() string {
  132. return s.String()
  133. }
  134. // Validate inspects the fields of the type to determine if they are valid.
  135. func (s *PutEventsInput) Validate() error {
  136. invalidParams := request.ErrInvalidParams{Context: "PutEventsInput"}
  137. if s.ClientContext == nil {
  138. invalidParams.Add(request.NewErrParamRequired("ClientContext"))
  139. }
  140. if s.Events == nil {
  141. invalidParams.Add(request.NewErrParamRequired("Events"))
  142. }
  143. if s.Events != nil {
  144. for i, v := range s.Events {
  145. if v == nil {
  146. continue
  147. }
  148. if err := v.Validate(); err != nil {
  149. invalidParams.AddNested(fmt.Sprintf("%s[%v]", "Events", i), err.(request.ErrInvalidParams))
  150. }
  151. }
  152. }
  153. if invalidParams.Len() > 0 {
  154. return invalidParams
  155. }
  156. return nil
  157. }
  158. type PutEventsOutput struct {
  159. _ struct{} `type:"structure"`
  160. }
  161. // String returns the string representation
  162. func (s PutEventsOutput) String() string {
  163. return awsutil.Prettify(s)
  164. }
  165. // GoString returns the string representation
  166. func (s PutEventsOutput) GoString() string {
  167. return s.String()
  168. }
  169. // Describes the session. Session information is required on ALL events.
  170. type Session struct {
  171. _ struct{} `type:"structure"`
  172. // The duration of the session.
  173. Duration *int64 `locationName:"duration" type:"long"`
  174. // A unique identifier for the session
  175. Id *string `locationName:"id" min:"1" type:"string"`
  176. // The time the event started in ISO 8601 standard date time format. For example,
  177. // 2014-06-30T19:07:47.885Z
  178. StartTimestamp *string `locationName:"startTimestamp" type:"string"`
  179. // The time the event terminated in ISO 8601 standard date time format. For
  180. // example, 2014-06-30T19:07:47.885Z
  181. StopTimestamp *string `locationName:"stopTimestamp" type:"string"`
  182. }
  183. // String returns the string representation
  184. func (s Session) String() string {
  185. return awsutil.Prettify(s)
  186. }
  187. // GoString returns the string representation
  188. func (s Session) GoString() string {
  189. return s.String()
  190. }
  191. // Validate inspects the fields of the type to determine if they are valid.
  192. func (s *Session) Validate() error {
  193. invalidParams := request.ErrInvalidParams{Context: "Session"}
  194. if s.Id != nil && len(*s.Id) < 1 {
  195. invalidParams.Add(request.NewErrParamMinLen("Id", 1))
  196. }
  197. if invalidParams.Len() > 0 {
  198. return invalidParams
  199. }
  200. return nil
  201. }