examples_test.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package mobileanalytics_test
  3. import (
  4. "bytes"
  5. "fmt"
  6. "time"
  7. "github.com/aws/aws-sdk-go/aws"
  8. "github.com/aws/aws-sdk-go/aws/session"
  9. "github.com/aws/aws-sdk-go/service/mobileanalytics"
  10. )
  11. var _ time.Duration
  12. var _ bytes.Buffer
  13. func ExampleMobileAnalytics_PutEvents() {
  14. sess, err := session.NewSession()
  15. if err != nil {
  16. fmt.Println("failed to create session,", err)
  17. return
  18. }
  19. svc := mobileanalytics.New(sess)
  20. params := &mobileanalytics.PutEventsInput{
  21. ClientContext: aws.String("String"), // Required
  22. Events: []*mobileanalytics.Event{ // Required
  23. { // Required
  24. EventType: aws.String("String50Chars"), // Required
  25. Timestamp: aws.String("ISO8601Timestamp"), // Required
  26. Attributes: map[string]*string{
  27. "Key": aws.String("String0to1000Chars"), // Required
  28. // More values...
  29. },
  30. Metrics: map[string]*float64{
  31. "Key": aws.Float64(1.0), // Required
  32. // More values...
  33. },
  34. Session: &mobileanalytics.Session{
  35. Duration: aws.Int64(1),
  36. Id: aws.String("String50Chars"),
  37. StartTimestamp: aws.String("ISO8601Timestamp"),
  38. StopTimestamp: aws.String("ISO8601Timestamp"),
  39. },
  40. Version: aws.String("String10Chars"),
  41. },
  42. // More values...
  43. },
  44. ClientContextEncoding: aws.String("String"),
  45. }
  46. resp, err := svc.PutEvents(params)
  47. if err != nil {
  48. // Print the error, cast err to awserr.Error to get the Code and
  49. // Message from an error.
  50. fmt.Println(err.Error())
  51. return
  52. }
  53. // Pretty-print the response data.
  54. fmt.Println(resp)
  55. }