Search in sources :

Example 11 with S3Configuration

use of com.ibm.cohort.tooling.s3.S3Configuration in project aws-sdk-java-v2 by aws.

the class S3ObjectLambdaOperationEndpointResolver method applyEndpointConfiguration.

@Override
public ConfiguredS3SdkHttpRequest applyEndpointConfiguration(S3EndpointResolverContext context) {
    S3Request originalRequest = (S3Request) context.originalRequest();
    validateObjectLambdaRequest(originalRequest);
    S3Configuration configuration = context.serviceConfiguration();
    validateConfiguration(configuration);
    SdkHttpRequest updatedRequest = context.request();
    if (context.endpointOverride() == null) {
        String newHost = getUriForObjectLambdaOperation(context).getHost();
        if (!context.isDisableHostPrefixInjection()) {
            newHost = applyHostPrefix(newHost, originalRequest);
        }
        updatedRequest = updatedRequest.toBuilder().host(newHost).build();
    }
    return ConfiguredS3SdkHttpRequest.builder().sdkHttpRequest(updatedRequest).signingServiceModification(SIGNING_NAME).build();
}
Also used : S3Configuration(software.amazon.awssdk.services.s3.S3Configuration) SdkHttpRequest(software.amazon.awssdk.http.SdkHttpRequest) ConfiguredS3SdkHttpRequest(software.amazon.awssdk.services.s3.internal.ConfiguredS3SdkHttpRequest) S3Request(software.amazon.awssdk.services.s3.model.S3Request)

Example 12 with S3Configuration

use of com.ibm.cohort.tooling.s3.S3Configuration in project aws-sdk-java-v2 by aws.

the class EndpointAddressInterceptor method modifyHttpRequest.

@Override
public SdkHttpRequest modifyHttpRequest(Context.ModifyHttpRequest context, ExecutionAttributes executionAttributes) {
    boolean endpointOverridden = Boolean.TRUE.equals(executionAttributes.getAttribute(SdkExecutionAttribute.ENDPOINT_OVERRIDDEN));
    URI endpointOverride = endpointOverridden ? executionAttributes.getAttribute(SdkExecutionAttribute.CLIENT_ENDPOINT) : null;
    S3Configuration serviceConfiguration = (S3Configuration) executionAttributes.getAttribute(AwsSignerExecutionAttribute.SERVICE_CONFIG);
    boolean disableHostPrefixInjection = isDisableHostPrefixInjection(executionAttributes);
    S3EndpointResolverContext resolverContext = S3EndpointResolverContext.builder().request(context.httpRequest()).originalRequest(context.request()).region(executionAttributes.getAttribute(AwsExecutionAttribute.AWS_REGION)).endpointOverride(endpointOverride).serviceConfiguration(serviceConfiguration).fipsEnabled(executionAttributes.getAttribute(AwsExecutionAttribute.FIPS_ENDPOINT_ENABLED)).disableHostPrefixInjection(disableHostPrefixInjection).build();
    String bucketName = context.request().getValueForField("Bucket", String.class).orElse(null);
    S3EndpointResolverFactoryContext resolverFactoryContext = S3EndpointResolverFactoryContext.builder().bucketName(bucketName).originalRequest((S3Request) context.request()).build();
    ConfiguredS3SdkHttpRequest configuredRequest = S3EndpointResolverFactory.getEndpointResolver(resolverFactoryContext).applyEndpointConfiguration(resolverContext);
    if (configuredRequest.signingRegionModification().isPresent()) {
        executionAttributes.putAttribute(AwsSignerExecutionAttribute.SIGNING_REGION, configuredRequest.signingRegionModification().get());
    } else {
        executionAttributes.putAttribute(AwsSignerExecutionAttribute.SIGNING_REGION_SCOPE, RegionScope.GLOBAL);
    }
    configuredRequest.signingServiceModification().ifPresent(name -> executionAttributes.putAttribute(AwsSignerExecutionAttribute.SERVICE_SIGNING_NAME, name));
    return configuredRequest.sdkHttpRequest();
}
Also used : S3Configuration(software.amazon.awssdk.services.s3.S3Configuration) ConfiguredS3SdkHttpRequest(software.amazon.awssdk.services.s3.internal.ConfiguredS3SdkHttpRequest) S3EndpointResolverContext(software.amazon.awssdk.services.s3.internal.endpoints.S3EndpointResolverContext) S3EndpointResolverFactoryContext(software.amazon.awssdk.services.s3.internal.endpoints.S3EndpointResolverFactoryContext) S3Request(software.amazon.awssdk.services.s3.model.S3Request) URI(java.net.URI)

Example 13 with S3Configuration

use of com.ibm.cohort.tooling.s3.S3Configuration in project aws-sdk-java-v2 by aws.

the class EnableChunkedEncodingInterceptorTest method modifyRequest_existingValueInExecutionAttributes_TakesPrecedenceOverClientConfig.

