From 53a5413171c80a2ac02f8141d76a61fc3c56fdf8 Mon Sep 17 00:00:00 2001 From: Fanis Tharropoulos Date: Thu, 11 Jun 2026 16:35:18 +0300 Subject: [PATCH 1/6] feat(docgen): add docgen generator --- generator/build.gradle | 29 + generator/settings.gradle | 1 + .../java/org/typesense/docgen/DocGen.java | 515 ++++++++++++++++++ 3 files changed, 545 insertions(+) create mode 100644 generator/build.gradle create mode 100644 generator/settings.gradle create mode 100644 generator/src/main/java/org/typesense/docgen/DocGen.java diff --git a/generator/build.gradle b/generator/build.gradle new file mode 100644 index 0000000..ee27e04 --- /dev/null +++ b/generator/build.gradle @@ -0,0 +1,29 @@ +plugins { + id 'java' + id 'application' +} + +repositories { + mavenCentral() +} + +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} + +dependencies { + implementation 'com.github.javaparser:javaparser-core:3.25.10' + implementation 'org.yaml:snakeyaml:2.2' +} + +application { + mainClass = 'org.typesense.docgen.DocGen' +} + +tasks.named('run') { + // Pass spec + wrapper dir via -PspecPath / -PwrapperDir or rely on defaults. + def specPath = project.findProperty('specPath') ?: "${rootDir}/../../api-spec/openapi.yml" + def wrapperDir = project.findProperty('wrapperDir') ?: "${rootDir}/../src/main/java/org/typesense/api" + args = [specPath, wrapperDir] +} diff --git a/generator/settings.gradle b/generator/settings.gradle new file mode 100644 index 0000000..23e9207 --- /dev/null +++ b/generator/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'typesense-java-docgen' diff --git a/generator/src/main/java/org/typesense/docgen/DocGen.java b/generator/src/main/java/org/typesense/docgen/DocGen.java new file mode 100644 index 0000000..e55d958 --- /dev/null +++ b/generator/src/main/java/org/typesense/docgen/DocGen.java @@ -0,0 +1,515 @@ +package org.typesense.docgen; + +import com.github.javaparser.StaticJavaParser; +import com.github.javaparser.ast.CompilationUnit; +import com.github.javaparser.ast.NodeList; +import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; +import com.github.javaparser.ast.body.ConstructorDeclaration; +import com.github.javaparser.ast.body.FieldDeclaration; +import com.github.javaparser.ast.body.MethodDeclaration; +import com.github.javaparser.ast.body.Parameter; +import com.github.javaparser.ast.body.VariableDeclarator; +import com.github.javaparser.ast.expr.AssignExpr; +import com.github.javaparser.ast.expr.BinaryExpr; +import com.github.javaparser.ast.expr.ConditionalExpr; +import com.github.javaparser.ast.expr.EnclosedExpr; +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.expr.FieldAccessExpr; +import com.github.javaparser.ast.expr.MethodCallExpr; +import com.github.javaparser.ast.expr.NameExpr; +import com.github.javaparser.ast.expr.StringLiteralExpr; +import com.github.javaparser.ast.expr.ThisExpr; +import com.github.javaparser.ast.stmt.ReturnStmt; +import com.github.javaparser.printer.lexicalpreservation.LexicalPreservingPrinter; +import org.yaml.snakeyaml.Yaml; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public final class DocGen { + + private static final String DOCS_BASE_URL = "https://typesense.org/docs/latest/api/"; + + private static final Map TAG_TO_DOCS; + static { + TAG_TO_DOCS = new HashMap(); + TAG_TO_DOCS.put("collections", "collections.html"); + TAG_TO_DOCS.put("documents", "documents.html"); + TAG_TO_DOCS.put("keys", "api-keys.html"); + TAG_TO_DOCS.put("aliases", "collection-alias.html"); + TAG_TO_DOCS.put("synonyms", "synonyms.html"); + TAG_TO_DOCS.put("curation_sets", "curation.html"); + TAG_TO_DOCS.put("stopwords", "stopwords.html"); + TAG_TO_DOCS.put("presets", "search.html#presets"); + TAG_TO_DOCS.put("analytics", "analytics-query-suggestions.html"); + TAG_TO_DOCS.put("conversations", "conversational-search-rag.html"); + TAG_TO_DOCS.put("stemming", "stemming.html"); + TAG_TO_DOCS.put("nl_search_models", "natural-language-search.html"); + TAG_TO_DOCS.put("debug", "cluster-operations.html#debug"); + TAG_TO_DOCS.put("health", "cluster-operations.html#health"); + TAG_TO_DOCS.put("operations", "cluster-operations.html"); + } + + private static final Set VERBS = new HashSet( + Arrays.asList("get", "post", "put", "patch", "delete")); + + public static void main(String[] args) throws Exception { + if (args.length < 2) { + System.err.println("usage: DocGen "); + System.exit(2); + } + Path specPath = Paths.get(args[0]); + Path wrapperDir = Paths.get(args[1]); + + Map opIndex = loadOpIndex(specPath); + System.out.println("docgen: loaded " + opIndex.size() + " operations from spec"); + + List files; + Stream s = Files.list(wrapperDir); + try { + files = s.filter(p -> p.toString().endsWith(".java")) + .sorted() + .collect(Collectors.toList()); + } finally { + s.close(); + } + + Registry registry = new Registry(); + Map parsed = new LinkedHashMap(); + for (Path f : files) { + CompilationUnit cu = StaticJavaParser.parse(f); + LexicalPreservingPrinter.setup(cu); + parsed.put(f, cu); + indexUnit(cu, registry); + } + + int touched = 0; + for (Map.Entry e : parsed.entrySet()) { + Path f = e.getKey(); + CompilationUnit cu = e.getValue(); + boolean changed = annotateUnit(cu, registry, opIndex); + if (changed) { + String out = LexicalPreservingPrinter.print(cu); + Files.write(f, out.getBytes()); + touched++; + System.out.println("docgen: updated " + f.getFileName()); + } + } + System.out.println("docgen: " + touched + " wrapper file(s) updated"); + } + + static final class OpInfo { + final String operationId; + final String method; + final String path; + final String summary; + final String description; + final String tag; + + OpInfo(String operationId, String method, String path, String summary, String description, String tag) { + this.operationId = operationId; + this.method = method; + this.path = path; + this.summary = summary == null ? "" : summary.trim(); + this.description = description == null ? "" : description.trim(); + this.tag = tag == null ? "" : tag; + } + } + + @SuppressWarnings("unchecked") + private static Map loadOpIndex(Path specPath) throws IOException { + Yaml yaml = new Yaml(); + Object root; + InputStream in = Files.newInputStream(specPath); + try { + root = yaml.load(in); + } finally { + in.close(); + } + if (!(root instanceof Map)) { + throw new IOException("spec root is not a map"); + } + Map spec = (Map) root; + Object pathsObj = spec.get("paths"); + if (!(pathsObj instanceof Map)) { + throw new IOException("spec missing paths"); + } + Map ops = new LinkedHashMap(); + for (Map.Entry e : ((Map) pathsObj).entrySet()) { + String path = e.getKey(); + if (!(e.getValue() instanceof Map)) continue; + Map item = (Map) e.getValue(); + for (Map.Entry me : item.entrySet()) { + String method = me.getKey().toLowerCase(Locale.ROOT); + if (!VERBS.contains(method)) continue; + if (!(me.getValue() instanceof Map)) continue; + Map op = (Map) me.getValue(); + String opId = stringOrEmpty(op.get("operationId")); + String summary = stringOrEmpty(op.get("summary")); + String description = stringOrEmpty(op.get("description")); + String tag = ""; + Object tagsObj = op.get("tags"); + if (tagsObj instanceof List && !((List) tagsObj).isEmpty()) { + Object t = ((List) tagsObj).get(0); + if (t != null) tag = t.toString(); + } + String key = method.toUpperCase(Locale.ROOT) + " " + normalizePath(path); + ops.put(key, new OpInfo(opId, method.toUpperCase(Locale.ROOT), path, summary, description, tag)); + } + } + return ops; + } + + private static String stringOrEmpty(Object o) { + return o == null ? "" : o.toString(); + } + + static final class Registry { + final Map constants = new HashMap(); + final Map helpers = new HashMap(); + final Map instanceFields = new HashMap(); + } + + private static void indexUnit(CompilationUnit cu, Registry reg) { + for (ClassOrInterfaceDeclaration cls : cu.findAll(ClassOrInterfaceDeclaration.class)) { + String name = cls.getNameAsString(); + for (FieldDeclaration fd : cls.getFields()) { + for (VariableDeclarator vd : fd.getVariables()) { + if (!"String".equals(vd.getTypeAsString())) continue; + Optional init = vd.getInitializer(); + if (!init.isPresent()) continue; + Expression e = init.get(); + if (e instanceof StringLiteralExpr) { + reg.constants.put(name + "." + vd.getNameAsString(), + ((StringLiteralExpr) e).asString()); + } + } + } + for (MethodDeclaration m : cls.getMethods()) { + if (!"String".equals(m.getTypeAsString())) continue; + reg.helpers.put(name + "." + m.getNameAsString(), m); + } + for (ConstructorDeclaration c : cls.getConstructors()) { + List assigns = c.getBody().findAll(AssignExpr.class); + for (AssignExpr ae : assigns) { + Expression target = ae.getTarget(); + if (target instanceof FieldAccessExpr) { + FieldAccessExpr fae = (FieldAccessExpr) target; + if (fae.getScope() instanceof ThisExpr) { + reg.instanceFields.put(name + "." + fae.getNameAsString(), ae.getValue()); + } + } else if (target instanceof NameExpr) { + NameExpr ne = (NameExpr) target; + reg.instanceFields.put(name + "." + ne.getNameAsString(), ae.getValue()); + } + } + } + } + } + + private static boolean annotateUnit(CompilationUnit cu, Registry reg, Map ops) { + boolean changed = false; + for (ClassOrInterfaceDeclaration cls : cu.findAll(ClassOrInterfaceDeclaration.class)) { + String className = cls.getNameAsString(); + for (MethodDeclaration m : cls.getMethods()) { + if (!m.getBody().isPresent()) continue; + ApiCallSite site = findUniqueApiCall(m); + if (site == null) continue; + String resolved = resolvePath(site.pathArg, className, m, reg); + if (resolved == null) { + System.out.println("docgen: cannot resolve path for " + className + "." + m.getNameAsString()); + continue; + } + String key = site.verb + " " + normalizePath(resolved); + OpInfo op = ops.get(key); + if (op == null) { + System.out.println("docgen: no spec match for " + className + "." + m.getNameAsString() + + " -> " + key); + continue; + } + if (writeJavadoc(m, op)) { + changed = true; + } + } + } + return changed; + } + + static final class ApiCallSite { + final String verb; + final Expression pathArg; + + ApiCallSite(String verb, Expression pathArg) { + this.verb = verb; + this.pathArg = pathArg; + } + } + + private static ApiCallSite findUniqueApiCall(MethodDeclaration m) { + List all = m.getBody().get().findAll(MethodCallExpr.class); + List calls = new ArrayList(); + for (MethodCallExpr c : all) { + if (isApiCall(c)) calls.add(c); + } + if (calls.size() != 1) return null; + MethodCallExpr call = calls.get(0); + String verb = call.getNameAsString().toUpperCase(Locale.ROOT); + if (call.getArguments().isEmpty()) return null; + return new ApiCallSite(verb, call.getArgument(0)); + } + + private static boolean isApiCall(MethodCallExpr call) { + if (!VERBS.contains(call.getNameAsString())) return false; + Optional scope = call.getScope(); + if (!scope.isPresent()) return false; + Expression s = scope.get(); + if (s instanceof NameExpr) { + return "apiCall".equals(((NameExpr) s).getNameAsString()); + } + if (s instanceof FieldAccessExpr) { + return "apiCall".equals(((FieldAccessExpr) s).getNameAsString()); + } + return false; + } + + + private static String resolvePath(Expression expr, String className, MethodDeclaration owner, Registry reg) { + return resolve(expr, className, new HashMap(), reg, 0, owner); + } + + private static String resolve(Expression expr, String className, Map scope, Registry reg, + int depth, MethodDeclaration owner) { + if (depth > 8) return null; + if (expr instanceof EnclosedExpr) { + return resolve(((EnclosedExpr) expr).getInner(), className, scope, reg, depth + 1, owner); + } + if (expr instanceof StringLiteralExpr) { + return ((StringLiteralExpr) expr).asString(); + } + if (expr instanceof BinaryExpr) { + BinaryExpr be = (BinaryExpr) expr; + if (be.getOperator() == BinaryExpr.Operator.PLUS) { + String l = resolve(be.getLeft(), className, scope, reg, depth + 1, owner); + String r = resolve(be.getRight(), className, scope, reg, depth + 1, owner); + if (l == null || r == null) return null; + return l + r; + } + return null; + } + if (expr instanceof NameExpr) { + String n = ((NameExpr) expr).getNameAsString(); + if (scope.containsKey(n)) return scope.get(n); + String fq = className + "." + n; + if (reg.constants.containsKey(fq)) return reg.constants.get(fq); + if (owner != null) { + for (Parameter p : owner.getParameters()) { + if (p.getNameAsString().equals(n)) return "{" + n + "}"; + } + } + if (reg.instanceFields.containsKey(fq)) { + return resolve(reg.instanceFields.get(fq), className, scope, reg, depth + 1, owner); + } + return null; + } + if (expr instanceof FieldAccessExpr) { + FieldAccessExpr fae = (FieldAccessExpr) expr; + if (fae.getScope() instanceof NameExpr) { + String fq = ((NameExpr) fae.getScope()).getNameAsString() + "." + fae.getNameAsString(); + if (reg.constants.containsKey(fq)) return reg.constants.get(fq); + } + if (fae.getScope() instanceof ThisExpr) { + String fq = className + "." + fae.getNameAsString(); + Expression init = reg.instanceFields.get(fq); + if (init == null) return "{" + fae.getNameAsString() + "}"; + // Field assigned directly from a ctor param (e.g. this.id = id) -> placeholder. + if (init instanceof NameExpr) return "{" + fae.getNameAsString() + "}"; + return resolve(init, className, scope, reg, depth + 1, owner); + } + return null; + } + if (expr instanceof ConditionalExpr) { + ConditionalExpr ce = (ConditionalExpr) expr; + String t = resolve(ce.getThenExpr(), className, scope, reg, depth + 1, owner); + String el = resolve(ce.getElseExpr(), className, scope, reg, depth + 1, owner); + if (!isEmpty(el) && isEmpty(t)) return el; + if (!isEmpty(t) && isEmpty(el)) return t; + if (t != null && t.indexOf('{') >= 0) return t; + if (el != null && el.indexOf('{') >= 0) return el; + return t != null ? t : el; + } + if (expr instanceof MethodCallExpr) { + MethodCallExpr mc = (MethodCallExpr) expr; + String name = mc.getNameAsString(); + if ("encodeURIComponent".equals(name) && !mc.getArguments().isEmpty()) { + Expression arg = mc.getArgument(0); + String var = extractVarName(arg); + return "{" + (var != null ? var : "x") + "}"; + } + String targetClass = className; + if (mc.getScope().isPresent()) { + Expression sc = mc.getScope().get(); + if (sc instanceof NameExpr) { + String n = ((NameExpr) sc).getNameAsString(); + if (!"this".equals(n)) targetClass = n; + } + } + String fq = targetClass + "." + name; + MethodDeclaration helper = reg.helpers.get(fq); + if (helper != null) { + return inlineHelper(helper, targetClass, mc.getArguments(), scope, reg, depth + 1, owner); + } + return null; + } + return null; + } + + private static String inlineHelper(MethodDeclaration helper, String targetClass, + NodeList args, Map outerScope, + Registry reg, int depth, MethodDeclaration owner) { + if (!helper.getBody().isPresent()) return null; + Map scope = new HashMap(); + for (int i = 0; i < helper.getParameters().size(); i++) { + String pname = helper.getParameter(i).getNameAsString(); + String pval = null; + if (i < args.size()) { + pval = resolve(args.get(i), targetClass, outerScope, reg, depth + 1, owner); + } + if (pval == null) pval = "{" + pname + "}"; + scope.put(pname, pval); + } + List returns = helper.getBody().get().findAll(ReturnStmt.class); + if (returns.size() != 1) return null; + Optional ret = returns.get(0).getExpression(); + if (!ret.isPresent()) return null; + return resolve(ret.get(), targetClass, scope, reg, depth + 1, helper); + } + + private static String extractVarName(Expression arg) { + if (arg instanceof NameExpr) return ((NameExpr) arg).getNameAsString(); + if (arg instanceof FieldAccessExpr) return ((FieldAccessExpr) arg).getNameAsString(); + if (arg instanceof EnclosedExpr) return extractVarName(((EnclosedExpr) arg).getInner()); + return null; + } + + private static boolean isEmpty(String s) { + return s == null || s.isEmpty(); + } + + private static String normalizePath(String path) { + if (path == null) return ""; + while (path.length() > 1 && path.endsWith("/")) { + path = path.substring(0, path.length() - 1); + } + path = path.replaceAll("/+", "/"); + path = path.replaceAll("\\{[^}]*\\}", "{}"); + return path; + } + + private static boolean writeJavadoc(MethodDeclaration m, OpInfo op) { + String content = renderJavadocContent(op); + if (m.getJavadocComment().isPresent()) { + String existing = m.getJavadocComment().get().getContent(); + if (!isGeneratedJavadoc(existing)) { + return false; + } + if (normalizeJavadocContent(existing).equals(normalizeJavadocContent(content))) { + return false; + } + } + m.setJavadocComment(content); + return true; + } + + private static boolean isGeneratedJavadoc(String content) { + return content != null + && content.contains("HTTP: ") + && content.contains("Typesense docs"); + } + + private static String normalizeJavadocContent(String content) { + if (content == null) return ""; + return content.replace("\r\n", "\n").trim(); + } + + private static String renderJavadocContent(OpInfo op) { + List lines = new ArrayList(); + String summary = sanitizeJavadocText(firstSentence(op.summary)); + if (summary.isEmpty()) summary = sanitizeJavadocText(firstSentence(op.description)); + if (!summary.isEmpty()) { + lines.add(ensureTrailingPeriod(upperFirst(summary))); + } + if (!op.description.isEmpty() + && !op.description.equalsIgnoreCase(op.summary) + && !firstSentence(op.description).equalsIgnoreCase(firstSentence(op.summary))) { + lines.add(""); + lines.add("

"); + for (String line : op.description.split("\n", -1)) { + lines.add(sanitizeJavadocText(line)); + } + } + lines.add(""); + lines.add("

"); + lines.add("HTTP: " + op.method + " " + op.path); + String section = TAG_TO_DOCS.get(op.tag); + if (section != null) { + lines.add(""); + lines.add("@see Typesense docs"); + } + StringBuilder sb = new StringBuilder(); + sb.append('\n'); + for (String line : lines) { + if (line.isEmpty()) { + sb.append(" *\n"); + } else { + sb.append(" * ").append(line).append('\n'); + } + } + sb.append(" "); + return sb.toString(); + } + + private static String sanitizeJavadocText(String s) { + if (s == null || s.isEmpty()) return s; + return s.replaceAll("\\s*&\\s*", " and ") + .replaceAll("\\s*&(?!#?[A-Za-z0-9]+;)\\s*", " and ") + .trim(); + } + + private static String firstSentence(String s) { + if (s == null) return ""; + s = s.trim(); + if (s.isEmpty()) return ""; + int nl = s.indexOf('\n'); + if (nl >= 0) s = s.substring(0, nl); + return s.trim(); + } + + private static String upperFirst(String s) { + if (s == null || s.isEmpty()) return s; + return Character.toUpperCase(s.charAt(0)) + s.substring(1); + } + + private static String ensureTrailingPeriod(String s) { + if (s == null || s.isEmpty()) return s; + char c = s.charAt(s.length() - 1); + if (c == '.' || c == '?' || c == '!') return s; + return s + "."; + } + + private DocGen() {} +} From 60d559865dc198d1e37f3f8794feee019c920628 Mon Sep 17 00:00:00 2001 From: Fanis Tharropoulos Date: Thu, 11 Jun 2026 16:35:31 +0300 Subject: [PATCH 2/6] chore(nix): add nix flake --- flake.lock | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 40 +++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..8f6b10e --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1780749050, + "narHash": "sha256-3av0pIjlOWQ6rDbNOmpUSvbNnJkGORQKKjb4LtCZsIY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "a799d3e3886da994fa307f817a6bc705ae538eeb", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..6fad976 --- /dev/null +++ b/flake.nix @@ -0,0 +1,40 @@ +{ + description = "Typesense Java client dev shell"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { + inherit system; + config.permittedInsecurePackages = [ "gradle-7.6.6" ]; + }; + in { + devShells.default = pkgs.mkShell { + buildInputs = with pkgs; [ + jdk17 + gradle_7 + jdt-language-server + ]; + + JDK8_HOME = "${pkgs.jdk8}"; + + shellHook = '' + export JAVA_HOME=${pkgs.jdk17} + echo "Java (jdtls/build runtime):" + java -version + echo "" + echo "Project JDK 8 available at: $JDK8_HOME" + echo "" + echo "Gradle:" + gradle --version | grep '^Gradle' + echo "" + echo "jdtls: $(command -v jdtls)" + ''; + }; + }); +} From 7fd1a8aeb1682e43b3e48d8159667845c590fc9e Mon Sep 17 00:00:00 2001 From: Fanis Tharropoulos Date: Thu, 11 Jun 2026 16:35:52 +0300 Subject: [PATCH 3/6] docs: generate javadocs with docgenerator --- src/main/java/org/typesense/api/Alias.java | 19 +++ src/main/java/org/typesense/api/Aliases.java | 22 ++++ .../org/typesense/api/AnalyticsEvents.java | 22 ++++ .../java/org/typesense/api/AnalyticsRule.java | 33 ++++++ .../org/typesense/api/AnalyticsRules.java | 22 ++++ .../java/org/typesense/api/Collection.java | 33 ++++++ .../java/org/typesense/api/Collections.java | 33 ++++++ .../java/org/typesense/api/CurationSet.java | 33 ++++++ .../java/org/typesense/api/CurationSets.java | 22 ++++ src/main/java/org/typesense/api/Debug.java | 8 ++ src/main/java/org/typesense/api/Document.java | 33 ++++++ .../java/org/typesense/api/Documents.java | 110 ++++++++++++++++++ src/main/java/org/typesense/api/Health.java | 8 ++ src/main/java/org/typesense/api/Key.java | 19 +++ src/main/java/org/typesense/api/Keys.java | 19 +++ src/main/java/org/typesense/api/Metrics.java | 11 ++ .../typesense/api/StemmingDictionaries.java | 33 ++++++ .../org/typesense/api/StemmingDictionary.java | 11 ++ .../java/org/typesense/api/Stopwords.java | 22 ++++ .../java/org/typesense/api/StopwordsSet.java | 22 ++++ .../java/org/typesense/api/SynonymSet.java | 33 ++++++ .../java/org/typesense/api/SynonymSets.java | 22 ++++ 22 files changed, 590 insertions(+) diff --git a/src/main/java/org/typesense/api/Alias.java b/src/main/java/org/typesense/api/Alias.java index 4645bd5..5ca2a22 100644 --- a/src/main/java/org/typesense/api/Alias.java +++ b/src/main/java/org/typesense/api/Alias.java @@ -13,10 +13,29 @@ public Alias(ApiCall apiCall, String name) { this.name = name; } + /** + * Retrieve an alias. + * + *

+ * Find out which collection an alias points to by fetching it + * + *

+ * HTTP: GET /aliases/{aliasName} + * + * @see Typesense docs + */ public CollectionAlias retrieve() throws Exception { return this.apiCall.get(this.getEndpoint(), null, CollectionAlias.class); } + /** + * Delete an alias. + * + *

+ * HTTP: DELETE /aliases/{aliasName} + * + * @see Typesense docs + */ public CollectionAlias delete() throws Exception { return this.apiCall.delete(this.getEndpoint(), null, CollectionAlias.class); } diff --git a/src/main/java/org/typesense/api/Aliases.java b/src/main/java/org/typesense/api/Aliases.java index 28a42cc..fbf3fc3 100644 --- a/src/main/java/org/typesense/api/Aliases.java +++ b/src/main/java/org/typesense/api/Aliases.java @@ -14,11 +14,33 @@ public Aliases(ApiCall apiCall) { this.apiCall = apiCall; } + /** + * Create or update a collection alias. + * + *

+ * Create or update a collection alias. An alias is a virtual collection name that points to a real collection. If you're familiar with symbolic links on Linux, it's very similar to that. Aliases are useful when you want to reindex your data in the background on a new collection and switch your application to it without any changes to your code. + * + *

+ * HTTP: PUT /aliases/{aliasName} + * + * @see Typesense docs + */ public CollectionAlias upsert(String name, CollectionAliasSchema collectionAliasSchema) throws Exception { return this.apiCall.put(RESOURCE_PATH + "/" + URLEncoding.encodeURIComponent(name), collectionAliasSchema, null, CollectionAlias.class); } + /** + * List all aliases. + * + *

+ * List all aliases and the corresponding collections that they map to. + * + *

+ * HTTP: GET /aliases + * + * @see Typesense docs + */ public CollectionAliasesResponse retrieve() throws Exception { return this.apiCall.get(RESOURCE_PATH, null, CollectionAliasesResponse.class); } diff --git a/src/main/java/org/typesense/api/AnalyticsEvents.java b/src/main/java/org/typesense/api/AnalyticsEvents.java index de2e295..7981f44 100644 --- a/src/main/java/org/typesense/api/AnalyticsEvents.java +++ b/src/main/java/org/typesense/api/AnalyticsEvents.java @@ -13,10 +13,32 @@ public AnalyticsEvents(ApiCall apiCall) { this.apiCall = apiCall; } + /** + * Create an analytics event. + * + *

+ * Submit a single analytics event. The event must correspond to an existing analytics rule by name. + * + *

+ * HTTP: POST /analytics/events + * + * @see Typesense docs + */ public AnalyticsEventCreateResponse create(AnalyticsEvent event) throws Exception { return this.apiCall.post(RESOURCE_PATH, event, null, AnalyticsEventCreateResponse.class); } + /** + * Retrieve analytics events. + * + *

+ * Retrieve the most recent events for a user and rule. + * + *

+ * HTTP: GET /analytics/events + * + * @see Typesense docs + */ public AnalyticsEventsResponse retrieve(Map params) throws Exception { return this.apiCall.get(RESOURCE_PATH, params, AnalyticsEventsResponse.class); } diff --git a/src/main/java/org/typesense/api/AnalyticsRule.java b/src/main/java/org/typesense/api/AnalyticsRule.java index cc9ef79..d98e942 100644 --- a/src/main/java/org/typesense/api/AnalyticsRule.java +++ b/src/main/java/org/typesense/api/AnalyticsRule.java @@ -20,11 +20,33 @@ public AnalyticsRule(String ruleId, ApiCall apiCall, AnalyticsRuleSerializer ser this.serializer = serializer; } + /** + * Retrieves an analytics rule. + * + *

+ * Retrieve the details of an analytics rule, given it's name + * + *

+ * HTTP: GET /analytics/rules/{ruleName} + * + * @see Typesense docs + */ public org.typesense.model.AnalyticsRule retrieve() throws Exception { String response = this.apiCall.get(this.getEndpoint(), null, String.class); return serializer.parseFromJson(response); } + /** + * Delete an analytics rule. + * + *

+ * Permanently deletes an analytics rule, given it's name + * + *

+ * HTTP: DELETE /analytics/rules/{ruleName} + * + * @see Typesense docs + */ public org.typesense.model.AnalyticsRule delete() throws Exception { String response = this.apiCall.delete(this.getEndpoint(), null, String.class); org.typesense.model.AnalyticsRule result = new org.typesense.model.AnalyticsRule(); @@ -32,6 +54,17 @@ public org.typesense.model.AnalyticsRule delete() throws Exception { return result; } + /** + * Upserts an analytics rule. + * + *

+ * Upserts an analytics rule with the given name. + * + *

+ * HTTP: PUT /analytics/rules/{ruleName} + * + * @see Typesense docs + */ public org.typesense.model.AnalyticsRule update(AnalyticsRuleUpdate rule) throws Exception { return this.apiCall.put(this.getEndpoint(), rule, null, org.typesense.model.AnalyticsRule.class); } diff --git a/src/main/java/org/typesense/api/AnalyticsRules.java b/src/main/java/org/typesense/api/AnalyticsRules.java index 7c113c2..9653d50 100644 --- a/src/main/java/org/typesense/api/AnalyticsRules.java +++ b/src/main/java/org/typesense/api/AnalyticsRules.java @@ -20,11 +20,33 @@ public AnalyticsRules(ApiCall apiCall, AnalyticsRuleSerializer serializer) { this.serializer = serializer; } + /** + * Create analytics rule(s). + * + *

+ * Create one or more analytics rules. You can send a single rule object or an array of rule objects. + * + *

+ * HTTP: POST /analytics/rules + * + * @see Typesense docs + */ public AnalyticsRulesResponse create(List rules) throws Exception { String response = this.apiCall.post(RESOURCE_PATH, rules, null, String.class); return parseCreateResponse(response); } + /** + * Retrieve analytics rules. + * + *

+ * Retrieve all analytics rules. Use the optional rule_tag filter to narrow down results. + * + *

+ * HTTP: GET /analytics/rules + * + * @see Typesense docs + */ public List retrieve() throws Exception { String response = this.apiCall.get(RESOURCE_PATH, null, String.class); return parseRetrieveResponse(response); diff --git a/src/main/java/org/typesense/api/Collection.java b/src/main/java/org/typesense/api/Collection.java index cc5524f..0589814 100644 --- a/src/main/java/org/typesense/api/Collection.java +++ b/src/main/java/org/typesense/api/Collection.java @@ -34,14 +34,47 @@ public class Collection { this.individualSynonyms = new HashMap<>(); } + /** + * Retrieve a single collection. + * + *

+ * Retrieve the details of a collection, given its name. + * + *

+ * HTTP: GET /collections/{collectionName} + * + * @see Typesense docs + */ public CollectionResponse retrieve() throws Exception { return this.apiCall.get(endpoint, null, CollectionResponse.class); } + /** + * Update a collection. + * + *

+ * Update a collection's schema to modify the fields and their types. + * + *

+ * HTTP: PATCH /collections/{collectionName} + * + * @see Typesense docs + */ public CollectionUpdateSchema update(CollectionUpdateSchema c) throws Exception { return this.apiCall.patch(endpoint, c, null, CollectionUpdateSchema.class); } + /** + * Delete a collection. + * + *

+ * Permanently drops a collection. This action cannot be undone. For large collections, this might have an impact on read latencies. + * + *

+ * HTTP: DELETE /collections/{collectionName} + * + * @see Typesense docs + */ public CollectionResponse delete() throws Exception { return this.apiCall.delete(endpoint, null, CollectionResponse.class); } diff --git a/src/main/java/org/typesense/api/Collections.java b/src/main/java/org/typesense/api/Collections.java index ec8f9fc..f75317d 100644 --- a/src/main/java/org/typesense/api/Collections.java +++ b/src/main/java/org/typesense/api/Collections.java @@ -12,14 +12,47 @@ public Collections(ApiCall apiCall){ this.apiCall = apiCall; } + /** + * Create a new collection. + * + *

+ * When a collection is created, we give it a name and describe the fields that will be indexed from the documents added to the collection. + * + *

+ * HTTP: POST /collections + * + * @see Typesense docs + */ public CollectionResponse create(CollectionSchema c) throws Exception { return this.apiCall.post(RESOURCE_PATH, c, null, CollectionResponse.class); } + /** + * Create a new collection. + * + *

+ * When a collection is created, we give it a name and describe the fields that will be indexed from the documents added to the collection. + * + *

+ * HTTP: POST /collections + * + * @see Typesense docs + */ public CollectionResponse create(String schemaJson) throws Exception { return this.apiCall.post(RESOURCE_PATH, schemaJson, null, CollectionResponse.class); } + /** + * List all collections. + * + *

+ * Returns a summary of all your collections. The collections are returned sorted by creation date, with the most recent collections appearing first. + * + *

+ * HTTP: GET /collections + * + * @see Typesense docs + */ public CollectionResponse[] retrieve() throws Exception { return this.apiCall.get(RESOURCE_PATH, null, CollectionResponse[].class); } diff --git a/src/main/java/org/typesense/api/CurationSet.java b/src/main/java/org/typesense/api/CurationSet.java index 8d9f8a1..5326294 100644 --- a/src/main/java/org/typesense/api/CurationSet.java +++ b/src/main/java/org/typesense/api/CurationSet.java @@ -15,14 +15,47 @@ public CurationSet(String curationSetName, ApiCall apiCall) { this.apiCall = apiCall; } + /** + * Retrieve a curation set. + * + *

+ * Retrieve a specific curation set by its name + * + *

+ * HTTP: GET /curation_sets/{curationSetName} + * + * @see Typesense docs + */ public CurationSetCreateSchema retrieve() throws Exception { return this.apiCall.get(this.getEndpoint(), null, CurationSetCreateSchema.class); } + /** + * Create or update a curation set. + * + *

+ * Create or update a curation set with the given name + * + *

+ * HTTP: PUT /curation_sets/{curationSetName} + * + * @see Typesense docs + */ public CurationSetSchema upsert(CurationSetCreateSchema curationSetCreateSchema) throws Exception { return this.apiCall.put(this.getEndpoint(), curationSetCreateSchema, null, CurationSetSchema.class); } + /** + * Delete a curation set. + * + *

+ * Delete a specific curation set by its name + * + *

+ * HTTP: DELETE /curation_sets/{curationSetName} + * + * @see Typesense docs + */ public CurationSetDeleteSchema delete() throws Exception { return this.apiCall.delete(this.getEndpoint(), null, CurationSetDeleteSchema.class); } diff --git a/src/main/java/org/typesense/api/CurationSets.java b/src/main/java/org/typesense/api/CurationSets.java index 5bcb197..b558b7a 100644 --- a/src/main/java/org/typesense/api/CurationSets.java +++ b/src/main/java/org/typesense/api/CurationSets.java @@ -12,10 +12,32 @@ public CurationSets(ApiCall apiCall) { this.apiCall = apiCall; } + /** + * Create or update a curation set. + * + *

+ * Create or update a curation set with the given name + * + *

+ * HTTP: PUT /curation_sets/{curationSetName} + * + * @see Typesense docs + */ public CurationSetSchema upsert(String curationSetName, CurationSetCreateSchema curationSetCreateSchema) throws Exception { return this.apiCall.put(getEndpoint(curationSetName), curationSetCreateSchema, null, CurationSetSchema.class); } + /** + * Retrieve a curation set. + * + *

+ * Retrieve a specific curation set by its name + * + *

+ * HTTP: GET /curation_sets/{curationSetName} + * + * @see Typesense docs + */ public CurationSetSchema[] retrieve() throws Exception { return this.apiCall.get(this.getEndpoint(null), null, CurationSetSchema[].class); } diff --git a/src/main/java/org/typesense/api/Debug.java b/src/main/java/org/typesense/api/Debug.java index cf0da07..64c2c37 100644 --- a/src/main/java/org/typesense/api/Debug.java +++ b/src/main/java/org/typesense/api/Debug.java @@ -11,6 +11,14 @@ public Debug(ApiCall apiCall) { this.apiCall = apiCall; } + /** + * Print debugging information. + * + *

+ * HTTP: GET /debug + * + * @see Typesense docs + */ public Map retrieve() throws Exception { return this.apiCall.get(RESOURCEPATH, null, Map.class); } diff --git a/src/main/java/org/typesense/api/Document.java b/src/main/java/org/typesense/api/Document.java index 6b22e9d..6113ac4 100644 --- a/src/main/java/org/typesense/api/Document.java +++ b/src/main/java/org/typesense/api/Document.java @@ -18,14 +18,47 @@ public class Document { + Documents.RESOURCE_PATH + "/" + URLEncoding.encodeURIComponent(this.documentId); } + /** + * Retrieve a document. + * + *

+ * Fetch an individual document from a collection by using its ID. + * + *

+ * HTTP: GET /collections/{collectionName}/documents/{documentId} + * + * @see Typesense docs + */ public Map retrieve() throws Exception { return this.apiCall.get(endpoint, null, Map.class); } + /** + * Delete a document. + * + *

+ * Delete an individual document from a collection by using its ID. + * + *

+ * HTTP: DELETE /collections/{collectionName}/documents/{documentId} + * + * @see Typesense docs + */ public Map delete() throws Exception { return this.apiCall.delete(this.endpoint, null, Map.class); } + /** + * Update a document. + * + *

+ * Update an individual document from a collection by using its ID. The update can be partial. + * + *

+ * HTTP: PATCH /collections/{collectionName}/documents/{documentId} + * + * @see Typesense docs + */ public Map update(Map document) throws Exception { return this.apiCall.patch(this.endpoint, document, null, Map.class); } diff --git a/src/main/java/org/typesense/api/Documents.java b/src/main/java/org/typesense/api/Documents.java index f4a7540..6827891 100644 --- a/src/main/java/org/typesense/api/Documents.java +++ b/src/main/java/org/typesense/api/Documents.java @@ -29,18 +29,62 @@ public class Documents { this.configuration = configuration; } + /** + * Index a document. + * + *

+ * A document to be indexed in a given collection must conform to the schema of the collection. + * + *

+ * HTTP: POST /collections/{collectionName}/documents + * + * @see Typesense docs + */ public Map create(Map document) throws Exception { return this.apiCall.post(getEndPoint("/"), document, null, Map.class); } + /** + * Index a document. + * + *

+ * A document to be indexed in a given collection must conform to the schema of the collection. + * + *

+ * HTTP: POST /collections/{collectionName}/documents + * + * @see Typesense docs + */ public String create(String document) throws Exception { return this.apiCall.post(getEndPoint("/"), document, null, String.class); } + /** + * Index a document. + * + *

+ * A document to be indexed in a given collection must conform to the schema of the collection. + * + *

+ * HTTP: POST /collections/{collectionName}/documents + * + * @see Typesense docs + */ public String create(Map document, ImportDocumentsParameters queryParameters) throws Exception { return this.apiCall.post(getEndPoint("/"), document, queryParameters, String.class); } + /** + * Index a document. + * + *

+ * A document to be indexed in a given collection must conform to the schema of the collection. + * + *

+ * HTTP: POST /collections/{collectionName}/documents + * + * @see Typesense docs + */ public Map upsert(Map document) throws Exception { ImportDocumentsParameters queryParameters = new ImportDocumentsParameters(); queryParameters.action(IndexAction.UPSERT); @@ -48,26 +92,92 @@ public Map upsert(Map document) throws Exception return this.apiCall.post(getEndPoint("/"), document, queryParameters, Map.class); } + /** + * Search for documents in a collection. + * + *

+ * Search for documents in a collection that match the search criteria. + * + *

+ * HTTP: GET /collections/{collectionName}/documents/search + * + * @see Typesense docs + */ public SearchResult search(SearchParameters searchParameters) throws Exception { return this.apiCall.get(getEndPoint("search"), searchParameters, org.typesense.model.SearchResult.class); } + /** + * Delete a bunch of documents. + * + *

+ * Delete a bunch of documents that match a specific filter condition. Use the `batch_size` parameter to control the number of documents that should deleted at a time. A larger value will speed up deletions, but will impact performance of other operations running on the server. + * + *

+ * HTTP: DELETE /collections/{collectionName}/documents + * + * @see Typesense docs + */ public Map delete(DeleteDocumentsParameters queryParameters) throws Exception { return this.apiCall.delete(getEndPoint("/"), queryParameters, Map.class); } + /** + * Export all documents in a collection. + * + *

+ * Export all documents in a collection in JSON lines format. + * + *

+ * HTTP: GET /collections/{collectionName}/documents/export + * + * @see Typesense docs + */ public String export() throws Exception { return this.apiCall.get(getEndPoint("export"), null, String.class); } + /** + * Export all documents in a collection. + * + *

+ * Export all documents in a collection in JSON lines format. + * + *

+ * HTTP: GET /collections/{collectionName}/documents/export + * + * @see Typesense docs + */ public String export(ExportDocumentsParameters exportDocumentsParameters) throws Exception { return this.apiCall.get(getEndPoint("export"), exportDocumentsParameters, String.class); } + /** + * Import documents into a collection. + * + *

+ * The documents to be imported must be formatted in a newline delimited JSON structure. You can feed the output file from a Typesense export operation directly as import. + * + *

+ * HTTP: POST /collections/{collectionName}/documents/import + * + * @see Typesense docs + */ public String import_(String document, ImportDocumentsParameters queryParameters) throws Exception { return this.apiCall.post(this.getEndPoint("import"), document, queryParameters, String.class); } + /** + * Import documents into a collection. + * + *

+ * The documents to be imported must be formatted in a newline delimited JSON structure. You can feed the output file from a Typesense export operation directly as import. + * + *

+ * HTTP: POST /collections/{collectionName}/documents/import + * + * @see Typesense docs + */ public String import_(Collection documents, ImportDocumentsParameters queryParameters) throws Exception { ObjectMapper mapper = new ObjectMapper(); diff --git a/src/main/java/org/typesense/api/Health.java b/src/main/java/org/typesense/api/Health.java index 7ac0d0c..7b14756 100644 --- a/src/main/java/org/typesense/api/Health.java +++ b/src/main/java/org/typesense/api/Health.java @@ -11,6 +11,14 @@ public Health(ApiCall apiCall) { this.apiCall = apiCall; } + /** + * Checks if Typesense server is ready to accept requests. + * + *

+ * HTTP: GET /health + * + * @see Typesense docs + */ public Map retrieve() throws Exception { return this.apiCall.get(RESOURCEPATH, null, Map.class); } diff --git a/src/main/java/org/typesense/api/Key.java b/src/main/java/org/typesense/api/Key.java index 4aa035d..1782930 100644 --- a/src/main/java/org/typesense/api/Key.java +++ b/src/main/java/org/typesense/api/Key.java @@ -12,10 +12,29 @@ public Key(Long id, ApiCall apiCall) { this.apiCall = apiCall; } + /** + * Retrieve (metadata about) a key. + * + *

+ * Retrieve (metadata about) a key. Only the key prefix is returned when you retrieve a key. Due to security reasons, only the create endpoint returns the full API key. + * + *

+ * HTTP: GET /keys/{keyId} + * + * @see Typesense docs + */ public ApiKey retrieve() throws Exception { return this.apiCall.get(this.getEndpoint(), null, ApiKey.class); } + /** + * Delete an API key given its ID. + * + *

+ * HTTP: DELETE /keys/{keyId} + * + * @see Typesense docs + */ public ApiKey delete() throws Exception { return this.apiCall.delete(this.getEndpoint(), null, ApiKey.class); } diff --git a/src/main/java/org/typesense/api/Keys.java b/src/main/java/org/typesense/api/Keys.java index 63dad0a..98d3768 100644 --- a/src/main/java/org/typesense/api/Keys.java +++ b/src/main/java/org/typesense/api/Keys.java @@ -21,6 +21,17 @@ public Keys(ApiCall apiCall) { this.apiCall = apiCall; } + /** + * Create an API Key. + * + *

+ * Create an API Key with fine-grain access control. You can restrict access on both a per-collection and per-action level. The generated key is returned only during creation. You want to store this key carefully in a secure place. + * + *

+ * HTTP: POST /keys + * + * @see Typesense docs + */ public ApiKey create(ApiKeySchema apiKeySchema) throws Exception { if (apiKeySchema.getExpiresAt() == null) { apiKeySchema.setExpiresAt(System.currentTimeMillis() / 1000L + 315360000); // Adding 10 years for expiration. @@ -28,6 +39,14 @@ public ApiKey create(ApiKeySchema apiKeySchema) throws Exception { return this.apiCall.post(Keys.RESOURCEPATH, apiKeySchema, null, ApiKey.class); } + /** + * Retrieve (metadata about) all keys. + * + *

+ * HTTP: GET /keys + * + * @see Typesense docs + */ public ApiKeysResponse retrieve() throws Exception { return this.apiCall.get(Keys.RESOURCEPATH, null, ApiKeysResponse.class); } diff --git a/src/main/java/org/typesense/api/Metrics.java b/src/main/java/org/typesense/api/Metrics.java index 1d12aeb..b3fed9c 100644 --- a/src/main/java/org/typesense/api/Metrics.java +++ b/src/main/java/org/typesense/api/Metrics.java @@ -11,6 +11,17 @@ public Metrics(ApiCall apiCall) { this.apiCall = apiCall; } + /** + * Get current RAM, CPU, Disk and Network usage metrics. + * + *

+ * Retrieve the metrics. + * + *

+ * HTTP: GET /metrics.json + * + * @see Typesense docs + */ public Map retrieve() throws Exception { return this.apiCall.get(RESOURCEPATH, null, Map.class); } diff --git a/src/main/java/org/typesense/api/StemmingDictionaries.java b/src/main/java/org/typesense/api/StemmingDictionaries.java index f97842b..95a53ae 100644 --- a/src/main/java/org/typesense/api/StemmingDictionaries.java +++ b/src/main/java/org/typesense/api/StemmingDictionaries.java @@ -17,12 +17,34 @@ public StemmingDictionaries(ApiCall apiCall) { this.apiCall = apiCall; } + /** + * Import a stemming dictionary. + * + *

+ * Upload a JSONL file containing word mappings to create or update a stemming dictionary. + * + *

+ * HTTP: POST /stemming/dictionaries/import + * + * @see Typesense docs + */ public String upsert(String dictionaryId, String wordRootCombinations) throws Exception { Map params = Collections.singletonMap("id", dictionaryId); return this.apiCall.post(this.getEndPoint("import"), wordRootCombinations, params, String.class); } + /** + * Import a stemming dictionary. + * + *

+ * Upload a JSONL file containing word mappings to create or update a stemming dictionary. + * + *

+ * HTTP: POST /stemming/dictionaries/import + * + * @see Typesense docs + */ public List upsert(String dictionaryId, List wordRootCombinations) throws Exception { ObjectMapper mapper = new ObjectMapper(); @@ -46,6 +68,17 @@ public List upsert(String dictionaryId, List + * Retrieve a list of all available stemming dictionaries. + * + *

+ * HTTP: GET /stemming/dictionaries + * + * @see Typesense docs + */ public StemmingDictionariesRetrieveSchema retrieve() throws Exception { StemmingDictionariesRetrieveSchema response = this.apiCall.get(RESOURCE_PATH, null, StemmingDictionariesRetrieveSchema.class); diff --git a/src/main/java/org/typesense/api/StemmingDictionary.java b/src/main/java/org/typesense/api/StemmingDictionary.java index b13e69f..31dea20 100644 --- a/src/main/java/org/typesense/api/StemmingDictionary.java +++ b/src/main/java/org/typesense/api/StemmingDictionary.java @@ -12,6 +12,17 @@ public StemmingDictionary(String dictionaryId, ApiCall apiCall) { } + /** + * Retrieve a stemming dictionary. + * + *

+ * Fetch details of a specific stemming dictionary. + * + *

+ * HTTP: GET /stemming/dictionaries/{dictionaryId} + * + * @see Typesense docs + */ public org.typesense.model.StemmingDictionary retrieve() throws Exception { return this.apiCall.get(this.getEndpoint(), null, org.typesense.model.StemmingDictionary.class); } diff --git a/src/main/java/org/typesense/api/Stopwords.java b/src/main/java/org/typesense/api/Stopwords.java index 921e43b..2eb238d 100644 --- a/src/main/java/org/typesense/api/Stopwords.java +++ b/src/main/java/org/typesense/api/Stopwords.java @@ -14,10 +14,32 @@ public Stopwords(ApiCall apiCall) { this.apiCall = apiCall; } + /** + * Upserts a stopwords set. + * + *

+ * When an analytics rule is created, we give it a name and describe the type, the source collections and the destination collection. + * + *

+ * HTTP: PUT /stopwords/{setId} + * + * @see Typesense docs + */ public StopwordsSetSchema upsert(String stopwordSetId, StopwordsSetUpsertSchema stopwordSet) throws Exception { return this.apiCall.put(getEndpoint(stopwordSetId), stopwordSet, null, StopwordsSetSchema.class); } + /** + * Retrieves all stopwords sets. + * + *

+ * Retrieve the details of all stopwords sets + * + *

+ * HTTP: GET /stopwords + * + * @see Typesense docs + */ public StopwordsSetsRetrieveAllSchema retrieve() throws Exception { return this.apiCall.get(Stopwords.RESOURCEPATH, null, StopwordsSetsRetrieveAllSchema.class); } diff --git a/src/main/java/org/typesense/api/StopwordsSet.java b/src/main/java/org/typesense/api/StopwordsSet.java index 9200960..986b7b4 100644 --- a/src/main/java/org/typesense/api/StopwordsSet.java +++ b/src/main/java/org/typesense/api/StopwordsSet.java @@ -13,10 +13,32 @@ public StopwordsSet(String stopwordsSetId, ApiCall apiCall) { this.apiCall = apiCall; } + /** + * Retrieves a stopwords set. + * + *

+ * Retrieve the details of a stopwords set, given it's name. + * + *

+ * HTTP: GET /stopwords/{setId} + * + * @see Typesense docs + */ public StopwordsSetRetrieveSchema retrieve() throws Exception { return this.apiCall.get(this.getEndpoint(), null, StopwordsSetRetrieveSchema.class); } + /** + * Delete a stopwords set. + * + *

+ * Permanently deletes a stopwords set, given it's name. + * + *

+ * HTTP: DELETE /stopwords/{setId} + * + * @see Typesense docs + */ public StopwordsSetSchema delete() throws Exception { return this.apiCall.delete(this.getEndpoint(), null, StopwordsSetSchema.class); } diff --git a/src/main/java/org/typesense/api/SynonymSet.java b/src/main/java/org/typesense/api/SynonymSet.java index 4672409..a993c99 100644 --- a/src/main/java/org/typesense/api/SynonymSet.java +++ b/src/main/java/org/typesense/api/SynonymSet.java @@ -16,14 +16,47 @@ public SynonymSet(String synonymSetName, ApiCall apiCall) { this.apiCall = apiCall; } + /** + * Retrieve a synonym set. + * + *

+ * Retrieve a specific synonym set by its name + * + *

+ * HTTP: GET /synonym_sets/{synonymSetName} + * + * @see Typesense docs + */ public SynonymSetCreateSchema retrieve() throws Exception { return this.apiCall.get(this.getEndpoint(), null, SynonymSetCreateSchema.class); } + /** + * Create or update a synonym set. + * + *

+ * Create or update a synonym set with the given name + * + *

+ * HTTP: PUT /synonym_sets/{synonymSetName} + * + * @see Typesense docs + */ public SynonymSetSchema upsert(SynonymSetCreateSchema synonymSetCreateSchema) throws Exception { return this.apiCall.put(this.getEndpoint(), synonymSetCreateSchema, null, SynonymSetSchema.class); } + /** + * Delete a synonym set. + * + *

+ * Delete a specific synonym set by its name + * + *

+ * HTTP: DELETE /synonym_sets/{synonymSetName} + * + * @see Typesense docs + */ public SynonymSetDeleteSchema delete() throws Exception { return this.apiCall.delete(this.getEndpoint(), null, SynonymSetDeleteSchema.class); } diff --git a/src/main/java/org/typesense/api/SynonymSets.java b/src/main/java/org/typesense/api/SynonymSets.java index 764cb3c..74f7fd6 100644 --- a/src/main/java/org/typesense/api/SynonymSets.java +++ b/src/main/java/org/typesense/api/SynonymSets.java @@ -13,10 +13,32 @@ public SynonymSets(ApiCall apiCall) { this.apiCall = apiCall; } + /** + * Create or update a synonym set. + * + *

+ * Create or update a synonym set with the given name + * + *

+ * HTTP: PUT /synonym_sets/{synonymSetName} + * + * @see Typesense docs + */ public SynonymSetSchema upsert(String synonymSetName, SynonymSetCreateSchema synonymSetCreateSchema) throws Exception { return this.apiCall.put(getEndpoint(synonymSetName), synonymSetCreateSchema, null, SynonymSetSchema.class); } + /** + * Retrieve a synonym set. + * + *

+ * Retrieve a specific synonym set by its name + * + *

+ * HTTP: GET /synonym_sets/{synonymSetName} + * + * @see Typesense docs + */ public SynonymSetSchema[] retrieve() throws Exception { return this.apiCall.get(this.getEndpoint(null), null, SynonymSetSchema[].class); } From 49d5326d384ace54ad82b8c2b5e0c642397a3d25 Mon Sep 17 00:00:00 2001 From: Fanis Tharropoulos Date: Thu, 11 Jun 2026 17:08:34 +0300 Subject: [PATCH 4/6] feat(docgen): add class and constructor javadocs --- .../java/org/typesense/docgen/DocGen.java | 72 ++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) diff --git a/generator/src/main/java/org/typesense/docgen/DocGen.java b/generator/src/main/java/org/typesense/docgen/DocGen.java index e55d958..02253b0 100644 --- a/generator/src/main/java/org/typesense/docgen/DocGen.java +++ b/generator/src/main/java/org/typesense/docgen/DocGen.java @@ -2,6 +2,7 @@ import com.github.javaparser.StaticJavaParser; import com.github.javaparser.ast.CompilationUnit; +import com.github.javaparser.ast.Node; import com.github.javaparser.ast.NodeList; import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; import com.github.javaparser.ast.body.ConstructorDeclaration; @@ -226,6 +227,14 @@ private static boolean annotateUnit(CompilationUnit cu, Registry reg, Map " + key); continue; } - if (writeJavadoc(m, op)) { + if (writeJavadoc(m, op, site)) { changed = true; } } @@ -420,6 +429,55 @@ private static String normalizePath(String path) { return path; } + private static boolean writeClassJavadoc(ClassOrInterfaceDeclaration cls) { + if (!cls.isPublic()) { + return false; + } + String content = renderClassJavadocContent(cls); + if (cls.getJavadocComment().isPresent()) { + String existing = cls.getJavadocComment().get().getContent(); + if (!isGeneratedClassJavadoc(existing)) { + return false; + } + if (normalizeJavadocContent(existing).equals(normalizeJavadocContent(content))) { + return false; + } + } + cls.setJavadocComment(content); + return true; + } + + private static String renderClassJavadocContent(ClassOrInterfaceDeclaration cls) { + List lines = new ArrayList(); + lines.add("Typesense " + humanizeIdentifier(cls.getNameAsString()) + " API wrapper."); + return renderJavadocBlock(lines, javadocIndent(cls)); + } + + private static boolean writeConstructorJavadoc(ConstructorDeclaration c, String className) { + if (!c.isPublic()) { + return false; + } + String content = renderConstructorJavadocContent(c, className); + if (c.getJavadocComment().isPresent()) { + String existing = c.getJavadocComment().get().getContent(); + if (!isGeneratedConstructorJavadoc(existing)) { + return false; + } + if (normalizeJavadocContent(existing).equals(normalizeJavadocContent(content))) { + return false; + } + } + c.setJavadocComment(content); + return true; + } + + private static String renderConstructorJavadocContent(ConstructorDeclaration c, String className) { + List lines = new ArrayList(); + lines.add("Creates a new " + className + " instance."); + addConstructorParamTags(lines, c.getParameters()); + return renderJavadocBlock(lines, javadocIndent(c)); + } + private static boolean writeJavadoc(MethodDeclaration m, OpInfo op) { String content = renderJavadocContent(op); if (m.getJavadocComment().isPresent()) { @@ -441,6 +499,18 @@ private static boolean isGeneratedJavadoc(String content) { && content.contains("Typesense docs"); } + private static boolean isGeneratedClassJavadoc(String content) { + return content != null + && content.contains("Typesense ") + && content.contains(" API wrapper"); + } + + private static boolean isGeneratedConstructorJavadoc(String content) { + return content != null + && content.contains("Creates a new ") + && content.contains(" instance."); + } + private static String normalizeJavadocContent(String content) { if (content == null) return ""; return content.replace("\r\n", "\n").trim(); From 6e8248a6f386bec9e862f990cc647fb2778f91b4 Mon Sep 17 00:00:00 2001 From: Fanis Tharropoulos Date: Thu, 11 Jun 2026 17:08:43 +0300 Subject: [PATCH 5/6] feat(docgen): enrich method javadocs --- .../java/org/typesense/docgen/DocGen.java | 160 +++++++++++++++++- 1 file changed, 152 insertions(+), 8 deletions(-) diff --git a/generator/src/main/java/org/typesense/docgen/DocGen.java b/generator/src/main/java/org/typesense/docgen/DocGen.java index 02253b0..5de9901 100644 --- a/generator/src/main/java/org/typesense/docgen/DocGen.java +++ b/generator/src/main/java/org/typesense/docgen/DocGen.java @@ -21,6 +21,7 @@ import com.github.javaparser.ast.expr.StringLiteralExpr; import com.github.javaparser.ast.expr.ThisExpr; import com.github.javaparser.ast.stmt.ReturnStmt; +import com.github.javaparser.ast.type.ReferenceType; import com.github.javaparser.printer.lexicalpreservation.LexicalPreservingPrinter; import org.yaml.snakeyaml.Yaml; @@ -262,10 +263,12 @@ private static boolean annotateUnit(CompilationUnit cu, Registry reg, Map lines = new ArrayList(); String summary = sanitizeJavadocText(firstSentence(op.summary)); if (summary.isEmpty()) summary = sanitizeJavadocText(firstSentence(op.description)); @@ -535,24 +538,165 @@ private static String renderJavadocContent(OpInfo op) { lines.add(""); lines.add("

"); lines.add("HTTP: " + op.method + " " + op.path); + + boolean hasParamTags = !m.getParameters().isEmpty(); + boolean hasReturnTag = !"void".equals(m.getTypeAsString()); + boolean hasThrowsTags = !m.getThrownExceptions().isEmpty(); + if (hasParamTags || hasReturnTag || hasThrowsTags || TAG_TO_DOCS.containsKey(op.tag)) { + lines.add(""); + } + addMethodParamTags(lines, m.getParameters(), site); + if (hasReturnTag) { + lines.add("@return " + describeReturn(m)); + } + for (ReferenceType thrown : m.getThrownExceptions()) { + lines.add("@throws " + thrown.asString() + " if the request fails"); + } + String section = TAG_TO_DOCS.get(op.tag); if (section != null) { lines.add(""); lines.add("@see Typesense docs"); } + return renderJavadocBlock(lines, javadocIndent(m)); + } + + private static void addMethodParamTags(List lines, NodeList parameters, ApiCallSite site) { + for (Parameter p : parameters) { + String name = p.getNameAsString(); + lines.add("@param " + name + " " + describeMethodParam(p, site)); + } + } + + private static void addConstructorParamTags(List lines, NodeList parameters) { + for (Parameter p : parameters) { + String name = p.getNameAsString(); + lines.add("@param " + name + " " + describeConstructorParam(p)); + } + } + + private static String describeMethodParam(Parameter p, ApiCallSite site) { + String name = p.getNameAsString(); + String type = codeType(p.getTypeAsString()); + if (site != null) { + if (expressionReferencesName(apiCallBodyArg(site), name)) { + return "the " + type + " request body"; + } + if (expressionReferencesName(apiCallQueryArg(site), name)) { + return "the " + type + " query parameters"; + } + if (expressionReferencesName(site.pathArg, name)) { + return "the " + type + " path parameter"; + } + } + return "the " + type + " " + humanizeIdentifier(name); + } + + private static String describeConstructorParam(Parameter p) { + String name = p.getNameAsString(); + String type = p.getTypeAsString(); + if ("ApiCall".equals(type)) { + return "the " + codeType(type) + " instance used to send requests"; + } + if ("Configuration".equals(type)) { + return "the client configuration"; + } + if ("OkHttpClient".equals(type)) { + return "the HTTP client"; + } + if (name.endsWith("Id") || name.endsWith("Name")) { + return "the " + codeType(type) + " path parameter"; + } + return "the " + codeType(type) + " " + humanizeIdentifier(name); + } + + private static String describeReturn(MethodDeclaration m) { + String type = m.getTypeAsString(); + if ("String".equals(type)) { + return "the raw response body"; + } + if (type.endsWith("[]")) { + return "the " + codeType(type) + " response array"; + } + if (type.startsWith("Map<")) { + return "the " + codeType(type) + " response map"; + } + return "the " + codeType(type) + " response"; + } + + private static Expression apiCallBodyArg(ApiCallSite site) { + if (!"POST".equals(site.verb) && !"PUT".equals(site.verb) && !"PATCH".equals(site.verb)) { + return null; + } + NodeList args = site.call.getArguments(); + return args.size() > 1 ? args.get(1) : null; + } + + private static Expression apiCallQueryArg(ApiCallSite site) { + NodeList args = site.call.getArguments(); + if ("GET".equals(site.verb) || "DELETE".equals(site.verb)) { + return args.size() > 1 ? args.get(1) : null; + } + if ("POST".equals(site.verb) || "PUT".equals(site.verb) || "PATCH".equals(site.verb)) { + return args.size() > 2 ? args.get(2) : null; + } + return null; + } + + private static boolean expressionReferencesName(Expression expr, String name) { + if (expr == null || name == null) return false; + for (NameExpr n : expr.findAll(NameExpr.class)) { + if (name.equals(n.getNameAsString())) { + return true; + } + } + return false; + } + + private static String codeType(String type) { + return "{@code " + type + "}"; + } + + private static String renderJavadocBlock(List lines, String indent) { StringBuilder sb = new StringBuilder(); sb.append('\n'); for (String line : lines) { if (line.isEmpty()) { - sb.append(" *\n"); + sb.append(indent).append(" *\n"); } else { - sb.append(" * ").append(line).append('\n'); + sb.append(indent).append(" * ").append(line).append('\n'); + } + } + sb.append(indent).append(" "); + return sb.toString(); + } + + private static String javadocIndent(Node node) { + int depth = 0; + Optional parent = node.getParentNode(); + while (parent.isPresent()) { + Node current = parent.get(); + if (current instanceof ClassOrInterfaceDeclaration) { + depth++; } + parent = current.getParentNode(); + } + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < depth; i++) { + sb.append(" "); } - sb.append(" "); return sb.toString(); } + private static String humanizeIdentifier(String identifier) { + if (identifier == null || identifier.isEmpty()) return ""; + String spaced = identifier.replaceAll("([a-z0-9])([A-Z])", "$1 $2") + .replace('_', ' ') + .replace('-', ' ') + .toLowerCase(Locale.ROOT); + return sanitizeJavadocText(spaced); + } + private static String sanitizeJavadocText(String s) { if (s == null || s.isEmpty()) return s; return s.replaceAll("\\s*&\\s*", " and ") From 85e68c901bbfc4497e3ce23caba7d5a79f8f33ec Mon Sep 17 00:00:00 2001 From: Fanis Tharropoulos Date: Thu, 11 Jun 2026 17:11:42 +0300 Subject: [PATCH 6/6] docs: generate new docs --- src/main/java/org/typesense/api/Alias.java | 14 ++++++ src/main/java/org/typesense/api/Aliases.java | 15 +++++++ .../java/org/typesense/api/Analytics.java | 7 +++ .../org/typesense/api/AnalyticsEvents.java | 15 +++++++ .../java/org/typesense/api/AnalyticsRule.java | 24 ++++++++++ .../api/AnalyticsRuleSerializer.java | 3 ++ .../org/typesense/api/AnalyticsRules.java | 23 ++++++++++ src/main/java/org/typesense/api/ApiCall.java | 12 +++++ src/main/java/org/typesense/api/Client.java | 12 +++++ .../java/org/typesense/api/Collection.java | 13 ++++++ .../java/org/typesense/api/Collections.java | 18 ++++++++ .../java/org/typesense/api/Configuration.java | 16 +++++++ .../java/org/typesense/api/CurationSet.java | 18 ++++++++ .../java/org/typesense/api/CurationSets.java | 15 +++++++ src/main/java/org/typesense/api/Debug.java | 10 +++++ src/main/java/org/typesense/api/Document.java | 13 ++++++ .../java/org/typesense/api/Documents.java | 45 +++++++++++++++++++ .../java/org/typesense/api/FieldTypes.java | 3 ++ src/main/java/org/typesense/api/Health.java | 10 +++++ src/main/java/org/typesense/api/Key.java | 14 ++++++ src/main/java/org/typesense/api/Keys.java | 14 ++++++ src/main/java/org/typesense/api/Metrics.java | 10 +++++ .../java/org/typesense/api/MultiSearch.java | 7 +++ .../java/org/typesense/api/Operations.java | 7 +++ src/main/java/org/typesense/api/Stemming.java | 7 +++ .../typesense/api/StemmingDictionaries.java | 20 +++++++++ .../StemmingDictionariesRetrieveSchema.java | 3 ++ .../org/typesense/api/StemmingDictionary.java | 11 +++++ .../java/org/typesense/api/Stopwords.java | 15 +++++++ .../java/org/typesense/api/StopwordsSet.java | 14 ++++++ src/main/java/org/typesense/api/Synonym.java | 6 +++ .../java/org/typesense/api/SynonymSet.java | 18 ++++++++ .../java/org/typesense/api/SynonymSets.java | 15 +++++++ src/main/java/org/typesense/api/Synonyms.java | 5 +++ 34 files changed, 452 insertions(+) diff --git a/src/main/java/org/typesense/api/Alias.java b/src/main/java/org/typesense/api/Alias.java index 5ca2a22..b9c94dc 100644 --- a/src/main/java/org/typesense/api/Alias.java +++ b/src/main/java/org/typesense/api/Alias.java @@ -3,11 +3,19 @@ import org.typesense.api.utils.URLEncoding; import org.typesense.model.CollectionAlias; +/** + * Typesense alias API wrapper. + */ public class Alias { public ApiCall apiCall; public String name; + /** + * Creates a new Alias instance. + * @param apiCall the {@code ApiCall} instance used to send requests + * @param name the {@code String} name + */ public Alias(ApiCall apiCall, String name) { this.apiCall = apiCall; this.name = name; @@ -22,6 +30,9 @@ public Alias(ApiCall apiCall, String name) { *

* HTTP: GET /aliases/{aliasName} * + * @return the {@code CollectionAlias} response + * @throws Exception if the request fails + * * @see Typesense docs */ public CollectionAlias retrieve() throws Exception { @@ -34,6 +45,9 @@ public CollectionAlias retrieve() throws Exception { *

* HTTP: DELETE /aliases/{aliasName} * + * @return the {@code CollectionAlias} response + * @throws Exception if the request fails + * * @see Typesense docs */ public CollectionAlias delete() throws Exception { diff --git a/src/main/java/org/typesense/api/Aliases.java b/src/main/java/org/typesense/api/Aliases.java index fbf3fc3..90a28d4 100644 --- a/src/main/java/org/typesense/api/Aliases.java +++ b/src/main/java/org/typesense/api/Aliases.java @@ -5,11 +5,18 @@ import org.typesense.model.CollectionAliasSchema; import org.typesense.model.CollectionAliasesResponse; +/** + * Typesense aliases API wrapper. + */ public class Aliases { private ApiCall apiCall; public final static String RESOURCE_PATH = "/aliases"; + /** + * Creates a new Aliases instance. + * @param apiCall the {@code ApiCall} instance used to send requests + */ public Aliases(ApiCall apiCall) { this.apiCall = apiCall; } @@ -23,6 +30,11 @@ public Aliases(ApiCall apiCall) { *

* HTTP: PUT /aliases/{aliasName} * + * @param name the {@code String} path parameter + * @param collectionAliasSchema the {@code CollectionAliasSchema} request body + * @return the {@code CollectionAlias} response + * @throws Exception if the request fails + * * @see Typesense docs */ public CollectionAlias upsert(String name, CollectionAliasSchema collectionAliasSchema) throws Exception { @@ -39,6 +51,9 @@ public CollectionAlias upsert(String name, CollectionAliasSchema collectionAlias *

* HTTP: GET /aliases * + * @return the {@code CollectionAliasesResponse} response + * @throws Exception if the request fails + * * @see Typesense docs */ public CollectionAliasesResponse retrieve() throws Exception { diff --git a/src/main/java/org/typesense/api/Analytics.java b/src/main/java/org/typesense/api/Analytics.java index 4503160..47bea0f 100644 --- a/src/main/java/org/typesense/api/Analytics.java +++ b/src/main/java/org/typesense/api/Analytics.java @@ -3,12 +3,19 @@ import java.util.HashMap; import java.util.Map; +/** + * Typesense analytics API wrapper. + */ public class Analytics { private final ApiCall apiCall; private final AnalyticsRules rules; private final Map individualRules; private final AnalyticsEvents events; + /** + * Creates a new Analytics instance. + * @param apiCall the {@code ApiCall} instance used to send requests + */ public Analytics(ApiCall apiCall) { this.apiCall = apiCall; this.rules = new AnalyticsRules(this.apiCall); diff --git a/src/main/java/org/typesense/api/AnalyticsEvents.java b/src/main/java/org/typesense/api/AnalyticsEvents.java index 7981f44..3346197 100644 --- a/src/main/java/org/typesense/api/AnalyticsEvents.java +++ b/src/main/java/org/typesense/api/AnalyticsEvents.java @@ -5,10 +5,17 @@ import org.typesense.model.AnalyticsEventsResponse; import java.util.Map; +/** + * Typesense analytics events API wrapper. + */ public class AnalyticsEvents { private final ApiCall apiCall; public final static String RESOURCE_PATH = "/analytics/events"; + /** + * Creates a new AnalyticsEvents instance. + * @param apiCall the {@code ApiCall} instance used to send requests + */ public AnalyticsEvents(ApiCall apiCall) { this.apiCall = apiCall; } @@ -22,6 +29,10 @@ public AnalyticsEvents(ApiCall apiCall) { *

* HTTP: POST /analytics/events * + * @param event the {@code AnalyticsEvent} request body + * @return the {@code AnalyticsEventCreateResponse} response + * @throws Exception if the request fails + * * @see Typesense docs */ public AnalyticsEventCreateResponse create(AnalyticsEvent event) throws Exception { @@ -37,6 +48,10 @@ public AnalyticsEventCreateResponse create(AnalyticsEvent event) throws Exceptio *

* HTTP: GET /analytics/events * + * @param params the {@code Map} query parameters + * @return the {@code AnalyticsEventsResponse} response + * @throws Exception if the request fails + * * @see Typesense docs */ public AnalyticsEventsResponse retrieve(Map params) throws Exception { diff --git a/src/main/java/org/typesense/api/AnalyticsRule.java b/src/main/java/org/typesense/api/AnalyticsRule.java index d98e942..5e961fd 100644 --- a/src/main/java/org/typesense/api/AnalyticsRule.java +++ b/src/main/java/org/typesense/api/AnalyticsRule.java @@ -3,17 +3,31 @@ import org.typesense.api.utils.URLEncoding; import org.typesense.model.AnalyticsRuleUpdate; +/** + * Typesense analytics rule API wrapper. + */ public class AnalyticsRule { private final ApiCall apiCall; private final String ruleId; private final AnalyticsRuleSerializer serializer; + /** + * Creates a new AnalyticsRule instance. + * @param ruleId the {@code String} path parameter + * @param apiCall the {@code ApiCall} instance used to send requests + */ public AnalyticsRule(String ruleId, ApiCall apiCall) { this.apiCall = apiCall; this.ruleId = ruleId; this.serializer = new AnalyticsRuleSerializer(); } + /** + * Creates a new AnalyticsRule instance. + * @param ruleId the {@code String} path parameter + * @param apiCall the {@code ApiCall} instance used to send requests + * @param serializer the {@code AnalyticsRuleSerializer} serializer + */ public AnalyticsRule(String ruleId, ApiCall apiCall, AnalyticsRuleSerializer serializer) { this.apiCall = apiCall; this.ruleId = ruleId; @@ -29,6 +43,9 @@ public AnalyticsRule(String ruleId, ApiCall apiCall, AnalyticsRuleSerializer ser *

* HTTP: GET /analytics/rules/{ruleName} * + * @return the {@code org.typesense.model.AnalyticsRule} response + * @throws Exception if the request fails + * * @see Typesense docs */ public org.typesense.model.AnalyticsRule retrieve() throws Exception { @@ -45,6 +62,9 @@ public org.typesense.model.AnalyticsRule retrieve() throws Exception { *

* HTTP: DELETE /analytics/rules/{ruleName} * + * @return the {@code org.typesense.model.AnalyticsRule} response + * @throws Exception if the request fails + * * @see Typesense docs */ public org.typesense.model.AnalyticsRule delete() throws Exception { @@ -63,6 +83,10 @@ public org.typesense.model.AnalyticsRule delete() throws Exception { *

* HTTP: PUT /analytics/rules/{ruleName} * + * @param rule the {@code AnalyticsRuleUpdate} request body + * @return the {@code org.typesense.model.AnalyticsRule} response + * @throws Exception if the request fails + * * @see Typesense docs */ public org.typesense.model.AnalyticsRule update(AnalyticsRuleUpdate rule) throws Exception { diff --git a/src/main/java/org/typesense/api/AnalyticsRuleSerializer.java b/src/main/java/org/typesense/api/AnalyticsRuleSerializer.java index 2e943ea..95add4f 100644 --- a/src/main/java/org/typesense/api/AnalyticsRuleSerializer.java +++ b/src/main/java/org/typesense/api/AnalyticsRuleSerializer.java @@ -17,6 +17,9 @@ public class AnalyticsRuleSerializer { private final ObjectMapper objectMapper; + /** + * Creates a new AnalyticsRuleSerializer instance. + */ public AnalyticsRuleSerializer() { this.objectMapper = new ObjectMapper(); this.objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); diff --git a/src/main/java/org/typesense/api/AnalyticsRules.java b/src/main/java/org/typesense/api/AnalyticsRules.java index 9653d50..8db2dca 100644 --- a/src/main/java/org/typesense/api/AnalyticsRules.java +++ b/src/main/java/org/typesense/api/AnalyticsRules.java @@ -4,17 +4,29 @@ import org.typesense.model.AnalyticsRuleCreate; import java.util.List; +/** + * Typesense analytics rules API wrapper. + */ public class AnalyticsRules { private final ApiCall apiCall; private final AnalyticsRuleSerializer serializer; public final static String RESOURCE_PATH = "/analytics/rules"; + /** + * Creates a new AnalyticsRules instance. + * @param apiCall the {@code ApiCall} instance used to send requests + */ public AnalyticsRules(ApiCall apiCall) { this.apiCall = apiCall; this.serializer = new AnalyticsRuleSerializer(); } + /** + * Creates a new AnalyticsRules instance. + * @param apiCall the {@code ApiCall} instance used to send requests + * @param serializer the {@code AnalyticsRuleSerializer} serializer + */ public AnalyticsRules(ApiCall apiCall, AnalyticsRuleSerializer serializer) { this.apiCall = apiCall; this.serializer = serializer; @@ -29,6 +41,10 @@ public AnalyticsRules(ApiCall apiCall, AnalyticsRuleSerializer serializer) { *

* HTTP: POST /analytics/rules * + * @param rules the {@code List} request body + * @return the {@code AnalyticsRulesResponse} response + * @throws Exception if the request fails + * * @see Typesense docs */ public AnalyticsRulesResponse create(List rules) throws Exception { @@ -45,6 +61,9 @@ public AnalyticsRulesResponse create(List rules) throws Exc *

* HTTP: GET /analytics/rules * + * @return the {@code List} response + * @throws Exception if the request fails + * * @see Typesense docs */ public List retrieve() throws Exception { @@ -82,6 +101,10 @@ private List parseRetrieveResponse(String jsonResponse) throws Ex public static class AnalyticsRulesResponse { private final List rules; + /** + * Creates a new AnalyticsRulesResponse instance. + * @param rules the {@code List} rules + */ public AnalyticsRulesResponse(List rules) { this.rules = rules; } diff --git a/src/main/java/org/typesense/api/ApiCall.java b/src/main/java/org/typesense/api/ApiCall.java index 23ceed3..fc02181 100644 --- a/src/main/java/org/typesense/api/ApiCall.java +++ b/src/main/java/org/typesense/api/ApiCall.java @@ -19,6 +19,9 @@ import java.util.Map; import java.util.concurrent.TimeUnit; +/** + * Typesense api call API wrapper. + */ public class ApiCall { private final Configuration configuration; @@ -35,6 +38,11 @@ public class ApiCall { public static final MediaType JSON = MediaType.parse("application/json; charset=utf-8"); private final ObjectMapper mapper = new ObjectMapper(); + /** + * Creates a new ApiCall instance. + * @param configuration the client configuration + * @param client the HTTP client + */ public ApiCall(Configuration configuration, OkHttpClient client) { this.configuration = configuration; this.nodes = configuration.nodes; @@ -47,6 +55,10 @@ public ApiCall(Configuration configuration, OkHttpClient client) { this.client = client; } + /** + * Creates a new ApiCall instance. + * @param configuration the client configuration + */ public ApiCall(Configuration configuration) { this.configuration = configuration; this.nodes = configuration.nodes; diff --git a/src/main/java/org/typesense/api/Client.java b/src/main/java/org/typesense/api/Client.java index b892628..4d4f64e 100644 --- a/src/main/java/org/typesense/api/Client.java +++ b/src/main/java/org/typesense/api/Client.java @@ -6,6 +6,9 @@ import java.util.HashMap; import java.util.Map; +/** + * Typesense client API wrapper. + */ public class Client { private Configuration configuration; @@ -40,6 +43,11 @@ public class Client { public Debug debug; public MultiSearch multiSearch; + /** + * Creates a new Client instance. + * @param configuration the client configuration + * @param okHttpClient the HTTP client + */ public Client(Configuration configuration, OkHttpClient okHttpClient){ this.configuration = configuration; this.apiCall = new ApiCall(configuration, okHttpClient); @@ -60,6 +68,10 @@ public Client(Configuration configuration, OkHttpClient okHttpClient){ this.individualStopwordsSets = new HashMap<>(); } + /** + * Creates a new Client instance. + * @param configuration the client configuration + */ public Client(Configuration configuration){ this.configuration = configuration; this.apiCall = new ApiCall(configuration); diff --git a/src/main/java/org/typesense/api/Collection.java b/src/main/java/org/typesense/api/Collection.java index 0589814..f1e9cf6 100644 --- a/src/main/java/org/typesense/api/Collection.java +++ b/src/main/java/org/typesense/api/Collection.java @@ -7,6 +7,9 @@ import java.util.HashMap; import java.util.Map; +/** + * Typesense collection API wrapper. + */ public class Collection { private final Configuration configuration; @@ -43,6 +46,9 @@ public class Collection { *

* HTTP: GET /collections/{collectionName} * + * @return the {@code CollectionResponse} response + * @throws Exception if the request fails + * * @see Typesense docs */ public CollectionResponse retrieve() throws Exception { @@ -58,6 +64,10 @@ public CollectionResponse retrieve() throws Exception { *

* HTTP: PATCH /collections/{collectionName} * + * @param c the {@code CollectionUpdateSchema} request body + * @return the {@code CollectionUpdateSchema} response + * @throws Exception if the request fails + * * @see Typesense docs */ public CollectionUpdateSchema update(CollectionUpdateSchema c) throws Exception { @@ -73,6 +83,9 @@ public CollectionUpdateSchema update(CollectionUpdateSchema c) throws Exception *

* HTTP: DELETE /collections/{collectionName} * + * @return the {@code CollectionResponse} response + * @throws Exception if the request fails + * * @see Typesense docs */ public CollectionResponse delete() throws Exception { diff --git a/src/main/java/org/typesense/api/Collections.java b/src/main/java/org/typesense/api/Collections.java index f75317d..d3956d9 100644 --- a/src/main/java/org/typesense/api/Collections.java +++ b/src/main/java/org/typesense/api/Collections.java @@ -3,11 +3,18 @@ import org.typesense.model.CollectionResponse; import org.typesense.model.CollectionSchema; +/** + * Typesense collections API wrapper. + */ public class Collections { private final ApiCall apiCall; public final static String RESOURCE_PATH = "/collections"; + /** + * Creates a new Collections instance. + * @param apiCall the {@code ApiCall} instance used to send requests + */ public Collections(ApiCall apiCall){ this.apiCall = apiCall; } @@ -21,6 +28,10 @@ public Collections(ApiCall apiCall){ *

* HTTP: POST /collections * + * @param c the {@code CollectionSchema} request body + * @return the {@code CollectionResponse} response + * @throws Exception if the request fails + * * @see Typesense docs */ public CollectionResponse create(CollectionSchema c) throws Exception { @@ -36,6 +47,10 @@ public CollectionResponse create(CollectionSchema c) throws Exception { *

* HTTP: POST /collections * + * @param schemaJson the {@code String} request body + * @return the {@code CollectionResponse} response + * @throws Exception if the request fails + * * @see Typesense docs */ public CollectionResponse create(String schemaJson) throws Exception { @@ -51,6 +66,9 @@ public CollectionResponse create(String schemaJson) throws Exception { *

* HTTP: GET /collections * + * @return the {@code CollectionResponse[]} response array + * @throws Exception if the request fails + * * @see Typesense docs */ public CollectionResponse[] retrieve() throws Exception { diff --git a/src/main/java/org/typesense/api/Configuration.java b/src/main/java/org/typesense/api/Configuration.java index 6e0e825..7e7e5d6 100644 --- a/src/main/java/org/typesense/api/Configuration.java +++ b/src/main/java/org/typesense/api/Configuration.java @@ -5,6 +5,9 @@ import java.time.Duration; import java.util.List; +/** + * Typesense configuration API wrapper. + */ public class Configuration { public List nodes; @@ -24,6 +27,12 @@ public class Configuration { * @param apiKey String describing the apiKey */ + /** + * Creates a new Configuration instance. + * @param nodes the {@code List} nodes + * @param connectionTimeout the {@code Duration} connection timeout + * @param apiKey the {@code String} api key + */ public Configuration(List nodes, Duration connectionTimeout, String apiKey) { this.nodes = nodes; this.connectionTimeout = connectionTimeout; @@ -55,6 +64,13 @@ public Configuration(List nodes, Duration connectionTimeout, Duration read this.sendApiKeyAsQueryParam = false; } + /** + * Creates a new Configuration instance. + * @param nearestNode the {@code Node} nearest node + * @param nodes the {@code List} nodes + * @param connectionTimeout the {@code Duration} connection timeout + * @param apiKey the {@code String} api key + */ public Configuration(Node nearestNode, List nodes, Duration connectionTimeout, String apiKey) { this(nodes,connectionTimeout,apiKey); this.nearestNode = nearestNode; diff --git a/src/main/java/org/typesense/api/CurationSet.java b/src/main/java/org/typesense/api/CurationSet.java index 5326294..ad44a9a 100644 --- a/src/main/java/org/typesense/api/CurationSet.java +++ b/src/main/java/org/typesense/api/CurationSet.java @@ -5,11 +5,19 @@ import org.typesense.model.CurationSetSchema; import org.typesense.model.CurationSetDeleteSchema; +/** + * Typesense curation set API wrapper. + */ public class CurationSet { private String curationSetName; private ApiCall apiCall; + /** + * Creates a new CurationSet instance. + * @param curationSetName the {@code String} path parameter + * @param apiCall the {@code ApiCall} instance used to send requests + */ public CurationSet(String curationSetName, ApiCall apiCall) { this.curationSetName = curationSetName; this.apiCall = apiCall; @@ -24,6 +32,9 @@ public CurationSet(String curationSetName, ApiCall apiCall) { *

* HTTP: GET /curation_sets/{curationSetName} * + * @return the {@code CurationSetCreateSchema} response + * @throws Exception if the request fails + * * @see Typesense docs */ public CurationSetCreateSchema retrieve() throws Exception { @@ -39,6 +50,10 @@ public CurationSetCreateSchema retrieve() throws Exception { *

* HTTP: PUT /curation_sets/{curationSetName} * + * @param curationSetCreateSchema the {@code CurationSetCreateSchema} request body + * @return the {@code CurationSetSchema} response + * @throws Exception if the request fails + * * @see Typesense docs */ public CurationSetSchema upsert(CurationSetCreateSchema curationSetCreateSchema) throws Exception { @@ -54,6 +69,9 @@ public CurationSetSchema upsert(CurationSetCreateSchema curationSetCreateSchema) *

* HTTP: DELETE /curation_sets/{curationSetName} * + * @return the {@code CurationSetDeleteSchema} response + * @throws Exception if the request fails + * * @see Typesense docs */ public CurationSetDeleteSchema delete() throws Exception { diff --git a/src/main/java/org/typesense/api/CurationSets.java b/src/main/java/org/typesense/api/CurationSets.java index b558b7a..c695805 100644 --- a/src/main/java/org/typesense/api/CurationSets.java +++ b/src/main/java/org/typesense/api/CurationSets.java @@ -3,11 +3,18 @@ import org.typesense.model.CurationSetCreateSchema; import org.typesense.model.CurationSetSchema; +/** + * Typesense curation sets API wrapper. + */ public class CurationSets { private ApiCall apiCall; public final static String RESOURCEPATH = "/curation_sets"; + /** + * Creates a new CurationSets instance. + * @param apiCall the {@code ApiCall} instance used to send requests + */ public CurationSets(ApiCall apiCall) { this.apiCall = apiCall; } @@ -21,6 +28,11 @@ public CurationSets(ApiCall apiCall) { *

* HTTP: PUT /curation_sets/{curationSetName} * + * @param curationSetName the {@code String} path parameter + * @param curationSetCreateSchema the {@code CurationSetCreateSchema} request body + * @return the {@code CurationSetSchema} response + * @throws Exception if the request fails + * * @see Typesense docs */ public CurationSetSchema upsert(String curationSetName, CurationSetCreateSchema curationSetCreateSchema) throws Exception { @@ -36,6 +48,9 @@ public CurationSetSchema upsert(String curationSetName, CurationSetCreateSchema *

* HTTP: GET /curation_sets/{curationSetName} * + * @return the {@code CurationSetSchema[]} response array + * @throws Exception if the request fails + * * @see Typesense docs */ public CurationSetSchema[] retrieve() throws Exception { diff --git a/src/main/java/org/typesense/api/Debug.java b/src/main/java/org/typesense/api/Debug.java index 64c2c37..980749a 100644 --- a/src/main/java/org/typesense/api/Debug.java +++ b/src/main/java/org/typesense/api/Debug.java @@ -2,11 +2,18 @@ import java.util.Map; +/** + * Typesense debug API wrapper. + */ public class Debug { private ApiCall apiCall; public static final String RESOURCEPATH = "/debug"; + /** + * Creates a new Debug instance. + * @param apiCall the {@code ApiCall} instance used to send requests + */ public Debug(ApiCall apiCall) { this.apiCall = apiCall; } @@ -17,6 +24,9 @@ public Debug(ApiCall apiCall) { *

* HTTP: GET /debug * + * @return the {@code Map} response map + * @throws Exception if the request fails + * * @see Typesense docs */ public Map retrieve() throws Exception { diff --git a/src/main/java/org/typesense/api/Document.java b/src/main/java/org/typesense/api/Document.java index 6113ac4..4160879 100644 --- a/src/main/java/org/typesense/api/Document.java +++ b/src/main/java/org/typesense/api/Document.java @@ -3,6 +3,9 @@ import java.util.Map; import org.typesense.api.utils.URLEncoding; +/** + * Typesense document API wrapper. + */ public class Document { private String collectionName; private String documentId; @@ -27,6 +30,9 @@ public class Document { *

* HTTP: GET /collections/{collectionName}/documents/{documentId} * + * @return the {@code Map} response map + * @throws Exception if the request fails + * * @see Typesense docs */ public Map retrieve() throws Exception { @@ -42,6 +48,9 @@ public Map retrieve() throws Exception { *

* HTTP: DELETE /collections/{collectionName}/documents/{documentId} * + * @return the {@code Map} response map + * @throws Exception if the request fails + * * @see Typesense docs */ public Map delete() throws Exception { @@ -57,6 +66,10 @@ public Map delete() throws Exception { *

* HTTP: PATCH /collections/{collectionName}/documents/{documentId} * + * @param document the {@code Map} request body + * @return the {@code Map} response map + * @throws Exception if the request fails + * * @see Typesense docs */ public Map update(Map document) throws Exception { diff --git a/src/main/java/org/typesense/api/Documents.java b/src/main/java/org/typesense/api/Documents.java index 6827891..b00b1cd 100644 --- a/src/main/java/org/typesense/api/Documents.java +++ b/src/main/java/org/typesense/api/Documents.java @@ -15,6 +15,9 @@ import org.typesense.model.SearchResult; import org.typesense.model.UpdateDocumentsParameters; +/** + * Typesense documents API wrapper. + */ public class Documents { private String collectionName; @@ -38,6 +41,10 @@ public class Documents { *

* HTTP: POST /collections/{collectionName}/documents * + * @param document the {@code Map} request body + * @return the {@code Map} response map + * @throws Exception if the request fails + * * @see Typesense docs */ public Map create(Map document) throws Exception { @@ -53,6 +60,10 @@ public Map create(Map document) throws Exception *

* HTTP: POST /collections/{collectionName}/documents * + * @param document the {@code String} request body + * @return the raw response body + * @throws Exception if the request fails + * * @see Typesense docs */ public String create(String document) throws Exception { @@ -68,6 +79,11 @@ public String create(String document) throws Exception { *

* HTTP: POST /collections/{collectionName}/documents * + * @param document the {@code Map} request body + * @param queryParameters the {@code ImportDocumentsParameters} query parameters + * @return the raw response body + * @throws Exception if the request fails + * * @see Typesense docs */ public String create(Map document, ImportDocumentsParameters queryParameters) throws Exception { @@ -83,6 +99,10 @@ public String create(Map document, ImportDocumentsParameters que *

* HTTP: POST /collections/{collectionName}/documents * + * @param document the {@code Map} request body + * @return the {@code Map} response map + * @throws Exception if the request fails + * * @see Typesense docs */ public Map upsert(Map document) throws Exception { @@ -101,6 +121,10 @@ public Map upsert(Map document) throws Exception *

* HTTP: GET /collections/{collectionName}/documents/search * + * @param searchParameters the {@code SearchParameters} query parameters + * @return the {@code SearchResult} response + * @throws Exception if the request fails + * * @see Typesense docs */ public SearchResult search(SearchParameters searchParameters) throws Exception { @@ -116,6 +140,10 @@ public SearchResult search(SearchParameters searchParameters) throws Exception { *

* HTTP: DELETE /collections/{collectionName}/documents * + * @param queryParameters the {@code DeleteDocumentsParameters} query parameters + * @return the {@code Map} response map + * @throws Exception if the request fails + * * @see Typesense docs */ public Map delete(DeleteDocumentsParameters queryParameters) throws Exception { @@ -131,6 +159,9 @@ public Map delete(DeleteDocumentsParameters queryParameters) thr *

* HTTP: GET /collections/{collectionName}/documents/export * + * @return the raw response body + * @throws Exception if the request fails + * * @see Typesense docs */ public String export() throws Exception { @@ -146,6 +177,10 @@ public String export() throws Exception { *

* HTTP: GET /collections/{collectionName}/documents/export * + * @param exportDocumentsParameters the {@code ExportDocumentsParameters} query parameters + * @return the raw response body + * @throws Exception if the request fails + * * @see Typesense docs */ public String export(ExportDocumentsParameters exportDocumentsParameters) throws Exception { @@ -161,6 +196,11 @@ public String export(ExportDocumentsParameters exportDocumentsParameters) throws *

* HTTP: POST /collections/{collectionName}/documents/import * + * @param document the {@code String} request body + * @param queryParameters the {@code ImportDocumentsParameters} query parameters + * @return the raw response body + * @throws Exception if the request fails + * * @see Typesense docs */ public String import_(String document, ImportDocumentsParameters queryParameters) throws Exception { @@ -176,6 +216,11 @@ public String import_(String document, ImportDocumentsParameters queryParameters *

* HTTP: POST /collections/{collectionName}/documents/import * + * @param documents the {@code Collection} documents + * @param queryParameters the {@code ImportDocumentsParameters} query parameters + * @return the raw response body + * @throws Exception if the request fails + * * @see Typesense docs */ public String import_(Collection documents, diff --git a/src/main/java/org/typesense/api/FieldTypes.java b/src/main/java/org/typesense/api/FieldTypes.java index 0db7e66..70edac9 100644 --- a/src/main/java/org/typesense/api/FieldTypes.java +++ b/src/main/java/org/typesense/api/FieldTypes.java @@ -1,5 +1,8 @@ package org.typesense.api; +/** + * Typesense field types API wrapper. + */ public final class FieldTypes { public static final String STRING = "string"; public static final String INT32 = "int32"; diff --git a/src/main/java/org/typesense/api/Health.java b/src/main/java/org/typesense/api/Health.java index 7b14756..2298ba5 100644 --- a/src/main/java/org/typesense/api/Health.java +++ b/src/main/java/org/typesense/api/Health.java @@ -2,11 +2,18 @@ import java.util.Map; +/** + * Typesense health API wrapper. + */ public class Health { private ApiCall apiCall; public static final String RESOURCEPATH = "/health"; + /** + * Creates a new Health instance. + * @param apiCall the {@code ApiCall} instance used to send requests + */ public Health(ApiCall apiCall) { this.apiCall = apiCall; } @@ -17,6 +24,9 @@ public Health(ApiCall apiCall) { *

* HTTP: GET /health * + * @return the {@code Map} response map + * @throws Exception if the request fails + * * @see Typesense docs */ public Map retrieve() throws Exception { diff --git a/src/main/java/org/typesense/api/Key.java b/src/main/java/org/typesense/api/Key.java index 1782930..683eb40 100644 --- a/src/main/java/org/typesense/api/Key.java +++ b/src/main/java/org/typesense/api/Key.java @@ -2,11 +2,19 @@ import org.typesense.model.ApiKey; +/** + * Typesense key API wrapper. + */ public class Key { private Long id; private ApiCall apiCall; + /** + * Creates a new Key instance. + * @param id the {@code Long} id + * @param apiCall the {@code ApiCall} instance used to send requests + */ public Key(Long id, ApiCall apiCall) { this.id = id; this.apiCall = apiCall; @@ -21,6 +29,9 @@ public Key(Long id, ApiCall apiCall) { *

* HTTP: GET /keys/{keyId} * + * @return the {@code ApiKey} response + * @throws Exception if the request fails + * * @see Typesense docs */ public ApiKey retrieve() throws Exception { @@ -33,6 +44,9 @@ public ApiKey retrieve() throws Exception { *

* HTTP: DELETE /keys/{keyId} * + * @return the {@code ApiKey} response + * @throws Exception if the request fails + * * @see Typesense docs */ public ApiKey delete() throws Exception { diff --git a/src/main/java/org/typesense/api/Keys.java b/src/main/java/org/typesense/api/Keys.java index 98d3768..dcdca14 100644 --- a/src/main/java/org/typesense/api/Keys.java +++ b/src/main/java/org/typesense/api/Keys.java @@ -12,11 +12,18 @@ import java.util.Base64; import java.util.Map; +/** + * Typesense keys API wrapper. + */ public class Keys { public static final String RESOURCEPATH = "/keys"; private ApiCall apiCall; + /** + * Creates a new Keys instance. + * @param apiCall the {@code ApiCall} instance used to send requests + */ public Keys(ApiCall apiCall) { this.apiCall = apiCall; } @@ -30,6 +37,10 @@ public Keys(ApiCall apiCall) { *

* HTTP: POST /keys * + * @param apiKeySchema the {@code ApiKeySchema} request body + * @return the {@code ApiKey} response + * @throws Exception if the request fails + * * @see Typesense docs */ public ApiKey create(ApiKeySchema apiKeySchema) throws Exception { @@ -45,6 +56,9 @@ public ApiKey create(ApiKeySchema apiKeySchema) throws Exception { *

* HTTP: GET /keys * + * @return the {@code ApiKeysResponse} response + * @throws Exception if the request fails + * * @see Typesense docs */ public ApiKeysResponse retrieve() throws Exception { diff --git a/src/main/java/org/typesense/api/Metrics.java b/src/main/java/org/typesense/api/Metrics.java index b3fed9c..5850f0c 100644 --- a/src/main/java/org/typesense/api/Metrics.java +++ b/src/main/java/org/typesense/api/Metrics.java @@ -2,11 +2,18 @@ import java.util.Map; +/** + * Typesense metrics API wrapper. + */ public class Metrics { private ApiCall apiCall; public static final String RESOURCEPATH = "/metrics.json"; + /** + * Creates a new Metrics instance. + * @param apiCall the {@code ApiCall} instance used to send requests + */ public Metrics(ApiCall apiCall) { this.apiCall = apiCall; } @@ -20,6 +27,9 @@ public Metrics(ApiCall apiCall) { *

* HTTP: GET /metrics.json * + * @return the {@code Map} response map + * @throws Exception if the request fails + * * @see Typesense docs */ public Map retrieve() throws Exception { diff --git a/src/main/java/org/typesense/api/MultiSearch.java b/src/main/java/org/typesense/api/MultiSearch.java index 12ac458..600d07b 100644 --- a/src/main/java/org/typesense/api/MultiSearch.java +++ b/src/main/java/org/typesense/api/MultiSearch.java @@ -6,11 +6,18 @@ import java.util.Map; +/** + * Typesense multi search API wrapper. + */ public class MultiSearch { private ApiCall apiCall; public static final String RESOURCEPATH = "/multi_search"; + /** + * Creates a new MultiSearch instance. + * @param apiCall the {@code ApiCall} instance used to send requests + */ public MultiSearch(ApiCall apiCall) { this.apiCall = apiCall; } diff --git a/src/main/java/org/typesense/api/Operations.java b/src/main/java/org/typesense/api/Operations.java index 0ecece3..95a1191 100644 --- a/src/main/java/org/typesense/api/Operations.java +++ b/src/main/java/org/typesense/api/Operations.java @@ -2,11 +2,18 @@ import java.util.Map; +/** + * Typesense operations API wrapper. + */ public class Operations { private ApiCall apiCall; public static final String RESOUCEPATH = "/operations"; + /** + * Creates a new Operations instance. + * @param apiCall the {@code ApiCall} instance used to send requests + */ public Operations(ApiCall apiCall) { this.apiCall = apiCall; } diff --git a/src/main/java/org/typesense/api/Stemming.java b/src/main/java/org/typesense/api/Stemming.java index 0942c5d..9e1bfe2 100644 --- a/src/main/java/org/typesense/api/Stemming.java +++ b/src/main/java/org/typesense/api/Stemming.java @@ -3,12 +3,19 @@ import java.util.HashMap; import java.util.Map; +/** + * Typesense stemming API wrapper. + */ public class Stemming { private final ApiCall apiCall; private final StemmingDictionaries dictionaries; private final Map individualDictionaries; + /** + * Creates a new Stemming instance. + * @param apiCall the {@code ApiCall} instance used to send requests + */ public Stemming(ApiCall apiCall) { this.apiCall = apiCall; this.dictionaries = new StemmingDictionaries(this.apiCall); diff --git a/src/main/java/org/typesense/api/StemmingDictionaries.java b/src/main/java/org/typesense/api/StemmingDictionaries.java index 95a53ae..f8a7e4d 100644 --- a/src/main/java/org/typesense/api/StemmingDictionaries.java +++ b/src/main/java/org/typesense/api/StemmingDictionaries.java @@ -9,10 +9,17 @@ import com.fasterxml.jackson.databind.ObjectMapper; +/** + * Typesense stemming dictionaries API wrapper. + */ public class StemmingDictionaries { private final ApiCall apiCall; public final static String RESOURCE_PATH = "/stemming/dictionaries"; + /** + * Creates a new StemmingDictionaries instance. + * @param apiCall the {@code ApiCall} instance used to send requests + */ public StemmingDictionaries(ApiCall apiCall) { this.apiCall = apiCall; } @@ -26,6 +33,11 @@ public StemmingDictionaries(ApiCall apiCall) { *

* HTTP: POST /stemming/dictionaries/import * + * @param dictionaryId the {@code String} dictionary id + * @param wordRootCombinations the {@code String} request body + * @return the raw response body + * @throws Exception if the request fails + * * @see Typesense docs */ public String upsert(String dictionaryId, String wordRootCombinations) throws Exception { @@ -43,6 +55,11 @@ public String upsert(String dictionaryId, String wordRootCombinations) throws Ex *

* HTTP: POST /stemming/dictionaries/import * + * @param dictionaryId the {@code String} dictionary id + * @param wordRootCombinations the {@code List} word root combinations + * @return the {@code List} response + * @throws Exception if the request fails + * * @see Typesense docs */ public List upsert(String dictionaryId, List wordRootCombinations) @@ -77,6 +94,9 @@ public List upsert(String dictionaryId, List * HTTP: GET /stemming/dictionaries * + * @return the {@code StemmingDictionariesRetrieveSchema} response + * @throws Exception if the request fails + * * @see Typesense docs */ public StemmingDictionariesRetrieveSchema retrieve() throws Exception { diff --git a/src/main/java/org/typesense/api/StemmingDictionariesRetrieveSchema.java b/src/main/java/org/typesense/api/StemmingDictionariesRetrieveSchema.java index aa956ac..30df9d9 100644 --- a/src/main/java/org/typesense/api/StemmingDictionariesRetrieveSchema.java +++ b/src/main/java/org/typesense/api/StemmingDictionariesRetrieveSchema.java @@ -2,6 +2,9 @@ import java.util.List; +/** + * Typesense stemming dictionaries retrieve schema API wrapper. + */ public class StemmingDictionariesRetrieveSchema { private List dictionaries; diff --git a/src/main/java/org/typesense/api/StemmingDictionary.java b/src/main/java/org/typesense/api/StemmingDictionary.java index 31dea20..359c403 100644 --- a/src/main/java/org/typesense/api/StemmingDictionary.java +++ b/src/main/java/org/typesense/api/StemmingDictionary.java @@ -2,10 +2,18 @@ import org.typesense.api.utils.URLEncoding; +/** + * Typesense stemming dictionary API wrapper. + */ public class StemmingDictionary { private final ApiCall apiCall; private final String dictionaryId; + /** + * Creates a new StemmingDictionary instance. + * @param dictionaryId the {@code String} path parameter + * @param apiCall the {@code ApiCall} instance used to send requests + */ public StemmingDictionary(String dictionaryId, ApiCall apiCall) { this.apiCall = apiCall; this.dictionaryId = dictionaryId; @@ -21,6 +29,9 @@ public StemmingDictionary(String dictionaryId, ApiCall apiCall) { *

* HTTP: GET /stemming/dictionaries/{dictionaryId} * + * @return the {@code org.typesense.model.StemmingDictionary} response + * @throws Exception if the request fails + * * @see Typesense docs */ public org.typesense.model.StemmingDictionary retrieve() throws Exception { diff --git a/src/main/java/org/typesense/api/Stopwords.java b/src/main/java/org/typesense/api/Stopwords.java index 2eb238d..d0c4621 100644 --- a/src/main/java/org/typesense/api/Stopwords.java +++ b/src/main/java/org/typesense/api/Stopwords.java @@ -5,11 +5,18 @@ import org.typesense.model.StopwordsSetUpsertSchema; import org.typesense.model.StopwordsSetsRetrieveAllSchema; +/** + * Typesense stopwords API wrapper. + */ public class Stopwords { public final static String RESOURCEPATH = "/stopwords"; private final ApiCall apiCall; + /** + * Creates a new Stopwords instance. + * @param apiCall the {@code ApiCall} instance used to send requests + */ public Stopwords(ApiCall apiCall) { this.apiCall = apiCall; } @@ -23,6 +30,11 @@ public Stopwords(ApiCall apiCall) { *

* HTTP: PUT /stopwords/{setId} * + * @param stopwordSetId the {@code String} path parameter + * @param stopwordSet the {@code StopwordsSetUpsertSchema} request body + * @return the {@code StopwordsSetSchema} response + * @throws Exception if the request fails + * * @see Typesense docs */ public StopwordsSetSchema upsert(String stopwordSetId, StopwordsSetUpsertSchema stopwordSet) throws Exception { @@ -38,6 +50,9 @@ public StopwordsSetSchema upsert(String stopwordSetId, StopwordsSetUpsertSchema *

* HTTP: GET /stopwords * + * @return the {@code StopwordsSetsRetrieveAllSchema} response + * @throws Exception if the request fails + * * @see Typesense docs */ public StopwordsSetsRetrieveAllSchema retrieve() throws Exception { diff --git a/src/main/java/org/typesense/api/StopwordsSet.java b/src/main/java/org/typesense/api/StopwordsSet.java index 986b7b4..bbe10ee 100644 --- a/src/main/java/org/typesense/api/StopwordsSet.java +++ b/src/main/java/org/typesense/api/StopwordsSet.java @@ -4,10 +4,18 @@ import org.typesense.model.StopwordsSetRetrieveSchema; import org.typesense.model.StopwordsSetSchema; +/** + * Typesense stopwords set API wrapper. + */ public class StopwordsSet { private final ApiCall apiCall; private final String stopwordsSetId; + /** + * Creates a new StopwordsSet instance. + * @param stopwordsSetId the {@code String} path parameter + * @param apiCall the {@code ApiCall} instance used to send requests + */ public StopwordsSet(String stopwordsSetId, ApiCall apiCall) { this.stopwordsSetId = stopwordsSetId; this.apiCall = apiCall; @@ -22,6 +30,9 @@ public StopwordsSet(String stopwordsSetId, ApiCall apiCall) { *

* HTTP: GET /stopwords/{setId} * + * @return the {@code StopwordsSetRetrieveSchema} response + * @throws Exception if the request fails + * * @see Typesense docs */ public StopwordsSetRetrieveSchema retrieve() throws Exception { @@ -37,6 +48,9 @@ public StopwordsSetRetrieveSchema retrieve() throws Exception { *

* HTTP: DELETE /stopwords/{setId} * + * @return the {@code StopwordsSetSchema} response + * @throws Exception if the request fails + * * @see Typesense docs */ public StopwordsSetSchema delete() throws Exception { diff --git a/src/main/java/org/typesense/api/Synonym.java b/src/main/java/org/typesense/api/Synonym.java index 1a8affe..0959be7 100644 --- a/src/main/java/org/typesense/api/Synonym.java +++ b/src/main/java/org/typesense/api/Synonym.java @@ -18,6 +18,12 @@ public class Synonym { private String synonymId; private ApiCall apiCall; + /** + * Creates a new Synonym instance. + * @param collectionName the {@code String} path parameter + * @param synonymId the {@code String} path parameter + * @param apiCall the {@code ApiCall} instance used to send requests + */ public Synonym(String collectionName, String synonymId, ApiCall apiCall) { this.collectionName = collectionName; this.synonymId = synonymId; diff --git a/src/main/java/org/typesense/api/SynonymSet.java b/src/main/java/org/typesense/api/SynonymSet.java index a993c99..a3fd4cd 100644 --- a/src/main/java/org/typesense/api/SynonymSet.java +++ b/src/main/java/org/typesense/api/SynonymSet.java @@ -6,11 +6,19 @@ import org.typesense.model.SynonymSetSchema; import org.typesense.model.SynonymSetDeleteSchema; +/** + * Typesense synonym set API wrapper. + */ public class SynonymSet { private String synonymSetName; private ApiCall apiCall; + /** + * Creates a new SynonymSet instance. + * @param synonymSetName the {@code String} path parameter + * @param apiCall the {@code ApiCall} instance used to send requests + */ public SynonymSet(String synonymSetName, ApiCall apiCall) { this.synonymSetName = synonymSetName; this.apiCall = apiCall; @@ -25,6 +33,9 @@ public SynonymSet(String synonymSetName, ApiCall apiCall) { *

* HTTP: GET /synonym_sets/{synonymSetName} * + * @return the {@code SynonymSetCreateSchema} response + * @throws Exception if the request fails + * * @see Typesense docs */ public SynonymSetCreateSchema retrieve() throws Exception { @@ -40,6 +51,10 @@ public SynonymSetCreateSchema retrieve() throws Exception { *

* HTTP: PUT /synonym_sets/{synonymSetName} * + * @param synonymSetCreateSchema the {@code SynonymSetCreateSchema} request body + * @return the {@code SynonymSetSchema} response + * @throws Exception if the request fails + * * @see Typesense docs */ public SynonymSetSchema upsert(SynonymSetCreateSchema synonymSetCreateSchema) throws Exception { @@ -55,6 +70,9 @@ public SynonymSetSchema upsert(SynonymSetCreateSchema synonymSetCreateSchema) th *

* HTTP: DELETE /synonym_sets/{synonymSetName} * + * @return the {@code SynonymSetDeleteSchema} response + * @throws Exception if the request fails + * * @see Typesense docs */ public SynonymSetDeleteSchema delete() throws Exception { diff --git a/src/main/java/org/typesense/api/SynonymSets.java b/src/main/java/org/typesense/api/SynonymSets.java index 74f7fd6..d9a9783 100644 --- a/src/main/java/org/typesense/api/SynonymSets.java +++ b/src/main/java/org/typesense/api/SynonymSets.java @@ -4,11 +4,18 @@ import org.typesense.model.SynonymSetCreateSchema; import org.typesense.model.SynonymSetSchema; +/** + * Typesense synonym sets API wrapper. + */ public class SynonymSets { private ApiCall apiCall; public final static String RESOURCEPATH = "/synonym_sets"; + /** + * Creates a new SynonymSets instance. + * @param apiCall the {@code ApiCall} instance used to send requests + */ public SynonymSets(ApiCall apiCall) { this.apiCall = apiCall; } @@ -22,6 +29,11 @@ public SynonymSets(ApiCall apiCall) { *

* HTTP: PUT /synonym_sets/{synonymSetName} * + * @param synonymSetName the {@code String} path parameter + * @param synonymSetCreateSchema the {@code SynonymSetCreateSchema} request body + * @return the {@code SynonymSetSchema} response + * @throws Exception if the request fails + * * @see Typesense docs */ public SynonymSetSchema upsert(String synonymSetName, SynonymSetCreateSchema synonymSetCreateSchema) throws Exception { @@ -37,6 +49,9 @@ public SynonymSetSchema upsert(String synonymSetName, SynonymSetCreateSchema syn *

* HTTP: GET /synonym_sets/{synonymSetName} * + * @return the {@code SynonymSetSchema[]} response array + * @throws Exception if the request fails + * * @see Typesense docs */ public SynonymSetSchema[] retrieve() throws Exception { diff --git a/src/main/java/org/typesense/api/Synonyms.java b/src/main/java/org/typesense/api/Synonyms.java index e46fc8b..e3dd131 100644 --- a/src/main/java/org/typesense/api/Synonyms.java +++ b/src/main/java/org/typesense/api/Synonyms.java @@ -20,6 +20,11 @@ public class Synonyms { private ApiCall apiCall; public final static String RESOURCEPATH = "/synonyms"; + /** + * Creates a new Synonyms instance. + * @param collectionName the {@code String} path parameter + * @param apiCall the {@code ApiCall} instance used to send requests + */ public Synonyms(String collectionName, ApiCall apiCall) { this.collectionName = collectionName; this.apiCall = apiCall;