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);
}
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));
}
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());
}
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));
}
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));
}
Aggregations