Example usage for com.amazonaws.http HttpResponse setStatusCode

List of usage examples for com.amazonaws.http HttpResponse setStatusCode

Introduction

In this page you can find the example usage for com.amazonaws.http HttpResponse setStatusCode.

Prototype

public void setStatusCode(int statusCode) 

Source Link

Document

Sets the HTTP status code that was returned with this response.

Usage

From source file:org.apache.beam.sdk.io.kinesis.AmazonKinesisMock.java

License:Apache License

@Override
public DescribeStreamResult describeStream(String streamName, String exclusiveStartShardId) {
    int nextShardId = 0;
    if (exclusiveStartShardId != null) {
        nextShardId = parseInt(exclusiveStartShardId) + 1;
    }//from ww  w  .j  a  va  2s  .  c o  m
    boolean hasMoreShards = nextShardId + 1 < shardedData.size();

    List<Shard> shards = new ArrayList<>();
    if (nextShardId < shardedData.size()) {
        shards.add(new Shard().withShardId(Integer.toString(nextShardId)));
    }

    HttpResponse response = new HttpResponse(null, null);
    response.setStatusCode(200);
    DescribeStreamResult result = new DescribeStreamResult();
    result.setSdkHttpMetadata(SdkHttpMetadata.from(response));
    result.withStreamDescription(new StreamDescription().withHasMoreShards(hasMoreShards).withShards(shards)
            .withStreamName(streamName));
    return result;
}