software.amazon.awssdk.regions.Region Java Examples

The following examples show how to use software.amazon.awssdk.regions.Region. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CreateBucketInterceptorTest.java    From aws-sdk-java-v2 with Apache License 2.0 6 votes vote down vote up
/**
 * For us-east-1 there must not be a location constraint (or containing CreateBucketConfiguration) sent.
 */
@Test
public void modifyRequest_UsEast1_UsesNullBucketConfiguration() {
    CreateBucketRequest request = CreateBucketRequest.builder()
                                                     .bucket("test-bucket")
                                                     .createBucketConfiguration(CreateBucketConfiguration.builder()
                                                                                                         .build())
                                                     .build();

    Context.ModifyRequest context = () -> request;

    ExecutionAttributes attributes = new ExecutionAttributes()
            .putAttribute(AwsExecutionAttribute.AWS_REGION, Region.US_EAST_1);

    SdkRequest modifiedRequest = new CreateBucketInterceptor().modifyRequest(context, attributes);
    assertThat(((CreateBucketRequest) modifiedRequest).createBucketConfiguration()).isNull();
}
 
Example #2
Source File: EndpointAddressInterceptorTest.java    From aws-sdk-java-v2 with Apache License 2.0 6 votes vote down vote up
@Test
public void accesspointArn_withFipsRegionSuffix_shouldThrowIllegalArgumentException() {
    assertThatThrownBy(() -> verifyAccesspointArn("http",
                                                  "arn:aws:s3:us-east-1:12345678910:accesspoint/foobar",
                                                  "http://foobar-12345678910.s3-accesspoint.us-east-1.amazonaws.com",
                                                  Region.of("us-east-1"),
                                                  S3Configuration.builder(),
                                                  Region.of("us-east-1-fips")))
        .isInstanceOf(IllegalArgumentException.class)
        .hasMessageContaining("FIPS");
    assertThatThrownBy(() -> verifyAccesspointArn("https",
                                                  "arn:aws:s3:us-east-1:12345678910:accesspoint/foobar",
                                                  "https://foobar-12345678910.s3-accesspoint.us-east-1.amazonaws.com",
                                                  Region.of("us-east-1"),
                                                  S3Configuration.builder(),
                                                  Region.of("us-east-1-fips")))
        .isInstanceOf(IllegalArgumentException.class)
        .hasMessageContaining("FIPS");
}
 
Example #3
Source File: S3EndpointResolutionTest.java    From aws-sdk-java-v2 with Apache License 2.0 6 votes vote down vote up
@Test
public void regionalSettingEnabledViaProfile_usesRegionalIadEndpoint() throws UnsupportedEncodingException {
    String profile =
        "[profile test]\n" +
        "s3_us_east_1_regional_endpoint = regional";

    ProfileFile profileFile = ProfileFile.builder()
                                         .content(new StringInputStream(profile))
                                         .type(ProfileFile.Type.CONFIGURATION)
                                         .build();

    mockHttpClient.stubNextResponse(mockListObjectsResponse());

    S3Client s3Client = S3Client.builder()
                                .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("akid", "skid")))
                                .httpClient(mockHttpClient)
                                .region(Region.US_EAST_1)
                                .overrideConfiguration(c -> c.defaultProfileFile(profileFile)
                                                             .defaultProfileName("test"))
                                .serviceConfiguration(c -> c.pathStyleAccessEnabled(true))
                                .build();

    s3Client.listObjects(ListObjectsRequest.builder().bucket(BUCKET).build());
    assertThat(mockHttpClient.getLastRequest().getUri().getHost()).isEqualTo("s3.us-east-1.amazonaws.com");
}
 
Example #4
Source File: JsonProtocolApiCall.java    From aws-sdk-java-v2 with Apache License 2.0 6 votes vote down vote up
public JsonProtocolApiCall() {
    super("json");
    this.client = ProtocolRestJsonClient.builder()
                                        .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create(
                                            "akid", "skid")))
                                        .region(Region.US_EAST_1)
                                        .httpClient(mockHttpClient)
                                        .build();
    this.asyncClient = ProtocolRestJsonAsyncClient.builder()
                                                  .credentialsProvider(
                                                      StaticCredentialsProvider.create(AwsBasicCredentials.create(
                                                      "akid", "skid")))
                                                  .region(Region.US_EAST_1)
                                                  .httpClient(mockAyncHttpClient)
                                                  .build();
}
 
