Search in sources :

Example 1 with FederatedIdentity

use of com.amazonaws.athena.connector.lambda.security.FederatedIdentity in project aws-athena-query-federation by awslabs.

the class MetadataRequestDeserializer method doTypedDeserialize.

protected FederationRequest doTypedDeserialize(JsonParser jparser, DeserializationContext ctxt) throws IOException {
    assertFieldName(jparser, IDENTITY_FIELD);
    FederatedIdentity identity = identityDeserializer.deserialize(jparser, ctxt);
    String queryId = getNextStringField(jparser, QUERY_ID_FIELD);
    String catalogName = getNextStringField(jparser, CATALOG_NAME_FIELD);
    return doRequestDeserialize(jparser, ctxt, identity, queryId, catalogName);
}
Also used : FederatedIdentity(com.amazonaws.athena.connector.lambda.security.FederatedIdentity)

Example 2 with FederatedIdentity

use of com.amazonaws.athena.connector.lambda.security.FederatedIdentity in project aws-athena-query-federation by awslabs.

the class BigQueryRecordHandlerTest method init.

@Before
public void init() {
    System.setProperty("aws.region", "us-east-1");
    logger.info("Starting init.");
    federatedIdentity = Mockito.mock(FederatedIdentity.class);
    // MockitoAnnotations.initMocks(this);
    allocator = new BlockAllocatorImpl();
    amazonS3 = mock(AmazonS3.class);
    mockS3Client();
    // Create Spill config
    spillConfig = SpillConfig.newBuilder().withEncryptionKey(encryptionKey).withMaxBlockBytes(100000).withMaxInlineBlockBytes(100).withNumSpillThreads(0).withRequestId(UUID.randomUUID().toString()).withSpillLocation(s3SpillLocation).build();
    schemaForRead = new Schema(BigQueryTestUtils.getTestSchemaFieldsArrow());
    spillWriter = new S3BlockSpiller(amazonS3, spillConfig, allocator, schemaForRead, ConstraintEvaluator.emptyEvaluator());
    spillReader = new S3BlockSpillReader(amazonS3, allocator);
    // Mock the BigQuery Client to return Datasets, and Table Schema information.
    BigQueryPage<Dataset> datasets = new BigQueryPage<Dataset>(BigQueryTestUtils.getDatasetList(BigQueryTestUtils.PROJECT_1_NAME, 2));
    when(bigQuery.listDatasets(any(String.class))).thenReturn(datasets);
    BigQueryPage<Table> tables = new BigQueryPage<Table>(BigQueryTestUtils.getTableList(BigQueryTestUtils.PROJECT_1_NAME, "dataset1", 2));
    when(bigQuery.listTables(any(DatasetId.class))).thenReturn(tables);
    // The class we want to test.
    bigQueryRecordHandler = new BigQueryRecordHandler(amazonS3, awsSecretsManager, athena, bigQuery);
    logger.info("Completed init.");
}
Also used : AmazonS3(com.amazonaws.services.s3.AmazonS3) Schema(org.apache.arrow.vector.types.pojo.Schema) FederatedIdentity(com.amazonaws.athena.connector.lambda.security.FederatedIdentity) Before(org.junit.Before)

Example 3 with FederatedIdentity

use of com.amazonaws.athena.connector.lambda.security.FederatedIdentity in project aws-athena-query-federation by awslabs.

the class ExampleRecordHandler method logCaller.

/**
 * Demonstrates how you can capture the identity of the caller that ran the Athena query which triggered the Lambda invocation.
 *
 * @param request
 */
private void logCaller(FederationRequest request) {
    FederatedIdentity identity = request.getIdentity();
    logger.info("logCaller: account[" + identity.getAccount() + "] arn[" + identity.getArn() + "]");
}
Also used : FederatedIdentity(com.amazonaws.athena.connector.lambda.security.FederatedIdentity)

Example 4 with FederatedIdentity

use of com.amazonaws.athena.connector.lambda.security.FederatedIdentity in project aws-athena-query-federation by awslabs.

the class BigQueryMetadataHandlerTest method setUp.

@Before
public void setUp() throws InterruptedException {
    System.setProperty("aws.region", "us-east-1");
    MockitoAnnotations.initMocks(this);
    bigQueryMetadataHandler = new BigQueryMetadataHandler(bigQuery);
    blockAllocator = new BlockAllocatorImpl();
    federatedIdentity = Mockito.mock(FederatedIdentity.class);
    job = mock(Job.class);
    jobStatus = mock(JobStatus.class);
    when(bigQuery.create(any(JobInfo.class), any())).thenReturn(job);
    when(job.waitFor(any())).thenReturn(job);
    when(job.getStatus()).thenReturn(jobStatus);
}
Also used : FederatedIdentity(com.amazonaws.athena.connector.lambda.security.FederatedIdentity) BlockAllocatorImpl(com.amazonaws.athena.connector.lambda.data.BlockAllocatorImpl) Before(org.junit.Before)

Example 5 with FederatedIdentity

use of com.amazonaws.athena.connector.lambda.security.FederatedIdentity in project aws-athena-query-federation by awslabs.

the class ExampleMetadataHandler method logCaller.

/**
 * Demonstrates how you can capture the identity of the caller that ran the Athena query which triggered the Lambda invocation.
 *
 * @param request
 */
private void logCaller(FederationRequest request) {
    FederatedIdentity identity = request.getIdentity();
    logger.info("logCaller: account[" + identity.getAccount() + "] arn[" + identity.getArn() + "]");
}
Also used : FederatedIdentity(com.amazonaws.athena.connector.lambda.security.FederatedIdentity)

Aggregations

FederatedIdentity (com.amazonaws.athena.connector.lambda.security.FederatedIdentity)5 Before (org.junit.Before)2 BlockAllocatorImpl (com.amazonaws.athena.connector.lambda.data.BlockAllocatorImpl)1 AmazonS3 (com.amazonaws.services.s3.AmazonS3)1 Schema (org.apache.arrow.vector.types.pojo.Schema)1