pip_services3_aws.clients.LambdaClient module

class pip_services3_aws.clients.LambdaClient.LambdaClient

Bases: pip_services3_commons.run.IOpenable.IOpenable, pip_services3_commons.config.IConfigurable.IConfigurable, pip_services3_commons.refer.IReferenceable.IReferenceable, abc.ABC

Abstract client that calls AWS Lambda Functions.

When making calls “cmd” parameter determines which what action shall be called, while other parameters are passed to the action itself.

### Configuration parameters ###

  • connections:
    • discovery_key: (optional) a key to retrieve the connection from IDiscovery

    • region: (optional) AWS region

  • credentials:
    • store_key: (optional) a key to retrieve the credentials from ICredentialStore

    • access_id: AWS access/client id

    • access_key: AWS access/client id

  • options:
    • connect_timeout: (optional) connection timeout in milliseconds (default: 10 sec)

### References ###
  • *:logger:*:*:1.0 (optional) ILogger components to pass log messages

  • *:counters:*:*:1.0 (optional) ICounters components to pass collected measurements

  • *:discovery:*:*:1.0 (optional) IDiscovery services to resolve connection

  • *:credential-store:*:*:1.0 (optional) Credential stores to resolve credentials

See CommandableLambdaClient, LambdaFunction

Example:

class MyLambdaClient(LambdaClient, IMyClient):
    ...

    def get_data(self, correlation_id: str, id: str) -> MyData: 
        timing = self._instrument(correlation_id, 'myclient.get_data')
        result = self._call("get_data" correlation_id, { 'id': id })
        timing.end_timing()
        return result

    ...


client = MyLambdaClient()
client.configure(ConfigParams.from_tuples(
    "connection.region", "us-east-1",
    "connection.access_id", "XXXXXXXXXXX",
    "connection.access_key", "XXXXXXXXXXX",
    "connection.arn", "YYYYYYYYYYYYY"
))

result = client.get_data("123", "1")
close(correlation_id: Optional[str])

Closes component and frees used resources.

Parameters

correlation_id – (optional) transaction id to trace execution through call chain.

configure(config: pip_services3_commons.config.ConfigParams.ConfigParams)

Configures component by passing configuration parameters.

Parameters

config – configuration parameters to be set.

is_open() bool

Checks if the component is opened.

Returns

true if the component has been opened and false otherwise.

open(correlation_id: Optional[str])

Opens the component.

Parameters

correlation_id – (optional) transaction id to trace execution through call chain.

set_references(references: pip_services3_commons.refer.IReferences.IReferences)

Sets references to dependent components.

Parameters

references – references to locate the component dependencies.