Example #5
Source File: AwsJsonCrc32ChecksumTests.java    From aws-sdk-java-v2 with Apache License 2.0 6 votes vote down vote up
@Test
public void useGzipFalse_WhenCrc32IsValid() {
    stubFor(post(urlEqualTo("/")).willReturn(aResponse()
                                                     .withStatus(200)
                                                     .withHeader("x-amz-crc32", JSON_BODY_Crc32_CHECKSUM)
                                                     .withBody(JSON_BODY)));

    ProtocolJsonRpcClient jsonRpc = ProtocolJsonRpcClient.builder()
            .credentialsProvider(FAKE_CREDENTIALS_PROVIDER)
            .region(Region.US_EAST_1)
            .endpointOverride(URI.create("http://localhost:" + mockServer.port()))
            .build();

    AllTypesResponse result =
            jsonRpc.allTypes(AllTypesRequest.builder().build());
    Assert.assertEquals("foo", result.stringMember());
}
 
Example #6
Source File: IntegrationTestBase.java    From aws-sdk-java-v2 with Apache License 2.0 6 votes vote down vote up
protected static void createKinesisStream() {
    kinesis = KinesisClient.builder().credentialsProvider(CREDENTIALS_PROVIDER_CHAIN).region(Region.US_WEST_2).build();

    kinesis.createStream(CreateStreamRequest.builder().streamName(KINESIS_STREAM_NAME).shardCount(1).build());

    StreamDescription description = kinesis.describeStream(DescribeStreamRequest.builder().streamName(KINESIS_STREAM_NAME).build())
            .streamDescription();
    streamArn = description.streamARN();

    // Wait till stream is active (less than a minute)
    Instant start = Instant.now();
    while (StreamStatus.ACTIVE != description.streamStatus()) {
        if (Duration.between(start, Instant.now()).toMillis() > MAX_WAIT_TIME.toMillis()) {
            throw new RuntimeException("Timed out waiting for stream to become active");
        }
        try {
            Thread.sleep(5000);
        } catch (InterruptedException ignored) {
            // Ignored or expected.
        }

        description = kinesis.describeStream(DescribeStreamRequest.builder().streamName(KINESIS_STREAM_NAME).build())
                .streamDescription();
    }
}
 
Example #7
Source File: CreateBucketInterceptorTest.java    From aws-sdk-java-v2 with Apache License 2.0 6 votes vote down vote up
@Test
public void modifyRequest_UpdatesLocationConstraint_When_NullCreateBucketConfiguration() {
    CreateBucketRequest request = CreateBucketRequest.builder()
                                                     .bucket("test-bucket")
                                                     .build();

    Context.ModifyRequest context = () -> request;

    ExecutionAttributes attributes = new ExecutionAttributes()
            .putAttribute(AwsExecutionAttribute.AWS_REGION, Region.US_EAST_2);

    SdkRequest modifiedRequest = new CreateBucketInterceptor().modifyRequest(context, attributes);
    String locationConstraint = ((CreateBucketRequest) modifiedRequest).createBucketConfiguration().locationConstraintAsString();

    assertThat(locationConstraint).isEqualToIgnoringCase("us-east-2");
}
 
Example #8
Source File: CreateCampaign.java    From aws-doc-sdk-examples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {

        final String USAGE = "\n" +
                "CreateCampaign - create a campaign for an application in Amazon Pinpoint\n\n" +
                "Usage: CreateCampaign <appId> <segmentId>\n\n" +
                "Where:\n" +
                "  appId - the ID of the application to create the campaign in.\n\n" +
                "  segmentId - the ID of the segment to create the campaign from.\n\n";

        if (args.length < 1) {
            System.out.println(USAGE);
            System.exit(1);
        }

        String appId = args[0];
        String segmentId = args[1];

        PinpointClient pinpoint = PinpointClient.builder()
                .region(Region.US_EAST_1)
                .build();

        createPinCampaign(pinpoint, appId, segmentId) ;
    }
 