@Test
public void modifyRequest_existingValueInExecutionAttributes_TakesPrecedenceOverClientConfig() {
    boolean configValue = false;
    S3Configuration config = S3Configuration.builder().chunkedEncodingEnabled(configValue).build();
    ExecutionAttributes executionAttributes = new ExecutionAttributes().putAttribute(SERVICE_CONFIG, config).putAttribute(ENABLE_CHUNKED_ENCODING, !configValue);
    interceptor.modifyRequest(context(PutObjectRequest.builder().build()), executionAttributes);
    assertThat(executionAttributes.getAttribute(ENABLE_CHUNKED_ENCODING)).isEqualTo(!configValue);
}
Also used : S3Configuration(software.amazon.awssdk.services.s3.S3Configuration) ExecutionAttributes(software.amazon.awssdk.core.interceptor.ExecutionAttributes) Test(org.junit.jupiter.api.Test)

Example 14 with S3Configuration

use of com.ibm.cohort.tooling.s3.S3Configuration in project aws-sdk-java-v2 by aws.

the class S3EndpointResolverContextTest method toBuilder_maximal.

@Test
public void toBuilder_maximal() {
    S3Configuration serviceConfiguration = S3Configuration.builder().build();
    SdkHttpFullRequest httpRequest = SdkHttpFullRequest.builder().protocol("http").host("host").method(SdkHttpMethod.POST).build();
    URI endpoint = URI.create("https://endpoint.com");
    S3EndpointResolverContext context = S3EndpointResolverContext.builder().endpointOverride(endpoint).originalRequest(PutObjectRequest.builder().build()).region(Region.US_EAST_1).serviceConfiguration(serviceConfiguration).request(httpRequest).build();
    assertThat(context.endpointOverride()).isEqualTo(endpoint);
    assertThat(context.originalRequest()).isInstanceOf(PutObjectRequest.class);
    assertThat(context.region()).isEqualTo(Region.US_EAST_1);
    assertThat(context.serviceConfiguration()).isEqualTo(serviceConfiguration);
    assertThat(context.request()).isEqualTo(httpRequest);
}
Also used : S3Configuration(software.amazon.awssdk.services.s3.S3Configuration) SdkHttpFullRequest(software.amazon.awssdk.http.SdkHttpFullRequest) URI(java.net.URI) Test(org.junit.jupiter.api.Test)

Example 15 with S3Configuration

use of com.ibm.cohort.tooling.s3.S3Configuration in project beam by apache.

the class S3FileSystemTest method beforeClass.

@BeforeClass
public static void beforeClass() {
    api = new S3Mock.Builder().withInMemoryBackend().withPort(8002).build();
    Http.ServerBinding binding = api.start();
    URI endpoint = URI.create("http://localhost:" + binding.localAddress().getPort());
    S3Configuration s3Configuration = S3Configuration.builder().pathStyleAccessEnabled(true).build();
    client = S3Client.builder().region(Region.US_WEST_1).serviceConfiguration(s3Configuration).endpointOverride(endpoint).credentialsProvider(AnonymousCredentialsProvider.create()).build();
}
Also used : S3Configuration(software.amazon.awssdk.services.s3.S3Configuration) Http(akka.http.scaladsl.Http) URI(java.net.URI) BeforeClass(org.junit.BeforeClass)

Aggregations

S3Configuration (software.amazon.awssdk.services.s3.S3Configuration)12 URI (java.net.URI)5 S3Configuration (jetbrains.buildServer.artifacts.s3.S3Configuration)4 File (java.io.File)3 NotNull (org.jetbrains.annotations.NotNull)3 Test (org.junit.jupiter.api.Test)3 ConfiguredS3SdkHttpRequest (software.amazon.awssdk.services.s3.internal.ConfiguredS3SdkHttpRequest)3 AmazonS3 (com.amazonaws.services.s3.AmazonS3)2 Consumer (java.util.function.Consumer)2 Supplier (java.util.function.Supplier)2 ExtensionHolder (jetbrains.buildServer.ExtensionHolder)2 AgentArtifactHelper (jetbrains.buildServer.agent.artifacts.AgentArtifactHelper)2 FileUploadInfo (jetbrains.buildServer.artifacts.s3.FileUploadInfo)2 S3UploadLogger (jetbrains.buildServer.artifacts.s3.publish.logger.S3UploadLogger)2 PresignedUrlsProviderClientFactory (jetbrains.buildServer.artifacts.s3.publish.presigned.upload.PresignedUrlsProviderClientFactory)2 S3Configuration (org.apache.camel.component.aws.s3.S3Configuration)2 SdkHttpRequest (software.amazon.awssdk.http.SdkHttpRequest)2 Region (software.amazon.awssdk.regions.Region)2 S3Request (software.amazon.awssdk.services.s3.model.S3Request)2 Http (akka.http.scaladsl.Http)1