1 SQS - Simple Queue Service
1.1 Configuration
(require "../aws/sqs/config.rkt") | package: wrap |
Currently SQS configuration is hardcoded in a "config.rkt" file and reviewed and modified to suit.
The version of the SQS API to use. This should be changed as Amazon releases new versions of the SQS API.
The SQS host to which all SQS commands are sent. This should be changed to match your desired AWS facility. Ideally this should be say a parameterizable configuration, but for now is a hard code.
The version of authentication that SQS is using. For current SQS api, "2011-10-01" version "2" authentication is used. This value is sent as part of the request and should in general not be changed.
The signing method used to create the authentication header. This value is also sent as part of the request. For the current SQS api, "2011-10-01" HMAC-SHA256 is used and should in general not be changed.
The namespace used in the XML contained in payload of an SQS HTTP response.
1.2 AWS Authentication
AWS uses a set of credentials which include a private key or a private session key to perform an signature of the request and then sending the signature as part of the request.
Currently this library expects and requires that a valid set of credentials is loadable from "~/.awscreds.sexp".
1.2.1 AWS Credentials
A parameterization containing the credentials used by this library authorizing an AWS call. An initial set of credential information is loaded during module initialization from a given path. Module initialization will fail if the expected credential file is not found.
Currently defined to be the path "~/.awscreds.sexp". It is an error if this file does not exist.
At a minimum this file must contain the AWS account access key and secret key in the following sexp alist form.
((access-key . "ACCESSKEY") |
(secret-key . "secretkey")) |
(struct | | BaseCredential (access-key secret-key) |
|
#:transparent) |
access-key : String |
secret-key : String |
An abstract base structure which contains the minimal set of credential information an AWS account access and secret key.
(struct | | SessionCredential BaseCredential (token expiration) |
|
#:transparent) |
token : String |
expiration : Time |
Contains an AWS STS (Security Token Service) issued token and its associated expiration time stamp. Some AWS services such as DynamoDB require session authorization. A valid session is token is implicitly maintained by this AWS library.
(struct | | AwsCredential BaseCredential | ( | account-id | | | | | associatate-tag | | | | | session) |
|
#:mutable |
#:transparent) |
account-id : String |
associatate-tag : String |
session : (Option SessionCredential) |
Extends "BaseCredential" and contains the full set of AWS credentialing information. The "account-id" and "associate-tag" are used for AWS affiliate program API which are not contained in this planet library. If these values are not found in the home directory ".awscreds.sexp" file their values are an empty string.
The session credential field holds the current (if any) ephemeral session credentials from AWS STS security token service.
The library will automatically maintain a valid session credential from STS by implicitly obtaining one if it is required or obtaining a fresh token if the current token has expired.
(load-credential path) → AwsCredential
|
path : Path |
Explicitly read in an sexp alist property file containing AWS credential information. The library implicitly loads "~/.awscreds.sexp" in module initialization, therefore use of this procedure is unnecessary for normal usage.
(set-aws-credential! credential) → Void
|
credential : AwsCredential |
Utility procedure to set the "current-aws-credential" parameter. Not required for normal use as the library loads and initializes the "current-aws-credential" parameter implicitly from "~/.awscreds.sexp" on initialization.
1.3 STS
(require "../aws/sts/stc.rkt") | package: wrap |
Obtains a session token valid for the given duration in seconds from the AWS STS service.
1.4 S3 API
1.5 S3 URI
S3 API prefixes are relative path strings to the bucket. A URI path is absolute.
Convert a S3 Uri, s3://mybucket/a/b/c, path, "/a/b/c" to a S3 prefix "a/b/c".
1.6 S3 Bucket Types
(struct | | Buckets (owner buckets) |
|
#:transparent) |
owner : Owner |
buckets : (Listof Bucket) |
Structure return by the "list-buckets" call to S3.
Ownership information associated with an S3 bucket.
Bucket meta information returned by S3 in a "list-buckets" call.
(struct | | S3Response (http sxml) |
|
#:transparent) |
http : Result |
sxml : Sxml |
Contains the low level HTTP response header, e.g. the HTTP code and message, and the S3 XML response parsed into sxml. Eventually all S3 API calls will be fully parsed into appropriate response structures.
1.6.1 S3 Bucket API
See AWS S3 documentation for detailed information on the various parameters.
Obtains a list of owned S3 buckets.
(create-bucket bucket-name) → S3Response
|
bucket-name : String |
Create a bucket on S3 with the given name.
(delete-bucket bucket-name) → S3Response
|
bucket-name : String |
Deletes the given S3 bucket
1.6.2 S3 Object Types
The meta information associated with an S3 object.
Result information returned from a call to "list-bucket-objects".
1.6.3 S3 Object API
See AWS S3 documentation for detailed information on the various parameters.
Lists the objects contained in the given bucket.
(put-object bytes bucket path) → S3Response
|
bytes : Bytes |
bucket : String |
path : String |
Stores a blob of bytes into a bucket under a path name.
(put-file-object path-to-file bucket path) → S3Response
|
path-to-file : String |
bucket : String |
path : String |
Stores a local on disk file up on S3 in a provided path.
(delete-object bucket path) → S3Response
|
bucket : String |
path : String |
Deletes an S3 stored object.
1.7 SQS
(list-queues prefix) → (U SQSError SQSListQueuesResp)
|
prefix : (Option String) |
List all SQS queues. If the optional prefix is provided only those queues starting
with the prefix are listed. e.g. "/txs" would include "/txs/q1" and not "/orders/qs".
(: send-message (String String -> (U SQSError Void))) |
(define (send-message queue-path msg) |
(sqs-invoke queue-path 'SendMessage (send-message-request msg))) |
(send-message queue-path msg) → (U SQSError SQSSendResp)
|
queue-path : String |
msg : String |
Sends a message to the given gueue. The queue-path should be absolute, e.g. "/myqueue".
AttributeName | : | (U 'All 'SenderId 'SentTimestamp | 'ApproximateReceiveCount | 'ApproximateFirstReceiveTimestamp) |
|
|
A define-type of an enumeration of allowable code values which specify the attribute values to be returned by SQS when receiving a message.
1.8 DynamoDB
1.8.1 Table Types
(struct | | CreateTableResp (name status create capacity schema) |
|
#:transparent) |
name : String |
status : TableStatus |
create : Float |
capacity : Throughput |
schema : KeySchema |
Response information from a "create-table" call.
The read and write throughput of a table.
TableStatus : (U 'Active 'Deleting 'Creating)
|
The status of a table.
Information returned from a "list-tables" call. The
"last" value can be used to initiate a second "list-tables" call
to start listing from there.
1.8.2 Table API
(create-table | | name | | | | | | | hash-key | | | | | | | range-key | | | | | | | throughput) | | → | | (U DDBFailure CreateTableResp) |
|
name : String |
hash-key : Key |
range-key : (Option Key) |
throughput : Throughput |
Creates a DynamboDB table.
(delete-table name) → (U DDBFailure DeleteTableRep)
|
name : String |
Deletes the table.
(describe-table | | name | | | | | | | schema | | | | | | | size | | | | | | | creation | | | | | | | status | | | | | | | capacity) | | → | | (U DDBFailure DescribeTableResp) |
|
name : String |
schema : (Option KeySchema) |
size : Integer |
creation : Float |
status : TableStatus |
capacity : Throughput |
Meta data information for a table.
List tables. If "start-from" is given the listing starts lexically after the string. Count is maximum number of tables to return in the response.