AWSLambdaInvoker

Objective-C

@interface AWSLambdaInvoker : AWSService

@property (nonatomic, strong, readonly) AWSClientContext *clientContext;

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

 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];

 @return A shared instance of this service client.
 */
+ (instancetype)defaultLambdaInvoker;

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

 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.

 @param configuration A service configuration object.
 @param key           A string to identify the service client.
 */
+ (void)registerLambdaInvokerWithConfiguration:(AWSServiceConfiguration *)configuration forKey:(NSString *)key;

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

 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"];

 @param key A string to identify the service client.

 @return An instance of the service client.
 */
+ (instancetype)LambdaInvokerForKey:(NSString *)key;

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

 @warning Before calling this method, make sure no method is running on this client.

 @param key A string to identify the service client.
 */
+ (void)removeLambdaInvokerForKey:(NSString *)key;

/**
 Invokes an AWS Lambda function with a given request object.

 @param request The request object.

 @return 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`.

 @see AWSLambdaInvokerInvocationRequest
 @see AWSLambdaInvokerInvocationResponse
 */
- (AWSTask<AWSLambdaInvokerInvocationResponse *> *)invoke:(AWSLambdaInvokerInvocationRequest *)request;

/**
 Invokes an AWS Lambda function with a given request object.

 @param request           The request object.
 @param 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`.

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

/**
 Invokes a synchronous AWS Lambda function with given parameters.

 @param functionName The name of a function.
 @param JSONObject   The object from which to generate JSON request data. Can be `nil`.

 @return 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`.
 */
- (AWSTask *)invokeFunction:(NSString *)functionName
                 JSONObject:(nullable id)JSONObject;

/**
 Invokes a synchronous AWS Lambda function with given parameters.

 @param functionName      The name of a function.
 @param JSONObject        The object from which to generate JSON request data. Can be `nil`.
 @param 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`.
 */
- (void)invokeFunction:(NSString *)functionName
            JSONObject:(nullable id)JSONObject
     completionHandler:(void (^ _Nullable)(id _Nullable response, NSError * _Nullable error))completionHandler;

@end

Swift

class AWSLambdaInvoker

Undocumented

  • Undocumented

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly) AWSClientContext *clientContext

    Swift

    var clientContext: AWSClientContext { get }
  • Returns a shared instance of this service client using [AWSServiceManager defaultServiceManager].defaultServiceConfiguration. When defaultServiceConfiguration is not set, this method returns nil.

    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];
    

    Declaration

    Objective-C

    + (nonnull instancetype)defaultLambdaInvoker;

    Swift

    class func `default`() -> Self

    Return Value

    A shared instance of this service client.

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

    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.

    Declaration

    Objective-C

    + (void)registerLambdaInvokerWithConfiguration:(id)configuration
                                            forKey:(nonnull NSString *)key;

    Swift

    class func register(withConfiguration configuration: Any!, forKey key: String)

    Parameters

    configuration

    A service configuration object.

    key

    A string to identify the service client.

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

    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"];
    

    Declaration

    Objective-C

    + (nonnull instancetype)LambdaInvokerForKey:(nonnull NSString *)key;

    Swift

    convenience init(forKey key: String)

    Parameters

    key

    A string to identify the service client.

    Return Value

    An instance of the service client.

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

    Warning

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

    Declaration

    Objective-C

    + (void)removeLambdaInvokerForKey:(nonnull NSString *)key;

    Swift

    class func remove(forKey key: String)

    Parameters

    key

    A string to identify the service client.

  • Invokes an AWS Lambda function with a given request object.

    See

    AWSLambdaInvokerInvocationRequest

    See

    AWSLambdaInvokerInvocationResponse

    Declaration

    Objective-C

    - (id)invoke:(nonnull AWSLambdaInvokerInvocationRequest *)request;

    Swift

    func invoke(_ request: AWSLambdaInvokerInvocationRequest) -> Any!

    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.

  • Invokes an AWS Lambda function with a given request object.

    See

    AWSLambdaInvokerInvocationRequest

    See

    AWSLambdaInvokerInvocationResponse

    Declaration

    Objective-C

    - (void)invoke:(nonnull AWSLambdaInvokerInvocationRequest *)request
        completionHandler:
            (void (^_Nullable)(AWSLambdaInvokerInvocationResponse *_Nullable,
                               NSError *_Nullable))completionHandler;

    Swift

    func invoke(_ request: AWSLambdaInvokerInvocationRequest) async throws -> AWSLambdaInvokerInvocationResponse

    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.

  • Invokes a synchronous AWS Lambda function with given parameters.

    Declaration

    Objective-C

    - (id)invokeFunction:(nonnull NSString *)functionName
              JSONObject:(nullable id)JSONObject;

    Swift

    func invokeFunction(_ functionName: String, jsonObject JSONObject: Any?) -> Any!

    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.

  • Invokes a synchronous AWS Lambda function with given parameters.

    Declaration

    Objective-C

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

    Swift

    func invokeFunction(_ functionName: String, jsonObject JSONObject: Any?) async throws -> Any

    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.