Example #9
Source File: CreateAccountAlias.java    From aws-doc-sdk-examples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {

        final String USAGE =
                "To run this example, supply an alias which has to be digits\n" +
                        "Ex: CreateAccountAlias <alias>\n";

        if (args.length != 1) {
            System.out.println(USAGE);
            System.exit(1);
        }

        String alias = args[0];
        Region region = Region.AWS_GLOBAL;
        IamClient iam = IamClient.builder()
                .region(region)
                .build();

        createIAMAccountAlias(iam, alias);
    }
 
Example #10
Source File: SdkHttpResponseTest.java    From aws-sdk-java-v2 with Apache License 2.0 6 votes vote down vote up
@Before
public void setupClient() {
    client = ProtocolRestJsonClient.builder()
                                   .region(Region.US_WEST_1)
                                   .endpointOverride(URI.create("http://localhost:"
                                                                + wireMock.port()))
                                   .credentialsProvider(() -> AwsBasicCredentials.create("akid", "skid"))
                                   .build();

    asyncClient = ProtocolRestJsonAsyncClient.builder()
                                             .region(Region.US_WEST_1)
                                             .endpointOverride(URI.create("http://localhost:"
                                                                          + wireMock.port()))
                                             .credentialsProvider(() -> AwsBasicCredentials.create("akid", "skid"))
                                             .build();
}
 
Example #11
Source File: AllocateAddress.java    From aws-doc-sdk-examples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
    final String USAGE =
            "To run this example, supply an instance id that you can obtain from the AWS Console\n" +
                    "Ex: AllocateAddress <instance_id>\n";

    if (args.length != 1) {
        System.out.println(USAGE);
        System.exit(1);
    }

    String instanceId = args[0];

    Region region = Region.US_EAST_1;
    Ec2Client ec2 = Ec2Client.builder()
            .region(region)
            .build();

    System.out.println(getAllocateAddress(ec2, instanceId));
}
 
Example #12
Source File: ListUserPoolClients.java    From aws-doc-sdk-examples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
    final String USAGE = "\n" +
            "Usage:\n" +
            "    ListUserPoolClients <user_pool_id> \n\n" +
            "Where:\n" +
            "    userPoolId - the ID given your user pool when created\n\n" +
            "Example:\n" +
            "    ListUserPoolClients us-east-2_P0oL1D\n";

    if (args.length < 1) {
         System.out.println(USAGE);
         System.exit(1);
     }

    String userPoolId = args[0];

    CognitoIdentityProviderClient cognitoclient = CognitoIdentityProviderClient.builder()
            .region(Region.US_EAST_1)
            .build();

    listAllUserPoolClients(cognitoclient, userPoolId ) ;
}
 
Example #13
Source File: QueryRequestTransformTest.java    From aws-sdk-java-v2 with Apache License 2.0 6 votes vote down vote up
@Before
public void setupClient() {
    client = ProtocolQueryClient.builder()
                                .credentialsProvider(StaticCredentialsProvider.create(
                                        AwsBasicCredentials.create("akid", "skid")))
                                .region(Region.US_EAST_1)
                                .endpointOverride(URI.create("http://localhost:" + wireMock.port()))
                                .build();

    asyncClient = ProtocolQueryAsyncClient.builder()
                                          .credentialsProvider(StaticCredentialsProvider.create(
                                                  AwsBasicCredentials.create("akid", "skid")))
                                          .region(Region.US_EAST_1)
                                          .endpointOverride(URI.create("http://localhost:" + wireMock.port()))
                                          .build();
}
 
Example #14
Source File: S3TestHelper.java    From edison-microservice with Apache License 2.0 6 votes vote down vote up
public static S3Client createS3Client(final Integer mappedPort) {
    final AwsBasicCredentials credentials = AwsBasicCredentials.create("test", "test");
    final StaticCredentialsProvider credentialsProvider = StaticCredentialsProvider.create(credentials);

    return S3Client.builder()
            .credentialsProvider(credentialsProvider)
            .endpointOverride(URI.create(String.format("http://localhost:%d", mappedPort)))
            .region(Region.EU_CENTRAL_1)
            .serviceConfiguration(S3Configuration.builder()
                    .pathStyleAccessEnabled(true)
                    .build())
            .overrideConfiguration(ClientOverrideConfiguration
                    .builder()
                    .putAdvancedOption(SdkAdvancedClientOption.SIGNER, new NoOpSigner())
                    .build())
            .build();
}
 
