Thank you for writing the aws package. Currently, it supports the api version 20111205. I updated dynamo.rkt to use the newer api 20120810. I updated the tests as well. I touched only dynamo.rkt.
(*) What did I change My needs began with create-table because the new api version changed considerably the jsexpr they accept. So I thought it'd be wiser to leave the building of the jsexpr to the user. Since creating a table is a bureaucratic jsexpr, I provided a function to friendly create the jsexpr with the basic requirements. If the user decides to use more complex table creation, s/he can do so by augmenting the result of create-table-jsexpr. The other changes were just due to the new string "DynamoDB_20120810." I didn't update the documentation as I don't know this will be welcome. I don't mind doing so. Let me know? Thank you. (*) Tests %raco test dynamo.rkt raco test: (submod "dynamo.rkt" test) Table status is 'CREATING', waiting for 'ACTIVE'... 6 tests passed % (*) Patch --- dynamo.rkt.orig 2016-07-20 19:19:08.000000000 -0300 +++ dynamo.rkt 2016-07-20 19:26:55.000000000 -0300 @@ -14,6 +14,7 @@ dynamo-region attribute-type/c create-table + create-table-jsexpr delete-table describe-table list-tables @@ -28,9 +29,9 @@ update-table) (define dynamo-endpoint - (make-parameter (endpoint "dynamodb.us-east-1.amazonaws.com" #t))) + (make-parameter (endpoint "dynamodb.us-west-2.amazonaws.com" #t))) (define dynamo-region - (make-parameter "us-east-1")) + (make-parameter "us-west-2")) (define service "dynamodb") (define attribute-type/c (or/c "S" "N" "B")) @@ -68,34 +69,37 @@ (check-response in h) (bytes->jsexpr (read-entity/bytes in h))))) -(define/contract (create-table name - read-units - write-units - hash-key-name - hash-key-type - [range-key-name #f] - [range-key-type #f]) +(define/contract (create-table-jsexpr name + read-units + write-units + hash-key-name + hash-key-type + [range-key-name #f] + [range-key-type #f]) ((string? exact-positive-integer? exact-positive-integer? string? attribute-type/c) (string? attribute-type/c) . ->* . jsexpr?) - (raw (hasheq - 'TableName name - 'KeySchema (apply hasheq - (append - (list 'HashKeyElement - (hasheq 'AttributeName hash-key-name - 'AttributeType hash-key-type)) - (if (and range-key-name range-key-type) - (list 'RangeKeyElement - (hasheq 'AttributeName range-key-name - 'AttributeType range-key-type)) - '()))) - 'ProvisionedThroughput (hasheq 'ReadCapacityUnits read-units - 'WriteCapacityUnits write-units)) - "DynamoDB_20120810.CreateTable")) + (hasheq + 'TableName name + 'AttributeDefinitions (append + (list (hasheq 'AttributeName hash-key-name + 'AttributeType hash-key-type)) + (if (and range-key-name range-key-type) + (list (hasheq 'AttributeName range-key-name + 'AttributeType range-key-type)) + '())) + 'KeySchema (append + (list (hasheq 'AttributeName hash-key-name + 'KeyType "HASH")) + (if (and range-key-name range-key-type) + (list (hasheq 'AttributeName range-key-name + 'KeyType "RANGE")) + '())) + 'ProvisionedThroughput (hasheq 'ReadCapacityUnits read-units + 'WriteCapacityUnits write-units))) (define/contract (delete-table name) (string? . -> . jsexpr?) @@ -144,6 +148,7 @@ (defraw query) (defraw scan) (defraw update-table) +(defraw create-table) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -154,9 +159,9 @@ (test-case "dynamo" (define test (test/dynamo-table)) - (check-not-exn (λ () (create-table test 1 1 - "HashKey" "S" - "RangeKey" "S"))) + (check-not-exn (λ () (create-table (create-table-jsexpr test 1 1 + "id" "S" + "sort" "S")))) (check-not-exn (λ () (list-tables #:limit 10))) (check-not-exn (λ () (describe-table test))) (let loop () @@ -168,13 +173,13 @@ (loop))) (check-not-exn (λ () (put-item (hasheq 'TableName test - 'Item (hasheq 'HashKey (hasheq 'S "Hi") - 'RangeKey (hasheq 'S "world") + 'Item (hasheq 'id (hasheq 'S "Hi") + 'sort (hasheq 'S "world") 'Foo (hasheq 'S "bar")))))) (sleep 2) (define js (get-item (hasheq 'TableName test - 'Key (hasheq 'HashKeyElement (hasheq 'S "Hi") - 'RangeKeyElement (hasheq 'S "world"))))) + 'Key (hasheq 'id (hasheq 'S "Hi") + 'sort (hasheq 'S "world"))))) (check-equal? (hash-ref (hash-ref js 'Item) 'Foo) (hasheq 'S "bar")) (check-not-exn (λ () (delete-table test)))))) -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.