### start Method Source: https://javadoc.io/doc/com.google.gerrit/gerrit-plugin-api/3.13.0-rc1/com/google/gerrit/server/plugins/PluginMetricMaker Invoked when the server is starting. ```APIDOC ## start Method ### Description Invoked when the server is starting. This method is part of the LifecycleListener interface. ### Method `start` ### Endpoint N/A (Method within a class) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json { "example": "start()" } ``` ### Response #### Success Response (200) None #### Response Example ```json { "example": "void" } ``` ``` -------------------------------- ### start() Method Implementation (Java) Source: https://javadoc.io/doc/com.google.gerrit/gerrit-plugin-api/3.13.0-rc1/com/google/gerrit/server/git/GarbageCollectionLogFile The implementation of the start() method, inherited from the LifecycleListener interface. This method is invoked when the server is starting. ```java public void start() ``` -------------------------------- ### POST /plugins Source: https://javadoc.io/doc/com.google.gerrit/gerrit-plugin-api/3.13.0-rc1/com/google/gerrit/server/plugins/InstallPlugin This endpoint allows for the installation of a new plugin into Gerrit. It processes the provided input and returns information about the installed plugin. ```APIDOC ## POST /plugins ### Description This endpoint allows for the installation of a new plugin into Gerrit. It processes the provided input and returns information about the installed plugin. ### Method POST ### Endpoint /plugins ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **input** (InstallPluginInput) - Required - The input object containing details for plugin installation. - **name** (String) - Optional - The name of the plugin to install. - **created** (boolean) - Optional - Indicates if the plugin was newly created during installation. ### Request Example ```json { "input": { "pluginData": "..." }, "name": "my-plugin", "created": true } ``` ### Response #### Success Response (200 OK) - **pluginInfo** (PluginInfo) - Information about the installed plugin. #### Response Example ```json { "pluginInfo": { "name": "my-plugin", "version": "1.0.0" } } ``` #### Error Response - **4xx** (RestApiException) - Indicates a client-side error during the request. - **500** (Internal Server Error) - Indicates a server-side error. ``` -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Get Start Line of Modifiable Content (Java) Source: https://javadoc.io/doc/com.google.gerrit/gerrit-plugin-api/3.13.0-rc1/com/google/gerrit/server/patch/MagicFile This method returns the starting line number (1-based) of the modifiable content within the MagicFile. ```java public int getStartLineOfModifiableContent() ``` -------------------------------- ### InitFlags Constructor with SitePaths and SecureStore Source: https://javadoc.io/doc/com.google.gerrit/gerrit-plugin-api/3.13.0-rc1/com/google/gerrit/pgm/init/api/InitFlags Initializes InitFlags with site paths, secure store, a list of plugins to install, and a flag to install all plugins. It can throw IOException or ConfigInvalidException. ```java public InitFlags(SitePaths site, SecureStore secureStore, List installPlugins, Boolean installAllPlugins) throws IOException, org.eclipse.jgit.errors.ConfigInvalidException ``` -------------------------------- ### List Installed Plugins Source: https://javadoc.io/doc/com.google.gerrit/gerrit-plugin-api/3.13.0-rc1/com/google/gerrit/server/plugins/ListPlugins This endpoint allows you to list installed plugins in Gerrit. You can filter the results by prefix, substring, regex, and control pagination with limit and start parameters. ```APIDOC ## GET /plugins ### Description Lists installed plugins. Supports filtering by prefix, substring, and regex, as well as pagination. ### Method GET ### Endpoint /plugins ### Query Parameters - **all** (boolean) - Optional - If true, list all plugins. Otherwise, only list plugins visible to the caller. - **limit** (int) - Optional - Maximum number of plugins to return. - **start** (int) - Optional - The index of the first plugin to return. - **matchPrefix** (string) - Optional - If set, only plugins with names starting with this prefix are returned. - **matchSubstring** (string) - Optional - If set, only plugins with names containing this substring are returned. - **matchRegex** (string) - Optional - If set, only plugins with names matching this regular expression are returned. ### Request Example ```json { "example": "" } ``` ### Response #### Success Response (200) - **plugins** (object) - A map where keys are plugin names and values are PluginInfo objects. - **name** (string) - The name of the plugin. - **version** (string) - The version of the plugin. - **id** (string) - The ID of the plugin. - **is_enabled** (boolean) - Whether the plugin is enabled. - **is_active** (boolean) - Whether the plugin is active. #### Response Example ```json { "example": "{\n \"plugin-name-1\": {\n \"name\": \"plugin-name-1\",\n \"version\": \"1.0.0\",\n \"id\": \"com.example.plugin1\",\n \"isEnabled\": true,\n \"isActive\": true\n },\n \"plugin-name-2\": {\n \"name\": \"plugin-name-2\",\n \"version\": \"2.1.0\",\n \"id\": \"com.example.plugin2\",\n \"isEnabled\": true,\n \"isActive\": false\n }\n}" } ``` ### Errors - **400 Bad Request** - The request was incorrectly specified and cannot be handled. - **500 Internal Server Error** - An unexpected error occurred on the server. ``` -------------------------------- ### Get Plugin Name in Java Source: https://javadoc.io/doc/com.google.gerrit/gerrit-plugin-api/3.13.0-rc1/com/google/gerrit/extensions/webui/WebUiPlugin This method returns the installed name of the plugin that provides the Web UI feature. ```java public final String getPluginName() ``` -------------------------------- ### InitFlags installAllPlugins Field Source: https://javadoc.io/doc/com.google.gerrit/gerrit-plugin-api/3.13.0-rc1/com/google/gerrit/pgm/init/api/InitFlags Final boolean flag indicating whether all available plugins should be installed. ```java public final boolean installAllPlugins ``` -------------------------------- ### OnlineReindexer Methods Source: https://javadoc.io/doc/com.google.gerrit/gerrit-plugin-api/3.13.0-rc1/com/google/gerrit/server/index/OnlineReindexer Methods for managing the online reindexing process, including starting, checking status, getting version, and activating the index. ```APIDOC ## OnlineReindexer Methods ### Method: start ### Description Starts the background process for reindexing documents in the search index. ### Method `start()` ### Endpoint N/A (Instance Method) ### Parameters None ### Request Example ```json { "example": "Not applicable for method call" } ``` ### Response #### Success Response (void) This method does not return a value. #### Response Example ```json { "example": "Not applicable" } ``` --- ### Method: isRunning ### Description Checks if the background indexer is currently running. ### Method `isRunning()` ### Endpoint N/A (Instance Method) ### Parameters None ### Request Example ```json { "example": "Not applicable for method call" } ``` ### Response #### Success Response (boolean) Returns `true` if the background indexer is currently running, `false` otherwise. #### Response Example ```json { "example": "true" } ``` --- ### Method: getVersion ### Description Returns the index version that this indexer is creating documents for. ### Method `getVersion()` ### Endpoint N/A (Instance Method) ### Parameters None ### Request Example ```json { "example": "Not applicable for method call" } ``` ### Response #### Success Response (int) Returns the current index version as an integer. #### Response Example ```json { "example": "3" } ``` --- ### Method: activateIndex ### Description Switches the search index from the old version to the new version. This method should be called when the new version is fully ready. ### Method `activateIndex()` ### Endpoint N/A (Instance Method) ### Parameters None ### Request Example ```json { "example": "Not applicable for method call" } ``` ### Response #### Success Response (void) This method does not return a value. #### Response Example ```json { "example": "Not applicable" } ``` ``` -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### IndexStartCommand Constructor - Java Source: https://javadoc.io/doc/com.google.gerrit/gerrit-plugin-api/3.13.0-rc1/com/google/gerrit/sshd/commands/IndexStartCommand This is the default constructor for the IndexStartCommand class. It initializes a new instance of the command. No specific parameters are required. ```java public IndexStartCommand() ``` -------------------------------- ### Untitled No description -------------------------------- ### SecureStoreProvider Constructor Source: https://javadoc.io/doc/com.google.gerrit/gerrit-plugin-api/3.13.0-rc1/com/google/gerrit/server/securestore/SecureStoreProvider Initializes a new instance of the SecureStoreProvider class. ```APIDOC ## SecureStoreProvider Constructor ### Description Initializes a new instance of the SecureStoreProvider class. ### Method CONSTRUCTOR ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json { "injector": "com.google.inject.Injector", "sitePaths": "SitePaths", "className": "String" } ``` ### Response #### Success Response (N/A) This is a constructor and does not return a value. #### Response Example N/A ``` -------------------------------- ### Get Current Revision (Java) Source: https://javadoc.io/doc/com.google.gerrit/gerrit-plugin-api/3.13.0-rc1/com/google/gerrit/extensions/api/changes/ChangeApi This example shows how to retrieve the current revision of a change using the current() method of the ChangeApi. ```Java RevisionApi revisionApi = changeApi.current(); ``` -------------------------------- ### Start Plugin Environment (Java) Source: https://javadoc.io/doc/com.google.gerrit/gerrit-plugin-api/3.13.0-rc1/com/google/gerrit/server/plugins/ServerPlugin Starts the plugin's environment. This method is specified by the Plugin class and takes a PluginGuiceEnvironment object. It can throw an Exception if the startup process fails. ```java protected void start(PluginGuiceEnvironment env) throws Exception ``` -------------------------------- ### Untitled No description -------------------------------- ### Get Change ID (Java) Source: https://javadoc.io/doc/com.google.gerrit/gerrit-plugin-api/3.13.0-rc1/com/google/gerrit/extensions/api/changes/ChangeApi This example shows how to retrieve the unique identifier (ID) of a change using the id() method of the ChangeApi. ```Java String changeId = changeApi.id(); ``` -------------------------------- ### Untitled No description -------------------------------- ### Get Commit Message (Java) Source: https://javadoc.io/doc/com.google.gerrit/gerrit-plugin-api/3.13.0-rc1/com/google/gerrit/extensions/api/changes/ChangeApi This example shows how to retrieve the commit message information for a change using the getMessage() method of the ChangeApi. ```Java CommitMessageInfo commitMessage = changeApi.getMessage(); ``` -------------------------------- ### InitFlags installPlugins Field Source: https://javadoc.io/doc/com.google.gerrit/gerrit-plugin-api/3.13.0-rc1/com/google/gerrit/pgm/init/api/InitFlags Final list of strings representing plugins to be installed during initialization. ```java public final List installPlugins ``` -------------------------------- ### Get Flow by UUID (Java) Source: https://javadoc.io/doc/com.google.gerrit/gerrit-plugin-api/3.13.0-rc1/com/google/gerrit/extensions/api/changes/ChangeApi This example shows how to look up a specific flow of a change by its UUID using the flow() method of the ChangeApi. ```Java FlowApi flowApi = changeApi.flow("flow_uuid"); ``` -------------------------------- ### AllProjectsConfig API Source: https://javadoc.io/doc/com.google.gerrit/gerrit-plugin-api/3.13.0-rc1/com/google/gerrit/pgm/init/api/AllProjectsConfig Documentation for the AllProjectsConfig class, which extends VersionedMetaDataOnInit and provides methods for managing project configurations. ```APIDOC ## AllProjectsConfig Class ### Description Represents the configuration for all projects in Gerrit, extending VersionedMetaDataOnInit for managing metadata updates. ### Class Hierarchy `java.lang.Object` > `com.google.gerrit.server.git.meta.VersionedMetaData` > `com.google.gerrit.pgm.init.api.VersionedMetaDataOnInit` > `com.google.gerrit.pgm.init.api.AllProjectsConfig` ### Methods #### `getConfig()` * **Method:** `getConfig` * **Returns:** `org.eclipse.jgit.lib.Config` - The project configuration object. #### `getGroups()` * **Method:** `getGroups` * **Returns:** `GroupList` - A list of groups associated with the project configuration. #### `load()` * **Method:** `load` * **Description:** Loads the configuration from the repository. * **Returns:** `AllProjectsConfig` - The loaded configuration object. * **Throws:** `IOException`, `org.eclipse.jgit.errors.ConfigInvalidException` * **Overrides:** `load` in class `VersionedMetaDataOnInit` #### `onLoad()` * **Method:** `onLoad` * **Description:** Called after the metadata is loaded, used for parsing and setting up internal state. * **Throws:** `IOException`, `org.eclipse.jgit.errors.ConfigInvalidException` * **Overrides:** `onLoad` in class `VersionedMetaData` #### `save(String pluginName, String message)` * **Method:** `save` * **Description:** Saves the current configuration with a specified plugin name and commit message. * **Throws:** `IOException`, `org.eclipse.jgit.errors.ConfigInvalidException` #### `save(org.eclipse.jgit.lib.PersonIdent ident, String msg)` * **Method:** `save` * **Description:** Saves the current configuration using a specific person ident and commit message. * **Throws:** `IOException`, `org.eclipse.jgit.errors.ConfigInvalidException` * **Overrides:** `save` in class `VersionedMetaDataOnInit` #### `onSave(org.eclipse.jgit.lib.CommitBuilder commit)` * **Method:** `onSave` * **Description:** Called before saving the metadata to a commit. Allows modification of the commit builder or aborting the save. * **Returns:** `boolean` - `true` if the commit should proceed, `false` to abort. * **Throws:** `IOException`, `org.eclipse.jgit.errors.ConfigInvalidException` * **Overrides:** `onSave` in class `VersionedMetaData` ``` -------------------------------- ### Get Custom Keyed Values (Java) Source: https://javadoc.io/doc/com.google.gerrit/gerrit-plugin-api/3.13.0-rc1/com/google/gerrit/extensions/api/changes/ChangeApi This example shows how to retrieve custom keyed values associated with a change using the getCustomKeyedValues() method of the ChangeApi. ```Java ImmutableMap customValues = changeApi.getCustomKeyedValues(); ``` -------------------------------- ### Untitled No description -------------------------------- ### Java PropertyMap Get Method Example Source: https://javadoc.io/doc/com.google.gerrit/gerrit-plugin-api/3.13.0-rc1/com/google/gerrit/server/PropertyMap Illustrates how to retrieve a value from a PropertyMap using a typed key. The result is wrapped in an Optional to handle cases where the key might not be present in the map. ```java Optional value = propertyMap.get(stringKey); ``` -------------------------------- ### Gerrit API: Get Git references by prefix Source: https://javadoc.io/doc/com.google.gerrit/gerrit-plugin-api/3.13.0-rc1/com/google/gerrit/server/git/PermissionAwareReadOnlyRefDatabase Retrieves Git references that start with a specified prefix. This is commonly used to list references within a certain namespace, like 'refs/heads/' for branches. ```java Map getRefs(String prefix) ``` -------------------------------- ### Get Email Resource Unencoded Content - Java Source: https://javadoc.io/doc/com.google.gerrit/gerrit-plugin-api/3.13.0-rc1/com/google/gerrit/server/mail/send/EmailResource Abstract method to retrieve the unencoded binary data of the email resource. This is the actual content that will be attached to the email, for example, image data. ```java public abstract com.google.protobuf.ByteString content() ``` -------------------------------- ### InstallPlugin Class Methods (Java) Source: https://javadoc.io/doc/com.google.gerrit/gerrit-plugin-api/3.13.0-rc1/com/google/gerrit/server/plugins/InstallPlugin This Java code snippet outlines the methods available in the InstallPlugin class. It includes methods for setting the plugin name and creation status, as well as the main apply method for processing plugin installation requests. ```java public class InstallPlugin extends Object implements RestModifyView public InstallPlugin setName(String name) public InstallPlugin setCreated(boolean created) public Response apply(TopLevelResource resource, InstallPluginInput input) throws RestApiException, IOException ``` -------------------------------- ### Utility Methods for Gerrit Site Initialization (Java) Source: https://javadoc.io/doc/com.google.gerrit/gerrit-plugin-api/3.13.0-rc1/com/google/gerrit/pgm/init/api/InitUtil Provides static utility methods for initializing a Gerrit site. This includes functions for file operations like copying and creating directories, network address validation, and retrieving system information such as hostname and version. It also includes methods for converting strings to URIs and extracting resources. ```java public static void copy(Path dst, byte[] buf) throws FileNotFoundException, IOException {} public static Die die(String why) {} public static Die die(String why, Throwable cause) {} public static String dnOf(String name) {} public static String domainOf(String name) {} public static void extract(Path dst, Class sibling, String name) throws IOException {} public static String hostname() {} public static boolean isAnyAddress(URI u) {} public static boolean isLocal(String hostname) {} public static void mkdir(File file) {} public static void mkdir(Path path) {} public static int portOf(URI uri) {} public static void savePublic(org.eclipse.jgit.storage.file.FileBasedConfig sec) throws IOException {} public static URI toURI(String url) throws URISyntaxException {} public static String username() {} public static String version() {} ``` -------------------------------- ### Java - Retrieving Query Parameters Source: https://javadoc.io/doc/com.google.gerrit/gerrit-plugin-api/3.13.0-rc1/com/google/gerrit/extensions/api/groups/Groups This snippet shows how to retrieve the parameters that have been set on a Groups.QueryRequest object in Java. It demonstrates methods for getting the query string, the maximum number of results, the starting index, and the currently active options. ```java import com.google.gerrit.extensions.api.groups.Groups; import com.google.gerrit.extensions.api.groups.Groups.ListGroupsOption; import java.util.Set; Groups.QueryRequest request = new Groups.QueryRequest(); request.withQuery("developers"); request.withLimit(5); request.withStart(20); request.withOption(ListGroupsOption.MEMBERS); String query = request.getQuery(); // "developers" int limit = request.getLimit(); // 5 int start = request.getStart(); // 20 Set options = request.getOptions(); // Contains ListGroupsOption.MEMBERS ``` -------------------------------- ### Untitled No description -------------------------------- ### ListPlugins Class Definition (Java) Source: https://javadoc.io/doc/com.google.gerrit/gerrit-plugin-api/3.13.0-rc1/com/google/gerrit/server/plugins/ListPlugins Defines the ListPlugins class, which implements RestReadView to list installed plugins. It includes methods for setting filters like prefix, substring, regex, limit, and start, as well as a method to convert a Plugin object to PluginInfo. ```java public class ListPlugins extends Object implements RestReadView List the installed plugins. @Inject protected ListPlugins(PluginLoader pluginLoader) public void setAll(boolean all) public void setLimit(int limit) public void setStart(int start) public void setMatchPrefix(String matchPrefix) public void setMatchSubstring(String matchSubstring) public void setMatchRegex(String matchRegex) public ListPlugins request(Plugins.ListRequest request) public Response> apply(TopLevelResource resource) throws BadRequestException public static PluginInfo toPluginInfo(Plugin p) ``` -------------------------------- ### Untitled No description -------------------------------- ### Java LifecycleListener Interface - start Method Source: https://javadoc.io/doc/com.google.gerrit/gerrit-plugin-api/3.13.0-rc1/com/google/gerrit/server/project/ProjectCacheWarmer The start() method is invoked when the server is starting. This method is specified by the LifecycleListener interface. ```java /** * Invoked when the server is starting. */ public void start(); ``` -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### InitStep Interface - Java Source: https://javadoc.io/doc/com.google.gerrit/gerrit-plugin-api/3.13.0-rc1/com/google/gerrit/pgm/init/api/InitStep This Java interface represents a single step in the site initialization process for Gerrit plugins. It defines a run() method for the core initialization logic and a postRun() method to be executed after the site has been initialized. Both methods can throw exceptions. ```java public interface InitStep { /** * Performs the initialization step. * @throws Exception if an error occurs during initialization. */ void run() throws Exception; /** * Executed after the site has been initialized. * @throws Exception if an error occurs after initialization. */ default void postRun() throws Exception { // Default implementation does nothing } } ``` -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Query Gerrit Projects API (Java) Source: https://javadoc.io/doc/com.google.gerrit/gerrit-plugin-api/3.13.0-rc1/com/google/gerrit/extensions/api/projects/Projects This Java snippet demonstrates how to query projects within Gerrit. The `query()` method can be called without arguments to get a request object for general querying, or with a specific query string for a shortcut. The example shows how to filter projects by name using the query functionality. A `RestApiException` may be thrown. ```java /** * Query projects. * @return API for setting parameters and getting result. */ Projects.QueryRequest query(); /** * Query projects. * Shortcut API for query().withQuery(String). * @param query the query string. * @return API for setting parameters and getting result. */ Projects.QueryRequest query(String query); // Example usage: // Projects.QueryRequest req = query().withQuery("name:project"); // ProjectInfo info = req.get(); ``` -------------------------------- ### Deploying a New SecureStore Implementation in Gerrit Source: https://javadoc.io/doc/com.google.gerrit/gerrit-plugin-api/3.13.0-rc1/com/google/gerrit/server/securestore/SecureStore This command demonstrates how to deploy a custom SecureStore implementation by providing a JAR file and switching the store. It requires a stopped Gerrit instance. ```bash java -jar gerrit.war SwitchSecureStore -d $gerrit_site --new-secure-store-lib $path_to_new_secure_store.jar ``` -------------------------------- ### Untitled No description -------------------------------- ### PluginSetContext Constructor Source: https://javadoc.io/doc/com.google.gerrit/gerrit-plugin-api/3.13.0-rc1/com/google/gerrit/server/plugincontext/PluginSetContext Initializes a new instance of the PluginSetContext class. ```APIDOC ## Constructor PluginSetContext ### Description Initializes a new instance of the PluginSetContext class. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json { "example": "Not applicable for constructor" } ``` ### Response #### Success Response (200) None #### Response Example ```json { "example": "Not applicable for constructor" } ``` ``` -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### GET /getRepositoryStatus Source: https://javadoc.io/doc/com.google.gerrit/gerrit-plugin-api/3.13.0-rc1/com/google/gerrit/server/git/LocalDiskRepositoryManager Gets the GitRepositoryManager.Status of a repository by its name. ```APIDOC ## GET /getRepositoryStatus ### Description Gets the GitRepositoryManager.Status of a repository by its name. ### Method GET ### Endpoint /getRepositoryStatus ### Parameters #### Query Parameters - **name** (Project.NameKey) - Required - The name of the repository. ### Response #### Success Response (200) - **status** (GitRepositoryManager.Status) - The status of the Git repository. #### Response Example ```json { "status": "HEALTHY" } ``` ```