AwsRequest class

A class to easily send API requests to AWS services.

awsAccessKey, awsSecretKey, and region are mutable so callers can rotate credentials or change region without constructing a new instance. Do not log or expose instances that hold secrets.

Temporary credentials (STS, IAM roles, assumed roles): Supported. Use the temporary access key ID for awsAccessKey and the temporary secret for awsSecretKey (same as long-lived keys). You must also send the session token: add X-Amz-Security-Token to headers and include x-amz-security-token in signedHeaders so it participates in the SigV4 signature. Example: headers: {'X-Amz-Security-Token': sessionToken}, signedHeaders: ['x-amz-security-token'].

Constructors

AwsRequest({required String awsAccessKey, required String awsSecretKey, required String region, String? service, Duration timeout = const Duration(seconds: 10), String? endpoint})

Properties

awsAccessKey String
AWS access key
getter/setter pair
awsSecretKey String
AWS secret key
getter/setter pair
endpoint String?
Optional custom endpoint hostname (e.g., 'mybucket.s3.us-east-1.amazonaws.com'). When null, the standard '{service}.{region}.amazonaws.com' pattern is used.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
region String
The region to send the request to
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
service String?
The aws service you are sending a request to
getter/setter pair
timeout Duration
The timeout on the request
getter/setter pair

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
send({required AwsRequestType type, String? service, List<String> signedHeaders = const [], Map<String, String> headers = defaultHeaders, String jsonBody = '', String queryPath = '/', Map<String, String>? queryString, List<MapEntry<String, String>>? queryStringPairs, bool hashedPayloadIsUnsigned = false, bool useNonS3DoubleEncodedCanonicalPath = false, Duration? timeout, String? endpoint}) Future<Response>
Builds, signs, and sends aws http requests.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

staticSend({required String awsAccessKey, required String awsSecretKey, required String region, required String service, required AwsRequestType type, List<String> signedHeaders = const [], Map<String, String> headers = defaultHeaders, String jsonBody = '', String queryPath = '/', Map<String, String>? queryString, List<MapEntry<String, String>>? queryStringPairs, bool hashedPayloadIsUnsigned = false, bool useNonS3DoubleEncodedCanonicalPath = false, Duration timeout = const Duration(seconds: 10), String? endpoint}) Future<Response>
Statically Builds, signs, and sends aws http requests.