SSS - S3 Toolkit 0.9.6
S3 client library and applications
|
S3 Client inteface. More...
#include <s3-api.h>
Data Structures | |
struct | ListObjectV2Config |
ListObjectsV2 request See https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html More... | |
struct | ListObjectV2Result |
ListObjectsV2 response. See https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html More... | |
struct | ObjectVersionInfo |
object version history More... | |
struct | ReadBuffer |
Memory buffer used in SendParams. More... | |
struct | SendParams |
Send request parameters. More... | |
struct | VersioningInfo |
versioning information More... | |
Public Types | |
enum | FileIOMode |
I/O mode used for reading and writing data from/to files. | |
Public Member Functions | |
S3Api (const std::string &access, const std::string &secret, const std::string &endpoint, const std::string &signingEndpoint="") | |
S3Api ()=delete | |
No default constructor. | |
S3Api (const S3Api &)=delete | |
No copy constructor, libcurl handle cannot be copied or shared. | |
S3Api (S3Api &&other) | |
Move constructor, libcurl handle is moved into new instance. | |
bool | TestBucket (const std::string &bucket) |
Check if bucket exist. | |
bool | TestObject (const std::string &bucket, const std::string &key) |
Check if key exists. | |
void | Clear () |
Clear data and reset read and write functions. | |
const WebClient & | Send (const SendParams &p) |
Send request. | |
WebClient & | Config (const SendParams &p) |
Configure instance. | |
void | Send (const SendParams ¶ms, WebClient::ReadFunction sendFun, void *sendUserData, WebClient::WriteFunction receiveFun, void *receiveUserData) |
void | GetFileObject (const std::string &outFileName, const std::string &bucket, const std::string &key, size_t writeOffset=0, size_t beginReadOffset=0, size_t endReadOffset=0, Headers headers={{}}, const std::string &versionId="") |
Download object into file. | |
ETag | PutFileObject (const std::string &infileName, const std::string &bucket, const std::string &key, size_t readOffset=0, size_t readSize=0, Headers headers={{}}, const std::string &payloadHash={}) |
Upload file to object. | |
ETag | UploadFilePart (const std::string &inFileName, size_t readOffset, size_t readSize, const std::string &bucket, const std::string &key, const UploadId &uid, int partNum, FileIOMode iomode=BUFFERED, int maxRetries=1, Headers headers={{}}, const std::string &payloadHash={}) |
Upload file part. Invoke after calling CreateMultipartUpload and before calling CompleteMultipartUpload. | |
ssize_t | GetObjectSize (const std::string &bucket, const std::string &key, const std::string &versionId="") |
Return object size. | |
void | AbortMultipartUpload (const std::string &bucket, const std::string &key, const UploadId &uploadId) |
Abort multipart upload. | |
ETag | CompleteMultipartUpload (const UploadId &uid, const std::string &bucket, const std::string &key, const std::vector< ETag > &etags) |
Complete multipart upload. | |
std::string | CreateBucket (const std::string &bucket, const Headers &headers={{}}, const std::string &locationConstraint=std::string()) |
Create bucket. | |
UploadId | CreateMultipartUpload (const std::string &bucket, const std::string &key, size_t partSize=0, Headers headers={}) |
Create multipart upload. | |
void | DeleteBucket (const std::string &bucket, const Headers &headers={{}}) |
Delete bucket. | |
void | DeleteObject (const std::string &bucket, const std::string &key, const Headers &headers={}, const std::string &versionId="") |
Delete object. | |
void | DeleteBucketTagging (const std::string &bucket, const Headers &headers={}) |
Remove all tags from bucket. | |
void | DeleteObjectTagging (const std::string &bucket, const std::string &key, const Headers &headers={}) |
Remove all tags from object. | |
AccessControlPolicy | GetBucketAcl (const std::string &bucket) |
TagMap | GetBucketTagging (const std::string &bucket) |
Return bucket tags. | |
VersioningInfo | GetBucketVersioning (const std::string &bucket) |
Retrieve versioning status. | |
const CharArray & | GetObject (const std::string &bucket, const std::string &key, size_t beginReadOffset=0, size_t endReadOffset=0, Headers={{}}, const std::string &versionId="") |
Download object data. | |
void | GetObject (const std::string &bucket, const std::string &key, CharArray &outBuffer, size_t writeOffset, size_t beginReadOffset=0, size_t endReadOffset=0, Headers headers={{}}, const std::string &versionId="") |
Download object data into vector<char> | |
void | GetObject (const std::string &bucket, const std::string &key, char *outBuffer, size_t writeOffset, size_t beginReadOffset=0, size_t endReadOffset=0, Headers headers={{}}, const std::string &versionId="") |
Download object data into char buffer. | |
AccessControlPolicy | GetObjectAcl (const std::string &bucket, const std::string &key) |
Return bucket's Access Control List. | |
TagMap | GetObjectTagging (const std::string &bucket, const std::string &key) |
Return object tags. | |
Headers | HeadBucket (const std::string &bucket, const Headers &headers={{}}) |
Headers | HeadObject (const std::string &bucket, const std::string &key, const Headers &={{}}, const std::string &versionId="") |
Send HeadObject request. | |
std::vector< BucketInfo > | ListBuckets (const Headers &headers={{}}) |
List buckets. | |
ListObjectV2Result | ListObjectsV2 (const std::string &bucket, const ListObjectV2Config &config=ListObjectV2Config{}, const Headers &={{}}) |
List objects by sending a ListObjectsV2 request. | |
ObjectVersionInfo | ListObjectVersions (const std::string &bucket, const std::string &key) |
Return all versions and delete markers for object. | |
void | PutBucketAcl (const std::string &bucket, const AccessControlPolicy &acl) |
Set Access Control Policy for bucket. | |
void | PutBucketTagging (const std::string &bucket, const TagMap &tags, const Headers &headers={}) |
Tag bucket. | |
void | PutBucketVersioning (const std::string &bucket, bool enabled) |
Enable bucket versioning. | |
ETag | PutObject (const std::string &bucket, const std::string &key, const CharArray &buffer, Headers headers={{}}, const std::string &payloadHash={}) |
Upload data to object by sending a PutObject request. | |
ETag | PutObject (const std::string &bucket, const std::string &key, const char *buffer, size_t size, Headers headers={{}}, const std::string &payloadHash={}) |
Upload data to object by sending a PutObject request. | |
void | PutObjectAcl (const std::string &bucket, const std::string &key, const AccessControlPolicy &acl) |
Set Access Control Policy. | |
void | PutObjectTagging (const std::string &bucket, const std::string &key, const TagMap &tags, const Headers &headers={}) |
Set object tags. | |
ETag | UploadPart (const std::string &bucket, const std::string &key, const UploadId &uid, int partNum, const char *data, size_t size, int maxRetries=1, Headers headers={{}}, const std::string &payloadHash={}) |
Upload part. | |
const std::string & | Access () const |
const std::string & | Secret () const |
const std::string & | Endpoint () const |
const std::string & | SigningEndpoint () const |
const std::vector< char > & | GetResponseBody () const |
std::string | GetResponseText () const |
Headers | GetResponseHeaders () const |
Get returned HTTP headers. Use this method to retrieve additional information e.g. versionId after sending a request. | |
S3 Client inteface.
Implements some of the S3 actions documented here: https://docs.aws.amazon.com/AmazonS3/latest/API/API_Operations_Amazon_Simple_Storage_Service.html
Also includes higher level methods to simplify access to the API.
When sending requests, the fields specified as URL prameters are passed to methods as C++ structs and sent as part of the request, but in most cases the optional parameters sent as HTTP header fields are not sent along, it is therefore required to explicitly pass them in the headers
parameter.
E.g. the ListObjectV2
request supports HTTP headers for specifying the payer for the request and owner of the listed objects.
Currently exceptions are being used to report errors, work is ongoing to move to result types similar to Rust's Result<ResultT,ErrorT>
.
All methods that send requests throw:
std::runtime_error
in case of errors sending the requeststd::logic_error
when the returned response code is >= 400From test cases printing results in CSV
format.
Bucket
Object
|
inline |
Constructor.
[in] | access | access token |
[in] | secret | token |
[in] | endpoint | where reqests as sent |
[in] | signingEndpoint | url used to sign request, required in case requests are not sent to S3 endpoint (e.g. SSH tunnel used). |
void sss::api::S3Api::AbortMultipartUpload | ( | const std::string & | bucket, |
const std::string & | key, | ||
const UploadId & | uploadId | ||
) |
Abort multipart upload.
[in] | bucket | bucket name |
[in] | key | key name |
[in] | uploadId | upload id returned by CreateMultipartUpload |
References Send().
|
inline |
ETag sss::api::S3Api::CompleteMultipartUpload | ( | const UploadId & | uid, |
const std::string & | bucket, | ||
const std::string & | key, | ||
const std::vector< ETag > & | etags | ||
) |
Complete multipart upload.
[in] | uid | upload id returned by CreateMultipartUpload |
[in] | bucket | bucket name |
[in] | key | key name |
[in] | etags | etags of uploaded parts |
std::runtime_error | in case of error sending request |
std::logic_error | in case of returned error (status >= 400) |
References Send(), and sss::XMLTag().
WebClient & sss::api::S3Api::Config | ( | const SendParams & | p | ) |
Configure instance.
[WebClient::Config]
[in] | p | configuration |
References Access(), sss::api::S3Api::SendParams::bucket, Clear(), Endpoint(), sss::api::S3Api::SendParams::headers, sss::api::S3Api::SendParams::key, sss::api::S3Api::SendParams::method, sss::api::S3Api::SendParams::params, sss::api::S3Api::SendParams::payloadHash, Secret(), sss::WebClient::SetEndpoint(), sss::WebClient::SetHeaders(), sss::WebClient::SetMethod(), sss::WebClient::SetPath(), sss::WebClient::SetReqParameters(), and sss::SignHeaders().
string sss::api::S3Api::CreateBucket | ( | const std::string & | bucket, |
const Headers & | headers = {{}} , |
||
const std::string & | locationConstraint = std::string() |
||
) |
Create bucket.
[in] | bucket | bucket name |
[in] | headers | optional HTTP headers as {name, value} map |
[in] | locationConstraint | bucket location e.g. ap-east-1 or EU refer to the updated list on the AWS web site |
References sss::api::S3Api::SendParams::method, sss::ParseHeaders(), Send(), and sss::ToLower().
UploadId sss::api::S3Api::CreateMultipartUpload | ( | const std::string & | bucket, |
const std::string & | key, | ||
size_t | partSize = 0 , |
||
Headers | headers = {} |
||
) |
Create multipart upload.
[in] | bucket | bucket name |
[in] | key | key name |
[in] | partSize | part size hint, optional |
[in] | headers | optional HTTP headers as {name, value} map |
References sss::WebClient::GetContentText(), Send(), and sss::XMLTag().
void sss::api::S3Api::DeleteBucket | ( | const std::string & | bucket, |
const Headers & | headers = {{}} |
||
) |
Delete bucket.
[in] | bucket | bucket name |
[in] | headers | headers sent along w |
[in] | headers | optional HTTP headers as {name, value} map |
References Send().
void sss::api::S3Api::DeleteBucketTagging | ( | const std::string & | bucket, |
const Headers & | headers = {} |
||
) |
Remove all tags from bucket.
[in] | bucket | bucket name |
[in] | headers | optional http headers as {name, value} map |
References Send().
void sss::api::S3Api::DeleteObject | ( | const std::string & | bucket, |
const std::string & | key, | ||
const Headers & | headers = {} , |
||
const std::string & | versionId = "" |
||
) |
Delete object.
[in] | bucket | bucket name |
[in] | key | key name |
[in] | headers | optional http headers as {name, value} map sent along with request |
[in] | versionId | version id, leave blank for latest version or in case versioning is not enabled |
References Send().
void sss::api::S3Api::DeleteObjectTagging | ( | const std::string & | bucket, |
const std::string & | key, | ||
const Headers & | headers = {} |
||
) |
Remove all tags from object.
[in] | bucket | bucket name |
[in] | key | name |
[in] | headers | optional http headers as {name, value} map |
References Send().
|
inline |
AccessControlPolicy sss::api::S3Api::GetBucketAcl | ( | const std::string & | bucket | ) |
Return bucket's Access Control List
bucket | bucket name |
References Send().
TagMap sss::api::S3Api::GetBucketTagging | ( | const std::string & | bucket | ) |
Return bucket tags.
[in] | bucket | bucket name |
tag name => tag value
map References Send().
S3Api::VersioningInfo sss::api::S3Api::GetBucketVersioning | ( | const std::string & | bucket | ) |
Retrieve versioning status.
[in] | bucket | bucket name |
References Send(), sss::ToLower(), and sss::XMLTag().
void sss::api::S3Api::GetFileObject | ( | const std::string & | outFileName, |
const std::string & | bucket, | ||
const std::string & | key, | ||
size_t | writeOffset = 0 , |
||
size_t | beginReadOffset = 0 , |
||
size_t | endReadOffset = 0 , |
||
Headers | headers = {{}} , |
||
const std::string & | versionId = "" |
||
) |
Download object into file.
[in] | outFileName | output file name |
[in] | bucket | bucket name |
[in] | key | key name |
[in] | writeOffset | write location in file |
[in] | beginReadOffset | offset of first byte to read from object |
[in] | endReadOffset | offset of last byte to read from object |
[in] | headers | optional headers |
[in] | versionId | version id |
References sss::begin(), Config(), sss::end(), sss::HandleError(), sss::WebClient::Send(), and sss::WebClient::SetWriteFunction().
void sss::api::S3Api::GetObject | ( | const std::string & | bucket, |
const std::string & | key, | ||
char * | outBuffer, | ||
size_t | writeOffset, | ||
size_t | beginReadOffset = 0 , |
||
size_t | endReadOffset = 0 , |
||
Headers | headers = {{}} , |
||
const std::string & | versionId = "" |
||
) |
Download object data into char
buffer.
[in] | bucket | bucket name |
[in] | key | key name |
[out] | outBuffer | output buffer |
[in] | writeOffset | offset in output buffer |
[in] | beginReadOffset | offset of first byte read from object |
[in] | endReadOffset | offset of last byte read from object |
[in] | optional | http headers as {name, value} map sent along with request |
[in] | versionId | version id, leave blank for latest version or in case versioning is not enabled |
void sss::api::S3Api::GetObject | ( | const std::string & | bucket, |
const std::string & | key, | ||
CharArray & | outBuffer, | ||
size_t | writeOffset, | ||
size_t | beginReadOffset = 0 , |
||
size_t | endReadOffset = 0 , |
||
Headers | headers = {{}} , |
||
const std::string & | versionId = "" |
||
) |
Download object data into vector<char>
[in] | bucket | bucket name |
[in] | key | key name |
[out] | outBuffer | output buffer |
[in] | writeOffset | offset in output buffer |
[in] | beginReadOffset | offset of first byte read from object |
[in] | endReadOffset | offset of last byte read from object |
[in] | optional | http headers as {name, value} map sent along with request |
[in] | versionId | version id, leave blank for latest version or in case versioning is not enabled |
const CharArray & sss::api::S3Api::GetObject | ( | const std::string & | bucket, |
const std::string & | key, | ||
size_t | beginReadOffset = 0 , |
||
size_t | endReadOffset = 0 , |
||
Headers | = {{}} , |
||
const std::string & | versionId = "" |
||
) |
Download object data.
[in] | bucket | bucket name |
[in] | key | key name |
[in] | beginReadOffset | offset of first byte read from object |
[in] | endReadOffset | offset of last byte read from object |
[in] | optional | http headers as {name, value} map sent along with request |
[in] | versionId | version id, leave blank for latest version or in case versioning is not enabled |
char
array; char
is the type used by libcurl
AccessControlPolicy sss::api::S3Api::GetObjectAcl | ( | const std::string & | bucket, |
const std::string & | key | ||
) |
Return bucket's Access Control List.
bucket | bucket name |
key | key name |
References Send().
ssize_t sss::api::S3Api::GetObjectSize | ( | const std::string & | bucket, |
const std::string & | key, | ||
const std::string & | versionId = "" |
||
) |
Return object size.
[WebClient::Config]
[in] | bucket | bucket name |
[in] | key | key name |
[in] | versionId | version id |
References sss::GetValue(), and HeadObject().
TagMap sss::api::S3Api::GetObjectTagging | ( | const std::string & | bucket, |
const std::string & | key | ||
) |
Return object tags.
[in] | bucket | bucket name |
[in] | key | key name |
tag name => tag value
map References Send().
|
inline |
References sss::WebClient::GetResponseBody().
|
inline |
Get returned HTTP headers. Use this method to retrieve additional information e.g. versionId
after sending a request.
References sss::WebClient::GetHeaderText(), and sss::HTTPHeaders().
|
inline |
References sss::WebClient::GetContentText().
Send HeadBucket
request
[in] | bucket | bucket name |
[in] | optional | http headers as {name, value} map sent along with request |
References sss::HTTPHeaders(), and Send().
Headers sss::api::S3Api::HeadObject | ( | const std::string & | bucket, |
const std::string & | key, | ||
const Headers & | = {{}} , |
||
const std::string & | versionId = "" |
||
) |
Send HeadObject
request.
[in] | bucket | bucket name |
[in] | key | key name |
[in] | optional | http headers as {name, value} map sent along with request |
[in] | versionId | version id, leave blank for latest version or in case versioning is not enabled |
References sss::HTTPHeaders(), and Send().
vector< BucketInfo > sss::api::S3Api::ListBuckets | ( | const Headers & | headers = {{}} | ) |
List buckets.
[in] | headers | optional http headers as {name, value} map sent along with request |
References sss::WebClient::GetContentText(), and Send().
S3Api::ListObjectV2Result sss::api::S3Api::ListObjectsV2 | ( | const std::string & | bucket, |
const ListObjectV2Config & | config = ListObjectV2Config{} , |
||
const Headers & | headers = {{}} |
||
) |
List objects by sending a ListObjectsV2
request.
[in] | bucket | bucket name |
[in] | config | optional configuration parameters |
[in] | headers | optional http headers as {name, value} map sent along with request |
References sss::WebClient::GetContentText(), and Send().
S3Api::ObjectVersionInfo sss::api::S3Api::ListObjectVersions | ( | const std::string & | bucket, |
const std::string & | key | ||
) |
Return all versions and delete markers for object.
[in] | bucket | bucket name |
\key[in] key name
References GetResponseText(), and Send().
void sss::api::S3Api::PutBucketAcl | ( | const std::string & | bucket, |
const AccessControlPolicy & | acl | ||
) |
Set Access Control Policy for bucket.
[in] | bucket | bucket name |
[in] | acl | Acess Control Policy |
References Send().
void sss::api::S3Api::PutBucketTagging | ( | const std::string & | bucket, |
const TagMap & | tags, | ||
const Headers & | headers = {} |
||
) |
Tag bucket.
[in] | bucket | bucket name |
[in] | tags | tag map: {tag name => tag value} |
[in] | http | headers as {header name, header value} map |
References Send().
void sss::api::S3Api::PutBucketVersioning | ( | const std::string & | bucket, |
bool | enabled | ||
) |
Enable bucket versioning.
[in] | bucket | bucket name |
[in] | enables | true to enable, false to disable |
References Send().
ETag sss::api::S3Api::PutFileObject | ( | const std::string & | infileName, |
const std::string & | bucket, | ||
const std::string & | key, | ||
size_t | readOffset = 0 , |
||
size_t | readSize = 0 , |
||
Headers | headers = {{}} , |
||
const std::string & | payloadHash = {} |
||
) |
Upload file to object.
[in] | infileName | input file name |
[in] | bucket | bucket name |
[in] | key | key name |
[in] | readOffset | offset of first byte to read from file |
[in] | readSize | number of bytes to read from file starting at readOffset |
References Config(), sss::WebClient::ErrorMsg(), sss::WebClient::GetHeaderText(), sss::HandleError(), sss::HTTPHeader(), and sss::WebClient::UploadFile().
ETag sss::api::S3Api::PutObject | ( | const std::string & | bucket, |
const std::string & | key, | ||
const char * | buffer, | ||
size_t | size, | ||
Headers | headers = {{}} , |
||
const std::string & | payloadHash = {} |
||
) |
Upload data to object by sending a PutObject
request.
[in] | bucket | bucket name |
[in] | key | key name |
[in] | buffer | input buffer |
[in] | headers | optional HTTP headers as {header name, value} map |
[in] | optional | payloadHash payload hash can be empty |
ETag sss::api::S3Api::PutObject | ( | const std::string & | bucket, |
const std::string & | key, | ||
const CharArray & | buffer, | ||
Headers | headers = {{}} , |
||
const std::string & | payloadHash = {} |
||
) |
Upload data to object by sending a PutObject
request.
[in] | bucket | bucket name |
[in] | key | key name |
[in] | buffer | input buffer |
[in] | headers | optional http headers as {header name, value} map |
[in] | optional | payloadHash payload hash can be empty |
void sss::api::S3Api::PutObjectAcl | ( | const std::string & | bucket, |
const std::string & | key, | ||
const AccessControlPolicy & | acl | ||
) |
Set Access Control Policy.
bucket[in] | bucket name |
key[in] | key name |
acl[in] | access control policy |
References Send().
void sss::api::S3Api::PutObjectTagging | ( | const std::string & | bucket, |
const std::string & | key, | ||
const TagMap & | tags, | ||
const Headers & | headers = {} |
||
) |
Set object tags.
[in] | bucket | bucket name |
[in] | key | key name |
[in] | tags | tag map |
[in] | headers | http headers as {header name, header value} map |
References Send().
|
inline |
|
inline |
Send request.
[in] | p | send parameters |
this
S3Api
instance. std::runtime_error | in case of error sending request |
std::logic_error | in case of returned error (status >= 400) |
References Config(), sss::HandleError(), sss::api::S3Api::SendParams::method, sss::ParseParams(), sss::WebClient::Send(), sss::WebClient::SetPostData(), sss::WebClient::SetUrlEncodedPostData(), sss::ToLower(), sss::api::S3Api::SendParams::uploadData, sss::WebClient::UploadDataFromBuffer(), and sss::api::S3Api::SendParams::urlEncodePostParams.
|
inline |
Send method with configurable send and receive functions.
[in] | params |
[in] | sendFun | pointer to function generating the data to send |
[in] | sendUseData | pointer to user data passed to sendFun at each invocation |
[in] | receiveFun | pointer to function receiving data |
[in] | receiveUserData | pointer to user data passed to receiveFun at each invocation |
References Send(), sss::WebClient::SetReadFunction(), and sss::WebClient::SetWriteFunction().
|
inline |
bool sss::api::S3Api::TestBucket | ( | const std::string & | bucket | ) |
Check if bucket exist.
[in] | bucket | bucket name |
true
if bucket exist, false
otherwise References Send(), and SigningEndpoint().
bool sss::api::S3Api::TestObject | ( | const std::string & | bucket, |
const std::string & | key | ||
) |
Check if key exists.
[in] | bucket | bucket name |
[in] | key | key name |
true
if key exists, false
otherwise References HeadObject().
ETag sss::api::S3Api::UploadFilePart | ( | const std::string & | inFileName, |
size_t | readOffset, | ||
size_t | readSize, | ||
const std::string & | bucket, | ||
const std::string & | key, | ||
const UploadId & | uid, | ||
int | partNum, | ||
FileIOMode | iomode = BUFFERED , |
||
int | maxRetries = 1 , |
||
Headers | headers = {{}} , |
||
const std::string & | payloadHash = {} |
||
) |
Upload file part. Invoke after calling CreateMultipartUpload and before calling CompleteMultipartUpload.
[in] | inFileName | input file name |
[in] | readOffset | offset of first byte to read in file |
[in] | readSize | number of bytes to read starting at readOffset |
[in] | bucket | bucket name |
[in] | key | key name |
[in] | uid | upload id returned by CreateMultipartUpload method |
[in] | partNum | zero-indexed part number |
[in] | iomode | read mode |
[in] | maxRetries | number of retried before aborting upload |
[in] | headers | optional HTTP headers as {name, value} map |
[in] | payloadHash | payload hash, can be empty |
ETag sss::api::S3Api::UploadPart | ( | const std::string & | bucket, |
const std::string & | key, | ||
const UploadId & | uid, | ||
int | partNum, | ||
const char * | data, | ||
size_t | size, | ||
int | maxRetries = 1 , |
||
Headers | headers = {{}} , |
||
const std::string & | payloadHash = {} |
||
) |
Upload part.
[in] | bucket | bucket name |
[in] | key | key name |
[in] | uid | upload id returned by CreateMultipartUpload |
[in] | partNum | zero-indexed part number |
[in] | data | input buffer |
[in] | size | data size |
[in] | maxRetries | maximum number of retries before aborting upload |
[in] | headers | optional HTTP headers as {header name, value} map |
[in] | payloadHash | optional payload hash, can be empty |