AWSClient
public class AWSClient
This is the workhorse of aws-sdk-swift-core. You provide it with a AWSShape
Input object, it converts it to AWSRequest
which is then converted to a raw HTTPClient
Request. This is then sent to AWS. When the response from AWS is received if it is successful it is converted to a AWSResponse
which is then decoded to generate a AWSShape
Output object. If it is not successful then AWSClient
will throw an AWSErrorType
.
-
Specifies how
See moreEventLoopGroup
will be created and establishes lifecycle ownership.Declaration
Swift
public enum EventLoopGroupProvider
-
eventLoopGroup used by client
Declaration
Swift
public let eventLoopGroup: EventLoopGroup
-
client region
Declaration
Swift
public var region: Region { get }
-
endpoint URL
Declaration
Swift
public var endpoint: String { get }
-
init(accessKeyId:secretAccessKey:sessionToken:region:amzTarget:service:signingName:serviceProtocol:apiVersion:endpoint:serviceEndpoints:partitionEndpoint:middlewares:possibleErrorTypes:eventLoopGroupProvider:)
Initialize an AWSClient struct
Declaration
Swift
public init(accessKeyId: String? = nil, secretAccessKey: String? = nil, sessionToken: String? = nil, region givenRegion: Region?, amzTarget: String? = nil, service: String, signingName: String? = nil, serviceProtocol: ServiceProtocol, apiVersion: String, endpoint: String? = nil, serviceEndpoints: [String : String] = [:], partitionEndpoint: String? = nil, middlewares: [AWSServiceMiddleware] = [], possibleErrorTypes: [AWSErrorType.Type]? = nil, eventLoopGroupProvider: EventLoopGroupProvider)
Parameters
accessKeyId
Public access key provided by AWS
secretAccessKey
Private access key provided by AWS
sessionToken
Token provided by STS.AssumeRole() which allows access to another AWS account
region
Region of server you want to communicate with
amzTarget
“x-amz-target” header value
service
Name of service endpoint
signingName
Name that all AWS requests are signed with
serviceProtocol
protocol of service (.json, .xml, .query etc)
apiVersion
“Version” header value
endpoint
Custom endpoint URL to use instead of standard AWS servers
serviceEndpoints
Dictionary of region to endpoints URLs
partitionEndpoint
Default endpoint to use
middlewares
Array of middlewares to apply to requests and responses
possibleErrorTypes
Array of possible error types that the client can throw
eventLoopGroupProvider
EventLoopGroup to use. Use
useAWSClientShared
if the client shall manage its own EventLoopGroup. -
If an AWS command is returning an arbituary sized array sometimes it adds support for paginating this array ie it will return the array in blocks of a defined size, each block also includes a token which can be used to access the next block. This function loads each block and calls a closure with each block as parameter.
Declaration
Swift
func paginate<Input: AWSPaginateStringToken, Output: AWSShape>( input: Input, command: @escaping (Input)->EventLoopFuture<Output>, tokenKey: KeyPath<Output, String?>, onPage: @escaping (Output, EventLoop)->EventLoopFuture<Bool> ) -> EventLoopFuture<Void>
Parameters
input
Input for request
command
Command to be paginated
resultKey
The keypath to the list of objects to be paginated
tokenKey
The name of token in the response object to continue pagination
onPage
closure called with each block of entries
-
If an AWS command is returning an arbituary sized array sometimes it adds support for paginating this array ie it will return the array in blocks of a defined size, each block also includes a token which can be used to access the next block. This function loads each block and calls a closure with each block as parameter.
This version uses an Int instead of a String for the token
Declaration
Swift
func paginate<Input: AWSPaginateIntToken, Output: AWSShape>( input: Input, command: @escaping (Input)->EventLoopFuture<Output>, tokenKey: KeyPath<Output, Int?>, onPage: @escaping (Output, EventLoop)->EventLoopFuture<Bool> ) -> EventLoopFuture<Void>
Parameters
input
Input for request
command
Command to be paginated
resultKey
The keypath to the list of objects to be paginated
tokenKey
The name of token in the response object to continue pagination
onPage
closure called with each block of entries
-
send a request with an input object and return a future with an empty response
Declaration
Swift
public func send<Input>(operation operationName: String, path: String, httpMethod: String, input: Input) -> EventLoopFuture<Void> where Input : AWSShape
Parameters
operationName
Name of the AWS operation
path
path to append to endpoint URL
httpMethod
HTTP method to use (“GET”, “PUT”, “PUSH” etc)
input
Input object
Return Value
Empty Future that completes when response is received
-
send an empty request and return a future with an empty response
Declaration
Swift
public func send(operation operationName: String, path: String, httpMethod: String) -> EventLoopFuture<Void>
Parameters
operationName
Name of the AWS operation
path
path to append to endpoint URL
httpMethod
HTTP method to use (“GET”, “PUT”, “PUSH” etc)
Return Value
Empty Future that completes when response is received
-
send an empty request and return a future with the output object generated from the response
Declaration
Swift
public func send<Output>(operation operationName: String, path: String, httpMethod: String) -> EventLoopFuture<Output> where Output : AWSShape
Parameters
operationName
Name of the AWS operation
path
path to append to endpoint URL
httpMethod
HTTP method to use (“GET”, “PUT”, “PUSH” etc)
Return Value
Future containing output object that completes when response is received
-
send a request with an input object and return a future with the output object generated from the response
Declaration
Parameters
operationName
Name of the AWS operation
path
path to append to endpoint URL
httpMethod
HTTP method to use (“GET”, “PUT”, “PUSH” etc)
input
Input object
Return Value
Future containing output object that completes when response is received
-
generate a signed URL
Declaration
Swift
public func signURL(url: URL, httpMethod: String, expires: Int = 86400) -> URL
Parameters
url
URL to sign
httpMethod
HTTP method to use (“GET”, “PUT”, “PUSH” etc)
expires
How long before the signed URL expires
Return Value
A signed URL