Search in sources :

Example 91 with AWSCredentialsProvider

use of com.amazonaws.auth.AWSCredentialsProvider in project aws-doc-sdk-examples by awsdocs.

the class SampleAPICall method main.

public static void main() {
    AWSCredentialsProvider credentials = new AWSStaticCredentialsProvider(new BasicAWSCredentials("YOUR AWS ACCESS KEY", "YOUR AWS SECRET"));
    AWSComprehendMedical client = AWSComprehendMedicalClient.builder().withCredentials(credentials).withRegion("YOUR REGION").build();
    DetectEntitiesRequest request = new DetectEntitiesRequest();
    request.setText("cerealx 84 mg daily");
    DetectEntitiesResult result = client.detectEntities(request);
    result.getEntities().forEach(System.out::println);
}
Also used : AWSComprehendMedical(com.amazonaws.services.comprehendmedical.AWSComprehendMedical) AWSStaticCredentialsProvider(com.amazonaws.auth.AWSStaticCredentialsProvider) DetectEntitiesResult(com.amazonaws.services.comprehendmedical.model.DetectEntitiesResult) DetectEntitiesRequest(com.amazonaws.services.comprehendmedical.model.DetectEntitiesRequest) AWSCredentialsProvider(com.amazonaws.auth.AWSCredentialsProvider) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials)

Example 92 with AWSCredentialsProvider

use of com.amazonaws.auth.AWSCredentialsProvider in project beam by apache.

the class AwsModuleTest method testPropertiesFileCredentialsProviderSerializationDeserialization.

@Test
public void testPropertiesFileCredentialsProviderSerializationDeserialization() throws Exception {
    String credentialsFilePath = "/path/to/file";
    AWSCredentialsProvider credentialsProvider = new PropertiesFileCredentialsProvider(credentialsFilePath);
    String serializedCredentialsProvider = serialize(credentialsProvider);
    AWSCredentialsProvider deserializedCredentialsProvider = deserializeCredentialsProvider(serializedCredentialsProvider);
    assertEquals(credentialsProvider.getClass(), deserializedCredentialsProvider.getClass());
    assertEquals(credentialsFilePath, readField(deserializedCredentialsProvider, "credentialsFilePath", true));
}
Also used : ClasspathPropertiesFileCredentialsProvider(com.amazonaws.auth.ClasspathPropertiesFileCredentialsProvider) PropertiesFileCredentialsProvider(com.amazonaws.auth.PropertiesFileCredentialsProvider) AWSCredentialsProvider(com.amazonaws.auth.AWSCredentialsProvider) Test(org.junit.Test)

Example 93 with AWSCredentialsProvider

use of com.amazonaws.auth.AWSCredentialsProvider in project beam by apache.

the class AwsModuleTest method testSingletonAWSCredentialsProviderSerializationDeserialization.

@Test
public void testSingletonAWSCredentialsProviderSerializationDeserialization() throws Exception {
    AWSCredentialsProvider credentialsProvider;
    String serializedCredentialsProvider;
    AWSCredentialsProvider deserializedCredentialsProvider;
    credentialsProvider = new DefaultAWSCredentialsProviderChain();
    serializedCredentialsProvider = serialize(credentialsProvider);
    deserializedCredentialsProvider = deserializeCredentialsProvider(serializedCredentialsProvider);
    assertEquals(credentialsProvider.getClass(), deserializedCredentialsProvider.getClass());
    credentialsProvider = new EnvironmentVariableCredentialsProvider();
    serializedCredentialsProvider = serialize(credentialsProvider);
    deserializedCredentialsProvider = deserializeCredentialsProvider(serializedCredentialsProvider);
    assertEquals(credentialsProvider.getClass(), deserializedCredentialsProvider.getClass());
    credentialsProvider = new SystemPropertiesCredentialsProvider();
    serializedCredentialsProvider = serialize(credentialsProvider);
    deserializedCredentialsProvider = deserializeCredentialsProvider(serializedCredentialsProvider);
    assertEquals(credentialsProvider.getClass(), deserializedCredentialsProvider.getClass());
    credentialsProvider = new ProfileCredentialsProvider();
    serializedCredentialsProvider = serialize(credentialsProvider);
    deserializedCredentialsProvider = deserializeCredentialsProvider(serializedCredentialsProvider);
    assertEquals(credentialsProvider.getClass(), deserializedCredentialsProvider.getClass());
    credentialsProvider = new EC2ContainerCredentialsProviderWrapper();
    serializedCredentialsProvider = serialize(credentialsProvider);
    deserializedCredentialsProvider = deserializeCredentialsProvider(serializedCredentialsProvider);
    assertEquals(credentialsProvider.getClass(), deserializedCredentialsProvider.getClass());
}
Also used : DefaultAWSCredentialsProviderChain(com.amazonaws.auth.DefaultAWSCredentialsProviderChain) SystemPropertiesCredentialsProvider(com.amazonaws.auth.SystemPropertiesCredentialsProvider) EnvironmentVariableCredentialsProvider(com.amazonaws.auth.EnvironmentVariableCredentialsProvider) ProfileCredentialsProvider(com.amazonaws.auth.profile.ProfileCredentialsProvider) AWSCredentialsProvider(com.amazonaws.auth.AWSCredentialsProvider) EC2ContainerCredentialsProviderWrapper(com.amazonaws.auth.EC2ContainerCredentialsProviderWrapper) Test(org.junit.Test)

