examples_test.go 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package kinesis_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/kinesis"
  9. )
  10. var _ time.Duration
  11. var _ bytes.Buffer
  12. func ExampleKinesis_AddTagsToStream() {
  13. svc := kinesis.New(nil)
  14. params := &kinesis.AddTagsToStreamInput{
  15. StreamName: aws.String("StreamName"), // Required
  16. Tags: map[string]*string{ // Required
  17. "Key": aws.String("TagValue"), // Required
  18. // More values...
  19. },
  20. }
  21. resp, err := svc.AddTagsToStream(params)
  22. if err != nil {
  23. // Print the error, cast err to awserr.Error to get the Code and
  24. // Message from an error.
  25. fmt.Println(err.Error())
  26. return
  27. }
  28. // Pretty-print the response data.
  29. fmt.Println(resp)
  30. }
  31. func ExampleKinesis_CreateStream() {
  32. svc := kinesis.New(nil)
  33. params := &kinesis.CreateStreamInput{
  34. ShardCount: aws.Int64(1), // Required
  35. StreamName: aws.String("StreamName"), // Required
  36. }
  37. resp, err := svc.CreateStream(params)
  38. if err != nil {
  39. // Print the error, cast err to awserr.Error to get the Code and
  40. // Message from an error.
  41. fmt.Println(err.Error())
  42. return
  43. }
  44. // Pretty-print the response data.
  45. fmt.Println(resp)
  46. }
  47. func ExampleKinesis_DeleteStream() {
  48. svc := kinesis.New(nil)
  49. params := &kinesis.DeleteStreamInput{
  50. StreamName: aws.String("StreamName"), // Required
  51. }
  52. resp, err := svc.DeleteStream(params)
  53. if err != nil {
  54. // Print the error, cast err to awserr.Error to get the Code and
  55. // Message from an error.
  56. fmt.Println(err.Error())
  57. return
  58. }
  59. // Pretty-print the response data.
  60. fmt.Println(resp)
  61. }
  62. func ExampleKinesis_DescribeStream() {
  63. svc := kinesis.New(nil)
  64. params := &kinesis.DescribeStreamInput{
  65. StreamName: aws.String("StreamName"), // Required
  66. ExclusiveStartShardId: aws.String("ShardId"),
  67. Limit: aws.Int64(1),
  68. }
  69. resp, err := svc.DescribeStream(params)
  70. if err != nil {
  71. // Print the error, cast err to awserr.Error to get the Code and
  72. // Message from an error.
  73. fmt.Println(err.Error())
  74. return
  75. }
  76. // Pretty-print the response data.
  77. fmt.Println(resp)
  78. }
  79. func ExampleKinesis_GetRecords() {
  80. svc := kinesis.New(nil)
  81. params := &kinesis.GetRecordsInput{
  82. ShardIterator: aws.String("ShardIterator"), // Required
  83. Limit: aws.Int64(1),
  84. }
  85. resp, err := svc.GetRecords(params)
  86. if err != nil {
  87. // Print the error, cast err to awserr.Error to get the Code and
  88. // Message from an error.
  89. fmt.Println(err.Error())
  90. return
  91. }
  92. // Pretty-print the response data.
  93. fmt.Println(resp)
  94. }
  95. func ExampleKinesis_GetShardIterator() {
  96. svc := kinesis.New(nil)
  97. params := &kinesis.GetShardIteratorInput{
  98. ShardId: aws.String("ShardId"), // Required
  99. ShardIteratorType: aws.String("ShardIteratorType"), // Required
  100. StreamName: aws.String("StreamName"), // Required
  101. StartingSequenceNumber: aws.String("SequenceNumber"),
  102. }
  103. resp, err := svc.GetShardIterator(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 ExampleKinesis_ListStreams() {
  114. svc := kinesis.New(nil)
  115. params := &kinesis.ListStreamsInput{
  116. ExclusiveStartStreamName: aws.String("StreamName"),
  117. Limit: aws.Int64(1),
  118. }
  119. resp, err := svc.ListStreams(params)
  120. if err != nil {
  121. // Print the error, cast err to awserr.Error to get the Code and
  122. // Message from an error.
  123. fmt.Println(err.Error())
  124. return
  125. }
  126. // Pretty-print the response data.
  127. fmt.Println(resp)
  128. }
  129. func ExampleKinesis_ListTagsForStream() {
  130. svc := kinesis.New(nil)
  131. params := &kinesis.ListTagsForStreamInput{
  132. StreamName: aws.String("StreamName"), // Required
  133. ExclusiveStartTagKey: aws.String("TagKey"),
  134. Limit: aws.Int64(1),
  135. }
  136. resp, err := svc.ListTagsForStream(params)
  137. if err != nil {
  138. // Print the error, cast err to awserr.Error to get the Code and
  139. // Message from an error.
  140. fmt.Println(err.Error())
  141. return
  142. }
  143. // Pretty-print the response data.
  144. fmt.Println(resp)
  145. }
  146. func ExampleKinesis_MergeShards() {
  147. svc := kinesis.New(nil)
  148. params := &kinesis.MergeShardsInput{
  149. AdjacentShardToMerge: aws.String("ShardId"), // Required
  150. ShardToMerge: aws.String("ShardId"), // Required
  151. StreamName: aws.String("StreamName"), // Required
  152. }
  153. resp, err := svc.MergeShards(params)
  154. if err != nil {
  155. // Print the error, cast err to awserr.Error to get the Code and
  156. // Message from an error.
  157. fmt.Println(err.Error())
  158. return
  159. }
  160. // Pretty-print the response data.
  161. fmt.Println(resp)
  162. }
  163. func ExampleKinesis_PutRecord() {
  164. svc := kinesis.New(nil)
  165. params := &kinesis.PutRecordInput{
  166. Data: []byte("PAYLOAD"), // Required
  167. PartitionKey: aws.String("PartitionKey"), // Required
  168. StreamName: aws.String("StreamName"), // Required
  169. ExplicitHashKey: aws.String("HashKey"),
  170. SequenceNumberForOrdering: aws.String("SequenceNumber"),
  171. }
  172. resp, err := svc.PutRecord(params)
  173. if err != nil {
  174. // Print the error, cast err to awserr.Error to get the Code and
  175. // Message from an error.
  176. fmt.Println(err.Error())
  177. return
  178. }
  179. // Pretty-print the response data.
  180. fmt.Println(resp)
  181. }
  182. func ExampleKinesis_PutRecords() {
  183. svc := kinesis.New(nil)
  184. params := &kinesis.PutRecordsInput{
  185. Records: []*kinesis.PutRecordsRequestEntry{ // Required
  186. { // Required
  187. Data: []byte("PAYLOAD"), // Required
  188. PartitionKey: aws.String("PartitionKey"), // Required
  189. ExplicitHashKey: aws.String("HashKey"),
  190. },
  191. // More values...
  192. },
  193. StreamName: aws.String("StreamName"), // Required
  194. }
  195. resp, err := svc.PutRecords(params)
  196. if err != nil {
  197. // Print the error, cast err to awserr.Error to get the Code and
  198. // Message from an error.
  199. fmt.Println(err.Error())
  200. return
  201. }
  202. // Pretty-print the response data.
  203. fmt.Println(resp)
  204. }
  205. func ExampleKinesis_RemoveTagsFromStream() {
  206. svc := kinesis.New(nil)
  207. params := &kinesis.RemoveTagsFromStreamInput{
  208. StreamName: aws.String("StreamName"), // Required
  209. TagKeys: []*string{ // Required
  210. aws.String("TagKey"), // Required
  211. // More values...
  212. },
  213. }
  214. resp, err := svc.RemoveTagsFromStream(params)
  215. if err != nil {
  216. // Print the error, cast err to awserr.Error to get the Code and
  217. // Message from an error.
  218. fmt.Println(err.Error())
  219. return
  220. }
  221. // Pretty-print the response data.
  222. fmt.Println(resp)
  223. }
  224. func ExampleKinesis_SplitShard() {
  225. svc := kinesis.New(nil)
  226. params := &kinesis.SplitShardInput{
  227. NewStartingHashKey: aws.String("HashKey"), // Required
  228. ShardToSplit: aws.String("ShardId"), // Required
  229. StreamName: aws.String("StreamName"), // Required
  230. }
  231. resp, err := svc.SplitShard(params)
  232. if err != nil {
  233. // Print the error, cast err to awserr.Error to get the Code and
  234. // Message from an error.
  235. fmt.Println(err.Error())
  236. return
  237. }
  238. // Pretty-print the response data.
  239. fmt.Println(resp)
  240. }