forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add high-level REST client API for
_freeze
and _unfreeze
This change adds support for `_freeze` and `_unfreeze` to the HLRC Relates to elastic#34352
- Loading branch information
Showing
7 changed files
with
222 additions
and
1 deletion.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
client/rest-high-level/src/main/java/org/elasticsearch/client/FreezeIndexRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.elasticsearch.client; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* Request for the _freeze index API | ||
*/ | ||
public final class FreezeIndexRequest implements Validatable { | ||
|
||
private final String indices; | ||
|
||
/** | ||
* Creates a new freeze index request | ||
* @param indices the index to freeze | ||
*/ | ||
public FreezeIndexRequest(String indices) { | ||
this.indices = Objects.requireNonNull(indices); | ||
} | ||
|
||
/** | ||
* Returns the indices to freeze | ||
*/ | ||
public String getIndices() { | ||
return indices; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
client/rest-high-level/src/main/java/org/elasticsearch/client/ShardAcknowledgedResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.elasticsearch.client; | ||
|
||
import org.elasticsearch.client.core.AcknowledgedResponse; | ||
import org.elasticsearch.common.ParseField; | ||
import org.elasticsearch.common.xcontent.ConstructingObjectParser; | ||
import org.elasticsearch.common.xcontent.XContentParser; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.elasticsearch.common.xcontent.ConstructingObjectParser.constructorArg; | ||
|
||
public class ShardAcknowledgedResponse extends AcknowledgedResponse implements Validatable { | ||
|
||
private static ConstructingObjectParser<ShardAcknowledgedResponse, Void> buildParser() { | ||
|
||
ConstructingObjectParser<ShardAcknowledgedResponse, Void> p = new ConstructingObjectParser<>("freeze", true, | ||
args -> new ShardAcknowledgedResponse((boolean) args[0], (boolean) args[1])); | ||
p.declareBoolean(constructorArg(), new ParseField(AcknowledgedResponse.PARSE_FIELD_NAME)); | ||
p.declareBoolean(constructorArg(), new ParseField("shards_acknowledged")); | ||
return p; | ||
} | ||
|
||
private static final ConstructingObjectParser<ShardAcknowledgedResponse, Void> PARSER = buildParser(); | ||
|
||
private final boolean shardsAcknowledged; | ||
|
||
public ShardAcknowledgedResponse(boolean acknowledged, boolean shardsAcknowledged) { | ||
super(acknowledged); | ||
this.shardsAcknowledged = shardsAcknowledged; | ||
} | ||
|
||
public boolean isShardsAcknowledged() { | ||
return shardsAcknowledged; | ||
} | ||
|
||
public static ShardAcknowledgedResponse fromXContent(XContentParser parser) throws IOException { | ||
return PARSER.parse(parser, null); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
client/rest-high-level/src/main/java/org/elasticsearch/client/UnfreezeIndexRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.elasticsearch.client; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* Request for the _unfreeze index API | ||
*/ | ||
public final class UnfreezeIndexRequest implements Validatable { | ||
|
||
private final String indices; | ||
|
||
/** | ||
* Creates a new unfreeze index request | ||
* @param indices the index to unfreeze | ||
*/ | ||
public UnfreezeIndexRequest(String indices) { | ||
this.indices = Objects.requireNonNull(indices); | ||
} | ||
|
||
/** | ||
* Returns the indices to unfreeze | ||
*/ | ||
public String getIndices() { | ||
return indices; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters