AWSLambdaInvoker Class Reference

Inherits from AWSService : NSObject
Declared in AWSLambdaInvoker.h
AWSLambdaInvoker.m

+ defaultLambdaInvoker

Returns a shared instance of this service client using [AWSServiceManager defaultServiceManager].defaultServiceConfiguration. When defaultServiceConfiguration is not set, this method returns nil.

+ (instancetype)defaultLambdaInvoker

Return Value

A shared instance of this service client.

Discussion

For example, set the default service configuration in - application:didFinishLaunchingWithOptions:

Swift

 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
     let credentialProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: "YourIdentityPoolId")
     let configuration = AWSServiceConfiguration(region: .USEast1, credentialsProvider: credentialProvider)
     AWSServiceManager.default().defaultServiceConfiguration = configuration

     return true
 }

Objective-C

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
      AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1
                                                                                                      identityPoolId:@"YourIdentityPoolId"];
      AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1
                                                                           credentialsProvider:credentialsProvider];
      [AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration;

      return YES;
  }

Then call the following to get the default service client:

Swift

 let LambdaInvoker = AWSLambdaInvoker.default()

Objective-C

 AWSLambdaInvoker *LambdaInvoker = [AWSLambdaInvoker defaultLambdaInvoker];

Declared In

AWSLambdaInvoker.h

+ registerLambdaInvokerWithConfiguration:forKey:

Creates a service client with the given service configuration and registers it for the key.

+ (void)registerLambdaInvokerWithConfiguration:(AWSServiceConfiguration *)configuration forKey:(NSString *)key

Parameters

configuration

A service configuration object.

key

A string to identify the service client.

Discussion

For example, set the default service configuration in - application:didFinishLaunchingWithOptions:

Swift

 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
     let credentialProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: "YourIdentityPoolId")
     let configuration = AWSServiceConfiguration(region: .USWest2, credentialsProvider: credentialProvider)
     AWSLambdaInvoker.register(with: configuration!, forKey: "USWest2LambdaInvoker")

     return true
 }

Objective-C

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
     AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1
                                                                                                     identityPoolId:@"YourIdentityPoolId"];
     AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSWest2
                                                                          credentialsProvider:credentialsProvider];

     [AWSLambdaInvoker registerLambdaInvokerWithConfiguration:configuration forKey:@"USWest2LambdaInvoker"];

     return YES;
 }

Then call the following to get the service client:

Swift

 let LambdaInvoker = AWSLambdaInvoker(forKey: "USWest2LambdaInvoker")

Objective-C

 AWSLambdaInvoker *LambdaInvoker = [AWSLambdaInvoker LambdaInvokerForKey:@"USWest2LambdaInvoker"];

Warning: After calling this method, do not modify the configuration object. It may cause unspecified behaviors.

Declared In

AWSLambdaInvoker.h

+ LambdaInvokerForKey:

Retrieves the service client associated with the key. You need to call + registerKinesisWithConfiguration:forKey: before invoking this method.

+ (instancetype)LambdaInvokerForKey:(NSString *)key

Parameters

key

A string to identify the service client.

Return Value

An instance of the service client.

Discussion

For example, set the default service configuration in - application:didFinishLaunchingWithOptions:

Swift

 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
     let credentialProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: "YourIdentityPoolId")
     let configuration = AWSServiceConfiguration(region: .USWest2, credentialsProvider: credentialProvider)
     AWSLambdaInvoker.register(with: configuration!, forKey: "USWest2LambdaInvoker")

     return true
 }

Objective-C

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
     AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1
                                                                                                     identityPoolId:@"YourIdentityPoolId"];
     AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSWest2
                                                                          credentialsProvider:credentialsProvider];

     [AWSLambdaInvoker registerLambdaInvokerWithConfiguration:configuration forKey:@"USWest2LambdaInvoker"];

     return YES;
 }

Then call the following to get the service client:

Swift

 let LambdaInvoker = AWSLambdaInvoker(forKey: "USWest2LambdaInvoker")

Objective-C

 AWSLambdaInvoker *LambdaInvoker = [AWSLambdaInvoker LambdaInvokerForKey:@"USWest2LambdaInvoker"];

