Example usage for com.amazonaws.services.lambda.model UpdateFunctionCodeResult getFunctionArn

List of usage examples for com.amazonaws.services.lambda.model UpdateFunctionCodeResult getFunctionArn

Introduction

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

Prototype


public String getFunctionArn() 

Source Link

Document

The function's Amazon Resource Name (ARN).

Usage

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

License:Apache License

private void updateFunctionCode(AWSLambda lambda) throws IOException {
    // to enable conventionMappings feature
    File zipFile = getZipFile();//from  w  ww .  jav a 2  s. co  m
    S3File s3File = getS3File();

    UpdateFunctionCodeRequest request = new UpdateFunctionCodeRequest().withFunctionName(getFunctionName());
    if (zipFile != null) {
        try (RandomAccessFile raf = new RandomAccessFile(getZipFile(), "r");
                FileChannel channel = raf.getChannel()) {
            MappedByteBuffer buffer = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
            buffer.load();
            request = request.withZipFile(buffer);
        }
    } else {
        // assume s3File is not null
        request = request.withS3Bucket(s3File.getBucketName()).withS3Key(s3File.getKey())
                .withS3ObjectVersion(s3File.getObjectVersion());
    }
    UpdateFunctionCodeResult updateFunctionCode = lambda.updateFunctionCode(request);
    getLogger().info("Update Lambda function requested: {}", updateFunctionCode.getFunctionArn());
}

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

License:Apache License

@TaskAction
public void updateFunctionCode() throws FileNotFoundException, IOException {
    // to enable conventionMappings feature
    String functionName = getFunctionName();

    if (functionName == null) {
        throw new GradleException("functionName is required");
    }/*ww  w . jav a 2  s  . c om*/

    if ((zipFile == null && s3File == null) || (zipFile != null && s3File != null)) {
        throw new GradleException("exactly one of zipFile or s3File is required");
    }

    AWSLambdaPluginExtension ext = getProject().getExtensions().getByType(AWSLambdaPluginExtension.class);
    AWSLambda lambda = ext.getClient();

    UpdateFunctionCodeRequest request = new UpdateFunctionCodeRequest().withFunctionName(getFunctionName());
    if (zipFile != null) {
        try (RandomAccessFile raf = new RandomAccessFile(getZipFile(), "r");
                FileChannel channel = raf.getChannel()) {
            MappedByteBuffer buffer = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
            buffer.load();
            request = request.withZipFile(buffer);
        }
    } else {
        // assume s3File is not null
        s3File.validate();
        request = request.withS3Bucket(s3File.getBucketName()).withS3Key(s3File.getKey())
                .withS3ObjectVersion(s3File.getObjectVersion());
    }
    UpdateFunctionCodeResult updateFunctionCode = lambda.updateFunctionCode(request);
    getLogger().info("Update Lambda function requested: {}", updateFunctionCode.getFunctionArn());
}

From source file:org.xmlsh.aws.gradle.lambda.AWSLambdaMigrateFunctionTask.java

License:BSD License

private void updateFunctionCode(AWSLambda lambda) throws IOException {
    UpdateFunctionCodeRequest request = new UpdateFunctionCodeRequest().withFunctionName(getFunctionName());
    if (zipFile != null) {
        try (RandomAccessFile raf = new RandomAccessFile(getZipFile(), "r");
                FileChannel channel = raf.getChannel()) {
            MappedByteBuffer buffer = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
            buffer.load();/* ww  w .ja  v  a 2  s. c  o m*/
            request = request.withZipFile(buffer);
        }
    } else {
        // assume s3File is not null
        request = request.withS3Bucket(s3File.getBucketName()).withS3Key(s3File.getKey())
                .withS3ObjectVersion(s3File.getObjectVersion());
    }
    UpdateFunctionCodeResult updateFunctionCode = lambda.updateFunctionCode(request);
    getLogger().info("Update Lambda function requested: {}", updateFunctionCode.getFunctionArn());
}

From source file:org.xmlsh.aws.gradle.lambda.AWSLambdaUpdateFunctionCodeTask.java

License:BSD License

@TaskAction
public void updateFunctionCode() throws FileNotFoundException, IOException {
    // to enable conventionMappings feature
    String functionName = getFunctionName();

    if (functionName == null)
        throw new GradleException("functionName is required");

    if ((zipFile == null && s3File == null) || (zipFile != null && s3File != null)) {
        throw new GradleException("exactly one of zipFile or s3File is required");
    }//  w  ww .j a v a2s  . com

    AWSLambdaPluginExtension ext = getProject().getExtensions().getByType(AWSLambdaPluginExtension.class);
    AWSLambda lambda = ext.getClient();

    UpdateFunctionCodeRequest request = new UpdateFunctionCodeRequest().withFunctionName(getFunctionName());
    if (zipFile != null) {
        try (RandomAccessFile raf = new RandomAccessFile(getZipFile(), "r");
                FileChannel channel = raf.getChannel()) {
            MappedByteBuffer buffer = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
            buffer.load();
            request = request.withZipFile(buffer);
        }
    } else {
        // assume s3File is not null
        s3File.validate();
        request = request.withS3Bucket(s3File.getBucketName()).withS3Key(s3File.getKey())
                .withS3ObjectVersion(s3File.getObjectVersion());
    }
    UpdateFunctionCodeResult updateFunctionCode = lambda.updateFunctionCode(request);
    getLogger().info("Update Lambda function requested: {}", updateFunctionCode.getFunctionArn());
}