examples_test.go 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package firehose_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/firehose"
  10. )
  11. var _ time.Duration
  12. var _ bytes.Buffer
  13. func ExampleFirehose_CreateDeliveryStream() {
  14. sess, err := session.NewSession()
  15. if err != nil {
  16. fmt.Println("failed to create session,", err)
  17. return
  18. }
  19. svc := firehose.New(sess)
  20. params := &firehose.CreateDeliveryStreamInput{
  21. DeliveryStreamName: aws.String("DeliveryStreamName"), // Required
  22. ElasticsearchDestinationConfiguration: &firehose.ElasticsearchDestinationConfiguration{
  23. DomainARN: aws.String("ElasticsearchDomainARN"), // Required
  24. IndexName: aws.String("ElasticsearchIndexName"), // Required
  25. RoleARN: aws.String("RoleARN"), // Required
  26. S3Configuration: &firehose.S3DestinationConfiguration{ // Required
  27. BucketARN: aws.String("BucketARN"), // Required
  28. RoleARN: aws.String("RoleARN"), // Required
  29. BufferingHints: &firehose.BufferingHints{
  30. IntervalInSeconds: aws.Int64(1),
  31. SizeInMBs: aws.Int64(1),
  32. },
  33. CloudWatchLoggingOptions: &firehose.CloudWatchLoggingOptions{
  34. Enabled: aws.Bool(true),
  35. LogGroupName: aws.String("LogGroupName"),
  36. LogStreamName: aws.String("LogStreamName"),
  37. },
  38. CompressionFormat: aws.String("CompressionFormat"),
  39. EncryptionConfiguration: &firehose.EncryptionConfiguration{
  40. KMSEncryptionConfig: &firehose.KMSEncryptionConfig{
  41. AWSKMSKeyARN: aws.String("AWSKMSKeyARN"), // Required
  42. },
  43. NoEncryptionConfig: aws.String("NoEncryptionConfig"),
  44. },
  45. Prefix: aws.String("Prefix"),
  46. },
  47. TypeName: aws.String("ElasticsearchTypeName"), // Required
  48. BufferingHints: &firehose.ElasticsearchBufferingHints{
  49. IntervalInSeconds: aws.Int64(1),
  50. SizeInMBs: aws.Int64(1),
  51. },
  52. CloudWatchLoggingOptions: &firehose.CloudWatchLoggingOptions{
  53. Enabled: aws.Bool(true),
  54. LogGroupName: aws.String("LogGroupName"),
  55. LogStreamName: aws.String("LogStreamName"),
  56. },
  57. IndexRotationPeriod: aws.String("ElasticsearchIndexRotationPeriod"),
  58. RetryOptions: &firehose.ElasticsearchRetryOptions{
  59. DurationInSeconds: aws.Int64(1),
  60. },
  61. S3BackupMode: aws.String("ElasticsearchS3BackupMode"),
  62. },
  63. RedshiftDestinationConfiguration: &firehose.RedshiftDestinationConfiguration{
  64. ClusterJDBCURL: aws.String("ClusterJDBCURL"), // Required
  65. CopyCommand: &firehose.CopyCommand{ // Required
  66. DataTableName: aws.String("DataTableName"), // Required
  67. CopyOptions: aws.String("CopyOptions"),
  68. DataTableColumns: aws.String("DataTableColumns"),
  69. },
  70. Password: aws.String("Password"), // Required
  71. RoleARN: aws.String("RoleARN"), // Required
  72. S3Configuration: &firehose.S3DestinationConfiguration{ // Required
  73. BucketARN: aws.String("BucketARN"), // Required
  74. RoleARN: aws.String("RoleARN"), // Required
  75. BufferingHints: &firehose.BufferingHints{
  76. IntervalInSeconds: aws.Int64(1),
  77. SizeInMBs: aws.Int64(1),
  78. },
  79. CloudWatchLoggingOptions: &firehose.CloudWatchLoggingOptions{
  80. Enabled: aws.Bool(true),
  81. LogGroupName: aws.String("LogGroupName"),
  82. LogStreamName: aws.String("LogStreamName"),
  83. },
  84. CompressionFormat: aws.String("CompressionFormat"),
  85. EncryptionConfiguration: &firehose.EncryptionConfiguration{
  86. KMSEncryptionConfig: &firehose.KMSEncryptionConfig{
  87. AWSKMSKeyARN: aws.String("AWSKMSKeyARN"), // Required
  88. },
  89. NoEncryptionConfig: aws.String("NoEncryptionConfig"),
  90. },
  91. Prefix: aws.String("Prefix"),
  92. },
  93. Username: aws.String("Username"), // Required
  94. CloudWatchLoggingOptions: &firehose.CloudWatchLoggingOptions{
  95. Enabled: aws.Bool(true),
  96. LogGroupName: aws.String("LogGroupName"),
  97. LogStreamName: aws.String("LogStreamName"),
  98. },
  99. RetryOptions: &firehose.RedshiftRetryOptions{
  100. DurationInSeconds: aws.Int64(1),
  101. },
  102. },
  103. S3DestinationConfiguration: &firehose.S3DestinationConfiguration{
  104. BucketARN: aws.String("BucketARN"), // Required
  105. RoleARN: aws.String("RoleARN"), // Required
  106. BufferingHints: &firehose.BufferingHints{
  107. IntervalInSeconds: aws.Int64(1),
  108. SizeInMBs: aws.Int64(1),
  109. },
  110. CloudWatchLoggingOptions: &firehose.CloudWatchLoggingOptions{
  111. Enabled: aws.Bool(true),
  112. LogGroupName: aws.String("LogGroupName"),
  113. LogStreamName: aws.String("LogStreamName"),
  114. },
  115. CompressionFormat: aws.String("CompressionFormat"),
  116. EncryptionConfiguration: &firehose.EncryptionConfiguration{
  117. KMSEncryptionConfig: &firehose.KMSEncryptionConfig{
  118. AWSKMSKeyARN: aws.String("AWSKMSKeyARN"), // Required
  119. },
  120. NoEncryptionConfig: aws.String("NoEncryptionConfig"),
  121. },
  122. Prefix: aws.String("Prefix"),
  123. },
  124. }
  125. resp, err := svc.CreateDeliveryStream(params)
  126. if err != nil {
  127. // Print the error, cast err to awserr.Error to get the Code and
  128. // Message from an error.
  129. fmt.Println(err.Error())
  130. return
  131. }
  132. // Pretty-print the response data.
  133. fmt.Println(resp)
  134. }
  135. func ExampleFirehose_DeleteDeliveryStream() {
  136. sess, err := session.NewSession()
  137. if err != nil {
  138. fmt.Println("failed to create session,", err)
  139. return
  140. }
  141. svc := firehose.New(sess)
  142. params := &firehose.DeleteDeliveryStreamInput{
  143. DeliveryStreamName: aws.String("DeliveryStreamName"), // Required
  144. }
  145. resp, err := svc.DeleteDeliveryStream(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 ExampleFirehose_DescribeDeliveryStream() {
  156. sess, err := session.NewSession()
  157. if err != nil {
  158. fmt.Println("failed to create session,", err)
  159. return
  160. }
  161. svc := firehose.New(sess)
  162. params := &firehose.DescribeDeliveryStreamInput{
  163. DeliveryStreamName: aws.String("DeliveryStreamName"), // Required
  164. ExclusiveStartDestinationId: aws.String("DestinationId"),
  165. Limit: aws.Int64(1),
  166. }
  167. resp, err := svc.DescribeDeliveryStream(params)
  168. if err != nil {
  169. // Print the error, cast err to awserr.Error to get the Code and
  170. // Message from an error.
  171. fmt.Println(err.Error())
  172. return
  173. }
  174. // Pretty-print the response data.
  175. fmt.Println(resp)
  176. }
  177. func ExampleFirehose_ListDeliveryStreams() {
  178. sess, err := session.NewSession()
  179. if err != nil {
  180. fmt.Println("failed to create session,", err)
  181. return
  182. }
  183. svc := firehose.New(sess)
  184. params := &firehose.ListDeliveryStreamsInput{
  185. ExclusiveStartDeliveryStreamName: aws.String("DeliveryStreamName"),
  186. Limit: aws.Int64(1),
  187. }
  188. resp, err := svc.ListDeliveryStreams(params)
  189. if err != nil {
  190. // Print the error, cast err to awserr.Error to get the Code and
  191. // Message from an error.
  192. fmt.Println(err.Error())
  193. return
  194. }
  195. // Pretty-print the response data.
  196. fmt.Println(resp)
  197. }
  198. func ExampleFirehose_PutRecord() {
  199. sess, err := session.NewSession()
  200. if err != nil {
  201. fmt.Println("failed to create session,", err)
  202. return
  203. }
  204. svc := firehose.New(sess)
  205. params := &firehose.PutRecordInput{
  206. DeliveryStreamName: aws.String("DeliveryStreamName"), // Required
  207. Record: &firehose.Record{ // Required
  208. Data: []byte("PAYLOAD"), // Required
  209. },
  210. }
  211. resp, err := svc.PutRecord(params)
  212. if err != nil {
  213. // Print the error, cast err to awserr.Error to get the Code and
  214. // Message from an error.
  215. fmt.Println(err.Error())
  216. return
  217. }
  218. // Pretty-print the response data.
  219. fmt.Println(resp)
  220. }
  221. func ExampleFirehose_PutRecordBatch() {
  222. sess, err := session.NewSession()
  223. if err != nil {
  224. fmt.Println("failed to create session,", err)
  225. return
  226. }
  227. svc := firehose.New(sess)
  228. params := &firehose.PutRecordBatchInput{
  229. DeliveryStreamName: aws.String("DeliveryStreamName"), // Required
  230. Records: []*firehose.Record{ // Required
  231. { // Required
  232. Data: []byte("PAYLOAD"), // Required
  233. },
  234. // More values...
  235. },
  236. }
  237. resp, err := svc.PutRecordBatch(params)
  238. if err != nil {
  239. // Print the error, cast err to awserr.Error to get the Code and
  240. // Message from an error.
  241. fmt.Println(err.Error())
  242. return
  243. }
  244. // Pretty-print the response data.
  245. fmt.Println(resp)
  246. }
  247. func ExampleFirehose_UpdateDestination() {
  248. sess, err := session.NewSession()
  249. if err != nil {
  250. fmt.Println("failed to create session,", err)
  251. return
  252. }
  253. svc := firehose.New(sess)
  254. params := &firehose.UpdateDestinationInput{
  255. CurrentDeliveryStreamVersionId: aws.String("DeliveryStreamVersionId"), // Required
  256. DeliveryStreamName: aws.String("DeliveryStreamName"), // Required
  257. DestinationId: aws.String("DestinationId"), // Required
  258. ElasticsearchDestinationUpdate: &firehose.ElasticsearchDestinationUpdate{
  259. BufferingHints: &firehose.ElasticsearchBufferingHints{
  260. IntervalInSeconds: aws.Int64(1),
  261. SizeInMBs: aws.Int64(1),
  262. },
  263. CloudWatchLoggingOptions: &firehose.CloudWatchLoggingOptions{
  264. Enabled: aws.Bool(true),
  265. LogGroupName: aws.String("LogGroupName"),
  266. LogStreamName: aws.String("LogStreamName"),
  267. },
  268. DomainARN: aws.String("ElasticsearchDomainARN"),
  269. IndexName: aws.String("ElasticsearchIndexName"),
  270. IndexRotationPeriod: aws.String("ElasticsearchIndexRotationPeriod"),
  271. RetryOptions: &firehose.ElasticsearchRetryOptions{
  272. DurationInSeconds: aws.Int64(1),
  273. },
  274. RoleARN: aws.String("RoleARN"),
  275. S3Update: &firehose.S3DestinationUpdate{
  276. BucketARN: aws.String("BucketARN"),
  277. BufferingHints: &firehose.BufferingHints{
  278. IntervalInSeconds: aws.Int64(1),
  279. SizeInMBs: aws.Int64(1),
  280. },
  281. CloudWatchLoggingOptions: &firehose.CloudWatchLoggingOptions{
  282. Enabled: aws.Bool(true),
  283. LogGroupName: aws.String("LogGroupName"),
  284. LogStreamName: aws.String("LogStreamName"),
  285. },
  286. CompressionFormat: aws.String("CompressionFormat"),
  287. EncryptionConfiguration: &firehose.EncryptionConfiguration{
  288. KMSEncryptionConfig: &firehose.KMSEncryptionConfig{
  289. AWSKMSKeyARN: aws.String("AWSKMSKeyARN"), // Required
  290. },
  291. NoEncryptionConfig: aws.String("NoEncryptionConfig"),
  292. },
  293. Prefix: aws.String("Prefix"),
  294. RoleARN: aws.String("RoleARN"),
  295. },
  296. TypeName: aws.String("ElasticsearchTypeName"),
  297. },
  298. RedshiftDestinationUpdate: &firehose.RedshiftDestinationUpdate{
  299. CloudWatchLoggingOptions: &firehose.CloudWatchLoggingOptions{
  300. Enabled: aws.Bool(true),
  301. LogGroupName: aws.String("LogGroupName"),
  302. LogStreamName: aws.String("LogStreamName"),
  303. },
  304. ClusterJDBCURL: aws.String("ClusterJDBCURL"),
  305. CopyCommand: &firehose.CopyCommand{
  306. DataTableName: aws.String("DataTableName"), // Required
  307. CopyOptions: aws.String("CopyOptions"),
  308. DataTableColumns: aws.String("DataTableColumns"),
  309. },
  310. Password: aws.String("Password"),
  311. RetryOptions: &firehose.RedshiftRetryOptions{
  312. DurationInSeconds: aws.Int64(1),
  313. },
  314. RoleARN: aws.String("RoleARN"),
  315. S3Update: &firehose.S3DestinationUpdate{
  316. BucketARN: aws.String("BucketARN"),
  317. BufferingHints: &firehose.BufferingHints{
  318. IntervalInSeconds: aws.Int64(1),
  319. SizeInMBs: aws.Int64(1),
  320. },
  321. CloudWatchLoggingOptions: &firehose.CloudWatchLoggingOptions{
  322. Enabled: aws.Bool(true),
  323. LogGroupName: aws.String("LogGroupName"),
  324. LogStreamName: aws.String("LogStreamName"),
  325. },
  326. CompressionFormat: aws.String("CompressionFormat"),
  327. EncryptionConfiguration: &firehose.EncryptionConfiguration{
  328. KMSEncryptionConfig: &firehose.KMSEncryptionConfig{
  329. AWSKMSKeyARN: aws.String("AWSKMSKeyARN"), // Required
  330. },
  331. NoEncryptionConfig: aws.String("NoEncryptionConfig"),
  332. },
  333. Prefix: aws.String("Prefix"),
  334. RoleARN: aws.String("RoleARN"),
  335. },
  336. Username: aws.String("Username"),
  337. },
  338. S3DestinationUpdate: &firehose.S3DestinationUpdate{
  339. BucketARN: aws.String("BucketARN"),
  340. BufferingHints: &firehose.BufferingHints{
  341. IntervalInSeconds: aws.Int64(1),
  342. SizeInMBs: aws.Int64(1),
  343. },
  344. CloudWatchLoggingOptions: &firehose.CloudWatchLoggingOptions{
  345. Enabled: aws.Bool(true),
  346. LogGroupName: aws.String("LogGroupName"),
  347. LogStreamName: aws.String("LogStreamName"),
  348. },
  349. CompressionFormat: aws.String("CompressionFormat"),
  350. EncryptionConfiguration: &firehose.EncryptionConfiguration{
  351. KMSEncryptionConfig: &firehose.KMSEncryptionConfig{
  352. AWSKMSKeyARN: aws.String("AWSKMSKeyARN"), // Required
  353. },
  354. NoEncryptionConfig: aws.String("NoEncryptionConfig"),
  355. },
  356. Prefix: aws.String("Prefix"),
  357. RoleARN: aws.String("RoleARN"),
  358. },
  359. }
  360. resp, err := svc.UpdateDestination(params)
  361. if err != nil {
  362. // Print the error, cast err to awserr.Error to get the Code and
  363. // Message from an error.
  364. fmt.Println(err.Error())
  365. return
  366. }
  367. // Pretty-print the response data.
  368. fmt.Println(resp)
  369. }