use of com.amazonaws.auth.AWSStaticCredentialsProvider in project thingsboard by thingsboard.
the class SqsDemoClient method main.
public static void main(String[] args) {
log.info("Starting SQS Demo Clinent...");
AWSCredentials awsCredentials = new BasicAWSCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY);
AmazonSQS sqs = AmazonSQSClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(awsCredentials)).withRegion(Regions.fromName(REGION)).build();
SqsDemoClient client = new SqsDemoClient();
client.pollMessages(sqs);
}
use of com.amazonaws.auth.AWSStaticCredentialsProvider 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.AWSStaticCredentialsProvider in project aws-doc-sdk-examples by awsdocs.
the class CreateService method main.
public static void main(String[] args) throws Exception {
AWSCredentials credentials = null;
try {
credentials = new ProfileCredentialsProvider().getCredentials();
} catch (Exception e) {
throw new AmazonClientException("Cannot Load credentials");
}
AWSServiceDiscovery client = AWSServiceDiscoveryClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(credentials)).withRegion("us-east-1").build();
CreateServiceRequest crequest = new CreateServiceRequest();
crequest.setName("example-service-01");
crequest.setDescription("This is an example service request");
// Replace with the namespaceID
crequest.setNamespaceId("ns-ldmexc5fqajjnhco");
System.out.println(client.createService(crequest));
}
use of com.amazonaws.auth.AWSStaticCredentialsProvider in project aws-doc-sdk-examples by awsdocs.
the class ListInstances method main.
public static void main(String[] args) throws Exception {
AWSCredentials credentials = null;
try {
credentials = new ProfileCredentialsProvider().getCredentials();
} catch (Exception e) {
throw new AmazonClientException("Cannot Load credentials");
}
AWSServiceDiscovery client = AWSServiceDiscoveryClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(credentials)).withRegion("us-east-1").build();
ListInstancesRequest lreq = new ListInstancesRequest();
// Replace with service id
lreq.setServiceId("srv-l7gkxmjapm5givba");
System.out.println(client.listInstances(lreq));
}
use of com.amazonaws.auth.AWSStaticCredentialsProvider in project aws-doc-sdk-examples by awsdocs.
the class LookUpServicewithFilter method main.
public static void main(String[] args) throws Exception {
AWSCredentials credentials = null;
try {
credentials = new ProfileCredentialsProvider().getCredentials();
} catch (Exception e) {
throw new AmazonClientException("Cannot Load credentials");
}
AWSServiceDiscovery client = AWSServiceDiscoveryClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(credentials)).withRegion("us-east-1").build();
DiscoverInstancesRequest direquest = new DiscoverInstancesRequest();
direquest.setNamespaceName("my-apps");
direquest.setServiceName("frontend");
// Use a filter to retrieve the service based on environment and version
Map<String, String> filtermap = new HashMap<String, String>();
// Stage - key of the custom attribute, Dev - value of the custom attribute
filtermap.put("Stage", "Dev");
// Version - key of the custom attribute, 01 - value of the custom attribute
filtermap.put("Version", "01");
direquest.setQueryParameters(filtermap);
System.out.println(client.discoverInstances(direquest));
}
Aggregations