Example usage for com.amazonaws.services.lambda.model AliasRoutingConfiguration withAdditionalVersionWeights

List of usage examples for com.amazonaws.services.lambda.model AliasRoutingConfiguration withAdditionalVersionWeights

Introduction

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

Prototype


public AliasRoutingConfiguration withAdditionalVersionWeights(
        java.util.Map<String, Double> additionalVersionWeights) 

Source Link

Document

The name of the second alias, and the percentage of traffic that's routed to it.

Usage

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

License:Apache License

public AliasRoutingConfiguration getAliasRoutingConfiguration(final String functionName,
        final String functionVersion) {

    validateRequiredProperties();//w  w  w  . j  av a  2 s  . c  om

    final Double additionalVersionWeight = getAdditionalVersionWeight();

    final AliasRoutingConfiguration aliasRoutingConfiguration = new AliasRoutingConfiguration();

    if (getAdditionalVersion() != null) {
        validateFunctionVersion(getAdditionalVersion());

        aliasRoutingConfiguration.withAdditionalVersionWeights(
                Collections.singletonMap(getAdditionalVersion(), additionalVersionWeight));
    } else if (getUsePreviousVersion() != null && getUsePreviousVersion()) {

        validateFunctionVersion(functionVersion);

        final Long functionVersionAsLong = Long.valueOf(functionVersion);
        final Long prevVersion = getPreviousVersion(functionName, functionVersionAsLong);
        aliasRoutingConfiguration.withAdditionalVersionWeights(
                Collections.singletonMap(prevVersion.toString(), additionalVersionWeight));

    } else if (getUseNextVersion() != null && getUseNextVersion()) {
        validateFunctionVersion(functionVersion);
        final Long functionVersionAsLong = Long.valueOf(functionVersion);
        final Long nextVersion = getNextVersion(functionVersionAsLong);
        aliasRoutingConfiguration.withAdditionalVersionWeights(
                Collections.singletonMap(nextVersion.toString(), additionalVersionWeight));

    }
    return aliasRoutingConfiguration;
}