Skip to content

Commit

Permalink
SOLR-16825: Migrate v2 API definitions to 'api' module, pt 8 (apache#…
Browse files Browse the repository at this point in the history
…2833)

SOLR-16825 added a new gradle module, 'api', which holds v2 API
definitions as interfaces.  This allows us to generate an OAS (and other
artifacts) as a part of the solrj build.  But these artifacts only cover
the v2 APIs present in the 'api' module.

This commit moves v2 API defining annotations to new interfaces in the
'api' module for several "schema", "replication", and "logging" APIs as
well as 'create-alias'.  This APIs are all now reflected in our OAS and
generated artifacts.
  • Loading branch information
gerlowskija authored Nov 12, 2024
1 parent 139351a commit eef9bbc
Show file tree
Hide file tree
Showing 44 changed files with 1,236 additions and 580 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* 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.api.endpoint;

import io.swagger.v3.oas.annotations.Operation;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import org.apache.solr.client.api.model.CreateAliasRequestBody;
import org.apache.solr.client.api.model.SolrJerseyResponse;

@Path("/aliases")
public interface CreateAliasApi {
@POST
@Operation(
summary = "Create a traditional or 'routed' alias",
tags = {"aliases"})
SolrJerseyResponse createAlias(CreateAliasRequestBody requestBody) throws Exception;
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,16 @@
import jakarta.ws.rs.DefaultValue;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.QueryParam;
import org.apache.solr.client.api.model.SchemaGetDynamicFieldInfoResponse;
import org.apache.solr.client.api.model.SchemaGetFieldInfoResponse;
import org.apache.solr.client.api.model.SchemaGetFieldTypeInfoResponse;
import org.apache.solr.client.api.model.SchemaInfoResponse;
import org.apache.solr.client.api.model.SchemaListCopyFieldsResponse;
import org.apache.solr.client.api.model.SchemaListDynamicFieldsResponse;
import org.apache.solr.client.api.model.SchemaListFieldTypesResponse;
import org.apache.solr.client.api.model.SchemaListFieldsResponse;
import org.apache.solr.client.api.model.SchemaNameResponse;
import org.apache.solr.client.api.model.SchemaSimilarityResponse;
import org.apache.solr.client.api.model.SchemaUniqueKeyResponse;
Expand All @@ -34,6 +42,67 @@
@Path(INDEX_PATH_PREFIX + "/schema")
public interface GetSchemaApi {

@Path(INDEX_PATH_PREFIX + "/schema")
interface Fields {

@GET
@Path("/fields")
@StoreApiParameters
@Operation(
summary = "List all non-dynamic fields in the schema of the specified core or collection",
tags = {"schema"})
SchemaListFieldsResponse listSchemaFields();

@GET
@Path("/fields/{fieldName}")
@StoreApiParameters
@Operation(
summary = "Get detailed info about a single non-dynamic field",
tags = {"schema"})
SchemaGetFieldInfoResponse getFieldInfo(@PathParam("fieldName") String fieldName);

@GET
@Path("/copyfields")
@StoreApiParameters
@Operation(
summary = "List all copy-fields in the schema of the specified core or collection",
tags = {"schema"})
SchemaListCopyFieldsResponse listCopyFields();

@GET
@Path("/dynamicfields")
@StoreApiParameters
@Operation(
summary = "List all dynamic-fields in the schema of the specified core or collection",
tags = {"schema"})
SchemaListDynamicFieldsResponse listDynamicFields();

@GET
@Path("/dynamicfields/{fieldName}")
@StoreApiParameters
@Operation(
summary = "Get detailed info about a single dynamic field",
tags = {"schema"})
SchemaGetDynamicFieldInfoResponse getDynamicFieldInfo(@PathParam("fieldName") String fieldName);

@GET
@Path("/fieldtypes")
@StoreApiParameters
@Operation(
summary = "List all field types in the schema used by the specified core or collection",
tags = {"schema"})
SchemaListFieldTypesResponse listSchemaFieldTypes();

@GET
@Path("/fieldtypes/{fieldTypeName}")
@StoreApiParameters
@Operation(
summary = "Get detailed info about a single field type",
tags = {"schema"})
SchemaGetFieldTypeInfoResponse getFieldTypeInfo(
@PathParam("fieldTypeName") String fieldTypeName);
}

@GET
@StoreApiParameters
@Operation(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* 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.api.endpoint;

import io.swagger.v3.oas.annotations.Operation;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.PUT;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.QueryParam;
import java.util.List;
import org.apache.solr.client.api.model.ListLevelsResponse;
import org.apache.solr.client.api.model.LogLevelChange;
import org.apache.solr.client.api.model.LogMessagesResponse;
import org.apache.solr.client.api.model.LoggingResponse;
import org.apache.solr.client.api.model.SetThresholdRequestBody;

@Path("/node/logging")
public interface NodeLoggingApis {

@GET
@Path("/levels")
@Operation(
summary = "List all log-levels for the target node.",
tags = {"logging"})
ListLevelsResponse listAllLoggersAndLevels();

@PUT
@Path("/levels")
@Operation(
summary = "Set one or more logger levels on the target node.",
tags = {"logging"})
LoggingResponse modifyLocalLogLevel(List<LogLevelChange> requestBody);

@GET
@Path("/messages")
@Operation(
summary = "Fetch recent log messages on the targeted node.",
tags = {"logging"})
LogMessagesResponse fetchLocalLogMessages(@QueryParam("since") Long boundingTimeMillis);

@PUT
@Path("/messages/threshold")
@Operation(
summary = "Set a threshold level for the targeted node's log message watcher.",
tags = {"logging"})
LoggingResponse setMessageThreshold(SetThresholdRequestBody requestBody);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* 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.api.endpoint;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.QueryParam;
import java.io.IOException;
import org.apache.solr.client.api.model.FileListResponse;
import org.apache.solr.client.api.model.IndexVersionResponse;
import org.apache.solr.client.api.util.CoreApiParameters;

@Path("/cores/{coreName}/replication")
public interface ReplicationApis {

@GET
@CoreApiParameters
@Path("/indexversion")
@Operation(
summary = "Return the index version of the specified core.",
tags = {"replication"})
IndexVersionResponse fetchIndexVersion() throws IOException;

@GET
@CoreApiParameters
@Path("/files")
@Operation(
summary = "Return the list of index file that make up the specified core.",
tags = {"replication"})
FileListResponse fetchFileList(
@Parameter(description = "The generation number of the index", required = true)
@QueryParam("generation")
long gen);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* 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.api.model;

import com.fasterxml.jackson.annotation.JsonProperty;

public class CategoryRoutedAliasProperties extends RoutedAliasProperties {
@JsonProperty("maxCardinality")
public Long maxCardinality;

@JsonProperty("mustMatch")
public String mustMatch;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* 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.api.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.List;

public class CreateAliasRequestBody {
@JsonProperty(required = true)
public String name;

@JsonProperty("collections")
public List<String> collections;

@JsonProperty("async")
public String async;

@JsonProperty("routers")
public List<RoutedAliasProperties> routers;

@Schema(
description =
"Parameters to be used for any collections created by this alias. Only used for 'routed' aliases",
name = "collCreationParameters")
@JsonProperty("create-collection")
public CreateCollectionRequestBody collCreationParameters;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* 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.api.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

/** Response body for the `GET /api/cores/coreName/replication/files` API */
public class FileListResponse extends SolrJerseyResponse {
@JsonProperty("filelist")
public List<FileMetaData> fileList;

@JsonProperty("confFiles")
public List<FileMetaData> confFiles;

@JsonProperty("status")
public String status;

@JsonProperty("message")
public String message;

@JsonProperty("exception")
public Exception exception;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* 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.api.model;

import com.fasterxml.jackson.annotation.JsonProperty;

public class FileMetaData {

@JsonProperty("size")
public long size;

@JsonProperty("name")
public String name;

@JsonProperty("checksum")
public long checksum;

@JsonProperty("alias")
public String alias;

public FileMetaData() {}

public FileMetaData(long size, String name, long checksum) {
this.size = size;
this.name = name;
this.checksum = checksum;
}
}
Loading

0 comments on commit eef9bbc

Please sign in to comment.