Declared In

AWSLambdaInvoker.h

+ removeLambdaInvokerForKey:

Removes the service client associated with the key and release it.

+ (void)removeLambdaInvokerForKey:(NSString *)key

Parameters

key

A string to identify the service client.

Discussion

Warning: Before calling this method, make sure no method is running on this client.

Declared In

AWSLambdaInvoker.h

– invoke:

Invokes an AWS Lambda function with a given request object.

- (AWSTask<AWSLambdaInvokerInvocationResponse*> *)invoke:(AWSLambdaInvokerInvocationRequest *)request

Parameters

request

The request object.

Return Value

An instance of AWSTask. On successful execution, task.result will contain an instance of AWSLambdaInvokerInvocationResponse. On failed service execution, task.error may contain an NSError with AWSLambdaErrorDomain domain and the following error code: AWSLambdaErrorService, AWSLambdaErrorResourceNotFound, AWSLambdaErrorInvalidParameterValue. On failed function execution, task.error may contain an NSError with AWSLambdaInvokerErrorDomain domain and the following error code: AWSLambdaInvokerErrorTypeFunctionError.

Declared In

AWSLambdaInvoker.h

– invoke:completionHandler:

Invokes an AWS Lambda function with a given request object.

- (void)invoke:(AWSLambdaInvokerInvocationRequest *)request completionHandler:(void ( ^ _Nullable ) ( AWSLambdaInvokerInvocationResponse *_Nullable response , NSError *_Nullable error ))completionHandler

Parameters

request

The request object.

completionHandler

The completion handler to call when the invoke request is complete. response - An AWSLambdaInvokerInvocationResponse object, or nil if the request failed. error - An error object that indicates why the request failed, or nil if the request was successful. On failed service execution, task.error may contain an NSError with AWSLambdaErrorDomain domain and the following error code: AWSLambdaErrorService, AWSLambdaErrorResourceNotFound, AWSLambdaErrorInvalidParameterValue. On failed function execution, task.error may contain an NSError with AWSLambdaInvokerErrorDomain domain and the following error code: AWSLambdaInvokerErrorTypeFunctionError.

Declared In

AWSLambdaInvoker.h

– invokeFunction:JSONObject:

Invokes a synchronous AWS Lambda function with given parameters.

- (AWSTask *)invokeFunction:(NSString *)functionName JSONObject:(nullable id)JSONObject

Parameters

functionName

The name of a function.

JSONObject

The object from which to generate JSON request data. Can be nil.

Return Value

An instance of AWSTask. On successful execution, task.result will contain a JSON object. On failed service execution, task.error may contain an NSError with AWSLambdaErrorDomain domain and the following error code: AWSLambdaErrorService, AWSLambdaErrorResourceNotFound, AWSLambdaErrorInvalidParameterValue. On failed function execution, task.error may contain an NSError with AWSLambdaInvokerErrorDomain domain and the following error code: AWSLambdaInvokerErrorTypeFunctionError.

Declared In

AWSLambdaInvoker.h

– invokeFunction:JSONObject:completionHandler:

Invokes a synchronous AWS Lambda function with given parameters.

- (void)invokeFunction:(NSString *)functionName JSONObject:(nullable id)JSONObject completionHandler:(void ( ^ _Nullable ) ( id _Nullable response , NSError *_Nullable error ))completionHandler

Parameters

functionName

The name of a function.

JSONObject

The object from which to generate JSON request data. Can be nil.

completionHandler

The completion handler to call when the invoke request is complete. response - A JSON object., or nil if the request failed. error - An error object that indicates why the request failed, or nil if the request was successful. On failed service execution, task.error may contain an NSError with AWSLambdaErrorDomain domain and the following error code: AWSLambdaErrorService, AWSLambdaErrorResourceNotFound, AWSLambdaErrorInvalidParameterValue. On failed function execution, task.error may contain an NSError with AWSLambdaInvokerErrorDomain domain and the following error code: AWSLambdaInvokerErrorTypeFunctionError.

Declared In

AWSLambdaInvoker.h