Hi, Greg.

I'm not sure how to elegantly keep it backward compatible.

The best thing I could come up with since yesterday would be to create
new functions for the new version, by adding a parameter to defraw.
(See below.)  Do you or does anyone have a good idea?

(defraw put-item "DynamoDB_20111205.")
(defraw get-item "DynamoDB_20111205.")
(defraw delete-item "DynamoDB_20111205.")
(defraw update-item "DynamoDB_20111205.")
(defraw batch-get-item "DynamoDB_20111205.")
(defraw batch-write-item "DynamoDB_20111205.")
(defraw query "DynamoDB_20111205.")
(defraw scan "DynamoDB_20111205.")
(defraw update-table "DynamoDB_20111205.")

(defraw put-item-20120810 "DynamoDB_20120810.")
(defraw get-item-20120810 "DynamoDB_20120810.")
(defraw delete-item-20120810 "DynamoDB_20120810.")
(defraw update-item-20120810 "DynamoDB_20120810.")
(defraw batch-get-item-20120810 "DynamoDB_20120810.")
(defraw batch-write-item-20120810 "DynamoDB_20120810.")
(defraw query-20120810 "DynamoDB_20120810.")
(defraw scan-20120810 "DynamoDB_20120810.")
(defraw update-table-20120810 "DynamoDB_20120810.")
(defraw create-table-20120810 "DynamoDB_20120810.")

Greg Hendershott <greghendersh...@gmail.com> writes:

> Hi, Daniel.
>
> Thank you. At a quick glance updating the AWS API version seems
> reasonable, as does adding new functionality like create-table-jsexpr
> (but not breaking backward compatibility -- e.g. let's not remove
> create-table or change the endpoint default.)
>
> In any case would you mind making a pull request at
> https://github.com/greghendershott/aws please? That would be easier
> (for me, at least) to review, run tests automatically, discuss, etc.
>
>
> On Wed, Jul 20, 2016 at 6:30 PM, Daniel Bastos <dbas...@toledo.com> wrote:
>> 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.

Reply via email to