Java 类com.amazonaws.services.lambda.model.UpdateFunctionCodeRequest 实例源码

项目:aws-maven-plugin    文件:LambdaDeployer.java   
void deploy(AwsKeyPair keyPair, String region, String zipFilename, String functionName, Proxy proxy) {
    long t = System.currentTimeMillis();
    final AWSCredentialsProvider credentials = new AWSStaticCredentialsProvider(
            new BasicAWSCredentials(keyPair.key, keyPair.secret));

    AWSLambda lambda = AWSLambdaClientBuilder.standard().withCredentials(credentials)
            .withClientConfiguration(Util.createConfiguration(proxy)).withRegion(region).build();

    byte[] bytes;
    try {
        bytes = IOUtils.toByteArray(new FileInputStream(zipFilename));
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    DecimalFormat df = new DecimalFormat("0.000");
    log.info("deploying " + zipFilename + ", length=" + df.format(bytes.length / 1024.0 / 1024.0)
            + "MB, to functionName=" + functionName);
    lambda.updateFunctionCode( //
            new UpdateFunctionCodeRequest() //
                    .withFunctionName(functionName) //
                    .withPublish(true) //
                    .withZipFile(ByteBuffer.wrap(bytes)));
    log.info("deployed in " + (System.currentTimeMillis() - t) + "ms");
}
项目:aws-lambda-jenkins-plugin    文件:LambdaDeployServiceTest.java   
private void calledUpdateCode(Boolean called){
    if(called){
        ArgumentCaptor<UpdateFunctionCodeRequest> args = ArgumentCaptor.forClass(UpdateFunctionCodeRequest.class);
        verify(awsLambdaClient, times(1)).updateFunctionCode(args.capture());
        UpdateFunctionCodeRequest expected = null;
        try {
            expected = new UpdateFunctionCodeRequest()
                    .withFunctionName(functionName)
                    .withPublish(publish)
                    .withZipFile(ByteBuffer.wrap(FileUtils.readFileToByteArray(getZipFile())));
        } catch (IOException e) {
            fail("Couldn't process echo.zip");
        }
        assertEquals(expected, args.getValue());

    } else {
        verify(awsLambdaClient, never()).updateFunctionCode(any(UpdateFunctionCodeRequest.class));
    }
}
项目:aws-lambda-deploy    文件:AWSLambdaDeployer.java   
private String updateLambdaCode(AWSLambdaClient lambdaClient,
        String functionName) {
    UpdateFunctionCodeRequest request = new UpdateFunctionCodeRequest();
    request.setFunctionName(functionName);
    request.setPublish(true);
    request.setS3Bucket(codeS3Bucket);
    request.setS3Key(artifactName);
    request.setS3ObjectVersion(codeS3Version);

    UpdateFunctionCodeResult result = lambdaClient
            .updateFunctionCode(request);

    return result.getFunctionArn();
}
项目:aws-lambda-jenkins-plugin    文件:LambdaDeployServiceTest.java   
@Before
public void setUp() throws Exception {
    description = "description";
    functionName = "function";
    handler = "function.handler";
    memory = 1024;
    role = "role";
    runtime = "nodejs";
    publish = Boolean.FALSE;
    functionVersion = null;
    createAlias = Boolean.FALSE;
    alias = null;
    timeout = 30;
    subnets = new ArrayList<>();
    securityGroups = new ArrayList<>();
    kmsArn = "arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012";
    environment = new HashMap<>();
    environment.put("key", "value");
    deadLetterQueueArn = "arn:aws:sqs:us-east-1:123456789012:queueName";
    lambdaDeployService = new LambdaDeployService(awsLambdaClient, jenkinsLogger);
    when(awsLambdaClient.updateFunctionConfiguration(any(UpdateFunctionConfigurationRequest.class)))
            .thenReturn(new UpdateFunctionConfigurationResult());
    when(awsLambdaClient.updateFunctionCode(any(UpdateFunctionCodeRequest.class)))
            .thenReturn(new UpdateFunctionCodeResult());
    when(awsLambdaClient.createFunction(any(CreateFunctionRequest.class)))
            .thenReturn(new CreateFunctionResult());
}
项目:aws-lambda-jenkins-plugin    文件:LambdaDeployServiceTest.java   
private void setPublishVersion(String version){
    this.functionVersion = version;
    this.publish = true;
    CreateFunctionResult createFunctionResult = new CreateFunctionResult()
            .withVersion(version);
    when(awsLambdaClient.createFunction(any(CreateFunctionRequest.class)))
            .thenReturn(createFunctionResult);
    UpdateFunctionCodeResult updateFunctionCodeResult = new UpdateFunctionCodeResult()
            .withVersion(version);
    when(awsLambdaClient.updateFunctionCode(any(UpdateFunctionCodeRequest.class)))
            .thenReturn(updateFunctionCodeResult);
}
项目:java-translatebot    文件:OauthHandlerDeployer.java   
public void updateFunction() {

        final UpdateFunctionCodeRequest ufrq = new UpdateFunctionCodeRequest().withFunctionName(FunctionName)
                .withZipFile(loadJar());

        this.awsLambdaClient.updateFunctionCode(ufrq);

    }
项目:java-translatebot    文件:EventHandlerDeployer.java   
public void updateFunction() {

        final UpdateFunctionCodeRequest ufrq = new UpdateFunctionCodeRequest().withFunctionName(FunctionName)
                .withZipFile(loadJar());

        this.awsLambdaClient.updateFunctionCode(ufrq);

    }
项目:java-translatebot    文件:CommandHandlerDeployer.java   
public void updateFunction() {

        final UpdateFunctionCodeRequest ufrq = new UpdateFunctionCodeRequest().withFunctionName(FunctionName)
                .withZipFile(loadJar());

        this.awsLambdaClient.updateFunctionCode(ufrq);

    }