Example #15
Source File: DetectMedicalEntities.java    From aws-doc-sdk-examples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {

        String text = "Pt is 87 yo woman, highschool teacher with past medical history that includes\n" +
                "   - status post cardiac catheterization in April 2019.\n" +
                "She presents today with palpitations and chest pressure.\n" +
                "HPI : Sleeping trouble on present dosage of Clonidine. Severe Rash  on face and leg, slightly itchy  \n" +
                "Meds : Vyvanse 50 mgs po at breakfast daily, \n" +
                "            Clonidine 0.2 mgs -- 1 and 1 / 2 tabs po qhs \n" +
                "HEENT : Boggy inferior turbinates, No oropharyngeal lesion \n" +
                "Lungs : clear \n" +
                "Heart : Regular rhythm \n" +
                "Skin :  Mild erythematous eruption to hairline \n" +
                "\n" +
                "Follow-up as scheduled";
        Region region = Region.US_EAST_1;
        ComprehendMedicalClient medClient = ComprehendMedicalClient.builder()
                .region(region)
                .build();

        System.out.println("Calling Detect Medical Entities");
        detectAllEntities(medClient, text) ;

    }
 
Example #16
Source File: DeleteQueue.java    From aws-doc-sdk-examples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {

        final String USAGE = "\n" +
                "DeleteQueue - delete a queue\n\n" +
                "Usage: DeleteQueue <queueName>\n\n" +
                "Where:\n" +
                "  queueName - the name of the queue\n\n" ;

        if (args.length < 1) {
            System.out.println(USAGE);
            System.exit(1);
        }

        String queueName = args[0];

        SqsClient sqs = SqsClient.builder()
                .region(Region.US_WEST_2)
                .build();

        deleteSQSQueue(sqs, queueName);
    }
 
Example #17
Source File: DefaultPollyPresignerTest.java    From aws-sdk-java-v2 with Apache License 2.0 6 votes vote down vote up
@Test
public void presign_includesRequestLevelQueryParams_included() {
    PollyPresigner presigner = DefaultPollyPresigner.builder()
            .region(Region.US_EAST_1)
            .credentialsProvider(credentialsProvider)
            .build();

    SynthesizeSpeechRequest synthesizeSpeechRequest = BASIC_SYNTHESIZE_SPEECH_REQUEST.toBuilder()
            .overrideConfiguration(AwsRequestOverrideConfiguration.builder()
                    .putRawQueryParameter("QueryParam1", "Param1Value")
                    .build())
            .build();

    SynthesizeSpeechPresignRequest presignRequest = SynthesizeSpeechPresignRequest.builder()
            .synthesizeSpeechRequest(synthesizeSpeechRequest)
            .signatureDuration(Duration.ofHours(3))
            .build();

    PresignedSynthesizeSpeechRequest presignedSynthesizeSpeechRequest = presigner.presignSynthesizeSpeech(presignRequest);

    assertThat(presignedSynthesizeSpeechRequest.httpRequest().rawQueryParameters().keySet()).contains("QueryParam1");
}
 
Example #18
Source File: RebootInstance.java    From aws-doc-sdk-examples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
    final String USAGE =
            "To run this example, supply an instance id\n" +
                    "Ex: RebootInstance <instance_id>\n";

    if (args.length != 1) {
        System.out.println(USAGE);
        System.exit(1);
    }

    String instanceId = args[0];

    //Create an Ec2Client object
    Region region = Region.US_WEST_2;
    Ec2Client ec2 = Ec2Client.builder()
            .region(region)
            .build();

    rebootEC2Instance(ec2, instanceId);
}
 
