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 moreEventLoopGroupwill 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
accessKeyIdPublic access key provided by AWS
secretAccessKeyPrivate access key provided by AWS
sessionTokenToken provided by STS.AssumeRole() which allows access to another AWS account
regionRegion of server you want to communicate with
amzTarget“x-amz-target” header value
serviceName of service endpoint
signingNameName that all AWS requests are signed with
serviceProtocolprotocol of service (.json, .xml, .query etc)
apiVersion“Version” header value
endpointCustom endpoint URL to use instead of standard AWS servers
serviceEndpointsDictionary of region to endpoints URLs
partitionEndpointDefault endpoint to use
middlewaresArray of middlewares to apply to requests and responses
possibleErrorTypesArray of possible error types that the client can throw
eventLoopGroupProviderEventLoopGroup to use. Use
useAWSClientSharedif 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
inputInput for request
commandCommand to be paginated
resultKeyThe keypath to the list of objects to be paginated
tokenKeyThe name of token in the response object to continue pagination
onPageclosure 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
inputInput for request
commandCommand to be paginated
resultKeyThe keypath to the list of objects to be paginated
tokenKeyThe name of token in the response object to continue pagination
onPageclosure 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 : AWSShapeParameters
operationNameName of the AWS operation
pathpath to append to endpoint URL
httpMethodHTTP method to use (“GET”, “PUT”, “PUSH” etc)
inputInput 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
operationNameName of the AWS operation
pathpath to append to endpoint URL
httpMethodHTTP 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 : AWSShapeParameters
operationNameName of the AWS operation
pathpath to append to endpoint URL
httpMethodHTTP 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
operationNameName of the AWS operation
pathpath to append to endpoint URL
httpMethodHTTP method to use (“GET”, “PUT”, “PUSH” etc)
inputInput 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) -> URLParameters
urlURL to sign
httpMethodHTTP method to use (“GET”, “PUT”, “PUSH” etc)
expiresHow long before the signed URL expires
Return Value
A signed URL
View on GitHub
AWSClient Class Reference