diff options
author | Ricardo Wurmus <rekado@elephly.net> | 2021-03-18 14:30:37 +0100 |
---|---|---|
committer | Ricardo Wurmus <rekado@elephly.net> | 2021-03-18 14:30:37 +0100 |
commit | c3ca0b399d96dc9881f551aea21f42ecd70acd9a (patch) | |
tree | 0985e4810bab4933ff0adc8979cd3fb2885e7a31 | |
parent | b1650734906eb0330de2c5c41a14642ecd6e8a52 (diff) |
serialize: Upcase the first letter of any property name.
-rw-r--r-- | aws/serialize.scm | 12 | ||||
-rw-r--r-- | tests/serialize.scm | 18 |
2 files changed, 20 insertions, 10 deletions
diff --git a/aws/serialize.scm b/aws/serialize.scm index e9a1382..f6d12fd 100644 --- a/aws/serialize.scm +++ b/aws/serialize.scm @@ -26,6 +26,16 @@ ;; See https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Query-Requests.html (define* (serialize-aws-value thing) + ;; XXX: I don't know why this is necessary, but it seems to be + ;; required that the locationName begin with an uppercase letter. + ;; There is nothing in the specification that would hint at this, + ;; but testing against the AWS API have revealed this to be the + ;; case. This is at least true for "Value" and "Key" of a "Tag" + ;; value, and for "ResourceType" of a "TagSpecification". + (define (up string) + (let ((s (format #false "~a" string))) + (string-set! s 0 (char-upcase (string-ref s 0))) + s)) (define inner (lambda (path thing) (cond @@ -63,7 +73,7 @@ (else (format #false "~{~a~^.~}=~a" - (reverse (filter identity path)) + (map up (reverse (filter identity path))) thing))))) (define (flatten lst) (match lst diff --git a/tests/serialize.scm b/tests/serialize.scm index ef851ba..5867edb 100644 --- a/tests/serialize.scm +++ b/tests/serialize.scm @@ -54,15 +54,15 @@ given by REPLACEMENT." (test-equal "simple query serialization with nested structures" '("ImageId=ami-72aa081b" "MaxCount=1" "MinCount=1" - "TagSpecification.1.resourceType=instance" - "TagSpecification.1.Tag.1.key=project" - "TagSpecification.1.Tag.1.value=pigx-web" - "TagSpecification.1.Tag.2.key=pigx-web:resource" - "TagSpecification.1.Tag.2.value=user-vm" - "TagSpecification.1.Tag.3.key=pigx-web:username" - "TagSpecification.1.Tag.3.value=username" - "TagSpecification.1.Tag.4.key=pigx-web:project" - "TagSpecification.1.Tag.4.value=project") + "TagSpecification.1.ResourceType=instance" + "TagSpecification.1.Tag.1.Key=project" + "TagSpecification.1.Tag.1.Value=pigx-web" + "TagSpecification.1.Tag.2.Key=pigx-web:resource" + "TagSpecification.1.Tag.2.Value=user-vm" + "TagSpecification.1.Tag.3.Key=pigx-web:username" + "TagSpecification.1.Tag.3.Value=username" + "TagSpecification.1.Tag.4.Key=pigx-web:project" + "TagSpecification.1.Tag.4.Value=project") (serialize-aws-value (RunInstancesRequest #:ImageId "ami-72aa081b" #:MinCount 1 |