List of usage examples for com.amazonaws.services.lambda.model UpdateFunctionCodeRequest withZipFile
public UpdateFunctionCodeRequest withZipFile(java.nio.ByteBuffer zipFile)
The base64-encoded contents of the deployment package.
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();// w w w. ja v a2 s .c om 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"); }/*from ww w . j a v a 2s . 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();//from w w w. j a va 2s . 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"); }//from ww w .j av a 2s . 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()); }