Search in sources :

Example 1 with HttpResponse

use of com.amazonaws.http.HttpResponse in project beam by apache.

the class AmazonKinesisMock method listShards.

@Override
public ListShardsResult listShards(ListShardsRequest listShardsRequest) {
    if (expectedListShardsLimitExceededException) {
        throw new LimitExceededException("ListShards rate limit exceeded");
    }
    ListShardsResult result = new ListShardsResult();
    List<Shard> shards = IntStream.range(0, shardedData.size()).boxed().map(i -> new Shard().withShardId(Integer.toString(i))).collect(Collectors.toList());
    result.setShards(shards);
    HttpResponse response = new HttpResponse(null, null);
    response.setStatusCode(200);
    result.setSdkHttpMetadata(SdkHttpMetadata.from(response));
    return result;
}
Also used : ListShardsResult(com.amazonaws.services.kinesis.model.ListShardsResult) Shard(com.amazonaws.services.kinesis.model.Shard) AddTagsToStreamResult(com.amazonaws.services.kinesis.model.AddTagsToStreamResult) MergeShardsResult(com.amazonaws.services.kinesis.model.MergeShardsResult) PutRecordsRequest(com.amazonaws.services.kinesis.model.PutRecordsRequest) PutRecordRequest(com.amazonaws.services.kinesis.model.PutRecordRequest) ListTagsForStreamRequest(com.amazonaws.services.kinesis.model.ListTagsForStreamRequest) KinesisProducerConfiguration(com.amazonaws.services.kinesis.producer.KinesisProducerConfiguration) ByteBuffer(java.nio.ByteBuffer) SplitShardRequest(com.amazonaws.services.kinesis.model.SplitShardRequest) GetShardIteratorRequest(com.amazonaws.services.kinesis.model.GetShardIteratorRequest) UpdateShardCountResult(com.amazonaws.services.kinesis.model.UpdateShardCountResult) GetShardIteratorResult(com.amazonaws.services.kinesis.model.GetShardIteratorResult) PutRecordsResult(com.amazonaws.services.kinesis.model.PutRecordsResult) HashCodeBuilder.reflectionHashCode(org.apache.commons.lang.builder.HashCodeBuilder.reflectionHashCode) DescribeStreamResult(com.amazonaws.services.kinesis.model.DescribeStreamResult) ListStreamConsumersRequest(com.amazonaws.services.kinesis.model.ListStreamConsumersRequest) RemoveTagsFromStreamResult(com.amazonaws.services.kinesis.model.RemoveTagsFromStreamResult) UpdateStreamModeRequest(com.amazonaws.services.kinesis.model.UpdateStreamModeRequest) ListShardsResult(com.amazonaws.services.kinesis.model.ListShardsResult) GetRecordsResult(com.amazonaws.services.kinesis.model.GetRecordsResult) StartStreamEncryptionResult(com.amazonaws.services.kinesis.model.StartStreamEncryptionResult) AmazonKinesis(com.amazonaws.services.kinesis.AmazonKinesis) ShardIteratorType(com.amazonaws.services.kinesis.model.ShardIteratorType) HttpResponse(com.amazonaws.http.HttpResponse) ListStreamsResult(com.amazonaws.services.kinesis.model.ListStreamsResult) AmazonKinesisWaiters(com.amazonaws.services.kinesis.waiters.AmazonKinesisWaiters) Math.min(java.lang.Math.min) SdkHttpMetadata(com.amazonaws.http.SdkHttpMetadata) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) Serializable(java.io.Serializable) DescribeStreamConsumerResult(com.amazonaws.services.kinesis.model.DescribeStreamConsumerResult) DecreaseStreamRetentionPeriodResult(com.amazonaws.services.kinesis.model.DecreaseStreamRetentionPeriodResult) List(java.util.List) LimitExceededException(com.amazonaws.services.kinesis.model.LimitExceededException) UpdateShardCountRequest(com.amazonaws.services.kinesis.model.UpdateShardCountRequest) IntStream(java.util.stream.IntStream) ListStreamConsumersResult(com.amazonaws.services.kinesis.model.ListStreamConsumersResult) ListStreamsRequest(com.amazonaws.services.kinesis.model.ListStreamsRequest) DescribeStreamSummaryResult(com.amazonaws.services.kinesis.model.DescribeStreamSummaryResult) Record(com.amazonaws.services.kinesis.model.Record) AddTagsToStreamRequest(com.amazonaws.services.kinesis.model.AddTagsToStreamRequest) EnableEnhancedMonitoringRequest(com.amazonaws.services.kinesis.model.EnableEnhancedMonitoringRequest) AmazonCloudWatch(com.amazonaws.services.cloudwatch.AmazonCloudWatch) DisableEnhancedMonitoringRequest(com.amazonaws.services.kinesis.model.DisableEnhancedMonitoringRequest) ListShardsRequest(com.amazonaws.services.kinesis.model.ListShardsRequest) StartStreamEncryptionRequest(com.amazonaws.services.kinesis.model.StartStreamEncryptionRequest) Splitter(org.apache.beam.vendor.guava.v26_0_jre.com.google.common.base.Splitter) EnableEnhancedMonitoringResult(com.amazonaws.services.kinesis.model.EnableEnhancedMonitoringResult) DescribeStreamRequest(com.amazonaws.services.kinesis.model.DescribeStreamRequest) StopStreamEncryptionResult(com.amazonaws.services.kinesis.model.StopStreamEncryptionResult) IKinesisProducer(com.amazonaws.services.kinesis.producer.IKinesisProducer) CreateStreamRequest(com.amazonaws.services.kinesis.model.CreateStreamRequest) DescribeLimitsRequest(com.amazonaws.services.kinesis.model.DescribeLimitsRequest) DeregisterStreamConsumerRequest(com.amazonaws.services.kinesis.model.DeregisterStreamConsumerRequest) CreateStreamResult(com.amazonaws.services.kinesis.model.CreateStreamResult) RemoveTagsFromStreamRequest(com.amazonaws.services.kinesis.model.RemoveTagsFromStreamRequest) StopStreamEncryptionRequest(com.amazonaws.services.kinesis.model.StopStreamEncryptionRequest) Nullable(org.checkerframework.checker.nullness.qual.Nullable) ListTagsForStreamResult(com.amazonaws.services.kinesis.model.ListTagsForStreamResult) AmazonWebServiceRequest(com.amazonaws.AmazonWebServiceRequest) DecreaseStreamRetentionPeriodRequest(com.amazonaws.services.kinesis.model.DecreaseStreamRetentionPeriodRequest) ResponseMetadata(com.amazonaws.ResponseMetadata) DescribeStreamSummaryRequest(com.amazonaws.services.kinesis.model.DescribeStreamSummaryRequest) PutRecordResult(com.amazonaws.services.kinesis.model.PutRecordResult) UpdateStreamModeResult(com.amazonaws.services.kinesis.model.UpdateStreamModeResult) DeleteStreamResult(com.amazonaws.services.kinesis.model.DeleteStreamResult) IncreaseStreamRetentionPeriodRequest(com.amazonaws.services.kinesis.model.IncreaseStreamRetentionPeriodRequest) MergeShardsRequest(com.amazonaws.services.kinesis.model.MergeShardsRequest) DescribeStreamConsumerRequest(com.amazonaws.services.kinesis.model.DescribeStreamConsumerRequest) Integer.parseInt(java.lang.Integer.parseInt) DeregisterStreamConsumerResult(com.amazonaws.services.kinesis.model.DeregisterStreamConsumerResult) RegisterStreamConsumerResult(com.amazonaws.services.kinesis.model.RegisterStreamConsumerResult) IncreaseStreamRetentionPeriodResult(com.amazonaws.services.kinesis.model.IncreaseStreamRetentionPeriodResult) Mockito(org.mockito.Mockito) Lists.transform(org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.Lists.transform) EqualsBuilder(org.apache.commons.lang.builder.EqualsBuilder) Instant(org.joda.time.Instant) GetRecordsRequest(com.amazonaws.services.kinesis.model.GetRecordsRequest) DeleteStreamRequest(com.amazonaws.services.kinesis.model.DeleteStreamRequest) SplitShardResult(com.amazonaws.services.kinesis.model.SplitShardResult) Region(com.amazonaws.regions.Region) DescribeLimitsResult(com.amazonaws.services.kinesis.model.DescribeLimitsResult) DisableEnhancedMonitoringResult(com.amazonaws.services.kinesis.model.DisableEnhancedMonitoringResult) RegisterStreamConsumerRequest(com.amazonaws.services.kinesis.model.RegisterStreamConsumerRequest) HttpResponse(com.amazonaws.http.HttpResponse) LimitExceededException(com.amazonaws.services.kinesis.model.LimitExceededException) Shard(com.amazonaws.services.kinesis.model.Shard)

