examples_test.go 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package cloudtrail_test
  3. import (
  4. "bytes"
  5. "fmt"
  6. "time"
  7. "github.com/aws/aws-sdk-go/aws"
  8. "github.com/aws/aws-sdk-go/service/cloudtrail"
  9. )
  10. var _ time.Duration
  11. var _ bytes.Buffer
  12. func ExampleCloudTrail_CreateTrail() {
  13. svc := cloudtrail.New(nil)
  14. params := &cloudtrail.CreateTrailInput{
  15. Name: aws.String("String"), // Required
  16. S3BucketName: aws.String("String"), // Required
  17. CloudWatchLogsLogGroupArn: aws.String("String"),
  18. CloudWatchLogsRoleArn: aws.String("String"),
  19. IncludeGlobalServiceEvents: aws.Bool(true),
  20. S3KeyPrefix: aws.String("String"),
  21. SnsTopicName: aws.String("String"),
  22. }
  23. resp, err := svc.CreateTrail(params)
  24. if err != nil {
  25. // Print the error, cast err to awserr.Error to get the Code and
  26. // Message from an error.
  27. fmt.Println(err.Error())
  28. return
  29. }
  30. // Pretty-print the response data.
  31. fmt.Println(resp)
  32. }
  33. func ExampleCloudTrail_DeleteTrail() {
  34. svc := cloudtrail.New(nil)
  35. params := &cloudtrail.DeleteTrailInput{
  36. Name: aws.String("String"), // Required
  37. }
  38. resp, err := svc.DeleteTrail(params)
  39. if err != nil {
  40. // Print the error, cast err to awserr.Error to get the Code and
  41. // Message from an error.
  42. fmt.Println(err.Error())
  43. return
  44. }
  45. // Pretty-print the response data.
  46. fmt.Println(resp)
  47. }
  48. func ExampleCloudTrail_DescribeTrails() {
  49. svc := cloudtrail.New(nil)
  50. params := &cloudtrail.DescribeTrailsInput{
  51. TrailNameList: []*string{
  52. aws.String("String"), // Required
  53. // More values...
  54. },
  55. }
  56. resp, err := svc.DescribeTrails(params)
  57. if err != nil {
  58. // Print the error, cast err to awserr.Error to get the Code and
  59. // Message from an error.
  60. fmt.Println(err.Error())
  61. return
  62. }
  63. // Pretty-print the response data.
  64. fmt.Println(resp)
  65. }
  66. func ExampleCloudTrail_GetTrailStatus() {
  67. svc := cloudtrail.New(nil)
  68. params := &cloudtrail.GetTrailStatusInput{
  69. Name: aws.String("String"), // Required
  70. }
  71. resp, err := svc.GetTrailStatus(params)
  72. if err != nil {
  73. // Print the error, cast err to awserr.Error to get the Code and
  74. // Message from an error.
  75. fmt.Println(err.Error())
  76. return
  77. }
  78. // Pretty-print the response data.
  79. fmt.Println(resp)
  80. }
  81. func ExampleCloudTrail_LookupEvents() {
  82. svc := cloudtrail.New(nil)
  83. params := &cloudtrail.LookupEventsInput{
  84. EndTime: aws.Time(time.Now()),
  85. LookupAttributes: []*cloudtrail.LookupAttribute{
  86. { // Required
  87. AttributeKey: aws.String("LookupAttributeKey"), // Required
  88. AttributeValue: aws.String("String"), // Required
  89. },
  90. // More values...
  91. },
  92. MaxResults: aws.Int64(1),
  93. NextToken: aws.String("NextToken"),
  94. StartTime: aws.Time(time.Now()),
  95. }
  96. resp, err := svc.LookupEvents(params)
  97. if err != nil {
  98. // Print the error, cast err to awserr.Error to get the Code and
  99. // Message from an error.
  100. fmt.Println(err.Error())
  101. return
  102. }
  103. // Pretty-print the response data.
  104. fmt.Println(resp)
  105. }
  106. func ExampleCloudTrail_StartLogging() {
  107. svc := cloudtrail.New(nil)
  108. params := &cloudtrail.StartLoggingInput{
  109. Name: aws.String("String"), // Required
  110. }
  111. resp, err := svc.StartLogging(params)
  112. if err != nil {
  113. // Print the error, cast err to awserr.Error to get the Code and
  114. // Message from an error.
  115. fmt.Println(err.Error())
  116. return
  117. }
  118. // Pretty-print the response data.
  119. fmt.Println(resp)
  120. }
  121. func ExampleCloudTrail_StopLogging() {
  122. svc := cloudtrail.New(nil)
  123. params := &cloudtrail.StopLoggingInput{
  124. Name: aws.String("String"), // Required
  125. }
  126. resp, err := svc.StopLogging(params)
  127. if err != nil {
  128. // Print the error, cast err to awserr.Error to get the Code and
  129. // Message from an error.
  130. fmt.Println(err.Error())
  131. return
  132. }
  133. // Pretty-print the response data.
  134. fmt.Println(resp)
  135. }
  136. func ExampleCloudTrail_UpdateTrail() {
  137. svc := cloudtrail.New(nil)
  138. params := &cloudtrail.UpdateTrailInput{
  139. Name: aws.String("String"), // Required
  140. CloudWatchLogsLogGroupArn: aws.String("String"),
  141. CloudWatchLogsRoleArn: aws.String("String"),
  142. IncludeGlobalServiceEvents: aws.Bool(true),
  143. S3BucketName: aws.String("String"),
  144. S3KeyPrefix: aws.String("String"),
  145. SnsTopicName: aws.String("String"),
  146. }
  147. resp, err := svc.UpdateTrail(params)
  148. if err != nil {
  149. // Print the error, cast err to awserr.Error to get the Code and
  150. // Message from an error.
  151. fmt.Println(err.Error())
  152. return
  153. }
  154. // Pretty-print the response data.
  155. fmt.Println(resp)
  156. }