![JAR search and dependency download from the Maven repository](/logo.png)
org.apache.solr.client.solrj.request.CollectionsApi Maven / Gradle / Ivy
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF 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.apache.solr.client.solrj.request;
import java.util.List;
import java.util.Map;
import org.apache.solr.client.api.model.BalanceShardUniqueRequestBody;
import org.apache.solr.client.api.model.CreateCollectionRequestBody;
import org.apache.solr.client.api.model.CreateCollectionRouterProperties;
import org.apache.solr.client.api.model.ListCollectionsResponse;
import org.apache.solr.client.api.model.ReloadCollectionRequestBody;
import org.apache.solr.client.api.model.RenameCollectionRequestBody;
import org.apache.solr.client.solrj.JacksonContentWriter;
import org.apache.solr.client.solrj.JacksonParsingResponse;
import org.apache.solr.client.solrj.ResponseParser;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.impl.InputStreamResponseParser;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.SolrParams;
// WARNING: This class is generated from a Mustache template; any intended
// changes should be made to the underlying template and not this file directly.
/**
* Experimental SolrRequest's and SolrResponse's for collections, generated from an OAS.
*
* See individual request and response classes for more detailed and relevant information.
*
*
All SolrRequest implementations rely on v2 APIs which may require a SolrClient configured to
* use the '/api' path prefix, instead of '/solr'.
*
* @lucene.experimental
*/
public class CollectionsApi {
public static class BalanceShardUniqueResponse
extends JacksonParsingResponse<
org.apache.solr.client.api.model.SubResponseAccumulatingJerseyResponse> {
public BalanceShardUniqueResponse() {
super(org.apache.solr.client.api.model.SubResponseAccumulatingJerseyResponse.class);
}
}
public static class BalanceShardUnique extends SolrRequest {
private final BalanceShardUniqueRequestBody requestBody;
private final String collectionName;
/**
* Create a BalanceShardUnique request object.
*
* @param collectionName Path param -
*/
public BalanceShardUnique(String collectionName) {
super(
SolrRequest.METHOD.valueOf("POST"),
"/collections/{collectionName}/balance-shard-unique"
.replace("{" + "collectionName" + "}", collectionName));
this.collectionName = collectionName;
this.requestBody = new BalanceShardUniqueRequestBody();
addHeader("Content-type", "application/json");
}
// TODO find a way to add required parameters in the request body to the class constructor
public void setProperty(String property) {
this.requestBody.property = property;
}
// TODO find a way to add required parameters in the request body to the class constructor
public void setOnlyActiveNodes(Boolean onlyActiveNodes) {
this.requestBody.onlyActiveNodes = onlyActiveNodes;
}
// TODO find a way to add required parameters in the request body to the class constructor
public void setShardUnique(Boolean shardUnique) {
this.requestBody.shardUnique = shardUnique;
}
// TODO find a way to add required parameters in the request body to the class constructor
public void setAsync(String async) {
this.requestBody.async = async;
}
@Override
@SuppressWarnings("unchecked")
public RequestWriter.ContentWriter getContentWriter(String expectedType) {
return new JacksonContentWriter(expectedType, requestBody);
}
// TODO Hardcode this for now, but in reality we'll want to parse this out of the Operation data
// somehow
@Override
public String getRequestType() {
return SolrRequestType.ADMIN.toString();
}
@Override
public ApiVersion getApiVersion() {
return ApiVersion.V2;
}
@Override
public SolrParams getParams() {
final ModifiableSolrParams params = new ModifiableSolrParams();
return params;
}
@Override
protected BalanceShardUniqueResponse createResponse(SolrClient client) {
return new BalanceShardUniqueResponse();
}
@Override
public ResponseParser getResponseParser() {
return new InputStreamResponseParser("json");
}
}
public static class CreateCollectionResponse
extends JacksonParsingResponse<
org.apache.solr.client.api.model.SubResponseAccumulatingJerseyResponse> {
public CreateCollectionResponse() {
super(org.apache.solr.client.api.model.SubResponseAccumulatingJerseyResponse.class);
}
}
public static class CreateCollection extends SolrRequest {
private final CreateCollectionRequestBody requestBody;
/** Create a CreateCollection request object. */
public CreateCollection() {
super(SolrRequest.METHOD.valueOf("POST"), "/collections");
this.requestBody = new CreateCollectionRequestBody();
addHeader("Content-type", "application/json");
}
// TODO find a way to add required parameters in the request body to the class constructor
public void setName(String name) {
this.requestBody.name = name;
}
// TODO find a way to add required parameters in the request body to the class constructor
public void setReplicationFactor(Integer replicationFactor) {
this.requestBody.replicationFactor = replicationFactor;
}
// TODO find a way to add required parameters in the request body to the class constructor
public void setConfig(String config) {
this.requestBody.config = config;
}
// TODO find a way to add required parameters in the request body to the class constructor
public void setNumShards(Integer numShards) {
this.requestBody.numShards = numShards;
}
// TODO find a way to add required parameters in the request body to the class constructor
public void setShardNames(List shardNames) {
this.requestBody.shardNames = shardNames;
}
// TODO find a way to add required parameters in the request body to the class constructor
public void setPullReplicas(Integer pullReplicas) {
this.requestBody.pullReplicas = pullReplicas;
}
// TODO find a way to add required parameters in the request body to the class constructor
public void setTlogReplicas(Integer tlogReplicas) {
this.requestBody.tlogReplicas = tlogReplicas;
}
// TODO find a way to add required parameters in the request body to the class constructor
public void setNrtReplicas(Integer nrtReplicas) {
this.requestBody.nrtReplicas = nrtReplicas;
}
// TODO find a way to add required parameters in the request body to the class constructor
public void setWaitForFinalState(Boolean waitForFinalState) {
this.requestBody.waitForFinalState = waitForFinalState;
}
// TODO find a way to add required parameters in the request body to the class constructor
public void setPerReplicaState(Boolean perReplicaState) {
this.requestBody.perReplicaState = perReplicaState;
}
// TODO find a way to add required parameters in the request body to the class constructor
public void setAlias(String alias) {
this.requestBody.alias = alias;
}
// TODO find a way to add required parameters in the request body to the class constructor
public void setProperties(Map properties) {
this.requestBody.properties = properties;
}
// TODO find a way to add required parameters in the request body to the class constructor
public void setAsync(String async) {
this.requestBody.async = async;
}
// TODO find a way to add required parameters in the request body to the class constructor
public void setRouter(CreateCollectionRouterProperties router) {
this.requestBody.router = router;
}
// TODO find a way to add required parameters in the request body to the class constructor
public void setNodeSet(List nodeSet) {
this.requestBody.nodeSet = nodeSet;
}
// TODO find a way to add required parameters in the request body to the class constructor
public void setCreateReplicas(Boolean createReplicas) {
this.requestBody.createReplicas = createReplicas;
}
// TODO find a way to add required parameters in the request body to the class constructor
public void setShuffleNodes(Boolean shuffleNodes) {
this.requestBody.shuffleNodes = shuffleNodes;
}
@Override
@SuppressWarnings("unchecked")
public RequestWriter.ContentWriter getContentWriter(String expectedType) {
return new JacksonContentWriter(expectedType, requestBody);
}
// TODO Hardcode this for now, but in reality we'll want to parse this out of the Operation data
// somehow
@Override
public String getRequestType() {
return SolrRequestType.ADMIN.toString();
}
@Override
public ApiVersion getApiVersion() {
return ApiVersion.V2;
}
@Override
public SolrParams getParams() {
final ModifiableSolrParams params = new ModifiableSolrParams();
return params;
}
@Override
protected CreateCollectionResponse createResponse(SolrClient client) {
return new CreateCollectionResponse();
}
@Override
public ResponseParser getResponseParser() {
return new InputStreamResponseParser("json");
}
}
public static class DeleteCollectionResponse
extends JacksonParsingResponse<
org.apache.solr.client.api.model.SubResponseAccumulatingJerseyResponse> {
public DeleteCollectionResponse() {
super(org.apache.solr.client.api.model.SubResponseAccumulatingJerseyResponse.class);
}
}
public static class DeleteCollection extends SolrRequest {
private final String collectionName;
private Boolean followAliases;
private String async;
/**
* Create a DeleteCollection request object.
*
* @param collectionName Path param - The name of the collection to be deleted.
*/
public DeleteCollection(String collectionName) {
super(
SolrRequest.METHOD.valueOf("DELETE"),
"/collections/{collectionName}".replace("{" + "collectionName" + "}", collectionName));
this.collectionName = collectionName;
}
public void setFollowAliases(Boolean followAliases) {
this.followAliases = followAliases;
}
/**
* @param async An ID to track the request asynchronously
*/
public void setAsync(String async) {
this.async = async;
}
// TODO Hardcode this for now, but in reality we'll want to parse this out of the Operation data
// somehow
@Override
public String getRequestType() {
return SolrRequestType.ADMIN.toString();
}
@Override
public ApiVersion getApiVersion() {
return ApiVersion.V2;
}
@Override
public SolrParams getParams() {
final ModifiableSolrParams params = new ModifiableSolrParams();
if (followAliases != null) {
params.add("followAliases", followAliases.toString());
}
if (async != null) {
params.add("async", async);
}
return params;
}
@Override
protected DeleteCollectionResponse createResponse(SolrClient client) {
return new DeleteCollectionResponse();
}
@Override
public ResponseParser getResponseParser() {
return new InputStreamResponseParser("json");
}
}
public static class ListCollectionsResponse
extends JacksonParsingResponse {
public ListCollectionsResponse() {
super(org.apache.solr.client.api.model.ListCollectionsResponse.class);
}
}
public static class ListCollections extends SolrRequest {
/** Create a ListCollections request object. */
public ListCollections() {
super(SolrRequest.METHOD.valueOf("GET"), "/collections");
}
// TODO Hardcode this for now, but in reality we'll want to parse this out of the Operation data
// somehow
@Override
public String getRequestType() {
return SolrRequestType.ADMIN.toString();
}
@Override
public ApiVersion getApiVersion() {
return ApiVersion.V2;
}
@Override
public SolrParams getParams() {
final ModifiableSolrParams params = new ModifiableSolrParams();
return params;
}
@Override
protected ListCollectionsResponse createResponse(SolrClient client) {
return new ListCollectionsResponse();
}
@Override
public ResponseParser getResponseParser() {
return new InputStreamResponseParser("json");
}
}
public static class ReloadCollectionResponse
extends JacksonParsingResponse<
org.apache.solr.client.api.model.SubResponseAccumulatingJerseyResponse> {
public ReloadCollectionResponse() {
super(org.apache.solr.client.api.model.SubResponseAccumulatingJerseyResponse.class);
}
}
public static class ReloadCollection extends SolrRequest {
private final ReloadCollectionRequestBody requestBody;
private final String collectionName;
/**
* Create a ReloadCollection request object.
*
* @param collectionName Path param -
*/
public ReloadCollection(String collectionName) {
super(
SolrRequest.METHOD.valueOf("POST"),
"/collections/{collectionName}/reload"
.replace("{" + "collectionName" + "}", collectionName));
this.collectionName = collectionName;
this.requestBody = new ReloadCollectionRequestBody();
addHeader("Content-type", "application/json");
}
// TODO find a way to add required parameters in the request body to the class constructor
public void setAsync(String async) {
this.requestBody.async = async;
}
@Override
@SuppressWarnings("unchecked")
public RequestWriter.ContentWriter getContentWriter(String expectedType) {
return new JacksonContentWriter(expectedType, requestBody);
}
// TODO Hardcode this for now, but in reality we'll want to parse this out of the Operation data
// somehow
@Override
public String getRequestType() {
return SolrRequestType.ADMIN.toString();
}
@Override
public ApiVersion getApiVersion() {
return ApiVersion.V2;
}
@Override
public SolrParams getParams() {
final ModifiableSolrParams params = new ModifiableSolrParams();
return params;
}
@Override
protected ReloadCollectionResponse createResponse(SolrClient client) {
return new ReloadCollectionResponse();
}
@Override
public ResponseParser getResponseParser() {
return new InputStreamResponseParser("json");
}
}
public static class RenameCollectionResponse
extends JacksonParsingResponse<
org.apache.solr.client.api.model.SubResponseAccumulatingJerseyResponse> {
public RenameCollectionResponse() {
super(org.apache.solr.client.api.model.SubResponseAccumulatingJerseyResponse.class);
}
}
public static class RenameCollection extends SolrRequest {
private final RenameCollectionRequestBody requestBody;
private final String collectionName;
/**
* Create a RenameCollection request object.
*
* @param collectionName Path param -
*/
public RenameCollection(String collectionName) {
super(
SolrRequest.METHOD.valueOf("POST"),
"/collections/{collectionName}/rename"
.replace("{" + "collectionName" + "}", collectionName));
this.collectionName = collectionName;
this.requestBody = new RenameCollectionRequestBody();
addHeader("Content-type", "application/json");
}
// TODO find a way to add required parameters in the request body to the class constructor
public void setTo(String to) {
this.requestBody.to = to;
}
// TODO find a way to add required parameters in the request body to the class constructor
public void setFollowAliases(Boolean followAliases) {
this.requestBody.followAliases = followAliases;
}
// TODO find a way to add required parameters in the request body to the class constructor
public void setAsync(String async) {
this.requestBody.async = async;
}
@Override
@SuppressWarnings("unchecked")
public RequestWriter.ContentWriter getContentWriter(String expectedType) {
return new JacksonContentWriter(expectedType, requestBody);
}
// TODO Hardcode this for now, but in reality we'll want to parse this out of the Operation data
// somehow
@Override
public String getRequestType() {
return SolrRequestType.ADMIN.toString();
}
@Override
public ApiVersion getApiVersion() {
return ApiVersion.V2;
}
@Override
public SolrParams getParams() {
final ModifiableSolrParams params = new ModifiableSolrParams();
return params;
}
@Override
protected RenameCollectionResponse createResponse(SolrClient client) {
return new RenameCollectionResponse();
}
@Override
public ResponseParser getResponseParser() {
return new InputStreamResponseParser("json");
}
}
}