examples_test.go 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  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/aws/session"
  9. "github.com/aws/aws-sdk-go/service/cloudtrail"
  10. )
  11. var _ time.Duration
  12. var _ bytes.Buffer
  13. func ExampleCloudTrail_AddTags() {
  14. sess, err := session.NewSession()
  15. if err != nil {
  16. fmt.Println("failed to create session,", err)
  17. return
  18. }
  19. svc := cloudtrail.New(sess)
  20. params := &cloudtrail.AddTagsInput{
  21. ResourceId: aws.String("String"), // Required
  22. TagsList: []*cloudtrail.Tag{
  23. { // Required
  24. Key: aws.String("String"), // Required
  25. Value: aws.String("String"),
  26. },
  27. // More values...
  28. },
  29. }
  30. resp, err := svc.AddTags(params)
  31. if err != nil {
  32. // Print the error, cast err to awserr.Error to get the Code and
  33. // Message from an error.
  34. fmt.Println(err.Error())
  35. return
  36. }
  37. // Pretty-print the response data.
  38. fmt.Println(resp)
  39. }
  40. func ExampleCloudTrail_CreateTrail() {
  41. sess, err := session.NewSession()
  42. if err != nil {
  43. fmt.Println("failed to create session,", err)
  44. return
  45. }
  46. svc := cloudtrail.New(sess)
  47. params := &cloudtrail.CreateTrailInput{
  48. Name: aws.String("String"), // Required
  49. S3BucketName: aws.String("String"), // Required
  50. CloudWatchLogsLogGroupArn: aws.String("String"),
  51. CloudWatchLogsRoleArn: aws.String("String"),
  52. EnableLogFileValidation: aws.Bool(true),
  53. IncludeGlobalServiceEvents: aws.Bool(true),
  54. IsMultiRegionTrail: aws.Bool(true),
  55. KmsKeyId: aws.String("String"),
  56. S3KeyPrefix: aws.String("String"),
  57. SnsTopicName: aws.String("String"),
  58. }
  59. resp, err := svc.CreateTrail(params)
  60. if err != nil {
  61. // Print the error, cast err to awserr.Error to get the Code and
  62. // Message from an error.
  63. fmt.Println(err.Error())
  64. return
  65. }
  66. // Pretty-print the response data.
  67. fmt.Println(resp)
  68. }
  69. func ExampleCloudTrail_DeleteTrail() {
  70. sess, err := session.NewSession()
  71. if err != nil {
  72. fmt.Println("failed to create session,", err)
  73. return
  74. }
  75. svc := cloudtrail.New(sess)
  76. params := &cloudtrail.DeleteTrailInput{
  77. Name: aws.String("String"), // Required
  78. }
  79. resp, err := svc.DeleteTrail(params)
  80. if err != nil {
  81. // Print the error, cast err to awserr.Error to get the Code and
  82. // Message from an error.
  83. fmt.Println(err.Error())
  84. return
  85. }
  86. // Pretty-print the response data.
  87. fmt.Println(resp)
  88. }
  89. func ExampleCloudTrail_DescribeTrails() {
  90. sess, err := session.NewSession()
  91. if err != nil {
  92. fmt.Println("failed to create session,", err)
  93. return
  94. }
  95. svc := cloudtrail.New(sess)
  96. params := &cloudtrail.DescribeTrailsInput{
  97. IncludeShadowTrails: aws.Bool(true),
  98. TrailNameList: []*string{
  99. aws.String("String"), // Required
  100. // More values...
  101. },
  102. }
  103. resp, err := svc.DescribeTrails(params)
  104. if err != nil {
  105. // Print the error, cast err to awserr.Error to get the Code and
  106. // Message from an error.
  107. fmt.Println(err.Error())
  108. return
  109. }
  110. // Pretty-print the response data.
  111. fmt.Println(resp)
  112. }
  113. func ExampleCloudTrail_GetTrailStatus() {
  114. sess, err := session.NewSession()
  115. if err != nil {
  116. fmt.Println("failed to create session,", err)
  117. return
  118. }
  119. svc := cloudtrail.New(sess)
  120. params := &cloudtrail.GetTrailStatusInput{
  121. Name: aws.String("String"), // Required
  122. }
  123. resp, err := svc.GetTrailStatus(params)
  124. if err != nil {
  125. // Print the error, cast err to awserr.Error to get the Code and
  126. // Message from an error.
  127. fmt.Println(err.Error())
  128. return
  129. }
  130. // Pretty-print the response data.
  131. fmt.Println(resp)
  132. }
  133. func ExampleCloudTrail_ListPublicKeys() {
  134. sess, err := session.NewSession()
  135. if err != nil {
  136. fmt.Println("failed to create session,", err)
  137. return
  138. }
  139. svc := cloudtrail.New(sess)
  140. params := &cloudtrail.ListPublicKeysInput{
  141. EndTime: aws.Time(time.Now()),
  142. NextToken: aws.String("String"),
  143. StartTime: aws.Time(time.Now()),
  144. }
  145. resp, err := svc.ListPublicKeys(params)
  146. if err != nil {
  147. // Print the error, cast err to awserr.Error to get the Code and
  148. // Message from an error.
  149. fmt.Println(err.Error())
  150. return
  151. }
  152. // Pretty-print the response data.
  153. fmt.Println(resp)
  154. }
  155. func ExampleCloudTrail_ListTags() {
  156. sess, err := session.NewSession()
  157. if err != nil {
  158. fmt.Println("failed to create session,", err)
  159. return
  160. }
  161. svc := cloudtrail.New(sess)
  162. params := &cloudtrail.ListTagsInput{
  163. ResourceIdList: []*string{ // Required
  164. aws.String("String"), // Required
  165. // More values...
  166. },
  167. NextToken: aws.String("String"),
  168. }
  169. resp, err := svc.ListTags(params)
  170. if err != nil {
  171. // Print the error, cast err to awserr.Error to get the Code and
  172. // Message from an error.
  173. fmt.Println(err.Error())
  174. return
  175. }
  176. // Pretty-print the response data.
  177. fmt.Println(resp)
  178. }
  179. func ExampleCloudTrail_LookupEvents() {
  180. sess, err := session.NewSession()
  181. if err != nil {
  182. fmt.Println("failed to create session,", err)
  183. return
  184. }
  185. svc := cloudtrail.New(sess)
  186. params := &cloudtrail.LookupEventsInput{
  187. EndTime: aws.Time(time.Now()),
  188. LookupAttributes: []*cloudtrail.LookupAttribute{
  189. { // Required
  190. AttributeKey: aws.String("LookupAttributeKey"), // Required
  191. AttributeValue: aws.String("String"), // Required
  192. },
  193. // More values...
  194. },
  195. MaxResults: aws.Int64(1),
  196. NextToken: aws.String("NextToken"),
  197. StartTime: aws.Time(time.Now()),
  198. }
  199. resp, err := svc.LookupEvents(params)
  200. if err != nil {
  201. // Print the error, cast err to awserr.Error to get the Code and
  202. // Message from an error.
  203. fmt.Println(err.Error())
  204. return
  205. }
  206. // Pretty-print the response data.
  207. fmt.Println(resp)
  208. }
  209. func ExampleCloudTrail_RemoveTags() {
  210. sess, err := session.NewSession()
  211. if err != nil {
  212. fmt.Println("failed to create session,", err)
  213. return
  214. }
  215. svc := cloudtrail.New(sess)
  216. params := &cloudtrail.RemoveTagsInput{
  217. ResourceId: aws.String("String"), // Required
  218. TagsList: []*cloudtrail.Tag{
  219. { // Required
  220. Key: aws.String("String"), // Required
  221. Value: aws.String("String"),
  222. },
  223. // More values...
  224. },
  225. }
  226. resp, err := svc.RemoveTags(params)
  227. if err != nil {
  228. // Print the error, cast err to awserr.Error to get the Code and
  229. // Message from an error.
  230. fmt.Println(err.Error())
  231. return
  232. }
  233. // Pretty-print the response data.
  234. fmt.Println(resp)
  235. }
  236. func ExampleCloudTrail_StartLogging() {
  237. sess, err := session.NewSession()
  238. if err != nil {
  239. fmt.Println("failed to create session,", err)
  240. return
  241. }
  242. svc := cloudtrail.New(sess)
  243. params := &cloudtrail.StartLoggingInput{
  244. Name: aws.String("String"), // Required
  245. }
  246. resp, err := svc.StartLogging(params)
  247. if err != nil {
  248. // Print the error, cast err to awserr.Error to get the Code and
  249. // Message from an error.
  250. fmt.Println(err.Error())
  251. return
  252. }
  253. // Pretty-print the response data.
  254. fmt.Println(resp)
  255. }
  256. func ExampleCloudTrail_StopLogging() {
  257. sess, err := session.NewSession()
  258. if err != nil {
  259. fmt.Println("failed to create session,", err)
  260. return
  261. }
  262. svc := cloudtrail.New(sess)
  263. params := &cloudtrail.StopLoggingInput{
  264. Name: aws.String("String"), // Required
  265. }
  266. resp, err := svc.StopLogging(params)
  267. if err != nil {
  268. // Print the error, cast err to awserr.Error to get the Code and
  269. // Message from an error.
  270. fmt.Println(err.Error())
  271. return
  272. }
  273. // Pretty-print the response data.
  274. fmt.Println(resp)
  275. }
  276. func ExampleCloudTrail_UpdateTrail() {
  277. sess, err := session.NewSession()
  278. if err != nil {
  279. fmt.Println("failed to create session,", err)
  280. return
  281. }
  282. svc := cloudtrail.New(sess)
  283. params := &cloudtrail.UpdateTrailInput{
  284. Name: aws.String("String"), // Required
  285. CloudWatchLogsLogGroupArn: aws.String("String"),
  286. CloudWatchLogsRoleArn: aws.String("String"),
  287. EnableLogFileValidation: aws.Bool(true),
  288. IncludeGlobalServiceEvents: aws.Bool(true),
  289. IsMultiRegionTrail: aws.Bool(true),
  290. KmsKeyId: aws.String("String"),
  291. S3BucketName: aws.String("String"),
  292. S3KeyPrefix: aws.String("String"),
  293. SnsTopicName: aws.String("String"),
  294. }
  295. resp, err := svc.UpdateTrail(params)
  296. if err != nil {
  297. // Print the error, cast err to awserr.Error to get the Code and
  298. // Message from an error.
  299. fmt.Println(err.Error())
  300. return
  301. }
  302. // Pretty-print the response data.
  303. fmt.Println(resp)
  304. }