Example #19
Source File: AsyncResponseThreadingTest.java    From aws-sdk-java-v2 with Apache License 2.0 6 votes vote down vote up
@Test
public void completionWithNioThreadWorksCorrectly() {
    stubFor(post(urlPathEqualTo(STREAMING_OUTPUT_PATH)).willReturn(aResponse().withStatus(200).withBody("test")));

    Executor mockExecutor = Mockito.spy(new SpyableExecutor());

    ProtocolRestJsonAsyncClient client =
            ProtocolRestJsonAsyncClient.builder()
                                       .region(Region.US_WEST_1)
                                       .endpointOverride(URI.create("http://localhost:" + wireMock.port()))
                                       .credentialsProvider(() -> AwsBasicCredentials.create("akid", "skid"))
                                       .asyncConfiguration(c -> c.advancedOption(FUTURE_COMPLETION_EXECUTOR, mockExecutor))
                                       .build();

    ResponseBytes<StreamingOutputOperationResponse> response =
            client.streamingOutputOperation(StreamingOutputOperationRequest.builder().build(),
                                            AsyncResponseTransformer.toBytes()).join();

    verify(mockExecutor).execute(any());

    byte[] arrayCopy = response.asByteArray();
    assertThat(arrayCopy).containsExactly('t', 'e', 's', 't');
}
 
Example #20
Source File: DeleteBucketPolicy.java    From aws-doc-sdk-examples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
    final String USAGE = "\n" +
            "Usage:\n" +
            "    DeleteBucketPolicy <bucket>\n\n" +
            "Where:\n" +
            "    bucket - the bucket to delete the policy from (i.e., bucket1)\n\n" +
            "Example:\n" +
            "    bucket1\n\n";

    if (args.length < 1) {
        System.out.println(USAGE);
        System.exit(1);
    }

    String bucketName = args[0];
    System.out.format("Deleting policy from bucket: \"%s\"\n\n", bucketName);

    //Create a S3Client object
    Region region = Region.US_WEST_2;
    S3Client s3 = S3Client.builder().region(region).build();

    //Delete the bucket policy
    deleteS3BucketPolicy(s3, bucketName);
}
 
Example #21
Source File: RestJsonCrc32ChecksumTests.java    From aws-sdk-java-v2 with Apache License 2.0 6 votes vote down vote up
@Test
public void clientCalculatesCrc32FromDecompressedData_WhenCrc32IsValid() {
    stubFor(post(urlEqualTo(RESOURCE_PATH)).willReturn(aResponse()
            .withStatus(200)
            .withHeader("Content-Encoding", "gzip")
            .withHeader("x-amz-crc32", JSON_BODY_Crc32_CHECKSUM)
            .withBodyFile(JSON_BODY_GZIP)));
    ProtocolRestJsonClient client = ProtocolRestJsonClient.builder()
            .credentialsProvider(FAKE_CREDENTIALS_PROVIDER)
            .region(Region.US_EAST_1)
            .endpointOverride(URI.create("http://localhost:" + mockServer.port()))
            .build();

    AllTypesResponse result =
            client.allTypes(AllTypesRequest.builder().build());
    Assert.assertEquals("foo", result.stringMember());
}
 
Example #22
Source File: RestJsonCrc32ChecksumTests.java    From aws-sdk-java-v2 with Apache License 2.0 6 votes vote down vote up
@Test
public void useGzipFalse_WhenCrc32IsValid() {
    stubFor(post(urlEqualTo(RESOURCE_PATH)).willReturn(aResponse()
            .withStatus(200)
            .withHeader("x-amz-crc32", JSON_BODY_Crc32_CHECKSUM)
            .withBody(JSON_BODY)));
    ProtocolRestJsonClient client = ProtocolRestJsonClient.builder()
            .credentialsProvider(FAKE_CREDENTIALS_PROVIDER)
            .region(Region.US_EAST_1)
            .endpointOverride(URI.create("http://localhost:" + mockServer.port()))
            .build();

    AllTypesResponse result =
            client.allTypes(AllTypesRequest.builder().build());
    Assert.assertEquals("foo", result.stringMember());
}
 
Example #23
Source File: CreateTopic.java    From aws-doc-sdk-examples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
    final String USAGE = "\n" +
            "CreateTopic - create an Amazon SNS topic\n" +
            "Usage: CreateTopic <topicName>\n\n" +
            "Where:\n" +
            "  topicName - the name of the topic to create.\n\n";

    if (args.length < 1) {
        System.out.println(USAGE);
        System.exit(1);
    }

    String topicName = args[0];

    System.out.println("Creating a topic with name: " + topicName);

    SnsClient snsClient = SnsClient.builder()
            .region(Region.US_WEST_2)
            .build();

    String arnVal = createSNSTopic(snsClient, topicName) ;
    System.out.println("The topic ARN is" +arnVal);
}
 
