examples_test.go 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package lambda_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/lambda"
  9. )
  10. var _ time.Duration
  11. var _ bytes.Buffer
  12. func ExampleLambda_AddPermission() {
  13. svc := lambda.New(nil)
  14. params := &lambda.AddPermissionInput{
  15. Action: aws.String("Action"), // Required
  16. FunctionName: aws.String("FunctionName"), // Required
  17. Principal: aws.String("Principal"), // Required
  18. StatementId: aws.String("StatementId"), // Required
  19. SourceAccount: aws.String("SourceOwner"),
  20. SourceArn: aws.String("Arn"),
  21. }
  22. resp, err := svc.AddPermission(params)
  23. if err != nil {
  24. // Print the error, cast err to awserr.Error to get the Code and
  25. // Message from an error.
  26. fmt.Println(err.Error())
  27. return
  28. }
  29. // Pretty-print the response data.
  30. fmt.Println(resp)
  31. }
  32. func ExampleLambda_CreateEventSourceMapping() {
  33. svc := lambda.New(nil)
  34. params := &lambda.CreateEventSourceMappingInput{
  35. EventSourceArn: aws.String("Arn"), // Required
  36. FunctionName: aws.String("FunctionName"), // Required
  37. StartingPosition: aws.String("EventSourcePosition"), // Required
  38. BatchSize: aws.Int64(1),
  39. Enabled: aws.Bool(true),
  40. }
  41. resp, err := svc.CreateEventSourceMapping(params)
  42. if err != nil {
  43. // Print the error, cast err to awserr.Error to get the Code and
  44. // Message from an error.
  45. fmt.Println(err.Error())
  46. return
  47. }
  48. // Pretty-print the response data.
  49. fmt.Println(resp)
  50. }
  51. func ExampleLambda_CreateFunction() {
  52. svc := lambda.New(nil)
  53. params := &lambda.CreateFunctionInput{
  54. Code: &lambda.FunctionCode{ // Required
  55. S3Bucket: aws.String("S3Bucket"),
  56. S3Key: aws.String("S3Key"),
  57. S3ObjectVersion: aws.String("S3ObjectVersion"),
  58. ZipFile: []byte("PAYLOAD"),
  59. },
  60. FunctionName: aws.String("FunctionName"), // Required
  61. Handler: aws.String("Handler"), // Required
  62. Role: aws.String("RoleArn"), // Required
  63. Runtime: aws.String("Runtime"), // Required
  64. Description: aws.String("Description"),
  65. MemorySize: aws.Int64(1),
  66. Timeout: aws.Int64(1),
  67. }
  68. resp, err := svc.CreateFunction(params)
  69. if err != nil {
  70. // Print the error, cast err to awserr.Error to get the Code and
  71. // Message from an error.
  72. fmt.Println(err.Error())
  73. return
  74. }
  75. // Pretty-print the response data.
  76. fmt.Println(resp)
  77. }
  78. func ExampleLambda_DeleteEventSourceMapping() {
  79. svc := lambda.New(nil)
  80. params := &lambda.DeleteEventSourceMappingInput{
  81. UUID: aws.String("String"), // Required
  82. }
  83. resp, err := svc.DeleteEventSourceMapping(params)
  84. if err != nil {
  85. // Print the error, cast err to awserr.Error to get the Code and
  86. // Message from an error.
  87. fmt.Println(err.Error())
  88. return
  89. }
  90. // Pretty-print the response data.
  91. fmt.Println(resp)
  92. }
  93. func ExampleLambda_DeleteFunction() {
  94. svc := lambda.New(nil)
  95. params := &lambda.DeleteFunctionInput{
  96. FunctionName: aws.String("FunctionName"), // Required
  97. }
  98. resp, err := svc.DeleteFunction(params)
  99. if err != nil {
  100. // Print the error, cast err to awserr.Error to get the Code and
  101. // Message from an error.
  102. fmt.Println(err.Error())
  103. return
  104. }
  105. // Pretty-print the response data.
  106. fmt.Println(resp)
  107. }
  108. func ExampleLambda_GetEventSourceMapping() {
  109. svc := lambda.New(nil)
  110. params := &lambda.GetEventSourceMappingInput{
  111. UUID: aws.String("String"), // Required
  112. }
  113. resp, err := svc.GetEventSourceMapping(params)
  114. if err != nil {
  115. // Print the error, cast err to awserr.Error to get the Code and
  116. // Message from an error.
  117. fmt.Println(err.Error())
  118. return
  119. }
  120. // Pretty-print the response data.
  121. fmt.Println(resp)
  122. }
  123. func ExampleLambda_GetFunction() {
  124. svc := lambda.New(nil)
  125. params := &lambda.GetFunctionInput{
  126. FunctionName: aws.String("FunctionName"), // Required
  127. }
  128. resp, err := svc.GetFunction(params)
  129. if err != nil {
  130. // Print the error, cast err to awserr.Error to get the Code and
  131. // Message from an error.
  132. fmt.Println(err.Error())
  133. return
  134. }
  135. // Pretty-print the response data.
  136. fmt.Println(resp)
  137. }
  138. func ExampleLambda_GetFunctionConfiguration() {
  139. svc := lambda.New(nil)
  140. params := &lambda.GetFunctionConfigurationInput{
  141. FunctionName: aws.String("FunctionName"), // Required
  142. }
  143. resp, err := svc.GetFunctionConfiguration(params)
  144. if err != nil {
  145. // Print the error, cast err to awserr.Error to get the Code and
  146. // Message from an error.
  147. fmt.Println(err.Error())
  148. return
  149. }
  150. // Pretty-print the response data.
  151. fmt.Println(resp)
  152. }
  153. func ExampleLambda_GetPolicy() {
  154. svc := lambda.New(nil)
  155. params := &lambda.GetPolicyInput{
  156. FunctionName: aws.String("FunctionName"), // Required
  157. }
  158. resp, err := svc.GetPolicy(params)
  159. if err != nil {
  160. // Print the error, cast err to awserr.Error to get the Code and
  161. // Message from an error.
  162. fmt.Println(err.Error())
  163. return
  164. }
  165. // Pretty-print the response data.
  166. fmt.Println(resp)
  167. }
  168. func ExampleLambda_Invoke() {
  169. svc := lambda.New(nil)
  170. params := &lambda.InvokeInput{
  171. FunctionName: aws.String("FunctionName"), // Required
  172. ClientContext: aws.String("String"),
  173. InvocationType: aws.String("InvocationType"),
  174. LogType: aws.String("LogType"),
  175. Payload: []byte("PAYLOAD"),
  176. }
  177. resp, err := svc.Invoke(params)
  178. if err != nil {
  179. // Print the error, cast err to awserr.Error to get the Code and
  180. // Message from an error.
  181. fmt.Println(err.Error())
  182. return
  183. }
  184. // Pretty-print the response data.
  185. fmt.Println(resp)
  186. }
  187. func ExampleLambda_InvokeAsync() {
  188. svc := lambda.New(nil)
  189. params := &lambda.InvokeAsyncInput{
  190. FunctionName: aws.String("FunctionName"), // Required
  191. InvokeArgs: bytes.NewReader([]byte("PAYLOAD")), // Required
  192. }
  193. resp, err := svc.InvokeAsync(params)
  194. if err != nil {
  195. // Print the error, cast err to awserr.Error to get the Code and
  196. // Message from an error.
  197. fmt.Println(err.Error())
  198. return
  199. }
  200. // Pretty-print the response data.
  201. fmt.Println(resp)
  202. }
  203. func ExampleLambda_ListEventSourceMappings() {
  204. svc := lambda.New(nil)
  205. params := &lambda.ListEventSourceMappingsInput{
  206. EventSourceArn: aws.String("Arn"),
  207. FunctionName: aws.String("FunctionName"),
  208. Marker: aws.String("String"),
  209. MaxItems: aws.Int64(1),
  210. }
  211. resp, err := svc.ListEventSourceMappings(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 ExampleLambda_ListFunctions() {
  222. svc := lambda.New(nil)
  223. params := &lambda.ListFunctionsInput{
  224. Marker: aws.String("String"),
  225. MaxItems: aws.Int64(1),
  226. }
  227. resp, err := svc.ListFunctions(params)
  228. if err != nil {
  229. // Print the error, cast err to awserr.Error to get the Code and
  230. // Message from an error.
  231. fmt.Println(err.Error())
  232. return
  233. }
  234. // Pretty-print the response data.
  235. fmt.Println(resp)
  236. }
  237. func ExampleLambda_RemovePermission() {
  238. svc := lambda.New(nil)
  239. params := &lambda.RemovePermissionInput{
  240. FunctionName: aws.String("FunctionName"), // Required
  241. StatementId: aws.String("StatementId"), // Required
  242. }
  243. resp, err := svc.RemovePermission(params)
  244. if err != nil {
  245. // Print the error, cast err to awserr.Error to get the Code and
  246. // Message from an error.
  247. fmt.Println(err.Error())
  248. return
  249. }
  250. // Pretty-print the response data.
  251. fmt.Println(resp)
  252. }
  253. func ExampleLambda_UpdateEventSourceMapping() {
  254. svc := lambda.New(nil)
  255. params := &lambda.UpdateEventSourceMappingInput{
  256. UUID: aws.String("String"), // Required
  257. BatchSize: aws.Int64(1),
  258. Enabled: aws.Bool(true),
  259. FunctionName: aws.String("FunctionName"),
  260. }
  261. resp, err := svc.UpdateEventSourceMapping(params)
  262. if err != nil {
  263. // Print the error, cast err to awserr.Error to get the Code and
  264. // Message from an error.
  265. fmt.Println(err.Error())
  266. return
  267. }
  268. // Pretty-print the response data.
  269. fmt.Println(resp)
  270. }
  271. func ExampleLambda_UpdateFunctionCode() {
  272. svc := lambda.New(nil)
  273. params := &lambda.UpdateFunctionCodeInput{
  274. FunctionName: aws.String("FunctionName"), // Required
  275. S3Bucket: aws.String("S3Bucket"),
  276. S3Key: aws.String("S3Key"),
  277. S3ObjectVersion: aws.String("S3ObjectVersion"),
  278. ZipFile: []byte("PAYLOAD"),
  279. }
  280. resp, err := svc.UpdateFunctionCode(params)
  281. if err != nil {
  282. // Print the error, cast err to awserr.Error to get the Code and
  283. // Message from an error.
  284. fmt.Println(err.Error())
  285. return
  286. }
  287. // Pretty-print the response data.
  288. fmt.Println(resp)
  289. }
  290. func ExampleLambda_UpdateFunctionConfiguration() {
  291. svc := lambda.New(nil)
  292. params := &lambda.UpdateFunctionConfigurationInput{
  293. FunctionName: aws.String("FunctionName"), // Required
  294. Description: aws.String("Description"),
  295. Handler: aws.String("Handler"),
  296. MemorySize: aws.Int64(1),
  297. Role: aws.String("RoleArn"),
  298. Timeout: aws.Int64(1),
  299. }
  300. resp, err := svc.UpdateFunctionConfiguration(params)
  301. if err != nil {
  302. // Print the error, cast err to awserr.Error to get the Code and
  303. // Message from an error.
  304. fmt.Println(err.Error())
  305. return
  306. }
  307. // Pretty-print the response data.
  308. fmt.Println(resp)
  309. }