com.amazonaws.services.lambda.runtime.ClientContext Java Examples

The following examples show how to use com.amazonaws.services.lambda.runtime.ClientContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClientContextTest.java    From quarkus with Apache License 2.0 6 votes vote down vote up
@Test
public void testContextMarshalling() throws Exception {
    ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
            .configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);

    ObjectReader reader = mapper.readerFor(ClientContextImpl.class);

    ClientContext clientContext = reader.readValue(ctx);
    Assertions.assertNotNull(clientContext.getClient());
    Assertions.assertNotNull(clientContext.getCustom());
    Assertions.assertNotNull(clientContext.getEnvironment());

    Assertions.assertEquals("<client_id>", clientContext.getClient().getInstallationId());
    Assertions.assertEquals("<app_title>", clientContext.getClient().getAppTitle());
    Assertions.assertEquals("<app_version_name>", clientContext.getClient().getAppVersionName());
    Assertions.assertEquals("<app_version_code>", clientContext.getClient().getAppVersionCode());
    Assertions.assertEquals("<app_package_name>", clientContext.getClient().getAppPackageName());

    Assertions.assertEquals("world", clientContext.getCustom().get("hello"));
    Assertions.assertEquals("<platform>", clientContext.getEnvironment().get("platform"));

}
 
Example #2
Source File: LambdaContext.java    From bender with Apache License 2.0 5 votes vote down vote up
public LambdaContext(Context ctx) {
  this.ctx = ctx;

  if (ctx == null) {
    return;
  }

  this.ctxMap.put("functionVersion", ctx.getFunctionVersion());
  this.ctxMap.put("functionName", ctx.getFunctionName());
  this.ctxMap.put("awsRequestId", ctx.getAwsRequestId());
  this.ctxMap.put("invokedFunctionArn", ctx.getInvokedFunctionArn());
  this.ctxMap.put("logGroupName", ctx.getLogGroupName());
  this.ctxMap.put("logStreamName", ctx.getLogStreamName());

  ClientContext cc = ctx.getClientContext();
  if (cc != null) {
    this.ctxMap.put("clientContextCustom", cc.getCustom().toString());
    this.ctxMap.put("clientContextEnvironment", cc.getEnvironment().toString());

    Client c = cc.getClient();
    if (c != null) {
      this.ctxMap.put("clientContextClientInstallationId", c.getInstallationId());
      this.ctxMap.put("clientContextClientAppPackageName", c.getAppPackageName());
      this.ctxMap.put("clientContextClientAppTitle", c.getAppTitle());
      this.ctxMap.put("clientContextClientAppVersionCode", c.getAppVersionCode());
      this.ctxMap.put("clientContextClientAppVersionName", c.getAppVersionName());
    }
  }

  this.ctxMap.values().removeIf(Objects::isNull);
}
 
Example #3
Source File: MockContext.java    From djl-demo with Apache License 2.0 4 votes vote down vote up
@Override
public ClientContext getClientContext() {
    return null;
}
 
Example #4
Source File: RuntimeContext.java    From micronaut-aws with Apache License 2.0 4 votes vote down vote up
@Override
public ClientContext getClientContext() {
    // TODO Use LambdaRuntimeInvocationResponseHeaders.LAMBDA_RUNTIME_CLIENT_CONTEXT to build this
    return null;
}
 
Example #5
Source File: StubContext.java    From jenkinsfile-runner-lambda with Apache License 2.0 4 votes vote down vote up
public ClientContext getClientContext() {
    // TODO Auto-generated method stub
    return null;
}
 
Example #6
Source File: SimulatedContext.java    From xyz-hub with Apache License 2.0 4 votes vote down vote up
@Override
public ClientContext getClientContext() {
  return null;
}
 
Example #7
Source File: NeptuneExportSvc.java    From amazon-neptune-tools with Apache License 2.0 4 votes vote down vote up
@Override
public void run() {
    InputStream input = new ByteArrayInputStream(json.getBytes(StandardCharsets.UTF_8));

    try {
        new NeptuneExportLambda().handleRequest(input, System.out, new Context() {
            @Override
            public String getAwsRequestId() {
                throw new NotImplementedException();
            }

            @Override
            public String getLogGroupName() {
                throw new NotImplementedException();
            }

            @Override
            public String getLogStreamName() {
                throw new NotImplementedException();
            }

            @Override
            public String getFunctionName() {
                throw new NotImplementedException();
            }

            @Override
            public String getFunctionVersion() {
                throw new NotImplementedException();
            }

            @Override
            public String getInvokedFunctionArn() {
                throw new NotImplementedException();
            }

            @Override
            public CognitoIdentity getIdentity() {
                throw new NotImplementedException();
            }

            @Override
            public ClientContext getClientContext() {
                throw new NotImplementedException();
            }

            @Override
            public int getRemainingTimeInMillis() {
                throw new NotImplementedException();
            }

            @Override
            public int getMemoryLimitInMB() {
                throw new NotImplementedException();
            }

            @Override
            public LambdaLogger getLogger() {
                return new LambdaLogger() {
                    @Override
                    public void log(String s) {
                        System.out.println(s);
                    }

                    @Override
                    public void log(byte[] bytes) {
                        throw new NotImplementedException();
                    }
                };
            }
        });
    } catch (Exception e) {
        System.err.println("An error occurred while exporting from Neptune:");
        e.printStackTrace();
        System.exit(-1);
    }

    System.exit(0);
}
 
Example #8
Source File: AmazonLambdaContext.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public ClientContext getClientContext() {
    return clientContext;
}
 
Example #9
Source File: HandlerTest.java    From lambadaframework with MIT License 4 votes vote down vote up
private Context getContext() {
    return new Context() {
        @Override
        public String getAwsRequestId() {
            return "23234234";
        }

        @Override
        public String getLogGroupName() {
            return null;
        }

        @Override
        public String getLogStreamName() {
            return null;
        }

        @Override
        public String getFunctionName() {
            return null;
        }

        @Override
        public String getFunctionVersion() {
            return null;
        }

        @Override
        public String getInvokedFunctionArn() {
            return null;
        }

        @Override
        public CognitoIdentity getIdentity() {
            return null;
        }

        @Override
        public ClientContext getClientContext() {
            return null;
        }

        @Override
        public int getRemainingTimeInMillis() {
            return 5000;
        }

        @Override
        public int getMemoryLimitInMB() {
            return 128;
        }

        @Override
        public LambdaLogger getLogger() {
            return null;
        }
    };
}
 
Example #10
Source File: TestContext.java    From bender with Apache License 2.0 4 votes vote down vote up
@Override
public ClientContext getClientContext() {
  return null;
}
 
Example #11
Source File: MockLambdaContext.java    From aws-serverless-java-container with Apache License 2.0 4 votes vote down vote up
@Override
public ClientContext getClientContext() {
    return null;
}
 
Example #12
Source File: TestContext.java    From aws-doc-sdk-examples with Apache License 2.0 4 votes vote down vote up
public ClientContext getClientContext(){
  return null;
}
 
Example #13
Source File: TestContext.java    From aws-lambda-java-example with Apache License 2.0 4 votes vote down vote up
@Override
public ClientContext getClientContext() {
    return clientContext;
}
 
Example #14
Source File: TestContext.java    From aws-lambda-java-example with Apache License 2.0 4 votes vote down vote up
public void setClientContext(ClientContext value) {
    clientContext = value;
}