Qore AwsRestClient Module Reference  1.0
AwsRestClient::AwsRestClient Class Reference

this class provides the REST client API for communication with AWS More...

Inheritance diagram for AwsRestClient::AwsRestClient:

Public Member Methods

 constructor (hash< auto > opts, *softbool do_not_connect)
 creates the object with the given options More...
 

Public Attributes

const AwsSignatureAlgorithm = "AWS4-HMAC-SHA256"
 AWS signature algorithm used; must match QoreDigest.
 
const AwsTermination = "aws4_request"
 Fixed termination string.
 
const DefaultSendEncoding = "gzip"
 default send encoding
 
const QoreDigest = CRYPTO_DIGEST_SHA256
 Qore digest algorithm to use for HMAC calculations; must match AwsSignatureAlgorithm.
 
const RequiredOptions
 required options
 

Detailed Description

this class provides the REST client API for communication with AWS

This class requires the following options ... XXXX

Member Function Documentation

◆ constructor()

AwsRestClient::AwsRestClient::constructor ( hash< auto >  opts,
*softbool  do_not_connect 
)

creates the object with the given options

Example:
AwsRestClient rest({
"url": "https://apigateway.eu-central-1.amazonaws.com",
"aws_keyid": aws_keyid,
"aws_secret": aws_secret.
});
Parameters
optsvalid options are:
  • additional_methods: Optional hash with more but not-HTTP-standardized methods to handle. It allows HTTP extensions like e.g. WebDAV to work. The hash takes the method name as a key, and the value is a boolean True or False: indicating if the method requires a message body as well. Example:
    # add new HTTP methods for WebDAV. Both of them require body posting to the server
    {"additional_methods": {"PROPFIND": True, "MKCOL": True}};
  • aws_keyid: (required) the AWS key ID
  • aws_region: the AWS region to use (ex: "us-east-1"); if it cannot be derived from the URL then it is a required option
  • was_service: the AWS service to use (ex: "iam"); if it cannot be derived from the URL then it is a required option
  • aws_secret: (required) the AWS secret access key value
  • aws_token: a temporary session token from AWS Security Token Service for this HTTP session
  • content_encoding: for possible values, see EncodingSupport; this sets the send encoding (if the "send_encoding" option is not set) and the requested response encoding (note that the RestClient class will only compress outgoing message bodies over CompressionThreshold bytes in size)
  • default_path: The default path to use for new connections if a path is not otherwise specified in the connection URL
  • default_port: The default port number to connect to if none is given in the URL
  • error_passthru: if True then HTTP status codes indicating errors will not cause a REST-RESPONSE-ERROR exception to be raised, rather such responses will be passed through to the caller like any other response
  • headers: an optional hash of headers to send with every request, these can also be overridden in request method calls
  • http_version: Either '1.0' or '1.1' (default) for the claimed HTTP protocol version compliancy in outgoing message headers
  • max_redirects: The maximum number of redirects before throwing an exception (the default is 5)
  • proxy: The proxy URL for connecting through a proxy
  • redirect_passthru: if True then redirect responses will be passed to the caller instead of processed
  • aws_s3: set to True to flag this object for use with AWS aws_s3, which requires special message encoding
  • send_encoding: a send data encoding option or the value "auto" which means to use automatic encoding; if not present defaults to "gzip" content encoding on sent message bodies (note that the RestClient class will only compress outgoing message bodies over CompressionThreshold bytes in size)
  • swagger: the path to a Swagger 2.0 REST schema file for API validation; only used if validator not provided (see the Swagger module)
  • timeout: The timeout value in milliseconds (also can be a relative date-time value for clarity, ex: 30s)
  • url: a string giving the URL to connect to; if not given then the target URL will be taken from any validator option, if given by calling AbstractRestSchemaValidator::getTargetUrl()
  • validator: an AbstractRestSchemaValidator object to validate request and response messages; overrides swagger
do_not_connectif False (the default), then a connection will be immediately established to the remote server
Exceptions
RESTCLIENT-ERRORinvalid option passed to constructor, unsupported data serialization, etc
AWSRESTCLIENT-ERRORmissing or invalid required option for AWS REST authentication or communication
Note
the data option is always set to "json"