Skip to content

Commit

Permalink
change in update pit response
Browse files Browse the repository at this point in the history
  • Loading branch information
Arpit-Bandejiya committed Nov 26, 2022
1 parent 2a2c038 commit 555d8ba
Showing 1 changed file with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@

import java.io.IOException;

import static org.opensearch.common.xcontent.XContentParserUtils.ensureExpectedToken;
import static org.opensearch.rest.RestStatus.OK;

public class UpdatePitResponse extends ActionResponse implements StatusToXContentObject {

private static final ParseField ID = new ParseField("pit_id");
private static final ParseField CREATION_TIME = new ParseField("creation_time");
private static final ParseField EXPIRY_TIME = new ParseField("expiry_time");
private static final ParseField SUCCESS_FULL = new ParseField("successfull");

private final String id;
private final int totalShards;
Expand Down Expand Up @@ -78,11 +78,28 @@ public UpdatePitResponse(
this.shardFailures = shardFailures;
}

public static CreatePitResponse fromXContent(XContentParser parser) throws IOException{
ensureExpectedToken(XContentParser.Token.START_OBJECT, parser.nextToken(), parser);
parser.nextToken();
return innerFromXContent(parser);
}

public static CreatePitResponse innerFromXContent(XContentParser parser) throws IOException {

}
@Override
public void writeTo(StreamOutput out) throws IOException{
out.writeString(id);
out.writeVInt(totalShards);
out.writeVInt(successfulShards);
out.writeVInt(failedShards);
out.writeVInt(skippedShards);
out.writeLong(creationTime);
out.writeLong(expiryTime);
out.writeVInt(shardFailures.length);
for (ShardSearchFailure shardSearchFailure : shardFailures) {
shardSearchFailure.writeTo(out);
}
}

@Override
Expand All @@ -98,6 +115,8 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
getFailedShards(),
getShardFailures()
);
builder.field(CREATION_TIME.getPreferredName(), creationTime);
builder.field(EXPIRY_TIME.getPreferredName(), expiryTime);
builder.endObject();
return builder;
}
Expand Down

0 comments on commit 555d8ba

Please sign in to comment.