Example usage for com.amazonaws.services.lambda.model ListFunctionsRequest setMarker

List of usage examples for com.amazonaws.services.lambda.model ListFunctionsRequest setMarker

Introduction

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

Prototype


public void setMarker(String marker) 

Source Link

Document

Specify the pagination token that's returned by a previous request to retrieve the next page of results.

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;/*from w w  w .  j a  v  a2 s .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));
}