Example #24
Source File: DescribeForecast.java    From aws-doc-sdk-examples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {

        final String USAGE = "\n" +
                "Usage:\n" +
                "    DescribeForecast <forecastarn> \n\n" +
                "Where:\n" +
                "    forecastarn - the Amazon Resource Name (ARN) of the forecast (i.e., \"arn:aws:forecast:us-west-2:81333322:forecast/my_forecast)\n\n" +
                "Example:\n" +
                "    DescribeForecast arn:aws:forecast:us-west-2:81333322:forecast/my_forecast\n";

        if (args.length < 1) {
            System.out.println(USAGE);
            System.exit(1);
        }

        String forecastarn = args[0];

        // Create a Forecast client
        Region region = Region.US_WEST_2;
        ForecastClient forecast = ForecastClient.builder()
                .region(region)
                .build();

        describe(forecast, forecastarn);
    }
 
Example #25
Source File: CreateUser.java    From aws-doc-sdk-examples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {

        final String USAGE =
                "To run this example, supply a username\n" +
                        "Ex: CreateUser <username>\n";

        if (args.length != 1) {
            System.out.println(USAGE);
            System.exit(1);
        }

        String username = args[0];

        Region region = Region.AWS_GLOBAL;
        IamClient iam = IamClient.builder()
                .region(region)
                .build();

        String result = createIAMUser(iam, username) ;
        System.out.println("Successfully created user: " +result);

    }
 
Example #26
Source File: HelpfulUnknownHostExceptionInterceptorTest.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
private Throwable modifyException(Throwable throwable, Region clientRegion, String serviceEndpointPrefix) {
    SdkRequest sdkRequest = Mockito.mock(SdkRequest.class);

    DefaultFailedExecutionContext context =
        DefaultFailedExecutionContext.builder()
                                     .interceptorContext(InterceptorContext.builder().request(sdkRequest).build())
                                     .exception(throwable)
                                     .build();

    ExecutionAttributes executionAttributes =
        new ExecutionAttributes().putAttribute(AwsExecutionAttribute.AWS_REGION, clientRegion)
                                 .putAttribute(AwsExecutionAttribute.ENDPOINT_PREFIX, serviceEndpointPrefix);

    return INTERCEPTOR.modifyException(context, executionAttributes);
}
 
Example #27
Source File: DynamoDBLockProviderIntegrationTest.java    From ShedLock with Apache License 2.0 5 votes vote down vote up
/**
 * Create a standard AWS v2 SDK client pointing to the local DynamoDb instance
 *
 * @return A DynamoDbClient pointing to the local DynamoDb instance
 */
static DynamoDbClient createClient() {
    String endpoint = "http://" + dynamoDbContainer.getContainerIpAddress() + ":" + dynamoDbContainer.getFirstMappedPort();
    return DynamoDbClient.builder()
        .endpointOverride(URI.create(endpoint))
        // The region is meaningless for local DynamoDb but required for client builder validation
        .region(Region.US_EAST_1)
        .credentialsProvider(StaticCredentialsProvider.create(
            AwsBasicCredentials.create("dummy-key", "dummy-secret"))
        )
        .build();
}
 
Example #28
Source File: DefaultAwsClientBuilderTest.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
@Test
public void explicitClientProvided_ClientIsNotManagedBySdk() {
    TestClient client = testClientBuilder()
        .region(Region.US_WEST_2)
        .httpClient(mock(SdkHttpClient.class))
        .build();
    assertThat(client.clientConfiguration.option(SdkClientOption.SYNC_HTTP_CLIENT))
        .isInstanceOf(AwsDefaultClientBuilder.NonManagedSdkHttpClient.class);
    verify(defaultHttpClientBuilder, never()).buildWithDefaults(any());
}
 
Example #29
Source File: ListUsers.java    From aws-doc-sdk-examples with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {

        Region region = Region.AWS_GLOBAL;
        IamClient iam = IamClient.builder()
                .region(region)
                .build();

        listAllUsers(iam );
    }
 
Example #30
Source File: AwsJsonExceptionTest.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
@Before
public void setupClient() {
    client = ProtocolJsonRpcClient.builder()
                                  .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("akid", "skid")))
                                  .region(Region.US_EAST_1)
                                  .endpointOverride(URI.create("http://localhost:" + wireMock.port()))
                                  .build();
}