Example 2 with HttpResponse

use of com.amazonaws.http.HttpResponse in project beam by apache.

the class PublishResultCodersTest method buildFullPublishResult.

private PublishResult buildFullPublishResult() {
    PublishResult publishResult = new PublishResult().withMessageId(UUID.randomUUID().toString());
    publishResult.setSdkResponseMetadata(new ResponseMetadata(ImmutableMap.of(ResponseMetadata.AWS_REQUEST_ID, UUID.randomUUID().toString())));
    HttpResponse httpResponse = new HttpResponse(null, null);
    httpResponse.setStatusCode(200);
    httpResponse.addHeader("Content-Type", "application/json");
    publishResult.setSdkHttpMetadata(SdkHttpMetadata.from(httpResponse));
    return publishResult;
}
Also used : PublishResult(com.amazonaws.services.sns.model.PublishResult) HttpResponse(com.amazonaws.http.HttpResponse) ResponseMetadata(com.amazonaws.ResponseMetadata)

Example 3 with HttpResponse

use of com.amazonaws.http.HttpResponse in project sandbox by irof.

the class AmazonHttpClientTest method sendRequest.

private void sendRequest(Supplier<AmazonHttpClient> client) {
    Request<?> request = new DefaultRequest<>("test-service");
    request.setEndpoint(server.getUri());
    InputStream in = new ByteArrayInputStream("hoge".getBytes(StandardCharsets.UTF_8));
    request.setContent(in);
    client.get().execute(request, new HttpResponseHandler<AmazonWebServiceResponse<Object>>() {

        @Override
        public AmazonWebServiceResponse<Object> handle(HttpResponse response) throws Exception {
            return new AmazonWebServiceResponse<>();
        }

        @Override
        public boolean needsConnectionLeftOpen() {
            return false;
        }
    }, new HttpResponseHandler<AmazonServiceException>() {

        @Override
        public AmazonServiceException handle(HttpResponse response) throws Exception {
            return null;
        }

        @Override
        public boolean needsConnectionLeftOpen() {
            return false;
        }
    }, new ExecutionContext());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) HttpResponse(com.amazonaws.http.HttpResponse) ExecutionContext(com.amazonaws.http.ExecutionContext) ByteArrayInputStream(java.io.ByteArrayInputStream)

