Search in sources :

Example 46 with AWSStaticCredentialsProvider

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);
}
Also used : AWSStaticCredentialsProvider(com.amazonaws.auth.AWSStaticCredentialsProvider) AmazonSQS(com.amazonaws.services.sqs.AmazonSQS) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials) AWSCredentials(com.amazonaws.auth.AWSCredentials) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials)

Example 47 with AWSStaticCredentialsProvider

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);
}
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 48 with AWSStaticCredentialsProvider

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));
}
Also used : AWSStaticCredentialsProvider(com.amazonaws.auth.AWSStaticCredentialsProvider) CreateServiceRequest(com.amazonaws.services.servicediscovery.model.CreateServiceRequest) AWSServiceDiscovery(com.amazonaws.services.servicediscovery.AWSServiceDiscovery) AmazonClientException(com.amazonaws.AmazonClientException) ProfileCredentialsProvider(com.amazonaws.auth.profile.ProfileCredentialsProvider) AWSCredentials(com.amazonaws.auth.AWSCredentials) AmazonClientException(com.amazonaws.AmazonClientException)

Example 49 with AWSStaticCredentialsProvider

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));
}
Also used : AWSStaticCredentialsProvider(com.amazonaws.auth.AWSStaticCredentialsProvider) AWSServiceDiscovery(com.amazonaws.services.servicediscovery.AWSServiceDiscovery) ListInstancesRequest(com.amazonaws.services.servicediscovery.model.ListInstancesRequest) AmazonClientException(com.amazonaws.AmazonClientException) ProfileCredentialsProvider(com.amazonaws.auth.profile.ProfileCredentialsProvider) AWSCredentials(com.amazonaws.auth.AWSCredentials) AmazonClientException(com.amazonaws.AmazonClientException)

Example 50 with AWSStaticCredentialsProvider

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));
}
Also used : AWSStaticCredentialsProvider(com.amazonaws.auth.AWSStaticCredentialsProvider) HashMap(java.util.HashMap) AWSServiceDiscovery(com.amazonaws.services.servicediscovery.AWSServiceDiscovery) AmazonClientException(com.amazonaws.AmazonClientException) DiscoverInstancesRequest(com.amazonaws.services.servicediscovery.model.DiscoverInstancesRequest) ProfileCredentialsProvider(com.amazonaws.auth.profile.ProfileCredentialsProvider) AWSCredentials(com.amazonaws.auth.AWSCredentials) AmazonClientException(com.amazonaws.AmazonClientException)

Aggregations

AWSStaticCredentialsProvider (com.amazonaws.auth.AWSStaticCredentialsProvider)79 BasicAWSCredentials (com.amazonaws.auth.BasicAWSCredentials)57 AWSCredentialsProvider (com.amazonaws.auth.AWSCredentialsProvider)18 AWSCredentials (com.amazonaws.auth.AWSCredentials)17 Test (org.junit.Test)14 ClientConfiguration (com.amazonaws.ClientConfiguration)13 ProfileCredentialsProvider (com.amazonaws.auth.profile.ProfileCredentialsProvider)11 AmazonS3 (com.amazonaws.services.s3.AmazonS3)11 AmazonS3ClientBuilder (com.amazonaws.services.s3.AmazonS3ClientBuilder)11 SdkClientException (com.amazonaws.SdkClientException)10 BasicSessionCredentials (com.amazonaws.auth.BasicSessionCredentials)9 AwsClientBuilder (com.amazonaws.client.builder.AwsClientBuilder)9 AmazonClientException (com.amazonaws.AmazonClientException)8 Regions (com.amazonaws.regions.Regions)8 Test (org.junit.jupiter.api.Test)7 EndpointConfiguration (com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration)6 File (java.io.File)6 AmazonServiceException (com.amazonaws.AmazonServiceException)5 AWSLambda (com.amazonaws.services.lambda.AWSLambda)4 Segment (com.amazonaws.xray.entities.Segment)4