Example 94 with AWSCredentialsProvider

use of com.amazonaws.auth.AWSCredentialsProvider in project beam by apache.

the class AwsModuleTest method testClasspathPropertiesFileCredentialsProviderSerializationDeserialization.

@Test
public void testClasspathPropertiesFileCredentialsProviderSerializationDeserialization() throws Exception {
    String credentialsFilePath = "/path/to/file";
    AWSCredentialsProvider credentialsProvider = new ClasspathPropertiesFileCredentialsProvider(credentialsFilePath);
    String serializedCredentialsProvider = serialize(credentialsProvider);
    AWSCredentialsProvider deserializedCredentialsProvider = deserializeCredentialsProvider(serializedCredentialsProvider);
    assertEquals(credentialsProvider.getClass(), deserializedCredentialsProvider.getClass());
    assertEquals(credentialsFilePath, readField(deserializedCredentialsProvider, "credentialsFilePath", true));
}
Also used : AWSCredentialsProvider(com.amazonaws.auth.AWSCredentialsProvider) ClasspathPropertiesFileCredentialsProvider(com.amazonaws.auth.ClasspathPropertiesFileCredentialsProvider) Test(org.junit.Test)

Example 95 with AWSCredentialsProvider

use of com.amazonaws.auth.AWSCredentialsProvider in project beam by apache.

the class KinesisIOWriteTest method testReadWithCredentialsProviderAndCustomEndpoint.

@Test
public void testReadWithCredentialsProviderAndCustomEndpoint() {
    String customEndpoint = "localhost:9999";
    Regions region = Regions.US_WEST_1;
    AWSCredentialsProvider credentialsProvider = DefaultAWSCredentialsProviderChain.getInstance();
    Write write = KinesisIO.write().withAWSClientsProvider(credentialsProvider, region, customEndpoint);
    assertEquals(write.getAWSClientsProvider(), new BasicKinesisProvider(credentialsProvider, region, customEndpoint, true));
}
Also used : Write(org.apache.beam.sdk.io.kinesis.KinesisIO.Write) Regions(com.amazonaws.regions.Regions) AWSCredentialsProvider(com.amazonaws.auth.AWSCredentialsProvider) Test(org.junit.Test)

Aggregations

AWSCredentialsProvider (com.amazonaws.auth.AWSCredentialsProvider)125 Test (org.junit.Test)75 DefaultAWSCredentialsProviderChain (com.amazonaws.auth.DefaultAWSCredentialsProviderChain)26 BasicAWSCredentials (com.amazonaws.auth.BasicAWSCredentials)20 AWSStaticCredentialsProvider (com.amazonaws.auth.AWSStaticCredentialsProvider)19 AWSCredentials (com.amazonaws.auth.AWSCredentials)16 TestRunner (org.apache.nifi.util.TestRunner)15 ClientConfiguration (com.amazonaws.ClientConfiguration)12 AmazonS3Client (com.amazonaws.services.s3.AmazonS3Client)12 STSAssumeRoleSessionCredentialsProvider (com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider)8 ProfileCredentialsProvider (com.amazonaws.auth.profile.ProfileCredentialsProvider)8 PropertyDescriptor (org.apache.nifi.components.PropertyDescriptor)8 AWSCredentialsProviderChain (com.amazonaws.auth.AWSCredentialsProviderChain)7 ClasspathPropertiesFileCredentialsProvider (com.amazonaws.auth.ClasspathPropertiesFileCredentialsProvider)7 EnvironmentVariableCredentialsProvider (com.amazonaws.auth.EnvironmentVariableCredentialsProvider)7 SystemPropertiesCredentialsProvider (com.amazonaws.auth.SystemPropertiesCredentialsProvider)7 ArrayList (java.util.ArrayList)7 Properties (java.util.Properties)7 Configuration (org.apache.hadoop.conf.Configuration)7 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)7