Example usage for com.amazonaws.services.lambda.model FunctionConfiguration getFunctionName

List of usage examples for com.amazonaws.services.lambda.model FunctionConfiguration getFunctionName

Introduction

In this page you can find the example usage for com.amazonaws.services.lambda.model FunctionConfiguration getFunctionName.

Prototype


public String getFunctionName() 

Source Link

Document

The name of the function.

Usage

From source file:com.netflix.spinnaker.clouddriver.lambda.provider.agent.LambdaCachingAgent.java

License:Apache License

@Override
public CacheResult loadData(ProviderCache providerCache) {
    log.info("Describing items in {}", getAgentType());

    AWSLambda lambda = amazonClientProvider.getAmazonLambda(account, region);
    String nextMarker = null;//w  w  w.ja v a 2s. c  om
    List<FunctionConfiguration> lstFunction = new ArrayList<FunctionConfiguration>();

    do {
        ListFunctionsRequest listFunctionsRequest = new ListFunctionsRequest();
        if (nextMarker != null) {
            listFunctionsRequest.setMarker(nextMarker);
        }

        ListFunctionsResult listFunctionsResult = lambda.listFunctions(listFunctionsRequest);
        lstFunction.addAll(listFunctionsResult.getFunctions());
        nextMarker = listFunctionsResult.getNextMarker();

    } while (nextMarker != null && nextMarker.length() != 0);

    Collection<CacheData> data = new LinkedList<>();
    for (FunctionConfiguration x : lstFunction) {
        Map<String, Object> attributes = objectMapper.convertValue(x, ATTRIBUTES);
        attributes.put("account", account.getName());
        attributes.put("region", region);

        attributes.put("revisions", listFunctionRevisions(x.getFunctionArn()));
        attributes.put("aliasConfiguration", listAliasConfiguration(x.getFunctionArn()));
        attributes.put("eventSourceMappings", listEventSourceMappingConfiguration(x.getFunctionArn()));

        data.add(new DefaultCacheData(Keys.getLambdaFunctionKey(account.getName(), region, x.getFunctionName()),
                attributes, Collections.emptyMap()));
    }

    log.info("Caching {} items in {}", String.valueOf(data.size()), getAgentType());
    return new DefaultCacheResult(Collections.singletonMap(LAMBDA_FUNCTIONS.ns, data));
}

From source file:jp.classmethod.aws.gradle.lambda.AWSLambdaMigrateFunctionTask.java

License:Apache License

private void updateFunctionConfiguration(AWSLambda lambda, FunctionConfiguration config) {
    String updateFunctionName = getFunctionName();
    if (updateFunctionName == null) {
        updateFunctionName = config.getFunctionName();
    }/*from ww  w.  java2  s. c o m*/

    String updateRole = getRole();
    if (updateRole == null) {
        updateRole = config.getRole();
    }

    Runtime updateRuntime = getRuntime();
    if (updateRuntime == null) {
        updateRuntime = Runtime.fromValue(config.getRuntime());
    }

    String updateHandler = getHandler();
    if (updateHandler == null) {
        updateHandler = config.getHandler();
    }

    String updateDescription = getFunctionDescription();
    if (updateDescription == null) {
        updateDescription = config.getDescription();
    }

    Integer updateTimeout = getTimeout();
    if (updateTimeout == null) {
        updateTimeout = config.getTimeout();
    }

    Integer updateMemorySize = getMemorySize();
    if (updateMemorySize == null) {
        updateMemorySize = config.getMemorySize();
    }

    UpdateFunctionConfigurationRequest request = new UpdateFunctionConfigurationRequest()
            .withFunctionName(updateFunctionName).withRole(updateRole).withRuntime(updateRuntime)
            .withHandler(updateHandler).withDescription(updateDescription).withTimeout(updateTimeout)
            .withVpcConfig(getVpcConfig()).withEnvironment(new Environment().withVariables(getEnvironment()))
            .withMemorySize(updateMemorySize);

    UpdateFunctionConfigurationResult updateFunctionConfiguration = lambda.updateFunctionConfiguration(request);
    getLogger().info("Update Lambda function configuration requested: {}",
            updateFunctionConfiguration.getFunctionArn());
}