examples_test.go 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package dynamodb_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/dynamodb"
  9. )
  10. var _ time.Duration
  11. var _ bytes.Buffer
  12. func ExampleDynamoDB_BatchGetItem() {
  13. svc := dynamodb.New(nil)
  14. params := &dynamodb.BatchGetItemInput{
  15. RequestItems: map[string]*dynamodb.KeysAndAttributes{ // Required
  16. "Key": { // Required
  17. Keys: []map[string]*dynamodb.AttributeValue{ // Required
  18. { // Required
  19. "Key": { // Required
  20. B: []byte("PAYLOAD"),
  21. BOOL: aws.Bool(true),
  22. BS: [][]byte{
  23. []byte("PAYLOAD"), // Required
  24. // More values...
  25. },
  26. L: []*dynamodb.AttributeValue{
  27. { // Required
  28. // Recursive values...
  29. },
  30. // More values...
  31. },
  32. M: map[string]*dynamodb.AttributeValue{
  33. "Key": { // Required
  34. // Recursive values...
  35. },
  36. // More values...
  37. },
  38. N: aws.String("NumberAttributeValue"),
  39. NS: []*string{
  40. aws.String("NumberAttributeValue"), // Required
  41. // More values...
  42. },
  43. NULL: aws.Bool(true),
  44. S: aws.String("StringAttributeValue"),
  45. SS: []*string{
  46. aws.String("StringAttributeValue"), // Required
  47. // More values...
  48. },
  49. },
  50. // More values...
  51. },
  52. // More values...
  53. },
  54. AttributesToGet: []*string{
  55. aws.String("AttributeName"), // Required
  56. // More values...
  57. },
  58. ConsistentRead: aws.Bool(true),
  59. ExpressionAttributeNames: map[string]*string{
  60. "Key": aws.String("AttributeName"), // Required
  61. // More values...
  62. },
  63. ProjectionExpression: aws.String("ProjectionExpression"),
  64. },
  65. // More values...
  66. },
  67. ReturnConsumedCapacity: aws.String("ReturnConsumedCapacity"),
  68. }
  69. resp, err := svc.BatchGetItem(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 ExampleDynamoDB_BatchWriteItem() {
  80. svc := dynamodb.New(nil)
  81. params := &dynamodb.BatchWriteItemInput{
  82. RequestItems: map[string][]*dynamodb.WriteRequest{ // Required
  83. "Key": { // Required
  84. { // Required
  85. DeleteRequest: &dynamodb.DeleteRequest{
  86. Key: map[string]*dynamodb.AttributeValue{ // Required
  87. "Key": { // Required
  88. B: []byte("PAYLOAD"),
  89. BOOL: aws.Bool(true),
  90. BS: [][]byte{
  91. []byte("PAYLOAD"), // Required
  92. // More values...
  93. },
  94. L: []*dynamodb.AttributeValue{
  95. { // Required
  96. // Recursive values...
  97. },
  98. // More values...
  99. },
  100. M: map[string]*dynamodb.AttributeValue{
  101. "Key": { // Required
  102. // Recursive values...
  103. },
  104. // More values...
  105. },
  106. N: aws.String("NumberAttributeValue"),
  107. NS: []*string{
  108. aws.String("NumberAttributeValue"), // Required
  109. // More values...
  110. },
  111. NULL: aws.Bool(true),
  112. S: aws.String("StringAttributeValue"),
  113. SS: []*string{
  114. aws.String("StringAttributeValue"), // Required
  115. // More values...
  116. },
  117. },
  118. // More values...
  119. },
  120. },
  121. PutRequest: &dynamodb.PutRequest{
  122. Item: map[string]*dynamodb.AttributeValue{ // Required
  123. "Key": { // Required
  124. B: []byte("PAYLOAD"),
  125. BOOL: aws.Bool(true),
  126. BS: [][]byte{
  127. []byte("PAYLOAD"), // Required
  128. // More values...
  129. },
  130. L: []*dynamodb.AttributeValue{
  131. { // Required
  132. // Recursive values...
  133. },
  134. // More values...
  135. },
  136. M: map[string]*dynamodb.AttributeValue{
  137. "Key": { // Required
  138. // Recursive values...
  139. },
  140. // More values...
  141. },
  142. N: aws.String("NumberAttributeValue"),
  143. NS: []*string{
  144. aws.String("NumberAttributeValue"), // Required
  145. // More values...
  146. },
  147. NULL: aws.Bool(true),
  148. S: aws.String("StringAttributeValue"),
  149. SS: []*string{
  150. aws.String("StringAttributeValue"), // Required
  151. // More values...
  152. },
  153. },
  154. // More values...
  155. },
  156. },
  157. },
  158. // More values...
  159. },
  160. // More values...
  161. },
  162. ReturnConsumedCapacity: aws.String("ReturnConsumedCapacity"),
  163. ReturnItemCollectionMetrics: aws.String("ReturnItemCollectionMetrics"),
  164. }
  165. resp, err := svc.BatchWriteItem(params)
  166. if err != nil {
  167. // Print the error, cast err to awserr.Error to get the Code and
  168. // Message from an error.
  169. fmt.Println(err.Error())
  170. return
  171. }
  172. // Pretty-print the response data.
  173. fmt.Println(resp)
  174. }
  175. func ExampleDynamoDB_CreateTable() {
  176. svc := dynamodb.New(nil)
  177. params := &dynamodb.CreateTableInput{
  178. AttributeDefinitions: []*dynamodb.AttributeDefinition{ // Required
  179. { // Required
  180. AttributeName: aws.String("KeySchemaAttributeName"), // Required
  181. AttributeType: aws.String("ScalarAttributeType"), // Required
  182. },
  183. // More values...
  184. },
  185. KeySchema: []*dynamodb.KeySchemaElement{ // Required
  186. { // Required
  187. AttributeName: aws.String("KeySchemaAttributeName"), // Required
  188. KeyType: aws.String("KeyType"), // Required
  189. },
  190. // More values...
  191. },
  192. ProvisionedThroughput: &dynamodb.ProvisionedThroughput{ // Required
  193. ReadCapacityUnits: aws.Int64(1), // Required
  194. WriteCapacityUnits: aws.Int64(1), // Required
  195. },
  196. TableName: aws.String("TableName"), // Required
  197. GlobalSecondaryIndexes: []*dynamodb.GlobalSecondaryIndex{
  198. { // Required
  199. IndexName: aws.String("IndexName"), // Required
  200. KeySchema: []*dynamodb.KeySchemaElement{ // Required
  201. { // Required
  202. AttributeName: aws.String("KeySchemaAttributeName"), // Required
  203. KeyType: aws.String("KeyType"), // Required
  204. },
  205. // More values...
  206. },
  207. Projection: &dynamodb.Projection{ // Required
  208. NonKeyAttributes: []*string{
  209. aws.String("NonKeyAttributeName"), // Required
  210. // More values...
  211. },
  212. ProjectionType: aws.String("ProjectionType"),
  213. },
  214. ProvisionedThroughput: &dynamodb.ProvisionedThroughput{ // Required
  215. ReadCapacityUnits: aws.Int64(1), // Required
  216. WriteCapacityUnits: aws.Int64(1), // Required
  217. },
  218. },
  219. // More values...
  220. },
  221. LocalSecondaryIndexes: []*dynamodb.LocalSecondaryIndex{
  222. { // Required
  223. IndexName: aws.String("IndexName"), // Required
  224. KeySchema: []*dynamodb.KeySchemaElement{ // Required
  225. { // Required
  226. AttributeName: aws.String("KeySchemaAttributeName"), // Required
  227. KeyType: aws.String("KeyType"), // Required
  228. },
  229. // More values...
  230. },
  231. Projection: &dynamodb.Projection{ // Required
  232. NonKeyAttributes: []*string{
  233. aws.String("NonKeyAttributeName"), // Required
  234. // More values...
  235. },
  236. ProjectionType: aws.String("ProjectionType"),
  237. },
  238. },
  239. // More values...
  240. },
  241. StreamSpecification: &dynamodb.StreamSpecification{
  242. StreamEnabled: aws.Bool(true),
  243. StreamViewType: aws.String("StreamViewType"),
  244. },
  245. }
  246. resp, err := svc.CreateTable(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 ExampleDynamoDB_DeleteItem() {
  257. svc := dynamodb.New(nil)
  258. params := &dynamodb.DeleteItemInput{
  259. Key: map[string]*dynamodb.AttributeValue{ // Required
  260. "Key": { // Required
  261. B: []byte("PAYLOAD"),
  262. BOOL: aws.Bool(true),
  263. BS: [][]byte{
  264. []byte("PAYLOAD"), // Required
  265. // More values...
  266. },
  267. L: []*dynamodb.AttributeValue{
  268. { // Required
  269. // Recursive values...
  270. },
  271. // More values...
  272. },
  273. M: map[string]*dynamodb.AttributeValue{
  274. "Key": { // Required
  275. // Recursive values...
  276. },
  277. // More values...
  278. },
  279. N: aws.String("NumberAttributeValue"),
  280. NS: []*string{
  281. aws.String("NumberAttributeValue"), // Required
  282. // More values...
  283. },
  284. NULL: aws.Bool(true),
  285. S: aws.String("StringAttributeValue"),
  286. SS: []*string{
  287. aws.String("StringAttributeValue"), // Required
  288. // More values...
  289. },
  290. },
  291. // More values...
  292. },
  293. TableName: aws.String("TableName"), // Required
  294. ConditionExpression: aws.String("ConditionExpression"),
  295. ConditionalOperator: aws.String("ConditionalOperator"),
  296. Expected: map[string]*dynamodb.ExpectedAttributeValue{
  297. "Key": { // Required
  298. AttributeValueList: []*dynamodb.AttributeValue{
  299. { // Required
  300. B: []byte("PAYLOAD"),
  301. BOOL: aws.Bool(true),
  302. BS: [][]byte{
  303. []byte("PAYLOAD"), // Required
  304. // More values...
  305. },
  306. L: []*dynamodb.AttributeValue{
  307. { // Required
  308. // Recursive values...
  309. },
  310. // More values...
  311. },
  312. M: map[string]*dynamodb.AttributeValue{
  313. "Key": { // Required
  314. // Recursive values...
  315. },
  316. // More values...
  317. },
  318. N: aws.String("NumberAttributeValue"),
  319. NS: []*string{
  320. aws.String("NumberAttributeValue"), // Required
  321. // More values...
  322. },
  323. NULL: aws.Bool(true),
  324. S: aws.String("StringAttributeValue"),
  325. SS: []*string{
  326. aws.String("StringAttributeValue"), // Required
  327. // More values...
  328. },
  329. },
  330. // More values...
  331. },
  332. ComparisonOperator: aws.String("ComparisonOperator"),
  333. Exists: aws.Bool(true),
  334. Value: &dynamodb.AttributeValue{
  335. B: []byte("PAYLOAD"),
  336. BOOL: aws.Bool(true),
  337. BS: [][]byte{
  338. []byte("PAYLOAD"), // Required
  339. // More values...
  340. },
  341. L: []*dynamodb.AttributeValue{
  342. { // Required
  343. // Recursive values...
  344. },
  345. // More values...
  346. },
  347. M: map[string]*dynamodb.AttributeValue{
  348. "Key": { // Required
  349. // Recursive values...
  350. },
  351. // More values...
  352. },
  353. N: aws.String("NumberAttributeValue"),
  354. NS: []*string{
  355. aws.String("NumberAttributeValue"), // Required
  356. // More values...
  357. },
  358. NULL: aws.Bool(true),
  359. S: aws.String("StringAttributeValue"),
  360. SS: []*string{
  361. aws.String("StringAttributeValue"), // Required
  362. // More values...
  363. },
  364. },
  365. },
  366. // More values...
  367. },
  368. ExpressionAttributeNames: map[string]*string{
  369. "Key": aws.String("AttributeName"), // Required
  370. // More values...
  371. },
  372. ExpressionAttributeValues: map[string]*dynamodb.AttributeValue{
  373. "Key": { // Required
  374. B: []byte("PAYLOAD"),
  375. BOOL: aws.Bool(true),
  376. BS: [][]byte{
  377. []byte("PAYLOAD"), // Required
  378. // More values...
  379. },
  380. L: []*dynamodb.AttributeValue{
  381. { // Required
  382. // Recursive values...
  383. },
  384. // More values...
  385. },
  386. M: map[string]*dynamodb.AttributeValue{
  387. "Key": { // Required
  388. // Recursive values...
  389. },
  390. // More values...
  391. },
  392. N: aws.String("NumberAttributeValue"),
  393. NS: []*string{
  394. aws.String("NumberAttributeValue"), // Required
  395. // More values...
  396. },
  397. NULL: aws.Bool(true),
  398. S: aws.String("StringAttributeValue"),
  399. SS: []*string{
  400. aws.String("StringAttributeValue"), // Required
  401. // More values...
  402. },
  403. },
  404. // More values...
  405. },
  406. ReturnConsumedCapacity: aws.String("ReturnConsumedCapacity"),
  407. ReturnItemCollectionMetrics: aws.String("ReturnItemCollectionMetrics"),
  408. ReturnValues: aws.String("ReturnValue"),
  409. }
  410. resp, err := svc.DeleteItem(params)
  411. if err != nil {
  412. // Print the error, cast err to awserr.Error to get the Code and
  413. // Message from an error.
  414. fmt.Println(err.Error())
  415. return
  416. }
  417. // Pretty-print the response data.
  418. fmt.Println(resp)
  419. }
  420. func ExampleDynamoDB_DeleteTable() {
  421. svc := dynamodb.New(nil)
  422. params := &dynamodb.DeleteTableInput{
  423. TableName: aws.String("TableName"), // Required
  424. }
  425. resp, err := svc.DeleteTable(params)
  426. if err != nil {
  427. // Print the error, cast err to awserr.Error to get the Code and
  428. // Message from an error.
  429. fmt.Println(err.Error())
  430. return
  431. }
  432. // Pretty-print the response data.
  433. fmt.Println(resp)
  434. }
  435. func ExampleDynamoDB_DescribeTable() {
  436. svc := dynamodb.New(nil)
  437. params := &dynamodb.DescribeTableInput{
  438. TableName: aws.String("TableName"), // Required
  439. }
  440. resp, err := svc.DescribeTable(params)
  441. if err != nil {
  442. // Print the error, cast err to awserr.Error to get the Code and
  443. // Message from an error.
  444. fmt.Println(err.Error())
  445. return
  446. }
  447. // Pretty-print the response data.
  448. fmt.Println(resp)
  449. }
  450. func ExampleDynamoDB_GetItem() {
  451. svc := dynamodb.New(nil)
  452. params := &dynamodb.GetItemInput{
  453. Key: map[string]*dynamodb.AttributeValue{ // Required
  454. "Key": { // Required
  455. B: []byte("PAYLOAD"),
  456. BOOL: aws.Bool(true),
  457. BS: [][]byte{
  458. []byte("PAYLOAD"), // Required
  459. // More values...
  460. },
  461. L: []*dynamodb.AttributeValue{
  462. { // Required
  463. // Recursive values...
  464. },
  465. // More values...
  466. },
  467. M: map[string]*dynamodb.AttributeValue{
  468. "Key": { // Required
  469. // Recursive values...
  470. },
  471. // More values...
  472. },
  473. N: aws.String("NumberAttributeValue"),
  474. NS: []*string{
  475. aws.String("NumberAttributeValue"), // Required
  476. // More values...
  477. },
  478. NULL: aws.Bool(true),
  479. S: aws.String("StringAttributeValue"),
  480. SS: []*string{
  481. aws.String("StringAttributeValue"), // Required
  482. // More values...
  483. },
  484. },
  485. // More values...
  486. },
  487. TableName: aws.String("TableName"), // Required
  488. AttributesToGet: []*string{
  489. aws.String("AttributeName"), // Required
  490. // More values...
  491. },
  492. ConsistentRead: aws.Bool(true),
  493. ExpressionAttributeNames: map[string]*string{
  494. "Key": aws.String("AttributeName"), // Required
  495. // More values...
  496. },
  497. ProjectionExpression: aws.String("ProjectionExpression"),
  498. ReturnConsumedCapacity: aws.String("ReturnConsumedCapacity"),
  499. }
  500. resp, err := svc.GetItem(params)
  501. if err != nil {
  502. // Print the error, cast err to awserr.Error to get the Code and
  503. // Message from an error.
  504. fmt.Println(err.Error())
  505. return
  506. }
  507. // Pretty-print the response data.
  508. fmt.Println(resp)
  509. }
  510. func ExampleDynamoDB_ListTables() {
  511. svc := dynamodb.New(nil)
  512. params := &dynamodb.ListTablesInput{
  513. ExclusiveStartTableName: aws.String("TableName"),
  514. Limit: aws.Int64(1),
  515. }
  516. resp, err := svc.ListTables(params)
  517. if err != nil {
  518. // Print the error, cast err to awserr.Error to get the Code and
  519. // Message from an error.
  520. fmt.Println(err.Error())
  521. return
  522. }
  523. // Pretty-print the response data.
  524. fmt.Println(resp)
  525. }
  526. func ExampleDynamoDB_PutItem() {
  527. svc := dynamodb.New(nil)
  528. params := &dynamodb.PutItemInput{
  529. Item: map[string]*dynamodb.AttributeValue{ // Required
  530. "Key": { // Required
  531. B: []byte("PAYLOAD"),
  532. BOOL: aws.Bool(true),
  533. BS: [][]byte{
  534. []byte("PAYLOAD"), // Required
  535. // More values...
  536. },
  537. L: []*dynamodb.AttributeValue{
  538. { // Required
  539. // Recursive values...
  540. },
  541. // More values...
  542. },
  543. M: map[string]*dynamodb.AttributeValue{
  544. "Key": { // Required
  545. // Recursive values...
  546. },
  547. // More values...
  548. },
  549. N: aws.String("NumberAttributeValue"),
  550. NS: []*string{
  551. aws.String("NumberAttributeValue"), // Required
  552. // More values...
  553. },
  554. NULL: aws.Bool(true),
  555. S: aws.String("StringAttributeValue"),
  556. SS: []*string{
  557. aws.String("StringAttributeValue"), // Required
  558. // More values...
  559. },
  560. },
  561. // More values...
  562. },
  563. TableName: aws.String("TableName"), // Required
  564. ConditionExpression: aws.String("ConditionExpression"),
  565. ConditionalOperator: aws.String("ConditionalOperator"),
  566. Expected: map[string]*dynamodb.ExpectedAttributeValue{
  567. "Key": { // Required
  568. AttributeValueList: []*dynamodb.AttributeValue{
  569. { // Required
  570. B: []byte("PAYLOAD"),
  571. BOOL: aws.Bool(true),
  572. BS: [][]byte{
  573. []byte("PAYLOAD"), // Required
  574. // More values...
  575. },
  576. L: []*dynamodb.AttributeValue{
  577. { // Required
  578. // Recursive values...
  579. },
  580. // More values...
  581. },
  582. M: map[string]*dynamodb.AttributeValue{
  583. "Key": { // Required
  584. // Recursive values...
  585. },
  586. // More values...
  587. },
  588. N: aws.String("NumberAttributeValue"),
  589. NS: []*string{
  590. aws.String("NumberAttributeValue"), // Required
  591. // More values...
  592. },
  593. NULL: aws.Bool(true),
  594. S: aws.String("StringAttributeValue"),
  595. SS: []*string{
  596. aws.String("StringAttributeValue"), // Required
  597. // More values...
  598. },
  599. },
  600. // More values...
  601. },
  602. ComparisonOperator: aws.String("ComparisonOperator"),
  603. Exists: aws.Bool(true),
  604. Value: &dynamodb.AttributeValue{
  605. B: []byte("PAYLOAD"),
  606. BOOL: aws.Bool(true),
  607. BS: [][]byte{
  608. []byte("PAYLOAD"), // Required
  609. // More values...
  610. },
  611. L: []*dynamodb.AttributeValue{
  612. { // Required
  613. // Recursive values...
  614. },
  615. // More values...
  616. },
  617. M: map[string]*dynamodb.AttributeValue{
  618. "Key": { // Required
  619. // Recursive values...
  620. },
  621. // More values...
  622. },
  623. N: aws.String("NumberAttributeValue"),
  624. NS: []*string{
  625. aws.String("NumberAttributeValue"), // Required
  626. // More values...
  627. },
  628. NULL: aws.Bool(true),
  629. S: aws.String("StringAttributeValue"),
  630. SS: []*string{
  631. aws.String("StringAttributeValue"), // Required
  632. // More values...
  633. },
  634. },
  635. },
  636. // More values...
  637. },
  638. ExpressionAttributeNames: map[string]*string{
  639. "Key": aws.String("AttributeName"), // Required
  640. // More values...
  641. },
  642. ExpressionAttributeValues: map[string]*dynamodb.AttributeValue{
  643. "Key": { // Required
  644. B: []byte("PAYLOAD"),
  645. BOOL: aws.Bool(true),
  646. BS: [][]byte{
  647. []byte("PAYLOAD"), // Required
  648. // More values...
  649. },
  650. L: []*dynamodb.AttributeValue{
  651. { // Required
  652. // Recursive values...
  653. },
  654. // More values...
  655. },
  656. M: map[string]*dynamodb.AttributeValue{
  657. "Key": { // Required
  658. // Recursive values...
  659. },
  660. // More values...
  661. },
  662. N: aws.String("NumberAttributeValue"),
  663. NS: []*string{
  664. aws.String("NumberAttributeValue"), // Required
  665. // More values...
  666. },
  667. NULL: aws.Bool(true),
  668. S: aws.String("StringAttributeValue"),
  669. SS: []*string{
  670. aws.String("StringAttributeValue"), // Required
  671. // More values...
  672. },
  673. },
  674. // More values...
  675. },
  676. ReturnConsumedCapacity: aws.String("ReturnConsumedCapacity"),
  677. ReturnItemCollectionMetrics: aws.String("ReturnItemCollectionMetrics"),
  678. ReturnValues: aws.String("ReturnValue"),
  679. }
  680. resp, err := svc.PutItem(params)
  681. if err != nil {
  682. // Print the error, cast err to awserr.Error to get the Code and
  683. // Message from an error.
  684. fmt.Println(err.Error())
  685. return
  686. }
  687. // Pretty-print the response data.
  688. fmt.Println(resp)
  689. }
  690. func ExampleDynamoDB_Query() {
  691. svc := dynamodb.New(nil)
  692. params := &dynamodb.QueryInput{
  693. TableName: aws.String("TableName"), // Required
  694. AttributesToGet: []*string{
  695. aws.String("AttributeName"), // Required
  696. // More values...
  697. },
  698. ConditionalOperator: aws.String("ConditionalOperator"),
  699. ConsistentRead: aws.Bool(true),
  700. ExclusiveStartKey: map[string]*dynamodb.AttributeValue{
  701. "Key": { // Required
  702. B: []byte("PAYLOAD"),
  703. BOOL: aws.Bool(true),
  704. BS: [][]byte{
  705. []byte("PAYLOAD"), // Required
  706. // More values...
  707. },
  708. L: []*dynamodb.AttributeValue{
  709. { // Required
  710. // Recursive values...
  711. },
  712. // More values...
  713. },
  714. M: map[string]*dynamodb.AttributeValue{
  715. "Key": { // Required
  716. // Recursive values...
  717. },
  718. // More values...
  719. },
  720. N: aws.String("NumberAttributeValue"),
  721. NS: []*string{
  722. aws.String("NumberAttributeValue"), // Required
  723. // More values...
  724. },
  725. NULL: aws.Bool(true),
  726. S: aws.String("StringAttributeValue"),
  727. SS: []*string{
  728. aws.String("StringAttributeValue"), // Required
  729. // More values...
  730. },
  731. },
  732. // More values...
  733. },
  734. ExpressionAttributeNames: map[string]*string{
  735. "Key": aws.String("AttributeName"), // Required
  736. // More values...
  737. },
  738. ExpressionAttributeValues: map[string]*dynamodb.AttributeValue{
  739. "Key": { // Required
  740. B: []byte("PAYLOAD"),
  741. BOOL: aws.Bool(true),
  742. BS: [][]byte{
  743. []byte("PAYLOAD"), // Required
  744. // More values...
  745. },
  746. L: []*dynamodb.AttributeValue{
  747. { // Required
  748. // Recursive values...
  749. },
  750. // More values...
  751. },
  752. M: map[string]*dynamodb.AttributeValue{
  753. "Key": { // Required
  754. // Recursive values...
  755. },
  756. // More values...
  757. },
  758. N: aws.String("NumberAttributeValue"),
  759. NS: []*string{
  760. aws.String("NumberAttributeValue"), // Required
  761. // More values...
  762. },
  763. NULL: aws.Bool(true),
  764. S: aws.String("StringAttributeValue"),
  765. SS: []*string{
  766. aws.String("StringAttributeValue"), // Required
  767. // More values...
  768. },
  769. },
  770. // More values...
  771. },
  772. FilterExpression: aws.String("ConditionExpression"),
  773. IndexName: aws.String("IndexName"),
  774. KeyConditionExpression: aws.String("KeyExpression"),
  775. KeyConditions: map[string]*dynamodb.Condition{
  776. "Key": { // Required
  777. ComparisonOperator: aws.String("ComparisonOperator"), // Required
  778. AttributeValueList: []*dynamodb.AttributeValue{
  779. { // Required
  780. B: []byte("PAYLOAD"),
  781. BOOL: aws.Bool(true),
  782. BS: [][]byte{
  783. []byte("PAYLOAD"), // Required
  784. // More values...
  785. },
  786. L: []*dynamodb.AttributeValue{
  787. { // Required
  788. // Recursive values...
  789. },
  790. // More values...
  791. },
  792. M: map[string]*dynamodb.AttributeValue{
  793. "Key": { // Required
  794. // Recursive values...
  795. },
  796. // More values...
  797. },
  798. N: aws.String("NumberAttributeValue"),
  799. NS: []*string{
  800. aws.String("NumberAttributeValue"), // Required
  801. // More values...
  802. },
  803. NULL: aws.Bool(true),
  804. S: aws.String("StringAttributeValue"),
  805. SS: []*string{
  806. aws.String("StringAttributeValue"), // Required
  807. // More values...
  808. },
  809. },
  810. // More values...
  811. },
  812. },
  813. // More values...
  814. },
  815. Limit: aws.Int64(1),
  816. ProjectionExpression: aws.String("ProjectionExpression"),
  817. QueryFilter: map[string]*dynamodb.Condition{
  818. "Key": { // Required
  819. ComparisonOperator: aws.String("ComparisonOperator"), // Required
  820. AttributeValueList: []*dynamodb.AttributeValue{
  821. { // Required
  822. B: []byte("PAYLOAD"),
  823. BOOL: aws.Bool(true),
  824. BS: [][]byte{
  825. []byte("PAYLOAD"), // Required
  826. // More values...
  827. },
  828. L: []*dynamodb.AttributeValue{
  829. { // Required
  830. // Recursive values...
  831. },
  832. // More values...
  833. },
  834. M: map[string]*dynamodb.AttributeValue{
  835. "Key": { // Required
  836. // Recursive values...
  837. },
  838. // More values...
  839. },
  840. N: aws.String("NumberAttributeValue"),
  841. NS: []*string{
  842. aws.String("NumberAttributeValue"), // Required
  843. // More values...
  844. },
  845. NULL: aws.Bool(true),
  846. S: aws.String("StringAttributeValue"),
  847. SS: []*string{
  848. aws.String("StringAttributeValue"), // Required
  849. // More values...
  850. },
  851. },
  852. // More values...
  853. },
  854. },
  855. // More values...
  856. },
  857. ReturnConsumedCapacity: aws.String("ReturnConsumedCapacity"),
  858. ScanIndexForward: aws.Bool(true),
  859. Select: aws.String("Select"),
  860. }
  861. resp, err := svc.Query(params)
  862. if err != nil {
  863. // Print the error, cast err to awserr.Error to get the Code and
  864. // Message from an error.
  865. fmt.Println(err.Error())
  866. return
  867. }
  868. // Pretty-print the response data.
  869. fmt.Println(resp)
  870. }
  871. func ExampleDynamoDB_Scan() {
  872. svc := dynamodb.New(nil)
  873. params := &dynamodb.ScanInput{
  874. TableName: aws.String("TableName"), // Required
  875. AttributesToGet: []*string{
  876. aws.String("AttributeName"), // Required
  877. // More values...
  878. },
  879. ConditionalOperator: aws.String("ConditionalOperator"),
  880. ConsistentRead: aws.Bool(true),
  881. ExclusiveStartKey: map[string]*dynamodb.AttributeValue{
  882. "Key": { // Required
  883. B: []byte("PAYLOAD"),
  884. BOOL: aws.Bool(true),
  885. BS: [][]byte{
  886. []byte("PAYLOAD"), // Required
  887. // More values...
  888. },
  889. L: []*dynamodb.AttributeValue{
  890. { // Required
  891. // Recursive values...
  892. },
  893. // More values...
  894. },
  895. M: map[string]*dynamodb.AttributeValue{
  896. "Key": { // Required
  897. // Recursive values...
  898. },
  899. // More values...
  900. },
  901. N: aws.String("NumberAttributeValue"),
  902. NS: []*string{
  903. aws.String("NumberAttributeValue"), // Required
  904. // More values...
  905. },
  906. NULL: aws.Bool(true),
  907. S: aws.String("StringAttributeValue"),
  908. SS: []*string{
  909. aws.String("StringAttributeValue"), // Required
  910. // More values...
  911. },
  912. },
  913. // More values...
  914. },
  915. ExpressionAttributeNames: map[string]*string{
  916. "Key": aws.String("AttributeName"), // Required
  917. // More values...
  918. },
  919. ExpressionAttributeValues: map[string]*dynamodb.AttributeValue{
  920. "Key": { // Required
  921. B: []byte("PAYLOAD"),
  922. BOOL: aws.Bool(true),
  923. BS: [][]byte{
  924. []byte("PAYLOAD"), // Required
  925. // More values...
  926. },
  927. L: []*dynamodb.AttributeValue{
  928. { // Required
  929. // Recursive values...
  930. },
  931. // More values...
  932. },
  933. M: map[string]*dynamodb.AttributeValue{
  934. "Key": { // Required
  935. // Recursive values...
  936. },
  937. // More values...
  938. },
  939. N: aws.String("NumberAttributeValue"),
  940. NS: []*string{
  941. aws.String("NumberAttributeValue"), // Required
  942. // More values...
  943. },
  944. NULL: aws.Bool(true),
  945. S: aws.String("StringAttributeValue"),
  946. SS: []*string{
  947. aws.String("StringAttributeValue"), // Required
  948. // More values...
  949. },
  950. },
  951. // More values...
  952. },
  953. FilterExpression: aws.String("ConditionExpression"),
  954. IndexName: aws.String("IndexName"),
  955. Limit: aws.Int64(1),
  956. ProjectionExpression: aws.String("ProjectionExpression"),
  957. ReturnConsumedCapacity: aws.String("ReturnConsumedCapacity"),
  958. ScanFilter: map[string]*dynamodb.Condition{
  959. "Key": { // Required
  960. ComparisonOperator: aws.String("ComparisonOperator"), // Required
  961. AttributeValueList: []*dynamodb.AttributeValue{
  962. { // Required
  963. B: []byte("PAYLOAD"),
  964. BOOL: aws.Bool(true),
  965. BS: [][]byte{
  966. []byte("PAYLOAD"), // Required
  967. // More values...
  968. },
  969. L: []*dynamodb.AttributeValue{
  970. { // Required
  971. // Recursive values...
  972. },
  973. // More values...
  974. },
  975. M: map[string]*dynamodb.AttributeValue{
  976. "Key": { // Required
  977. // Recursive values...
  978. },
  979. // More values...
  980. },
  981. N: aws.String("NumberAttributeValue"),
  982. NS: []*string{
  983. aws.String("NumberAttributeValue"), // Required
  984. // More values...
  985. },
  986. NULL: aws.Bool(true),
  987. S: aws.String("StringAttributeValue"),
  988. SS: []*string{
  989. aws.String("StringAttributeValue"), // Required
  990. // More values...
  991. },
  992. },
  993. // More values...
  994. },
  995. },
  996. // More values...
  997. },
  998. Segment: aws.Int64(1),
  999. Select: aws.String("Select"),
  1000. TotalSegments: aws.Int64(1),
  1001. }
  1002. resp, err := svc.Scan(params)
  1003. if err != nil {
  1004. // Print the error, cast err to awserr.Error to get the Code and
  1005. // Message from an error.
  1006. fmt.Println(err.Error())
  1007. return
  1008. }
  1009. // Pretty-print the response data.
  1010. fmt.Println(resp)
  1011. }
  1012. func ExampleDynamoDB_UpdateItem() {
  1013. svc := dynamodb.New(nil)
  1014. params := &dynamodb.UpdateItemInput{
  1015. Key: map[string]*dynamodb.AttributeValue{ // Required
  1016. "Key": { // Required
  1017. B: []byte("PAYLOAD"),
  1018. BOOL: aws.Bool(true),
  1019. BS: [][]byte{
  1020. []byte("PAYLOAD"), // Required
  1021. // More values...
  1022. },
  1023. L: []*dynamodb.AttributeValue{
  1024. { // Required
  1025. // Recursive values...
  1026. },
  1027. // More values...
  1028. },
  1029. M: map[string]*dynamodb.AttributeValue{
  1030. "Key": { // Required
  1031. // Recursive values...
  1032. },
  1033. // More values...
  1034. },
  1035. N: aws.String("NumberAttributeValue"),
  1036. NS: []*string{
  1037. aws.String("NumberAttributeValue"), // Required
  1038. // More values...
  1039. },
  1040. NULL: aws.Bool(true),
  1041. S: aws.String("StringAttributeValue"),
  1042. SS: []*string{
  1043. aws.String("StringAttributeValue"), // Required
  1044. // More values...
  1045. },
  1046. },
  1047. // More values...
  1048. },
  1049. TableName: aws.String("TableName"), // Required
  1050. AttributeUpdates: map[string]*dynamodb.AttributeValueUpdate{
  1051. "Key": { // Required
  1052. Action: aws.String("AttributeAction"),
  1053. Value: &dynamodb.AttributeValue{
  1054. B: []byte("PAYLOAD"),
  1055. BOOL: aws.Bool(true),
  1056. BS: [][]byte{
  1057. []byte("PAYLOAD"), // Required
  1058. // More values...
  1059. },
  1060. L: []*dynamodb.AttributeValue{
  1061. { // Required
  1062. // Recursive values...
  1063. },
  1064. // More values...
  1065. },
  1066. M: map[string]*dynamodb.AttributeValue{
  1067. "Key": { // Required
  1068. // Recursive values...
  1069. },
  1070. // More values...
  1071. },
  1072. N: aws.String("NumberAttributeValue"),
  1073. NS: []*string{
  1074. aws.String("NumberAttributeValue"), // Required
  1075. // More values...
  1076. },
  1077. NULL: aws.Bool(true),
  1078. S: aws.String("StringAttributeValue"),
  1079. SS: []*string{
  1080. aws.String("StringAttributeValue"), // Required
  1081. // More values...
  1082. },
  1083. },
  1084. },
  1085. // More values...
  1086. },
  1087. ConditionExpression: aws.String("ConditionExpression"),
  1088. ConditionalOperator: aws.String("ConditionalOperator"),
  1089. Expected: map[string]*dynamodb.ExpectedAttributeValue{
  1090. "Key": { // Required
  1091. AttributeValueList: []*dynamodb.AttributeValue{
  1092. { // Required
  1093. B: []byte("PAYLOAD"),
  1094. BOOL: aws.Bool(true),
  1095. BS: [][]byte{
  1096. []byte("PAYLOAD"), // Required
  1097. // More values...
  1098. },
  1099. L: []*dynamodb.AttributeValue{
  1100. { // Required
  1101. // Recursive values...
  1102. },
  1103. // More values...
  1104. },
  1105. M: map[string]*dynamodb.AttributeValue{
  1106. "Key": { // Required
  1107. // Recursive values...
  1108. },
  1109. // More values...
  1110. },
  1111. N: aws.String("NumberAttributeValue"),
  1112. NS: []*string{
  1113. aws.String("NumberAttributeValue"), // Required
  1114. // More values...
  1115. },
  1116. NULL: aws.Bool(true),
  1117. S: aws.String("StringAttributeValue"),
  1118. SS: []*string{
  1119. aws.String("StringAttributeValue"), // Required
  1120. // More values...
  1121. },
  1122. },
  1123. // More values...
  1124. },
  1125. ComparisonOperator: aws.String("ComparisonOperator"),
  1126. Exists: aws.Bool(true),
  1127. Value: &dynamodb.AttributeValue{
  1128. B: []byte("PAYLOAD"),
  1129. BOOL: aws.Bool(true),
  1130. BS: [][]byte{
  1131. []byte("PAYLOAD"), // Required
  1132. // More values...
  1133. },
  1134. L: []*dynamodb.AttributeValue{
  1135. { // Required
  1136. // Recursive values...
  1137. },
  1138. // More values...
  1139. },
  1140. M: map[string]*dynamodb.AttributeValue{
  1141. "Key": { // Required
  1142. // Recursive values...
  1143. },
  1144. // More values...
  1145. },
  1146. N: aws.String("NumberAttributeValue"),
  1147. NS: []*string{
  1148. aws.String("NumberAttributeValue"), // Required
  1149. // More values...
  1150. },
  1151. NULL: aws.Bool(true),
  1152. S: aws.String("StringAttributeValue"),
  1153. SS: []*string{
  1154. aws.String("StringAttributeValue"), // Required
  1155. // More values...
  1156. },
  1157. },
  1158. },
  1159. // More values...
  1160. },
  1161. ExpressionAttributeNames: map[string]*string{
  1162. "Key": aws.String("AttributeName"), // Required
  1163. // More values...
  1164. },
  1165. ExpressionAttributeValues: map[string]*dynamodb.AttributeValue{
  1166. "Key": { // Required
  1167. B: []byte("PAYLOAD"),
  1168. BOOL: aws.Bool(true),
  1169. BS: [][]byte{
  1170. []byte("PAYLOAD"), // Required
  1171. // More values...
  1172. },
  1173. L: []*dynamodb.AttributeValue{
  1174. { // Required
  1175. // Recursive values...
  1176. },
  1177. // More values...
  1178. },
  1179. M: map[string]*dynamodb.AttributeValue{
  1180. "Key": { // Required
  1181. // Recursive values...
  1182. },
  1183. // More values...
  1184. },
  1185. N: aws.String("NumberAttributeValue"),
  1186. NS: []*string{
  1187. aws.String("NumberAttributeValue"), // Required
  1188. // More values...
  1189. },
  1190. NULL: aws.Bool(true),
  1191. S: aws.String("StringAttributeValue"),
  1192. SS: []*string{
  1193. aws.String("StringAttributeValue"), // Required
  1194. // More values...
  1195. },
  1196. },
  1197. // More values...
  1198. },
  1199. ReturnConsumedCapacity: aws.String("ReturnConsumedCapacity"),
  1200. ReturnItemCollectionMetrics: aws.String("ReturnItemCollectionMetrics"),
  1201. ReturnValues: aws.String("ReturnValue"),
  1202. UpdateExpression: aws.String("UpdateExpression"),
  1203. }
  1204. resp, err := svc.UpdateItem(params)
  1205. if err != nil {
  1206. // Print the error, cast err to awserr.Error to get the Code and
  1207. // Message from an error.
  1208. fmt.Println(err.Error())
  1209. return
  1210. }
  1211. // Pretty-print the response data.
  1212. fmt.Println(resp)
  1213. }
  1214. func ExampleDynamoDB_UpdateTable() {
  1215. svc := dynamodb.New(nil)
  1216. params := &dynamodb.UpdateTableInput{
  1217. TableName: aws.String("TableName"), // Required
  1218. AttributeDefinitions: []*dynamodb.AttributeDefinition{
  1219. { // Required
  1220. AttributeName: aws.String("KeySchemaAttributeName"), // Required
  1221. AttributeType: aws.String("ScalarAttributeType"), // Required
  1222. },
  1223. // More values...
  1224. },
  1225. GlobalSecondaryIndexUpdates: []*dynamodb.GlobalSecondaryIndexUpdate{
  1226. { // Required
  1227. Create: &dynamodb.CreateGlobalSecondaryIndexAction{
  1228. IndexName: aws.String("IndexName"), // Required
  1229. KeySchema: []*dynamodb.KeySchemaElement{ // Required
  1230. { // Required
  1231. AttributeName: aws.String("KeySchemaAttributeName"), // Required
  1232. KeyType: aws.String("KeyType"), // Required
  1233. },
  1234. // More values...
  1235. },
  1236. Projection: &dynamodb.Projection{ // Required
  1237. NonKeyAttributes: []*string{
  1238. aws.String("NonKeyAttributeName"), // Required
  1239. // More values...
  1240. },
  1241. ProjectionType: aws.String("ProjectionType"),
  1242. },
  1243. ProvisionedThroughput: &dynamodb.ProvisionedThroughput{ // Required
  1244. ReadCapacityUnits: aws.Int64(1), // Required
  1245. WriteCapacityUnits: aws.Int64(1), // Required
  1246. },
  1247. },
  1248. Delete: &dynamodb.DeleteGlobalSecondaryIndexAction{
  1249. IndexName: aws.String("IndexName"), // Required
  1250. },
  1251. Update: &dynamodb.UpdateGlobalSecondaryIndexAction{
  1252. IndexName: aws.String("IndexName"), // Required
  1253. ProvisionedThroughput: &dynamodb.ProvisionedThroughput{ // Required
  1254. ReadCapacityUnits: aws.Int64(1), // Required
  1255. WriteCapacityUnits: aws.Int64(1), // Required
  1256. },
  1257. },
  1258. },
  1259. // More values...
  1260. },
  1261. ProvisionedThroughput: &dynamodb.ProvisionedThroughput{
  1262. ReadCapacityUnits: aws.Int64(1), // Required
  1263. WriteCapacityUnits: aws.Int64(1), // Required
  1264. },
  1265. StreamSpecification: &dynamodb.StreamSpecification{
  1266. StreamEnabled: aws.Bool(true),
  1267. StreamViewType: aws.String("StreamViewType"),
  1268. },
  1269. }
  1270. resp, err := svc.UpdateTable(params)
  1271. if err != nil {
  1272. // Print the error, cast err to awserr.Error to get the Code and
  1273. // Message from an error.
  1274. fmt.Println(err.Error())
  1275. return
  1276. }
  1277. // Pretty-print the response data.
  1278. fmt.Println(resp)
  1279. }