Example 4 with HttpResponse

use of com.amazonaws.http.HttpResponse in project beam by apache.

the class AwsCodersTest method buildSdkHttpMetadata.

private SdkHttpMetadata buildSdkHttpMetadata() {
    HttpResponse httpResponse = new HttpResponse(null, null);
    httpResponse.setStatusCode(200);
    httpResponse.addHeader("Content-Type", "application/json");
    return SdkHttpMetadata.from(httpResponse);
}
Also used : HttpResponse(com.amazonaws.http.HttpResponse)

Aggregations

HttpResponse (com.amazonaws.http.HttpResponse)4 ResponseMetadata (com.amazonaws.ResponseMetadata)2 AmazonWebServiceRequest (com.amazonaws.AmazonWebServiceRequest)1 ExecutionContext (com.amazonaws.http.ExecutionContext)1 SdkHttpMetadata (com.amazonaws.http.SdkHttpMetadata)1 Region (com.amazonaws.regions.Region)1 AmazonCloudWatch (com.amazonaws.services.cloudwatch.AmazonCloudWatch)1 AmazonKinesis (com.amazonaws.services.kinesis.AmazonKinesis)1 AddTagsToStreamRequest (com.amazonaws.services.kinesis.model.AddTagsToStreamRequest)1 AddTagsToStreamResult (com.amazonaws.services.kinesis.model.AddTagsToStreamResult)1 CreateStreamRequest (com.amazonaws.services.kinesis.model.CreateStreamRequest)1 CreateStreamResult (com.amazonaws.services.kinesis.model.CreateStreamResult)1 DecreaseStreamRetentionPeriodRequest (com.amazonaws.services.kinesis.model.DecreaseStreamRetentionPeriodRequest)1 DecreaseStreamRetentionPeriodResult (com.amazonaws.services.kinesis.model.DecreaseStreamRetentionPeriodResult)1 DeleteStreamRequest (com.amazonaws.services.kinesis.model.DeleteStreamRequest)1 DeleteStreamResult (com.amazonaws.services.kinesis.model.DeleteStreamResult)1 DeregisterStreamConsumerRequest (com.amazonaws.services.kinesis.model.DeregisterStreamConsumerRequest)1 DeregisterStreamConsumerResult (com.amazonaws.services.kinesis.model.DeregisterStreamConsumerResult)1 DescribeLimitsRequest (com.amazonaws.services.kinesis.model.DescribeLimitsRequest)1 DescribeLimitsResult (com.amazonaws.services.kinesis.model.DescribeLimitsResult)1