Skip to content
OpenClaw 不踩坑恶意 Skills ,企业需 Skills Registry:Nacos 3.2 发布Know more

Maintainer SDK

The Nacos Maintainer SDK, also known as Nacos-Maintainer-SDK, is a Java SDK for maintenance scenarios of Nacos features such as the config center, service registry, and distributed locks. It provides stable and easy-to-use config center, service registry, and distributed lock capabilities for Nacos maintainers and special application scenarios such as gateway applications and console applications, making it easier to operate configs, services, and distributed locks in Nacos.

Because of its maintainer-oriented positioning, the Nacos Maintainer SDK provides broad data access APIs. Therefore, it must be used with an identity that has higher privileges to prevent potential data leakage.

If your scenario is not maintainer operations or a special application scenario such as a gateway application or console application, use Nacos Client instead, such as Nacos Java Client or Nacos Go Client.

Currently, the Nacos Maintainer SDK only supports Java. More languages will be supported later.

The Nacos Maintainer SDK is implemented based on Nacos Admin API. The same capabilities can also be operated through the corresponding Nacos Admin API.

1. Dependency Overview

1.1. Java Version Requirement

The Nacos Java SDK requires JDK 1.8 or later.

1.2. Maven Coordinates

<!-- Supported in version 3.0.0 and later -->
<dependency>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-maintainer-client</artifactId>
<version>${nacos.client.version}</version>
</dependency>

2. Initialize the SDK

When initializing the Nacos SDK, use the corresponding Factory class to create services for different modules:

Properties properties = new Properties();
// Specify the Nacos Server address
properties.setProperty("serverAddr","localhost:8848");
// Set the Nacos administrator username and password
properties.setProperty("username","nacos");
properties.setProperty("password","{your_admin_password}");
// Initialize the Nacos Maintainer Service for the config center
ConfigMaintainerService configMaintainerService = ConfigMaintainerFactory.createConfigMaintainerService(properties);
// Initialize the Nacos Maintainer Service for the service registry
NamingMaintainerService maintainService = NamingMaintainerFactory.createNamingMaintainerService(properties);
// Initialize the Nacos Maintainer Service for the AI module
AiMaintainerService aiMaintainerService = AiMaintainerFactory.createAiMaintainerService(properties);

3. Config Center Maintainer APIs

3.1. Get Config

Description

Gets a config from Nacos.

ConfigDetailInfo getConfig(String dataId) throws NacosException;
ConfigDetailInfo getConfig(String dataId, String groupName) throws NacosException;
ConfigDetailInfo getConfig(String dataId, String groupName, String namespaceId) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
dataIdstringConfig ID. Only English letters and four special characters (., :, -, _) are allowed. The length cannot exceed 256 bytes.
groupNamestringConfig group. Only English letters and four special characters (., :, -, _) are allowed. The length cannot exceed 128 bytes.
namespaceIdstringNamespace ID to which the config belongs.

Return Value

Parameter TypeDescription
ConfigDetailInfoDetailed config information.

The specific ConfigDetailInfo content is as follows:

Parameter NameParameter TypeDescription
idlongID of the config in the actual storage medium. It has no business meaning and is only a unique identifier in storage. It is usually an auto-increment ID.
namespaceIdstringNamespace ID to which the config belongs.
groupNamestringConfig group. Only English letters and four special characters (., :, -, _) are allowed. The length cannot exceed 128 bytes.
dataIdstringConfig ID. Only English letters and four special characters (., :, -, _) are allowed. The length cannot exceed 256 bytes.
md5stringMD5 value of the config content.
typestringConfig type, such as properties, json, or yaml. It is mainly used for labeling and display.
appNamestringApplication name to which the config belongs.
createTimelongConfig creation time as a timestamp in milliseconds.
modifyTimelongLatest config update time as a timestamp in milliseconds.
contentstringConfig content.
descstringConfig description.
encryptedDataKeystringConfig encryption key. This field has a value only when config encryption is used.
createUserstringUsername that created this config.
createIpstringSource IP address that created this config.
configTagsstringTags of this config. Multiple tags are separated by commas ,.

Request Example

try {
// The following three calls all obtain config information for dataId `maintain.client.test` and groupName `DEFAULT_GROUP` under the `public` namespace.
ConfigDetailInfo configDetailInfo = configMaintainerService.getConfig("maintain.client.test");
configDetailInfo = configMaintainerService.getConfig("maintain.client.test", Constants.DEFAULT_GROUP);
configDetailInfo = configMaintainerService.getConfig("maintain.client.test", Constants.DEFAULT_GROUP, Constants.DEFAULT_NAMESPACE_ID);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

3.2. Publish Config

Description

Publishes a Nacos config to reduce maintenance costs through automation.

boolean publishConfig(String dataId, String content) throws NacosException;
boolean publishConfig(String dataId, String groupName, String content) throws NacosException;
boolean publishConfig(String dataId, String groupName, String namespaceId, String content) throws NacosException;
boolean publishConfig(String dataId, String groupName, String namespaceId, String content, String desc) throws NacosException;
boolean publishConfig(String dataId, String groupName, String namespaceId, String content, String desc, String type) throws NacosException;
boolean publishConfig(String dataId, String groupName, String namespaceId, String content, String appName, String srcUser, String configTags, String desc, String type) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
dataIdstringConfig ID. Only English letters and four special characters (., :, -, _) are allowed. The length cannot exceed 256 bytes.
groupNamestringConfig group. Only English letters and four special characters (., :, -, _) are allowed. The length cannot exceed 128 bytes.
namespaceIdstringNamespace ID to which the config belongs.
contentstringConfig content. The length cannot exceed 100 KB.
descstringConfig description.
typestringConfig type. See com.alibaba.nacos.api.config.ConfigType. The default value is TEXT.
appNamestringApplication name to which the config belongs.
srcUserstringUsername used to publish this config. The config is published on behalf of this user, and the config createUser is set to this user. If an empty string is passed, the current logged-in username is used as createUser.
configTagsstringTags of this config. Multiple tags are separated by commas ,.

Response Parameters

Parameter TypeDescription
booleanWhether publishing succeeds.

Request Example

try {
// The following calls all create a config with groupName `DEFAULT_GROUP`, dataId `maintain.client.test`, and content `testContent` under the `public` namespace.
boolean result = configMaintainerService.publishConfig("maintain.client.test", "testContent");
result = configMaintainerService.publishConfig("maintain.client.test", Constants.DEFAULT_GROUP, "testContent");
result = configMaintainerService.publishConfig("maintain.client.test", Constants.DEFAULT_GROUP, Constants.DEFAULT_NAMESPACE_ID, "testContent");
result = configMaintainerService.publishConfig("maintain.client.test", Constants.DEFAULT_GROUP, Constants.DEFAULT_NAMESPACE_ID, "testContent", "test");
result = configMaintainerService.publishConfig("maintain.client.test", Constants.DEFAULT_GROUP, Constants.DEFAULT_NAMESPACE_ID, "testContent", "test", "TEXT");
result = configMaintainerService.publishConfig("maintain.client.test", Constants.DEFAULT_GROUP, Constants.DEFAULT_NAMESPACE_ID, "testContent", "testApp", null, "testTag", "test", "TEXT");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

3.3. Delete Config

Description

Deletes a Nacos config to reduce maintenance costs through automation.

boolean deleteConfig(String dataId) throws NacosException;
boolean deleteConfig(String dataId, String groupName) throws NacosException;
boolean deleteConfig(String dataId, String groupName, String namespaceId) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
dataIdstringConfig ID. Only English letters and four special characters (., :, -, _) are allowed. The length cannot exceed 256 bytes.
groupNamestringConfig group. Only English letters and four special characters (., :, -, _) are allowed. The length cannot exceed 128 bytes.
namespaceIdstringNamespace ID to which the config belongs.

Response Parameters

Parameter TypeDescription
booleanWhether deletion succeeds.

Request Example

try {
// The following three calls all delete the config with groupName `DEFAULT_GROUP` and dataId `maintain.client.test` under the `public` namespace.
boolean result = configMaintainerService.deleteConfig("maintain.client.test");
result = configMaintainerService.deleteConfig("maintain.client.test", Constants.DEFAULT_GROUP);
result = configMaintainerService.deleteConfig("maintain.client.test", Constants.DEFAULT_GROUP, Constants.DEFAULT_NAMESPACE_ID);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

3.4. Batch Delete Configs

Description

Deletes Nacos configs in batches to reduce maintenance costs through automation.

boolean deleteConfigs(List<Long> ids) throws NacosException;
boolean deleteConfigs(List<Long> ids, String namespaceId) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
idsList<Long>List of config IDs to delete. This ID is the ID of the config in the actual storage medium. Obtain it from the id field returned by the Get Config or Get Config List API.
namespaceIdstringNamespace ID of the configs. The default is public when omitted.

Return Value

Parameter TypeDescription
booleanWhether deletion succeeds.

Request Example

try {
ConfigDetailInfo configDetailInfo = configMaintainerService.getConfig("maintain.client.test");
boolean result = configMaintainerService.deleteConfigs(Collections.singletonList(configDetailInfo.getId()));
// To specify the namespace explicitly, use:
// boolean result = configMaintainerService.deleteConfigs(Collections.singletonList(configDetailInfo.getId()), Constants.DEFAULT_NAMESPACE_ID);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

3.5. Get Config List

Description

Use this API to obtain a config list that matches the specified conditions. Fuzzy search is not supported. To perform fuzzy search, use the Search Config List API.

Page<ConfigBasicInfo> listConfigs(String namespaceId) throws NacosException;
Page<ConfigBasicInfo> listConfigs(String dataId, String groupName, String namespaceId) throws NacosException;
Page<ConfigBasicInfo> listConfigs(String dataId, String groupName, String namespaceId, String type) throws NacosException;
Page<ConfigBasicInfo> listConfigs(String dataId, String groupName, String namespaceId, String type, String configTags, String appName) throws NacosException;
Page<ConfigBasicInfo> listConfigs(String dataId, String groupName, String namespaceId, String type, String configTags, String appName, int pageNo, int pageSize) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID to which the config belongs.
dataIdstringConfig ID. Only English letters and four special characters (., :, -, _) are allowed. The length cannot exceed 256 bytes. The default value is "". If it is not empty, only configs whose dataId equals this value are matched.
groupNamestringConfig group. Only English letters and four special characters (., :, -, _) are allowed. The length cannot exceed 128 bytes. The default value is "". If it is not empty, only configs whose groupName equals this value are matched.
typestringConfig type. See com.alibaba.nacos.api.config.ConfigType. The default value is "", If it is not empty, only configs whose type equals this value are matched.
configTagsstringTags of this config. Multiple tags are separated by commas ,. The default value is "". If it is not empty, only configs whose tag equals this value are matched.
appNamestringApplication name to which the config belongs. The default value is "". If it is not empty, only configs whose application name equals this value are matched.
pageNointPage number of the config list. The default value is 1.
pageSizeintPage size of the config list. The default value is 100.

Response Parameters

Parameter TypeDescription
Page<ConfigBasicInfo>Paginated config list result.

The specific Page and ConfigBasicInfo content is as follows:

Parameter NameParameter TypeDescription
totalCountintTotal number of configs that match the condition.
pageNumberintCurrent page number.
pagesAvailableintTotal number of pages.
pageItemsList<ConfigBasicInfo>Config list on the current page.
Parameter NameParameter TypeDescription
idlongID of the config in the actual storage medium. It has no business meaning and is only a unique identifier in storage. It is usually an auto-increment ID.
namespaceIdstringNamespace ID to which the config belongs.
groupNamestringConfig group. Only English letters and four special characters (., :, -, _) are allowed. The length cannot exceed 128 bytes.
dataIdstringConfig ID. Only English letters and four special characters (., :, -, _) are allowed. The length cannot exceed 256 bytes.
md5stringMD5 value of the config content.
typestringConfig type, such as properties, json, or yaml. It is mainly used for labeling and display.
appNamestringApplication name to which the config belongs.
createTimelongConfig creation time as a timestamp in milliseconds.
modifyTimelongLatest config update time as a timestamp in milliseconds.

Request Example

try {
// Gets the first page of all configs under the `public` namespace (up to 100 configs).
Page<ConfigBasicInfo> result = configMaintainerService.listConfigs(Constants.DEFAULT_NAMESPACE_ID);
// Gets the first page of all configs whose config group is `DEFAULT_GROUP` under the `public` namespace (up to 100 configs).
result = configMaintainerService.listConfigs("", Constants.DEFAULT_GROUP, Constants.DEFAULT_NAMESPACE_ID);
// Gets the first page of all configs whose type is `JSON` under the `public` namespace (up to 100 configs).
result = configMaintainerService.listConfigs("", "", Constants.DEFAULT_NAMESPACE_ID, "JSON");
// Gets the first page of all configs under the `public` namespace whose tag is `testTag1` and application is `testApp` (up to 100 configs).
result = configMaintainerService.listConfigs("", "", Constants.DEFAULT_NAMESPACE_ID, "", "testTag1", "testApp");
// Gets the first page of all configs under the `public` namespace (up to 10 configs).
result = configMaintainerService.listConfigs("", "", Constants.DEFAULT_NAMESPACE_ID, "", "", "", 1, 10);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

3.6. Search Config List

Description

Use this API to obtain a config list that matches the specified conditions. Fuzzy search is supported. To perform exact search, use the Query Config List API.

Page<ConfigBasicInfo> searchConfigs(String dataId, String groupName, String namespaceId) throws NacosException;
Page<ConfigBasicInfo> searchConfigs(String dataId, String groupName, String namespaceId, String type) throws NacosException;
Page<ConfigBasicInfo> searchConfigs(String dataId, String groupName, String namespaceId, String configDetail, String type) throws NacosException;
Page<ConfigBasicInfo> searchConfigs(String dataId, String groupName, String namespaceId, String configDetail, String type, String configTags, String appName) throws NacosException;
Page<ConfigBasicInfo> searchConfigs(String dataId, String groupName, String namespaceId, String configDetail, String type, String configTags, String appName, int pageNo, int pageSize) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID to which the config belongs.
dataIdstringConfig ID. Only English letters and four special characters (., :, -, _) are allowed. The length cannot exceed 256 bytes. The default value is "". If it is not empty, only configs whose dataId contains this value are matched.
groupNamestringConfig group. Only English letters and four special characters (., :, -, _) are allowed. The length cannot exceed 128 bytes. The default value is "". If it is not empty, only configs whose groupName contains this value are matched.
typestringConfig type. See com.alibaba.nacos.api.config.ConfigType. The default value is "", If it is not empty, only configs whose type equals this value are matched.
configDetailstringConfig content. The default value is "". If it is not empty, only configs whose content contains this value are matched.
configTagsstringTags of this config. Multiple tags are separated by commas ,. The default value is "". If it is not empty, only configs whose tag equals this value are matched.
appNamestringApplication name to which the config belongs. The default value is "". If it is not empty, only configs whose application name equals this value are matched.
pageNointPage number of the config list. The default value is 1.
pageSizeintPage size of the config list. The default value is 100.

Response Parameters

Parameter TypeDescription
Page<ConfigBasicInfo>Paginated config list result.

The specific Page and ConfigBasicInfo content is as follows:

Parameter NameParameter TypeDescription
totalCountintTotal number of configs that match the condition.
pageNumberintCurrent page number.
pagesAvailableintTotal number of pages.
pageItemsList<ConfigBasicInfo>Config list on the current page.
Parameter NameParameter TypeDescription
idlongID of the config in the actual storage medium. It has no business meaning and is only a unique identifier in storage. It is usually an auto-increment ID.
namespaceIdstringNamespace ID to which the config belongs.
groupNamestringConfig group. Only English letters and four special characters (., :, -, _) are allowed. The length cannot exceed 128 bytes.
dataIdstringConfig ID. Only English letters and four special characters (., :, -, _) are allowed. The length cannot exceed 256 bytes.
md5stringMD5 value of the config content.
typestringConfig type, such as properties, json, or yaml. It is mainly used for labeling and display.
appNamestringApplication name to which the config belongs.
createTimelongConfig creation time as a timestamp in milliseconds.
modifyTimelongLatest config update time as a timestamp in milliseconds.

Request Example

try {
// Gets the first page of all configs under the `public` namespace whose config group contains `test` (up to 100 configs).
Page<ConfigBasicInfo> result = configMaintainerService.searchConfigs("", "test", Constants.DEFAULT_NAMESPACE_ID);
// Gets the first page of all configs whose type is `JSON` under the `public` namespace (up to 100 configs).
result = configMaintainerService.searchConfigs("", "", Constants.DEFAULT_NAMESPACE_ID, "JSON");
// Gets the first page of all configs under the `public` namespace whose content contains `test` (up to 100 configs).
result = configMaintainerService.searchConfigs("", "", Constants.DEFAULT_NAMESPACE_ID, "test", "");
// Gets the first page of all configs under the `public` namespace whose tag is `testTag1` and application is `testApp` (up to 100 configs).
result = configMaintainerService.searchConfigs("", "", Constants.DEFAULT_NAMESPACE_ID, "", "", "testTag1", "testApp");
// Gets the first page of all configs under the `public` namespace (up to 10 configs).
result = configMaintainerService.searchConfigs("", "", Constants.DEFAULT_NAMESPACE_ID, "", "", "", "", 1, 10);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

3.7. Clone Config

Description

Use this API to clone the specified config to another namespace. You can specify a new groupName and dataId during cloning.

Map<String, Object> cloneConfig(String namespaceId, List<ConfigCloneInfo> cloneInfos, String srcUser, SameConfigPolicy policy) throws NacosException;
Map<String, Object> cloneConfig(String sourceNamespaceId, String targetNamespaceId, List<ConfigCloneInfo> cloneInfos, String srcUser, SameConfigPolicy policy) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID used for both source lookup and clone target. The default is public when omitted.
sourceNamespaceIdstringSource namespace ID. The default is public when omitted.
targetNamespaceIdstringTarget namespace ID. The default is public when omitted.
cloneInfosList<ConfigCloneInfo>List of configs to clone.
srcUserstringUsername used to clone this config. The cloned config uses this user as createUser. If an empty string is passed, the current logged-in username is used as createUser.
policySameConfigPolicyConflict handling policy used when cloning configs. The default value is ABORT. Optional values are ABORT (abort), SKIP (skip), and OVERWRITE (overwrite).

The parameters in ConfigCloneInfo are as follows:

Parameter NameParameter TypeDescription
configIdlongID of the config in the actual storage medium. It has no business meaning and is only a unique identifier in storage. It is usually an auto-increment ID.
targetGroupNamestringTarget config group. Only English characters and four special characters (., :, -, _) are allowed. The length must not exceed 128 bytes. If empty, the current group of the config is used.
targetDataIdstringTarget config ID. Only English characters and four special characters (., :, -, _) are allowed. The length must not exceed 256 bytes. If empty, the current ID of the config is used.

Response Parameters

Parameter TypeDescription
Map<String, Object>Config clone result. Depending on policy, it may return the number of successful, failed, skipped, or overwritten configs.

Request Example

try {
// Clones the config whose ID is 1 to the `clone-test` namespace with the clone policy `ABORT`. If a config with the same name exists in the target namespace, the clone fails.
ConfigCloneInfo configCloneInfo = new ConfigCloneInfo();
configCloneInfo.setConfigId(1L);
Map<String, Object> result = configMaintainerService.cloneConfig("clone-test", Collections.singletonList(configCloneInfo), "", SameConfigPolicy.ABORT);
// Clone the config from the public namespace to the clone-test namespace.
// result = configMaintainerService.cloneConfig(Constants.DEFAULT_NAMESPACE_ID, "clone-test", Collections.singletonList(configCloneInfo), "", SameConfigPolicy.ABORT);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

3.8. Get All Configs Under a Namespace

Description

Use this API to obtain all configs under the specified namespace.

List<ConfigBasicInfo> getConfigListByNamespace(String namespaceId) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID to which the config belongs.

Response Parameters

Parameter TypeDescription
List<ConfigBasicInfo>Paginated config list result.

The specific ConfigBasicInfo content is as follows:

Parameter NameParameter TypeDescription
idlongID of the config in the actual storage medium. It has no business meaning and is only a unique identifier in storage. It is usually an auto-increment ID.
namespaceIdstringNamespace ID to which the config belongs.
groupNamestringConfig group. Only English letters and four special characters (., :, -, _) are allowed. The length cannot exceed 128 bytes.
dataIdstringConfig ID. Only English letters and four special characters (., :, -, _) are allowed. The length cannot exceed 256 bytes.
md5stringMD5 value of the config content.
typestringConfig type, such as properties, json, or yaml. It is mainly used for labeling and display.
appNamestringApplication name to which the config belongs.
createTimelongConfig creation time as a timestamp in milliseconds.
modifyTimelongLatest config update time as a timestamp in milliseconds.

Request Example

try {
List<ConfigBasicInfo> result = configMaintainerService.getConfigListByNamespace(Constants.DEFAULT_NAMESPACE_ID);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

3.9. Get Config Subscriber List

Description

Use this API to obtain the subscriber list of a config. To obtain the configs subscribed to by a config subscriber, use Get All Configs Subscribed to by a Subscriber.

ConfigListenerInfo getListeners(String dataId, String groupName) throws NacosException;
ConfigListenerInfo getListeners(String dataId, String groupName, String namespaceId, boolean aggregation) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
groupNamestringConfig group. Only English letters and four special characters (., :, -, _) are allowed. The length cannot exceed 128 bytes.
dataIdstringConfig ID. Only English letters and four special characters (., :, -, _) are allowed. The length cannot exceed 256 bytes.
namespaceIdstringNamespace ID to which the config belongs.
aggregationbooleanWhether to perform an aggregated query. The default value is true. If false, only the subscriber list on the node that receives the request is queried. If true, the subscriber list of this config in the entire cluster is queried.

Response Parameters

Parameter TypeDescription
ConfigListenerInfoConfig subscriber information.

The ConfigListenerInfo content is as follows:

Parameter NameParameter TypeDescription
queryTypestringThis API always returns config.
listenersStatusMap<String, List<String>>Subscriber list. The key is the subscriber IP, and the value is the MD5 value of the config subscribed to by this subscriber.

Request Example

try {
// The following two calls both obtain the cluster-wide subscriber list of config `maintain.client.test` in group `DEFAULT_GROUP` under namespace `public`.
ConfigListenerInfo result = configMaintainerService.getListeners("maintain.client.test", Constants.DEFAULT_GROUP);
result = configMaintainerService.getListeners("maintain.client.test", Constants.DEFAULT_GROUP, Constants.DEFAULT_NAMESPACE_ID, true);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

3.10. Get All Configs Subscribed to by a Subscriber

Description

Use this API to obtain the config list subscribed to by a config subscriber. To query the subscriber list of a config, use Get Config Subscriber List.

ConfigListenerInfo getAllSubClientConfigByIp(String ip, boolean all, String namespaceId, boolean aggregation) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
ipstringIP address of the config subscriber.
allbooleanWhether to query the config lists subscribed to by all subscribers with the same IP. The default value is false. If false, only the config list subscribed to by the first subscriber that matches ip is returned. If true, the config lists subscribed to by all subscribers that match ip are returned.
namespaceIdstringNamespace ID to which the config belongs.
aggregationbooleanWhether to perform an aggregated query. The default value is true. If false, only the subscriber list on the node that receives the request is queried. If true, the subscriber list of this config in the entire cluster is queried.

Response Parameters

Parameter TypeDescription
ConfigListenerInfoConfig subscriber information.

The ConfigListenerInfo content is as follows:

Parameter NameParameter TypeDescription
queryTypestringThis API always returns ip.
listenersStatusMap<String, List<String>>Subscriber list. The key is dataId+groupName+namespaceId of the subscribed config, and the value is the MD5 value of the config subscribed to by this subscriber.

Request Example

try {
ConfigListenerInfo result = configMaintainerService.getAllSubClientConfigByIp("127.0.0.1", false, Constants.DEFAULT_NAMESPACE_ID, true);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

3.11. Publish Beta Gray Config

Description

Publishes a Nacos config in gray mode so changes can be tested and the impact of config errors can be reduced.

boolean publishBetaConfig(String dataId, String groupName, String namespaceId, String content, String appName, String srcUser, String configTags, String desc, String type, String betaIps) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
dataIdstringConfig ID. Only English letters and four special characters (., :, -, _) are allowed. The length cannot exceed 256 bytes.
groupNamestringConfig group. Only English letters and four special characters (., :, -, _) are allowed. The length cannot exceed 128 bytes.
namespaceIdstringNamespace ID to which the config belongs.
contentstringConfig content. The length cannot exceed 100 KB.
descstringConfig description.
typestringConfig type. See com.alibaba.nacos.api.config.ConfigType. The default value is TEXT.
appNamestringApplication name to which the config belongs.
srcUserstringUsername used to publish this config. The config is published on behalf of this user, and the config createUser is set to this user. If an empty string is passed, the current logged-in username is used as createUser.
configTagsstringTags of this config. Multiple tags are separated by commas ,.
betaIpsstringGray IP list of the config. Multiple IP addresses are separated by commas ,.

Response Parameters

Parameter TypeDescription
booleanWhether publishing succeeds.

Request Example

try {
// Performs beta gray release of config `maintain.client.test` for IP `127.0.0.1`.
boolean result = configMaintainerService.publishBetaConfig("maintain.client.test", Constants.DEFAULT_GROUP, Constants.DEFAULT_NAMESPACE_ID, "testBeta", "testApp", "", "testTag1", "test", "TEXT", "127.0.0.1");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

3.12. Stop Config Beta Gray Release

Description

Stops the beta config of the specified config.

boolean stopBeta(String dataId, String groupName) throws NacosException;
boolean stopBeta(String dataId, String groupName, String namespaceId) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
dataIdstringConfig ID. Only English letters and four special characters (., :, -, _) are allowed. The length cannot exceed 256 bytes.
groupNamestringConfig group. Only English letters and four special characters (., :, -, _) are allowed. The length cannot exceed 128 bytes.
namespaceIdstringNamespace ID to which the config belongs.

Response Parameters

Parameter TypeDescription
booleanWhether stopping beta gray release succeeds.

Request Example

try {
// Performs beta gray release of config `maintain.client.test` for IP `127.0.0.1`.
boolean result = configMaintainerService.publishBetaConfig("maintain.client.test", Constants.DEFAULT_GROUP, Constants.DEFAULT_NAMESPACE_ID, "testBeta", "testApp", "", "testTag1", "test", "TEXT", "127.0.0.1");
// Stops the beta gray release of config `maintain.client.test`.
result = configMaintainerService.stopBeta("maintain.client.test", Constants.DEFAULT_GROUP);
result = configMaintainerService.stopBeta("maintain.client.test", Constants.DEFAULT_GROUP, Constants.DEFAULT_NAMESPACE_ID);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

3.13. Query Beta Gray Config

Description

Queries the beta config of the specified config.

ConfigGrayInfo queryBeta(String dataId, String groupName) throws NacosException;
ConfigGrayInfo queryBeta(String dataId, String groupName, String namespaceId) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
dataIdstringConfig ID. Only English letters and four special characters (., :, -, _) are allowed. The length cannot exceed 256 bytes.
groupNamestringConfig group. Only English letters and four special characters (., :, -, _) are allowed. The length cannot exceed 128 bytes.
namespaceIdstringNamespace ID to which the config belongs.

Response Parameters

Parameter TypeDescription
ConfigGrayInfoGray config information.

The ConfigGrayInfo content is as follows:

Parameter NameParameter TypeDescription
idlongID of the config in the actual storage medium. It has no business meaning and is only a unique identifier in storage. It is usually an auto-increment ID.
namespaceIdstringNamespace ID to which the config belongs.
groupNamestringConfig group. Only English letters and four special characters (., :, -, _) are allowed. The length cannot exceed 128 bytes.
dataIdstringConfig ID. Only English letters and four special characters (., :, -, _) are allowed. The length cannot exceed 256 bytes.
md5stringMD5 value of the config content.
typestringConfig type, such as properties, json, or yaml. It is mainly used for labeling and display.
appNamestringApplication name to which the config belongs.
createTimelongConfig creation time as a timestamp in milliseconds.
modifyTimelongLatest config update time as a timestamp in milliseconds.
contentstringConfig content.
descstringConfig description.
encryptedDataKeystringConfig encryption key. This field has a value only when config encryption is used.
createUserstringUsername that created this config.
createIpstringSource IP address that created this config.
configTagsstringTags of this config. Multiple tags are separated by commas ,.
grayNamestringGray name. The value is fixed to beta.
grayRulestringGray rule in json format. The expr field is the gray IP list.

Request Example

try {
// Performs beta gray release of config `maintain.client.test` for IP `127.0.0.1`.
boolean publishResult = configMaintainerService.publishBetaConfig("maintain.client.test", Constants.DEFAULT_GROUP, Constants.DEFAULT_NAMESPACE_ID, "testBeta", "testApp", "", "testTag1", "test", "TEXT", "127.0.0.1");
// Queries the beta gray release of config `maintain.client.test`.
ConfigGrayInfo result = configMaintainerService.queryBeta("maintain.client.test", Constants.DEFAULT_GROUP);
result = configMaintainerService.queryBeta("maintain.client.test", Constants.DEFAULT_GROUP, Constants.DEFAULT_NAMESPACE_ID);}
catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

3.14. Get Config History Version List

Description

Gets the historical version list of the specified config.

Page<ConfigHistoryBasicInfo> listConfigHistory(String dataId, String groupName, String namespaceId, int pageNo, int pageSize) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
dataIdstringConfig ID. Only English letters and four special characters (., :, -, _) are allowed. The length cannot exceed 256 bytes.
groupNamestringConfig group. Only English letters and four special characters (., :, -, _) are allowed. The length cannot exceed 128 bytes.
namespaceIdstringNamespace ID to which the config belongs.
pageNointPage number of the config history list. The default value is 1.
pageSizeintPage size of the config history list. The default value is 100.

Response Parameters

Parameter TypeDescription
Page<ConfigHistoryBasicInfo>Paginated config history list result.

The Page and ConfigHistoryBasicInfo content is as follows:

Parameter NameParameter TypeDescription
totalCountintTotal number of config history versions that match the condition.
pageNumberintCurrent page number.
pagesAvailableintTotal number of pages.
pageItemsList<ConfigHistoryBasicInfo>Config history version list on the current page.
Parameter NameParameter TypeDescription
idlongID of the config history version. It has no business meaning and is only a unique identifier in storage. It is usually an auto-increment ID.
namespaceIdstringNamespace ID to which the config belongs.
groupNamestringConfig group. Only English letters and four special characters (., :, -, _) are allowed. The length cannot exceed 128 bytes.
dataIdstringConfig ID. Only English letters and four special characters (., :, -, _) are allowed. The length cannot exceed 256 bytes.
md5stringMD5 value of the config content.
typestringConfig type, such as properties, json, or yaml. It is mainly used for labeling and display.
appNamestringApplication name to which the config belongs.
createTimelongConfig creation time as a timestamp in milliseconds.
modifyTimelongLatest config update time as a timestamp in milliseconds.
srcUserstringUsername that operated this version.
srcIpstringSource IP address that operated this version.
opTypestringOperation type of this historical version. I indicates creation, U indicates update, and D indicates deletion.
publishTypestringPublish type of this historical version. formal indicates formal release, and gray indicates gray release.

Request Example

try {
// Queries the historical version list of config `maintain.client.test`.
Page<ConfigHistoryBasicInfo> configHistoryBasicInfoPage = configMaintainerService.listConfigHistory("maintain.client.test", Constants.DEFAULT_GROUP, Constants.DEFAULT_NAMESPACE_ID, 1, 10);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

3.15. Get Config History Version Details

Description

Use this API to query the details of a historical version of a config.

ConfigHistoryDetailInfo getConfigHistoryInfo(String dataId, String groupName, String namespaceId, Long nid) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID to which the config belongs.
groupNamestringConfig group. Only English letters and four special characters (., :, -, _) are allowed. The length cannot exceed 128 bytes.
dataIdstringConfig ID. Only English letters and four special characters (., :, -, _) are allowed. The length cannot exceed 256 bytes.
nidlongID of the target historical version. Obtain it through the Get Config History Version List API.

Response Parameters

Parameter TypeDescription
ConfigHistoryDetailInfoDetailed information about the config history version.

The ConfigHistoryDetailInfo content is as follows:

Parameter NameParameter TypeDescription
idlongID of the config history version. It has no business meaning and is only a unique identifier in storage. It is usually an auto-increment ID.
namespaceIdstringNamespace ID to which the config belongs.
groupNamestringConfig group. Only English letters and four special characters (., :, -, _) are allowed. The length cannot exceed 128 bytes.
dataIdstringConfig ID. Only English letters and four special characters (., :, -, _) are allowed. The length cannot exceed 256 bytes.
md5stringMD5 value of the config content.
typestringConfig type, such as properties, json, or yaml. It is mainly used for labeling and display.
appNamestringApplication name to which the config belongs.
createTimelongConfig creation time as a timestamp in milliseconds.
modifyTimelongLatest config update time as a timestamp in milliseconds.
contentstringContent of the config history version.
encryptedDataKeystringConfig decryption key. It is returned only when the config is encrypted.
grayNamestringGray publish name of the config history version. It exists when this historical version is a gray release and is usually beta.
extInfostringExtended information of the historical version. It currently stores gray publish rules, such as the gray IP address list, in json format.

Request Example

try {
// Queries the historical version list of config `maintain.client.test`.
Page<ConfigHistoryBasicInfo> configHistoryBasicInfoPage = configMaintainerService.listConfigHistory("maintain.client.test", Constants.DEFAULT_GROUP, Constants.DEFAULT_NAMESPACE_ID, 1, 10);
int nid = configHistoryBasicInfoPage.getPageItems().get(0).getId();
// Queries the details of the first historical version in the historical version list of config `maintain.client.test`.
ConfigHistoryDetailInfo result = configMaintainerService.getConfigHistoryInfo("maintain.client.test", Constants.DEFAULT_GROUP, Constants.DEFAULT_NAMESPACE_ID, nid);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

3.16. Query Previous Config Version Details

Description

Gets the details of the previous historical version of the specified config.

ConfigHistoryDetailInfo getPreviousConfigHistoryInfo(String dataId, String groupName, String namespaceId, Long id) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID to which the config belongs.
groupNamestringConfig group. Only English letters and four special characters (., :, -, _) are allowed. The length cannot exceed 128 bytes.
dataIdstringConfig ID. Only English letters and four special characters (., :, -, _) are allowed. The length cannot exceed 256 bytes.
idlongID of the config in the actual storage medium. Obtain it through Get Config.

Response Parameters

Parameter TypeDescription
ConfigHistoryDetailInfoDetailed information about the config history version.

The ConfigHistoryDetailInfo content is as follows:

Parameter NameParameter TypeDescription
idlongID of the config history version. It has no business meaning and is only a unique identifier in storage. It is usually an auto-increment ID.
namespaceIdstringNamespace ID to which the config belongs.
groupNamestringConfig group. Only English letters and four special characters (., :, -, _) are allowed. The length cannot exceed 128 bytes.
dataIdstringConfig ID. Only English letters and four special characters (., :, -, _) are allowed. The length cannot exceed 256 bytes.
md5stringMD5 value of the config content.
typestringConfig type, such as properties, json, or yaml. It is mainly used for labeling and display.
appNamestringApplication name to which the config belongs.
createTimelongConfig creation time as a timestamp in milliseconds.
modifyTimelongLatest config update time as a timestamp in milliseconds.
contentstringContent of the config history version.
encryptedDataKeystringConfig decryption key. It is returned only when the config is encrypted.
grayNamestringGray publish name of the config history version. It exists when this historical version is a gray release and is usually beta.
extInfostringExtended information of the historical version. It currently stores gray publish rules, such as the gray IP address list, in json format.

Request Example

try {
// Gets the ID of config `maintain.client.test`.
int id = configMaintainerService.getConfig("maintain.client.test").getId();
// Gets the details of the previous historical version of config `maintain.client.test`.
ConfigHistoryDetailInfo result = configMaintainerService.getPreviousConfigHistoryInfo("maintain.client.test", Constants.DEFAULT_GROUP, Constants.DEFAULT_NAMESPACE_ID, id);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

3.17. Trigger Nacos Server to Dump Data from Storage to Disk Cache

Description

Manually triggers loading all config data from storage to the local cache of Nacos Server.

String updateLocalCacheFromStore() throws NacosException;

Request Parameters

None

Response Parameters

Parameter TypeDescription
StringReturn information of the dump operation.

Request Example

try {
configMaintainerService.updateLocalCacheFromStore();
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

3.18. Set Config Center Log Level

Description

Dynamically sets the log level of the specified module.

String setLogLevel(String logName, String logLevel) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
logNamestringLog module name, such as config-server or config-dump.
logLevelstringLog level, such as INFO or DEBUG.

Response Parameters

Parameter TypeDescription
StringResult information of setting the log level.

Request Example

try {
configMaintainerService.setLogLevel("config-server", "DEBUG");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

3.19. Update config metadata

Description

Update config metadata such as description and config tags.

boolean updateConfigMetadata(String dataId, String groupName, String namespaceId, String description, String configTags) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
dataIdstringConfig ID. Only English letters and four special characters (., :, -, _) are allowed. The length cannot exceed 256 bytes.
groupNamestringConfig group. Only English letters and four special characters (., :, -, _) are allowed. The length cannot exceed 128 bytes.
namespaceIdstringNamespace ID to which the config belongs.
descriptionstringConfig description.
configTagsstringTags of this config. Multiple tags are separated by commas ,.

Response Parameters

Parameter TypeDescription
booleanWhether the update succeeds.

Request Example

try {
configMaintainerService.updateConfigMetadata("maintain.client.test", "DEFAULT_GROUP", "public", "this is a description", "tag1,tag2");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

3.20. Search config list by details

Description

Search config list by dataId, groupName, namespaceId, search mode, config detail, type, tags, app name with pagination.

Page<ConfigBasicInfo> searchConfigByDetails(String dataId, String groupName, String namespaceId, String search,
String configDetail, String type, String configTags, String appName, int pageNo, int pageSize) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
dataIdstringConfig ID. Fuzzy or exact matching is supported depending on search.
groupNamestringConfig group.
namespaceIdstringNamespace ID to which the config belongs.
searchstringSearch mode: accurate for exact search or blur for fuzzy search.
configDetailstringConfig detail filter (optional).
typestringConfig type (optional).
configTagsstringConfig tags, separated by commas (optional).
appNamestringApplication name to which the config belongs (optional).
pageNointPage number, starting from 1.
pageSizeintNumber of items per page.

Response Parameters

Parameter TypeDescription
Page<ConfigBasicInfo>Paginated config list.

Request Example

try {
Page<ConfigBasicInfo> result = configMaintainerService.searchConfigByDetails(
"maintain.client.test", Constants.DEFAULT_GROUP, Constants.DEFAULT_NAMESPACE_ID,
"blur", null, null, null, null, 1, 100);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

4. Service Discovery Maintainer APIs

4.1. Create Service

Description

Creates a new empty service. The default is a persistent service.

String createService(String serviceName) throws NacosException;
String createService(String groupName, String serviceName) throws NacosException;
String createService(String namespaceId, String groupName, String serviceName) throws NacosException;
String createService(String namespaceId, String groupName, String serviceName, boolean ephemeral) throws NacosException;
String createService(String namespaceId, String groupName, String serviceName, boolean ephemeral, float protectThreshold) throws NacosException;
String createService(Service service) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
serviceName(Service.serviceName)stringService name
groupName(Service.groupName)stringService group name
namespaceId(Service.namespaceId)stringNamespace ID to which the service belongs
ephemeral(Service.ephemeral)booleanWhether the service is ephemeral. The default value is false.
protectThreshold(Service.protectThreshold)floatService protection threshold. The default value is 0.0.
Service.metadataMap<String,String>Service metadata
Service.selectorSelectorService instance selector. The default value is none.

Response Parameters

Parameter TypeDescription
StringResult description of service creation.

Request Example

try {
// The following requests all create a persistent service named `maintain.client.test`.
String result = namingMaintainerService.createService("maintain.client.test");
result = namingMaintainerService.createService("maintain.client.test", Constants.DEFAULT_GROUP);
result = namingMaintainerService.createService("maintain.client.test", Constants.DEFAULT_GROUP, Constants.DEFAULT_NAMESPACE_ID);
result = namingMaintainerService.createService("maintain.client.test", Constants.DEFAULT_GROUP, Constants.DEFAULT_NAMESPACE_ID, false);
result = namingMaintainerService.createService("maintain.client.test", Constants.DEFAULT_GROUP, Constants.DEFAULT_NAMESPACE_ID, false, 0.0f);
Service service = new Service();
service.setName("maintain.client.test");
service.setGroupName(Constants.DEFAULT_GROUP);
service.setNamespaceId(Constants.DEFAULT_NAMESPACE_ID);
result = namingMaintainerService.createService(service);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

4.2. Update Service

Description

Updates service information, including protection threshold, metadata, and instance selector. The service name, group, namespace, and persistence information cannot be modified.

String updateService(String serviceName, Map<String, String> newMetadata, float newProtectThreshold, Selector newSelector) throws NacosException;
String updateService(String groupName, String serviceName, Map<String, String> newMetadata, float newProtectThreshold, Selector newSelector) throws NacosException;
String updateService(String namespaceId, String groupName, String serviceName, Map<String, String> newMetadata, float newProtectThreshold, Selector newSelector) throws NacosException;
String updateService(String namespaceId, String groupName, String serviceName, boolean ephemeral, Map<String, String> newMetadata, float newProtectThreshold, Selector newSelector) throws NacosException;
String updateService(Service service) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
serviceName(Service.serviceName)stringService name
groupName(Service.groupName)stringService group name
namespaceId(Service.namespaceId)stringNamespace ID to which the service belongs
ephemeral(Service.ephemeral)booleanWhether the service is ephemeral. The default value is false.
protectThreshold(Service.protectThreshold)floatService protection threshold. The default value is 0.0.
Service.metadataMap<String,String>Service metadata
Service.selectorSelectorService instance selector. The default value is none.

Response Parameters

Parameter TypeDescription
StringResult description of service update.

Request Example

try {
// The following requests all update the persistent service named `maintain.client.test`.
String result = namingMaintainerService.updateService("maintain.client.test", new HashMap<>(), 0.0f, new NoneSelector());
result = namingMaintainerService.updateService("maintain.client.test", Constants.DEFAULT_GROUP, new HashMap<>(), 0.0f, new NoneSelector());
result = namingMaintainerService.updateService("maintain.client.test", Constants.DEFAULT_GROUP, Constants.DEFAULT_NAMESPACE_ID, new HashMap<>(), 0.0f, new NoneSelector());
result = namingMaintainerService.updateService("maintain.client.test", Constants.DEFAULT_GROUP, Constants.DEFAULT_NAMESPACE_ID, false, new HashMap<>(), 0.0f, new NoneSelector());
Service service = new Service();
service.setName("maintain.client.test");
service.setGroupName(Constants.DEFAULT_GROUP);
service.setNamespaceId(Constants.DEFAULT_NAMESPACE_ID);
result = namingMaintainerService.updateService(service);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

4.3. Delete Service

Description

Deletes a service. A service can be deleted only when it has no instances. If the service to delete does not exist, deletion success is also returned.

String removeService(String serviceName) throws NacosException;
String removeService(String groupName, String serviceName) throws NacosException;
String removeService(String namespaceId, String groupName, String serviceName) throws NacosException;
String removeService(Service service) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
serviceName(Service.serviceName)stringService name
groupName(Service.groupName)stringService group name
namespaceId(Service.namespaceId)stringNamespace ID to which the service belongs

Response Parameters

Parameter TypeDescription
StringResult description of service deletion.

Request Example

try {
// The following requests all delete a service named `maintain.client.test`.
String result = namingMaintainerService.removeService("maintain.client.test");
result = namingMaintainerService.removeService("maintain.client.test", Constants.DEFAULT_GROUP);
result = namingMaintainerService.removeService("maintain.client.test", Constants.DEFAULT_GROUP, Constants.DEFAULT_NAMESPACE_ID);
Service service = new Service();
service.setName("maintain.client.test");
service.setGroupName(Constants.DEFAULT_GROUP);
service.setNamespaceId(Constants.DEFAULT_NAMESPACE_ID);
result = namingMaintainerService.removeService(service);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

4.4. Query Service Details

Description

Queries service details, including service metadata, protection threshold, instance selector, and metadata of logical clusters Cluster under the service.

ServiceDetailInfo getServiceDetail(String serviceName) throws NacosException;
ServiceDetailInfo getServiceDetail(String groupName, String serviceName) throws NacosException;
ServiceDetailInfo getServiceDetail(String namespaceId, String groupName, String serviceName) throws NacosException;
ServiceDetailInfo getServiceDetail(Service service) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
serviceName(Service.serviceName)stringService name
groupName(Service.groupName)stringService group name
namespaceId(Service.namespaceId)stringNamespace ID to which the service belongs

Response Parameters

Parameter TypeDescription
ServiceDetailInfoService details.

The details in ServiceDetailInfo are as follows:

Parameter NameParameter TypeDescription
namespaceIdstringService namespace ID
groupNamestringService group name
serviceNamestringService name
ephemeralbooleanService persistence attribute
protectThresholdfloatService protection threshold
selectorSelectorService instance selector
metadataMap<String,String>Service metadata
clusterMapMap<String, ClusterInfo>Map of logical cluster information under the service. The key is the logical cluster name, and the value is detailed information.
clusterMap.${key}.clusterNamestringLogical cluster name
clusterMap.${key}.healthyCheckPortintHealth check port of the logical cluster
clusterMap.${key}.useInstancePortForCheckbooleanWhether the logical cluster uses the instance port for health checks
clusterMap.${key}.healthCheckerAbstractHealthCheckerHealth check type of the logical cluster
clusterMap.${key}.metadataMap<String,String>Logical cluster metadata

Request Example

try {
// The following requests all obtain details of a service named `maintain.client.test`.
ServiceDetailInfo result = namingMaintainService.getServiceDetail("maintain.client.test");
result = namingMaintainService.getServiceDetail("maintain.client.test", Constants.DEFAULT_GROUP);
result = namingMaintainService.getServiceDetail("maintain.client.test", Constants.DEFAULT_GROUP, Constants.DEFAULT_NAMESPACE_ID);
Service service = new Service();
service.setName("maintain.client.test");
service.setNamespaceId(Constants.DEFAULT_NAMESPACE_ID);
service.setGroupName(Constants.DEFAULT_GROUP);
result = namingMaintainService.getServiceDetail(service);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

4.5. Query Service List

Description

Gets a service list that matches the conditions. The service list obtained through this API does not contain instance information. To obtain the instance list and instance information under services, use Query Service instance List.

Page<ServiceView> listServices(String namespaceId) throws NacosException;
Page<ServiceView> listServices(String namespaceId, String groupNameParam, String serviceNameParam) throws NacosException;
Page<ServiceView> listServices(String namespaceId, String groupNameParam, String serviceNameParam, boolean ignoreEmptyService, int pageNo, int pageSize) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID to which the service belongs
groupNameParamstringService group name pattern. * can be used for prefix and suffix fuzzy matching. If empty, all groups are returned.
serviceNameParamstringService name pattern. * can be used for prefix and suffix fuzzy matching. If empty, all services are returned.
ignoreEmptyServicebooleanWhether to ignore empty services. The default value is true. If true, empty services are not returned.
pageNointPage number. The default value is 1.
pageSizeintPage size. The default value is 100.

Response Parameters

Parameter TypeDescription
Page<ServiceView>Paginated result of services that match the conditions.

The specific Page and ServiceView content is as follows:

Parameter NameParameter TypeDescription
totalCountintTotal number of services that match the condition.
pageNumberintCurrent page number.
pagesAvailableintTotal number of pages.
pageItemsList<ConfigBasicInfo>Service list on the current page.
Parameter NameParameter TypeDescription
namestringService name
groupNamestringService group name
clusterCountintNumber of logical clusters under the service
ipCountintTotal number of instances under the service
healthyInstanceCountintTotal number of healthy instances under the service
triggerFlagbooleanWhether threshold protection is triggered

Request Example

try {
// The following requests all obtain the service list (up to the first 100 services).
Page<ServiceView> result = namingMaintainService.listServices(Constants.DEFAULT_NAMESPACE_ID);
result = namingMaintainService.listServices(Constants.DEFAULT_NAMESPACE_ID, "", "");
result = namingMaintainService.listServices(Constants.DEFAULT_NAMESPACE_ID, "", "", true, 1, 100);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

4.6. Query Service List with instance Information

Description

Gets a service list that matches the conditions. The service list obtained through this API includes instance information.

Page<ServiceDetailInfo> listServicesWithDetail(String namespaceId) throws NacosException;
Page<ServiceDetailInfo> listServicesWithDetail(String namespaceId, String groupNameParam, String serviceNameParam) throws NacosException;
Page<ServiceDetailInfo> listServicesWithDetail(String namespaceId, String groupNameParam, String serviceNameParam, int pageNo, int pageSize) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID to which the service belongs
groupNameParamstringService group name pattern. * can be used for prefix and suffix fuzzy matching. If empty, all groups are returned.
serviceNameParamstringService name pattern. * can be used for prefix and suffix fuzzy matching. If empty, all services are returned.
pageNointPage number. The default value is 1.
pageSizeintPage size. The default value is 100.

Response Parameters

Parameter TypeDescription
Page<ServiceDetailInfo>Paginated result of services that match the conditions.

The specific Page and ServiceDetailInfo content is as follows:

Parameter NameParameter TypeDescription
totalCountintTotal number of services that match the condition.
pageNumberintCurrent page number.
pagesAvailableintTotal number of pages.
pageItemsList<ConfigBasicInfo>Service list on the current page.
Parameter NameParameter TypeDescription
namespaceIdstringService namespace ID
groupNamestringService group name
serviceNamestringService name
ephemeralbooleanService persistence attribute
protectThresholdfloatService protection threshold
selectorSelectorService instance selector
metadataMap<String,String>Service metadata
clusterMapMap<String, ClusterInfo>Map of logical cluster information under the service. The key is the logical cluster name, and the value is detailed information.
clusterMap.${key}.clusterNamestringLogical cluster name
clusterMap.${key}.healthyCheckPortintHealth check port of the logical cluster
clusterMap.${key}.useInstancePortForCheckbooleanWhether the logical cluster uses the instance port for health checks
clusterMap.${key}.healthCheckerAbstractHealthCheckerHealth check type of the logical cluster
clusterMap.${key}.metadataMap<String,String>Logical cluster metadata

Request Example

try {
// The following requests all obtain the service list (up to the first 100 services).
Page<ServiceDetailInfo> result = namingMaintainService.listServicesWithDetail(Constants.DEFAULT_NAMESPACE_ID);
result = namingMaintainService.listServicesWithDetail(Constants.DEFAULT_NAMESPACE_ID, "", "");
result = namingMaintainService.listServicesWithDetail(Constants.DEFAULT_NAMESPACE_ID, "", "", 1, 10);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

4.7. Query Service Subscriber List

Description

Queries the subscriber list of the specified service.

Page<SubscriberInfo> getSubscribers(String serviceName) throws NacosException;
Page<SubscriberInfo> getSubscribers(String groupName, String serviceName) throws NacosException;
Page<SubscriberInfo> getSubscribers(String namespaceId, String groupName, String serviceName) throws NacosException;
Page<SubscriberInfo> getSubscribers(String namespaceId, String groupName, String serviceName, int pageNo, int pageSize) throws NacosException;
Page<SubscriberInfo> getSubscribers(String namespaceId, String groupName, String serviceName, int pageNo, int pageSize, boolean aggregation) throws NacosException;
Page<SubscriberInfo> getSubscribers(Service service, int pageNo, int pageSize, boolean aggregation) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
serviceName(Service.serviceName)stringService name
groupName(Service.groupName)stringService group name
namespaceId(Service.namespaceId)stringNamespace ID to which the service belongs
pageNointPage number. The default value is 1.
pageSizeintPage size. The default value is 100.
aggregationbooleanWhether to perform an aggregated query. The default value is false. If false, only the subscriber list on the node that receives the request is queried. If true, the subscriber list in the entire cluster is queried.

Response Parameters

Parameter TypeDescription
Page<SubscriberInfo>Paginated subscriber list result.

Request Example

try {
// The following requests all obtain the subscriber list of service `maintain.client.test` (up to the first 100 subscribers).
Page<SubscriberInfo> result = namingMaintainService.getSubscribers("maintain.client.test");
result = namingMaintainService.getSubscribers(Constants.DEFAULT_GROUP, "maintain.client.test");
result = namingMaintainService.getSubscribers(Constants.DEFAULT_NAMESPACE_ID, Constants.DEFAULT_GROUP, "maintain.client.test");
result = namingMaintainService.getSubscribers(Constants.DEFAULT_NAMESPACE_ID, Constants.DEFAULT_GROUP, "maintain.client.test", 1, 100);
result = namingMaintainService.getSubscribers(Constants.DEFAULT_NAMESPACE_ID, Constants.DEFAULT_GROUP, "maintain.client.test", 1, 100, false);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

4.8. Query Supported Service instance Selectors

Description

Use this API to obtain the supported service instance selector list. Only selector names are returned.

List<String> listSelectorTypes() throws NacosException;

Request Parameters

None

Response Parameters

Parameter TypeDescription
List<String>List of instance selector names.

Request Example

try {
List<String> result = namingMaintainService.listSelectorTypes();
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

4.9. Register Instance

Description

Registers an instance for a service through this API. The instance is registered as persistent by default.

String registerInstance(String serviceName, String ip, int port) throws NacosException;
String registerInstance(String groupName, String serviceName, String ip, int port) throws NacosException;
String registerInstance(String namespaceId, String groupName, String serviceName, String ip, int port) throws NacosException;
String registerInstance(String serviceName, String ip, int port, String clusterName) throws NacosException;
String registerInstance(String groupName, String serviceName, String ip, int port, String clusterName) throws NacosException;
String registerInstance(String namespaceId, String groupName, String serviceName, String ip, int port, String clusterName) throws NacosException;
String registerInstance(String serviceName, Instance instance) throws NacosException;
String registerInstance(String groupName, String serviceName, Instance instance) throws NacosException;
String registerInstance(String namespaceId, String groupName, String serviceName, Instance instance);
String registerInstance(Service service, Instance instance) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
serviceName(Service.serviceName)stringService name
groupName(Service.groupName)stringService group name
namespaceId(Service.namespaceId)stringNamespace ID to which the service belongs
clusterName(Instance.clusterName)stringLogical cluster name to which the instance belongs
ip(Instance.ip)stringinstance IP address. Domain names are supported.
port(Instance.port)intinstance port. Valid values are 0 to 65535.
Instance.ephemeralbooleaninstance persistence attribute
Instance.weightdoubleinstance weight
Instance.healthybooleaninstance health status
Instance.enabledbooleaninstance online/offline status
Instance.instanceIdstringinstance ID
Instance.metadataMap<String,String>instance metadata

Response Parameters

Parameter TypeDescription
StringResult description of instance registration.

Request Example

try {
// The following requests all register an instance with IP `127.0.0.1` and port `8080` for service `maintain.client.test`.
String result = namingMaintainService.registerInstance("maintain.client.test", "127.0.0.1", 8080);
result = namingMaintainService.registerInstance(Constants.DEFAULT_GROUP, "maintain.client.test", "127.0.0.1", 8080);
result = namingMaintainService.registerInstance(Constants.DEFAULT_NAMESPACE_ID, Constants.DEFAULT_GROUP, "maintain.client.test", "127.0.0.1", 8080);
result = namingMaintainService.registerInstance(Constants.DEFAULT_NAMESPACE_ID, Constants.DEFAULT_GROUP, "maintain.client.test", "127.0.0.1", 8080);
result = namingMaintainService.registerInstance("maintain.client.test", "127.0.0.1", 8080, Constants.DEFAULT_CLUSTER_NAME);
result = namingMaintainService.registerInstance(Constants.DEFAULT_GROUP,"maintain.client.test", "127.0.0.1", 8080, Constants.DEFAULT_CLUSTER_NAME);
result = namingMaintainService.registerInstance(Constants.DEFAULT_NAMESPACE_ID, Constants.DEFAULT_GROUP,"maintain.client.test", "127.0.0.1", 8080, Constants.DEFAULT_CLUSTER_NAME);
Instance instance = new Instance();
instance.setIp("127.0.0.1");
instance.setPort(8080);
instance.setEphemeral(false);
result = namingMaintainService.registerInstance("maintain.client.test", instance);
result = namingMaintainService.registerInstance(Constants.DEFAULT_GROUP,"maintain.client.test", instance);
result = namingMaintainService.registerInstance(Constants.DEFAULT_NAMESPACE_ID, Constants.DEFAULT_GROUP, "maintain.client.test", instance);
Service service = new Service();
service.setNamespaceId(Constants.DEFAULT_NAMESPACE_ID);
service.setGroupName(Constants.DEFAULT_GROUP);
service.setName("maintain.client.test");
result = namingMaintainService.registerInstance(service, instance);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

4.10. Deregister Instance

Description

Deregisters an instance of a service through this API.

String deregisterInstance(String serviceName, String ip, int port) throws NacosException;
String deregisterInstance(String groupName, String serviceName, String ip, int port) throws NacosException;
String deregisterInstance(String namespaceId, String groupName, String serviceName, String ip, int port) throws NacosException;
String deregisterInstance(String serviceName, String ip, int port, String clusterName) throws NacosException;
String deregisterInstance(String groupName, String serviceName, String ip, int port, String clusterName) throws NacosException;
String deregisterInstance(String namespaceId, String groupName, String serviceName, String ip, int port, String clusterName) throws NacosException;
String deregisterInstance(String serviceName, Instance instance) throws NacosException;
String deregisterInstance(String groupName, String serviceName, Instance instance) throws NacosException;
String deregisterInstance(String namespaceId, String groupName, String serviceName, Instance instance) throws NacosException;
String deregisterInstance(Service service, Instance instance) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
serviceName(Service.serviceName)stringService name
groupName(Service.groupName)stringService group name
namespaceId(Service.namespaceId)stringNamespace ID to which the service belongs
clusterName(Instance.clusterName)stringLogical cluster name to which the instance belongs
ip(Instance.ip)stringinstance IP address. Domain names are supported.
port(Instance.port)intinstance port. Valid values are 0 to 65535.
Instance.ephemeralbooleaninstance persistence attribute

Response Parameters

Parameter TypeDescription
StringResult description of instance deregistration.

Request Example

try {
// The following requests all deregister an instance whose IP is `127.0.0.1` and port is `8080` from service `maintain.client.test`.
String result = namingMaintainService.registerInstance("maintain.client.test", "127.0.0.1", 8080);
result = namingMaintainService.deregisterInstance(Constants.DEFAULT_GROUP, "maintain.client.test", "127.0.0.1", 8080);
result = namingMaintainService.deregisterInstance(Constants.DEFAULT_NAMESPACE_ID, Constants.DEFAULT_GROUP, "maintain.client.test", "127.0.0.1", 8080);
result = namingMaintainService.deregisterInstance(Constants.DEFAULT_NAMESPACE_ID, Constants.DEFAULT_GROUP, "maintain.client.test", "127.0.0.1", 8080);
result = namingMaintainService.deregisterInstance("maintain.client.test", "127.0.0.1", 8080, Constants.DEFAULT_CLUSTER_NAME);
result = namingMaintainService.deregisterInstance(Constants.DEFAULT_GROUP,"maintain.client.test", "127.0.0.1", 8080, Constants.DEFAULT_CLUSTER_NAME);
result = namingMaintainService.deregisterInstance(Constants.DEFAULT_NAMESPACE_ID, Constants.DEFAULT_GROUP,"maintain.client.test", "127.0.0.1", 8080, Constants.DEFAULT_CLUSTER_NAME);
Instance instance = new Instance();
instance.setIp("127.0.0.1");
instance.setPort(8080);
instance.setEphemeral(false);
result = namingMaintainService.deregisterInstance("maintain.client.test", instance);
result = namingMaintainService.deregisterInstance(Constants.DEFAULT_GROUP,"maintain.client.test", instance);
result = namingMaintainService.deregisterInstance(Constants.DEFAULT_NAMESPACE_ID, Constants.DEFAULT_GROUP, "maintain.client.test", instance);
Service service = new Service();
service.setNamespaceId(Constants.DEFAULT_NAMESPACE_ID);
service.setGroupName(Constants.DEFAULT_GROUP);
service.setName("maintain.client.test");
result = namingMaintainService.deregisterInstance(service, instance);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

4.11. Update Instance

Description

Updates metadata of a service instance through this API, but the instance service, IP address, port, and logical cluster cannot be modified.

String updateInstance(String serviceName, Instance instance) throws NacosException;
String updateInstance(String groupName, String serviceName, Instance instance) throws NacosException;
String updateInstance(String namespaceId, String groupName, String serviceName, Instance instance) throws NacosException;
String updateInstance(Service service, Instance instance) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
serviceName(Service.serviceName)stringService name
groupName(Service.groupName)stringService group name
namespaceId(Service.namespaceId)stringNamespace ID to which the service belongs
Instance.clusterNamestringLogical cluster name to which the instance belongs
Instance.ipstringinstance IP address. Domain names are supported.
Instance.portintinstance port. Valid values are 0 to 65535.
Instance.ephemeralbooleaninstance persistence attribute
Instance.weightdoubleinstance weight
Instance.healthybooleaninstance health status
Instance.enabledbooleaninstance online/offline status
Instance.instanceIdstringinstance ID
Instance.metadataMap<String,String>instance metadata

Response Parameters

Parameter TypeDescription
StringResult description of instance update.

Request Example

try {
Instance instance = new Instance();
instance.setIp("127.0.0.1");
instance.setPort(8080);
instance.setEphemeral(false);
instance.setEnabled(false);
// The following requests all update an instance whose IP is `127.0.0.1` and port is `8080` under service `maintain.client.test`, and change the instance `enabled` value to `false`.
String result = namingMaintainService.registerInstance("maintain.client.test", instance);
result = namingMaintainService.registerInstance(Constants.DEFAULT_GROUP,"maintain.client.test", instance);
result = namingMaintainService.registerInstance(Constants.DEFAULT_NAMESPACE_ID, Constants.DEFAULT_GROUP, "maintain.client.test", instance);
Service service = new Service();
service.setNamespaceId(Constants.DEFAULT_NAMESPACE_ID);
service.setGroupName(Constants.DEFAULT_GROUP);
service.setName("maintain.client.test");
result = namingMaintainService.registerInstance(service, instance);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

4.12. Batch Update instance Metadata

Description

Updates metadata for some or all instances under the specified service in batches.

InstanceMetadataBatchResult batchUpdateInstanceMetadata(Service service, List<Instance> instances, Map<String, String> newMetadata) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
Service.serviceNamestringService name
Service.groupNamestringService group name
Service.namespaceIdstringNamespace ID to which the service belongs
instancesList<Instance>List of instances whose metadata needs to be updated. Only ip, port, and clusterName are required.
newMetadataMap<String,String>New metadata.

Response Parameters

Parameter TypeDescription
InstanceMetadataBatchResultinstance metadata update result.

The content of InstanceMetadataBatchResult is as follows:

Parameter NameParameter TypeDescription
updatedList<String>IDs of instances updated successfully.

Request Example

try {
Service service = new Service();
service.setNamespaceId(Constants.DEFAULT_NAMESPACE_ID);
service.setGroupName(Constants.DEFAULT_GROUP);
service.setName("maintain.client.test");
Instance instance = new Instance();
instance.setIp("127.0.0.1");
instance.setPort(8080);
Map<String, String> newMetadata = Collections.singletonMap("testK", "testV");
InstanceMetadataBatchResult result = namingMaintainService.batchUpdateInstanceMetadata(service, Collections.singletonList(instance), newMetadata);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

4.13. Batch Remove instance Metadata

Description

Removes metadata from some or all instances under the specified service in batches.

InstanceMetadataBatchResult batchDeleteInstanceMetadata(Service service, List<Instance> instances, Map<String, String> newMetadata) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
Service.serviceNamestringService name
Service.groupNamestringService group name
Service.namespaceIdstringNamespace ID to which the service belongs
instancesList<Instance>List of instances whose metadata needs to be updated. Only ip, port, and clusterName are required.
newMetadataMap<String,String>Metadata to remove.

Response Parameters

Parameter TypeDescription
InstanceMetadataBatchResultinstance metadata update result.

The content of InstanceMetadataBatchResult is as follows:

Parameter NameParameter TypeDescription
updatedList<String>IDs of instances removed successfully.

Request Example

try {
Service service = new Service();
service.setNamespaceId(Constants.DEFAULT_NAMESPACE_ID);
service.setGroupName(Constants.DEFAULT_GROUP);
service.setName("maintain.client.test");
Instance instance = new Instance();
instance.setIp("127.0.0.1");
instance.setPort(8080);
Map<String, String> newMetadata = Collections.singletonMap("testK", "testV");
InstanceMetadataBatchResult result = namingMaintainService.batchDeleteInstanceMetadata(service, Collections.singletonList(instance), newMetadata);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

4.14. Update Partial instance Metadata

Description

Updates part of instance metadata. Compared with the Update Instance API, only metadata passed in the request is updated. If a key in the instance metadata is not included in the request parameters, it is not updated.

For example, if the current metadata is k1=v1,k2=v2 and the API receives k2=v3, the metadata becomes k1=v1,k2=v3, not k2=v3.

Note that some fields in the Instance object have default values, such as weight. Pass the corresponding values, otherwise the defaults may overwrite existing values.

String partialUpdateInstance(Service service, Instance instance) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
Service.serviceNamestringService name
Service.groupNamestringService group name
Service.namespaceIdstringNamespace ID to which the service belongs
Instance.clusterNamestringLogical cluster name to which the instance belongs
Instance.ipstringinstance IP address. Domain names are supported.
Instance.portintinstance port. Valid values are 0 to 65535.
Instance.ephemeralbooleaninstance persistence attribute
Instance.weightdoubleinstance weight
Instance.healthybooleaninstance health status
Instance.enabledbooleaninstance online/offline status
Instance.metadataMap<String,String>instance metadata

Response Parameters

Parameter TypeDescription
StringResult description of instance update.

Request Example

try {
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

4.15. Query Service instance List

Description

Queries all instances that match the conditions under the specified service.

List<Instance> listInstances(String serviceName, String clusterName, boolean healthyOnly) throws NacosException;
List<Instance> listInstances(String groupName, String serviceName, String clusterName, boolean healthyOnly) throws NacosException;
List<Instance> listInstances(String namespaceId, String groupName, String serviceName, String clusterName, boolean healthyOnly) throws NacosException;
List<Instance> listInstances(Service service, String clusterName, boolean healthyOnly) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
serviceName(Service.serviceName)stringService name
groupName(Service.groupName)stringService group name
namespaceId(Service.namespaceId)stringNamespace ID to which the service belongs
clusterNamestringLogical cluster name to which the instance belongs. If empty, instances in all logical clusters are returned. To query multiple logical clusters, separate them with commas ,.
healthyOnlybooleanWhether to return only healthy instances.

Response Parameters

Parameter TypeDescription
List<Instance>instance information list.

Request Example

try {
List<Instance> result = namingMaintainService.listInstances("maintain.client.test", "", false);
result = namingMaintainService.listInstances(Constants.DEFAULT_GROUP, "maintain.client.test", "", false);
result = namingMaintainService.listInstances(Constants.DEFAULT_NAMESPACE_ID, Constants.DEFAULT_GROUP, "maintain.client.test", "", false);
Service service = new Service();
service.setNamespaceId(Constants.DEFAULT_NAMESPACE_ID);
service.setGroupName(Constants.DEFAULT_GROUP);
service.setName("maintain.client.test");
result = namingMaintainService.listInstances(service, "", false);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

4.16. Query Details of a Specified Service Instance

Description

Queries details of the specified service instance, mainly including metadata and other additional information such as weight.

Instance getInstanceDetail(String serviceName, String ip, int port) throws NacosException;
Instance getInstanceDetail(String groupName, String serviceName, String ip, int port) throws NacosException;
Instance getInstanceDetail(String namespaceId, String groupName, String serviceName, String ip, int port) throws NacosException;
Instance getInstanceDetail(String serviceName, String ip, int port, String clusterName) throws NacosException;
Instance getInstanceDetail(String groupName, String serviceName, String ip, int port, String clusterName) throws NacosException;
Instance getInstanceDetail(String namespaceId, String groupName, String serviceName, String ip, int port, String clusterName) throws NacosException;
Instance getInstanceDetail(Service service, Instance instance) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
serviceName(Service.serviceName)stringService name
groupName(Service.groupName)stringService group name
namespaceId(Service.namespaceId)stringNamespace ID to which the service belongs
clusterName(Instance.clusterName)stringLogical cluster name to which the instance belongs
ip(Instance.ip)stringinstance IP address. Domain names are supported.
port(Instance.port)intinstance port. Valid values are 0 to 65535.

Response Parameters

Parameter TypeDescription

Request Example

try {
instance result = namingMaintainService.getInstanceDetail("maintain.client.test", "127.0.0.1", 8080);
result = namingMaintainService.getInstanceDetail(Constants.DEFAULT_GROUP, "maintain.client.test", "127.0.0.1", 8080);
result = namingMaintainService.getInstanceDetail(Constants.DEFAULT_NAMESPACE_ID, Constants.DEFAULT_GROUP, "maintain.client.test", "127.0.0.1", 8080);
result = namingMaintainService.getInstanceDetail("maintain.client.test", "127.0.0.1", 8080, Constants.DEFAULT_CLUSTER_NAME);
result = namingMaintainService.getInstanceDetail(Constants.DEFAULT_GROUP,"maintain.client.test", "127.0.0.1", 8080, Constants.DEFAULT_CLUSTER_NAME);
result = namingMaintainService.getInstanceDetail(Constants.DEFAULT_NAMESPACE_ID, Constants.DEFAULT_GROUP,"maintain.client.test", "127.0.0.1", 8080, Constants.DEFAULT_CLUSTER_NAME);
Service service = new Service();
service.setNamespaceId(Constants.DEFAULT_NAMESPACE_ID);
service.setGroupName(Constants.DEFAULT_GROUP);
service.setName("maintain.client.test");
Instance instance = new Instance();
instance.setIp("127.0.0.1");
instance.setPort(8080);
instance.setClusterName(Constants.DEFAULT_CLUSTER_NAME);
result = namingMaintainService.getInstanceDetail(service, instance);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

4.17. Query Service Registry Statistics

Description

Queries service registry statistics, mainly including availability status, instance count, service count, and other information.

MetricsInfo getMetrics(boolean onlyStatus) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
onlyStatusbooleanWhether to query only availability status.

Response Parameters

Parameter TypeDescription
MetricsInfoService registry statistics.

The content of MetricsInfo is as follows:

Parameter NameParameter TypeDescription
statusstringAvailability status of the service registry, such as UP.
serviceCountintTotal number of services.
instanceCountintTotal number of service instances.
subscribeCountintTotal number of service subscribers.
clientCountintTotal number of client connections.
connectionBasedClientCountintTotal number of connection-based clients, corresponding to clients with SDK version later than 2.0.
ephemeralIpPortClientCountintTotal number of IP-port-based ephemeral clients, corresponding to clients with SDK versions earlier than 2.0, including ephemeral clients registered through HTTP OpenAPI and maintainer APIs.
persistentIpPortClientCountintTotal number of IP-port-based persistent clients, corresponding to clients of persistent instances.
responsibleClientCountintTotal number of clients maintained by this Nacos Server node, including connectionBasedClientCount directly connected to this node and ephemeralIpPortClientCount and persistentIpPortClientCount that the Distro protocol considers this node responsible for.

Request Example

try {
MetricsInfo metricsInfo = namingMaintainService.getMetrics(false);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

4.18. Set Service Registry Log Level

Description

Sets log levels for service registry related modules.

String setLogLevel(String logName, String logLevel) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
:---------:-------:----------------------------------------
logNamestringLog module name, such as naming-server or naming-event.
logLevelstringLog level, such as INFO or DEBUG.

Response Parameters

Parameter TypeDescription
StringResult information of setting the log level.

Request Example

try {
String result = namingMaintainService.setLogLevel("naming-server", "DEBUG");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

4.19. Update Persistent instance Health Status

Description

Updates persistent instance health status.

String updateInstanceHealthStatus(Service service, Instance instance) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
serviceName(Service.serviceName)stringService name
groupName(Service.groupName)stringService group name
namespaceId(Service.namespaceId)stringNamespace ID to which the service belongs
clusterName(Instance.clusterName)stringLogical cluster name to which the instance belongs
ip(Instance.ip)stringinstance IP address. Domain names are supported.
port(Instance.port)intinstance port. Valid values are 0 to 65535.
healthy(Instance.healthy)booleanTarget health status of the instance.

Response Parameters

Parameter TypeDescription
StringResult description of health status update.

Request Example

try {
// Updates the health status of instance `127.0.0.1:8080` under `maintain.client.test` to false.
Service service = new Service();
service.setNamespaceId(Constants.DEFAULT_NAMESPACE_ID);
service.setGroupName(Constants.DEFAULT_GROUP);
service.setName("maintain.client.test");
Instance instance = new Instance();
instance.setIp("127.0.0.1");
instance.setPort(8080);
instance.setClusterName(Constants.DEFAULT_CLUSTER_NAME);
instance.setEphemeral(false)
instance.setHealthy(false);
String result = namingMaintainService.updateInstanceHealthStatus(service, instance);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

4.20. Query Supported Health Check Types

Description

Queries supported health check types through this API.

Map<String, AbstractHealthChecker> getHealthCheckers() throws NacosException;

Request Parameters

None

Response Parameters

Parameter TypeDescription
Map<String, AbstractHealthChecker>Map of supported health check methods. The key is the type, and the value is the corresponding config content of the specific health checker.

Request Example

try {
Map<String, AbstractHealthChecker> result = namingMaintainService.getHealthCheckers();
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

4.21. Update Logical Cluster Metadata

Description

Updates metadata of the specified logical cluster under the specified service.

String updateCluster(Service service, ClusterInfo cluster) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
Service.serviceNamestringService name
Service.groupNamestringService group name
Service.namespaceIdstringNamespace ID to which the service belongs
ClusterInfo.clusterNamestringLogical cluster name
ClusterInfo.healthCheckerstringHealth check type of the logical cluster, Obtain it through Query Supported Health Check Types.
ClusterInfo.healthyCheckPortstringHealth check port.
ClusterInfo.useInstancePortForCheckstringWhether to use the port registered by the instance for health checks. If true, the port set by healthyCheckPort is ignored.
ClusterInfo.metadataMap<String,String>Metadata of the cluster to which the instance belongs.

Response Parameters

Parameter TypeDescription

Request Example

try {
Service service = new Service();
service.setNamespaceId(Constants.DEFAULT_NAMESPACE_ID);
service.setGroupName(Constants.DEFAULT_GROUP);
service.setName("maintain.client.test");
ClusterInfo clusterInfo = new ClusterInfo();
clusterInfo.setClusterName(Constants.DEFAULT_CLUSTER_NAME);
clusterInfo.setHealthChecker(new AbstractHealthChecker.None());
clusterInfo.setUseInstancePortForCheck(true);
clusterInfo.setMetadata(Collections.singletonMap("testK", "testV"));
String result = namingMaintainService.updateCluster(service, clusterInfo);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

4.22. Query Service Client List

Description

Gets the list of all clients that register or subscribe to services in the service registry.

List<String> getClientList() throws NacosException;

Request Parameters

None

Response Parameters

Parameter TypeDescription
List<String>Client ID list.

Request Example

try {
List<String> result = namingMaintainService.getClientList();
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

4.23. Query Service Client Details

Description

Queries detailed information about a service client. The returned content may vary for clients of different versions.

ClientSummaryInfo getClientDetail(String clientId) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
clientIdstringClient ID. You can obtain it from logs or Query Service Client List.

Response Parameters

Parameter TypeDescription
ClientSummaryInfoClient summary information.

The content of ClientSummaryInfo is as follows:

Parameter NameParameter TypeDescription
clientIdstringClient ID.
ephemeralbooleanWhether this is a persistent service client.
lastUpdatedTimelongTimestamp when the client was last updated, such as registration or deregistration.
clientTypestringClient type. ipPort corresponds to 1.x clients or HTTP OpenAPI access, and connection corresponds to 2.x or later clients or gRPC OpenAPI access.
connectTypestringWhen clientType is connection, this field indicates the client connection type. The current value is grpc.
appNamestringClient application name. It must be added to connection metadata when the client connects. The default value is unknown.
versionstringClient version, such as Nacos-Java-Client:v3.0.0.
clientIpstringClient IP address. In proxy registration scenarios such as Nacos-Sync, this IP address may differ from the IP address of the service instance registered by this client.
clientPortintClient port address, indicating the remote port of this connection.

Request Example

try {
ClientSummaryInfo result = namingMaintainService.getClientDetail("127.0.0.1:8080#true");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

4.24. Query Services Registered by a Specified Service Client

Description

Queries the list of services registered by the specified service client.

List<ClientServiceInfo> getPublishedServiceList(String clientId) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
clientIdstringClient ID. You can obtain it from logs or Query Service Client List.

Response Parameters

Parameter TypeDescription
List<ClientServiceInfo>Information about services registered by the client.

The ClientServiceInfo content is as follows:

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID to which the service belongs.
groupNamestringService group name
serviceNamestringService name
publisherInfoClientPublisherInfoInformation about service instances registered by the client.
publisherInfo.ipstringinstance IP address.
publisherInfo.portstringinstance port.
publisherInfo.clusterNamestringinstance logical cluster name.

Request Example

try {
List<ClientServiceInfo> result = namingMaintainService.getPublishedServiceList("127.0.0.1:8080#true");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

4.25. Query Services Subscribed to by a Specified Service Client

Description

Queries the list of services subscribed to by the specified service client.

List<ClientServiceInfo> getSubscribeServiceList(String clientId) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
clientIdstringClient ID. You can obtain it from logs or Query Service Client List.

Response Parameters

Parameter TypeDescription
List<ClientServiceInfo>Information about services subscribed to by the client.

The ClientServiceInfo content is as follows:

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID to which the service belongs.
groupNamestringService group name
serviceNamestringService name
subscriberInfoClientSubscriberInfoClient subscriber information.
subscriberInfo.appNamestringApplication name to which the subscriber belongs. The default value is unknown.
subscriberInfo.agentstringSubscriber client version.
subscriberInfo.addressstringSubscriber address in IP:PORT format.

Request Example

try {
List<ClientServiceInfo> result = namingMaintainService.getSubscribeServiceList("127.0.0.1:8080#true");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

4.26. Query Service Clients That Registered a Specified Service

Description

Queries which clients registered the specified service.

List<ClientPublisherInfo> getPublishedClientList(String namespaceId, String groupName, String serviceName, String ip, Integer port) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID to which the service belongs.
groupNamestringService group name
serviceNamestringService name
ipstringIP address of the service instance. If empty, all service instances are matched.
portintService instance port. If empty, all service instances are matched.

Response Parameters

Parameter TypeDescription
List<ClientPublisherInfo>Information about clients that registered service instances.

The ClientPublisherInfo content is as follows:

Parameter NameParameter TypeDescription
clientIdstringID of the client that registered the service.
ipstringRegistered instance IP address.
portstringRegistered instance port.
clusterNamestringRegistered instance logical cluster name.

Request Example

try {
List<ClientPublisherInfo> result = namingMaintainService.getPublishedClientList(Constants.DEFAULT_NAMESPACE_ID, Constants.DEFAULT_GROUP, "maintain.client.test", "", "");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

4.27. Query Service Clients That Subscribed to a Specified Service

Description

Queries which clients subscribed to the specified service.

List<ClientSubscriberInfo> getSubscribeClientList(String namespaceId, String groupName, String serviceName, String ip, Integer port) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID to which the service belongs.
groupNamestringService group name
serviceNamestringService name
ipstringIP address of the service subscriber. If empty, all subscribers are matched.
portintPort of the service subscriber. If empty, all subscribers are matched.

Response Parameters

Parameter TypeDescription
List<ClientSubscriberInfo>Information about clients that subscribed to the service.

The ClientSubscriberInfo content is as follows:

Parameter NameParameter TypeDescription
clientIdstringID of the client that subscribed to the service.
appNamestringApplication name to which the subscriber belongs. The default value is unknown.
agentstringSubscriber client version.
addressstringSubscriber address in IP:PORT format.

Request Example

try {
List<ClientSubscriberInfo> result = namingMaintainService.getSubscribeClientList(Constants.DEFAULT_NAMESPACE_ID, Constants.DEFAULT_GROUP, "maintain.client.test", "", "");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

5. Other Nacos Core Maintainer APIs

Nacos core maintainer APIs can be called through NacosNamingMaintainerService or NacosConfigMaintainerService.

5.1. Query Nacos Server Status Information

Description

Queries Nacos Server status information, including version, running mode, authentication enabled, and running modules.

Map<String, String> getServerState() throws NacosException;

Request Parameters

None

Response Parameters

Parameter TypeDescription
Map<String, String>Nacos Server status information.

Request Example

try {
Map<String,String> result = namingMaintainService.getServerState();
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

5.2. Get Nacos Server Liveness Status

Description

Gets the liveness status of Nacos Server.

Boolean liveness() throws NacosException;

Request Parameters

None

Response Parameters

Parameter TypeDescription
booleantrue means live, and false means there is a problem.

Request Example

try {
boolean result = namingMaintainService.liveness();
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

5.3. Get Nacos Server Readiness Status

Description

Gets the readiness status of Nacos Server.

Boolean readiness() throws NacosException;

Request Parameters

None

Response Parameters

Parameter TypeDescription
booleantrue means ready, and false means not ready.

Request Example

try {
boolean result = namingMaintainService.readiness();
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

5.4. Nacos Raft Operations

Description

Use this API to perform maintenance operations on the Raft protocol in Nacos Server, such as re-elect leader and take snapshot.

String raftOps(String command, String value, String groupId) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
commandstringRaft operation command. See com.alibaba.nacos.core.distributed.raft.utils.JRaftOps.
valuestringTarget value of the Raft operation.
groupIdstringTarget Raft group of the operation. If empty, all Raft groups are operated on.

Response Parameters

Parameter TypeDescription
StringOperation result.

Request Example

try {
String result = namingMaintainService.raftOps("doSnapshot", "172.0.0.1:7848", "");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

5.5. Query Distributed ID Generators Supported by Nacos Server

Description

Queries the list of distributed ID generators supported by Nacos Server, such as the Snowflake ID generator.

List<IdGeneratorInfo> getIdGenerators() throws NacosException;

Request Parameters

None

Response Parameters

Parameter TypeDescription
List<IdGeneratorInfo>ID generator information list.

Request Example

try {
List<IdGeneratorInfo> result = namingMaintainService.getIdGenerators();
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

5.6. Update Core Module Log Level

Description

Updates the log level of core modules.

void updateLogLevel(String logName, String logLevel) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
logNamestringLog module name, such as core-auth.
logLevelstringLog level, such as INFO or DEBUG.

Response Parameters

None

Request Example

try {
namingMaintainService.updateLogLevel("core-auth", "INFO");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

5.7. Query Nacos Server Node List

Description

Queries the Nacos Server node list.

Collection<NacosMember> listClusterNodes(String address, String state) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
addressstringServer node address. The default value is "". If empty, all nodes are returned. If not empty, nodes that match the prefix are returned.
statestringServer node status, such as UP. The default value is "". If empty, all nodes are returned. If not empty, nodes that match this status are returned.

Response Parameters

Parameter TypeDescription
Collection<NacosMember>Nacos Server node list.

The fields of NacosMember are described as follows:

Parameter NameParameter TypeDescription
ipstringServer node IP address.
portintServer node main port.
stateNodeStateServer node running status.
extendInfoMap<String, Object>Server node extension data, such as Raft-related information.

Request Example

try {
Collection<NacosMember> result = namingMaintainService.namingMaintainService("", "");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

5.8. Update Nacos Server Address Discovery Mode

Description

Nacos Server address discovery mode controls how Nacos Server discovers addresses of other nodes in the same cluster. It is used to form a Nacos cluster during server startup and runtime.

Use this API to dynamically modify the Nacos Server address discovery mode and form a Nacos cluster in different ways.

Boolean updateLookupMode(String type) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
typestringAddress discovery mode type. file and address are supported by default.

Response Parameters

Parameter TypeDescription
booleantrue means the update succeeds.

Request Example

try {
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

5.9. Query Long Connection List of the Current Nacos Server Node

Description

Queries the long connection list connected to the current Nacos Server node.

Map<String, ConnectionInfo> getCurrentClients() throws NacosException;

Request Parameters

None

Response Parameters

Parameter TypeDescription
Map<String, ConnectionInfo>Long connection list. The key is the connection ID, and the value is the connection details.

Request Example

try {
Map<String, ConnectionInfo> result = namingMaintainService.getCurrentClients();
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

5.10. Balance Long Connection Load of Nacos Server Nodes

Description

Nacos Server node long connection load balancing controls long connection load on Nacos Server nodes and evenly distributes long connections among nodes.

String reloadConnectionCount(Integer count, String redirectAddress) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
countintExpected number of long connections to retain.
redirectAddressstringExpected redirect address. The default value is empty. If empty, load is randomly balanced.

Response Parameters

Parameter TypeDescription
StringConnection balancing result.

Request Example

try {
String result = namingMaintainService.reloadConnectionCount(10, "");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

5.11. Automatically Balance Long Connection Load of Nacos Server Nodes

Description

Allows Nacos Server to automatically balance load among servers based on the number of long connections.

String smartReloadCluster(String loaderFactorStr) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
loaderFactorStrstringVariance ratio for automatic load balancing. The default value is 0.1f, which means the difference between the maximum and minimum number of connections among cluster nodes is within 10% during automatic load balancing.

Response Parameters

Parameter TypeDescription
StringConnection balancing result.

Request Example

try {
String result = namingMaintainService.smartReloadCluster("0.1f");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

5.12. Reload a Specified Nacos Client Connection

Description

Reloads a specified Nacos client connection.

String reloadSingleClient(String connectionId, String redirectAddress) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
connectionIdstringConnection ID.
redirectAddressstringExpected redirect address. The default value is empty. If empty, load is randomly balanced.

Response Parameters

Parameter TypeDescription
StringConnection balancing result.

Request Example

try {
String result = namingMaintainService.reloadSingleClient("111111111_127.0.0.1_10000");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

5.13. Query Nacos Server Long Connection Load Statistics

Description

Queries Nacos Server long connection load statistics.

ServerLoaderMetrics getClusterLoaderMetrics() throws NacosException;

Request Parameters

None

Response Parameters

Parameter TypeDescription
ServerLoaderMetricsLong connection load statistics.

Request Example

try {
ServerLoaderMetrics result = namingMaintainService.getClusterLoaderMetrics();
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

5.14. Query Namespace List

Description

Queries the namespace list.

List<Namespace> getNamespaceList() throws NacosException;

Request Parameters

None

Response Parameters

Parameter TypeDescription
List<Namespace>Namespace list.

The attributes of Namespace are as follows:

Parameter NameParameter TypeDescription
namespacestringnamespace ID
namespaceShowNamestringNamespace name.
namespaceDescstringNamespace description.
quotaintConfig count quota under the namespace. It takes effect only when used with config center capacity management. The default value is 200.
configCountintNumber of configs under the namespace.
typeintNamespace type. This is a reserved field and is currently always 1.

Request Example

try {
List<Namespace> result = namingMaintainService.getNamespaceList();
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

5.15. Query Specified Namespace

Description

Queries the specified namespace.

Namespace getNamespace(String namespaceId) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID

Response Parameters

Parameter TypeDescription
NamespaceNamespace details.

The attributes of Namespace are as follows:

Parameter NameParameter TypeDescription
namespacestringnamespace ID
namespaceShowNamestringNamespace name.
namespaceDescstringNamespace description.
quotaintConfig count quota under the namespace. It takes effect only when used with config center capacity management. The default value is 200.
configCountintNumber of configs under the namespace.
typeintNamespace type. This is a reserved field and is currently always 1.

Request Example

try {
Namespace result = namingMaintainService.getNamespace("public");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

5.16. Create Namespace

Description

Creates a namespace.

Boolean createNamespace(String namespaceName, String namespaceDesc) throws NacosException;
Boolean createNamespace(String namespaceId, String namespaceName, String namespaceDesc) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceNamestringNamespace name.
namespaceDescstringNamespace description.
namespaceIdstringCustom namespace ID. The default value is "". If empty, Nacos automatically generates a UUID as the namespace ID.

Response Parameters

Parameter TypeDescription
booleanNamespace creation result.

Request Example

try {
boolean result = namingMaintainService.createNamespace("test", "test");
result = namingMaintainService.createNamespace("test", "test", "test");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

5.17. Update Namespace

Description

Updates the specified namespace name or description.

Boolean updateNamespace(String namespaceId, String namespaceName, String namespaceDesc) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID to update.
namespaceNamestringUpdated namespace name.
namespaceDescstringUpdated namespace description.

Response Parameters

Parameter TypeDescription
booleanNamespace update result.

Request Example

try {
boolean result = namingMaintainService.updateNamespace("test", "testNamespaceName", "testNamespaceDesc");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

5.18. Delete Namespace

Description

Deletes the specified namespace.

Boolean deleteNamespace(String namespaceId) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID to delete.

Response Parameters

Parameter TypeDescription
booleanNamespace deletion result.

Request Example

try {
boolean result = namingMaintainService.deleteNamespace("test");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

5.19. Check Whether a Namespace Exists

Description

Checks whether a namespace exists.

Boolean checkNamespaceIdExist(String namespaceId) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID to check.

Response Parameters

Parameter TypeDescription
booleanNamespace check result. true indicates that the namespace ID already exists.

Request Example

try {
boolean result = namingMaintainService.checkNamespaceIdExist("test");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

5.20. Query Plugin List

Description

List unified plugins loaded by Nacos, optionally filtered by type. Returned identities use pluginType:pluginName and include state, critical, executionMode, configurable, and related metadata.

List<Map<String, Object>> listPlugins(String pluginType) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
pluginTypestringPlugin type filter, such as auth or control. Pass null or an empty value to return all plugins.

Response Parameters

Parameter TypeDescription
List<Map<String, Object>>Plugin information list.

Request Example

try {
List<Map<String, Object>> plugins = coreMaintainerService.listPlugins(null);
List<Map<String, Object>> authPlugins = coreMaintainerService.listPlugins("auth");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the operation fails.

5.21. Query Plugin Details

Description

Get plugin detail by type and name, including definitions, masked effective configuration, and per-item source/overridden metadata.

Map<String, Object> getPluginDetail(String pluginType, String pluginName) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
pluginTypestringPlugin type.
pluginNamestringPlugin name.

Response Parameters

Parameter TypeDescription
Map<String, Object>Plugin detail information.

Request Example

try {
Map<String, Object> detail = coreMaintainerService.getPluginDetail("auth", "ldap");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the operation fails.

5.22. Update Plugin Status

Description

Enable or disable a plugin. Exclusive selection, PRE_CONTEXT implementations, and active critical providers cannot be changed illegally at runtime. localOnly=true affects this node only and overrides persisted state.

void updatePluginStatus(String pluginType, String pluginName, boolean enabled) throws NacosException;
void updatePluginStatus(String pluginType, String pluginName, boolean enabled, boolean localOnly) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
pluginTypestringPlugin type.
pluginNamestringPlugin name.
enabledbooleanWhether to enable the plugin. true enables it, and false disables it.
localOnlybooleanWhether to apply only to the current node.

Response Parameters

None (void).

Request Example

try {
coreMaintainerService.updatePluginStatus("auth", "ldap", false);
coreMaintainerService.updatePluginStatus("auth", "ldap", false, true);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the operation fails.

5.23. Update Plugin Config

Description

Replace the complete configuration map for the target source. Only definitions with effectMode=RUNTIME can be changed. Adding, changing, or removing a RESTART item is rejected. localOnly=true writes higher-priority LOCAL_ONLY; otherwise the method writes RUNTIME_PERSISTED.

void updatePluginConfig(String pluginType, String pluginName, Map<String, String> config) throws NacosException;
void updatePluginConfig(String pluginType, String pluginName, Map<String, String> config, boolean localOnly) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
pluginTypestringPlugin type.
pluginNamestringPlugin name.
configMap<String, String>Complete target-source map keyed by definition item key.
localOnlybooleanWhether to apply only to the current node.

Response Parameters

None (void).

Request Example

try {
Map<String, String> config = new HashMap<>();
config.put("connect-timeout", "6000");
coreMaintainerService.updatePluginConfig("auth", "ldap", config);
coreMaintainerService.updatePluginConfig("auth", "ldap", config, true);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the operation fails.

5.24. Query Plugin Availability

Description

Get plugin availability across cluster nodes.

Map<String, Boolean> getPluginAvailability(String pluginType, String pluginName) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
pluginTypestringPlugin type.
pluginNamestringPlugin name.

Response Parameters

Parameter TypeDescription
Map<String, Boolean>Mapping from node address to availability.

Request Example

try {
Map<String, Boolean> availability = coreMaintainerService.getPluginAvailability("auth", "ldap");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the operation fails.

6. MCP Services

6.1. Get MCP Service List

Description

Gets the MCP service list by exact mcpName. If mcpName is empty, all MCP services are returned.

Page<McpServerBasicInfo> listMcpServer() throws NacosException;
Page<McpServerBasicInfo> listMcpServer(int pageNo, int pageSize) throws NacosException;
Page<McpServerBasicInfo> listMcpServer(String mcpName, int pageNo, int pageSize) throws NacosException;
Page<McpServerBasicInfo> listMcpServer(String namespaceId, String mcpName, int pageNo, int pageSize) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
pageNointPage number of the MCP service list. The default value is 1.
pageSizeintPage size of MCP services. The default value is 100.
mcpNameStringExact MCP service name. If mcpName is empty, all MCP services are returned.
namespaceIdStringNamespace ID to which the MCP service belongs. The default value is public.

Response Parameters

Parameter TypeDescription
Page<McpServerBasicInfo>Paginated MCP service list result.

Request Example

try {
Page<McpServerBasicInfo> result = aiMaintainerService.listMcpServer();
result = aiMaintainerService.listMcpServer(1, 100);
result = aiMaintainerService.listMcpServer("", 1, 100);
result = aiMaintainerService.listMcpServer("public", "", 1, 100);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

6.2. Search MCP Service List

Description

Searches the MCP service list by fuzzy mcpName. If mcpName is empty, all MCP services are returned.

Page<McpServerBasicInfo> searchMcpServer(String mcpName) throws NacosException;
Page<McpServerBasicInfo> searchMcpServer(String mcpName, int pageNo, int pageSize) throws NacosException;
Page<McpServerBasicInfo> searchMcpServer(String namespaceId, String mcpName, int pageNo, int pageSize) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
pageNointPage number of the MCP service list. The default value is 1.
pageSizeintPage size of MCP services. The default value is 100.
mcpNameStringExact MCP service name. If mcpName is empty, all MCP services are returned.
namespaceIdStringNamespace ID to which the MCP service belongs. The default value is public.

Response Parameters

Parameter TypeDescription
Page<McpServerBasicInfo>Paginated MCP service list result.

Request Example

try {
Page<McpServerBasicInfo> result = aiMaintainerService.searchMcpServer("");
result = aiMaintainerService.searchMcpServer("", 1, 100);
result = aiMaintainerService.searchMcpServer("public", "", 1, 100);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

6.3. Get MCP Service Details

Description

Gets detailed MCP service information by mcpName.

McpServerDetailInfo getMcpServerDetail(String mcpName) throws NacosException;
McpServerDetailInfo getMcpServerDetail(String mcpName, String version) throws NacosException;
McpServerDetailInfo getMcpServerDetail(String namespaceId, String mcpName, String version) throws NacosException;
McpServerDetailInfo getMcpServerDetail(String namespaceId, String mcpName, String mcpId, String version) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
mcpNameStringExact MCP service name.
versionStringMCP service version. If not specified, the latest version is returned by default.
namespaceIdStringNamespace ID to which the MCP service belongs. The default value is public.
mcpIdStringMCP service ID. If not specified, pass null.

Response Parameters

Parameter TypeDescription
McpServerDetailInfoMCP service detail object.

Request Example

try {
McpServerDetailInfo result = aiMaintainerService.getMcpServerDetail("test");
result = aiMaintainerService.getMcpServerDetail("test", "1.0.0");
result = aiMaintainerService.getMcpServerDetail("public", "test", "1.0.0");
result = aiMaintainerService.getMcpServerDetail("public", "test", null, "1.0.0");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

6.4. Create a Local (stdio) MCP Service

Description

Creates an MCP service of Local (stdio) type.

String createLocalMcpServer(String mcpName, String version) throws NacosException;
String createLocalMcpServer(String mcpName, String version, String description) throws NacosException;
String createLocalMcpServer(String mcpName, String version, String description, McpToolSpecification toolSpec) throws NacosException;
String createLocalMcpServer(String mcpName, String version, String description, Map<String, Object> localServerConfig, McpToolSpecification toolSpec) throws NacosException;
String createLocalMcpServer(String mcpName, McpServerBasicInfo serverSpec, McpToolSpecification toolSpec) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
mcpNameStringName of the MCP service to create.
versionStringVersion of the MCP service to create.
descriptionStringMCP service description.
localServerConfigMap<String, Object>Config information of the stdio MCP service. Configure it by referring to the startup config of this MCP service.
toolSpecMcpToolSpecificationTool definition content supported by the MCP service.
serverSpecMcpServerBasicInfoDefinition content of the MCP service. It can be composed of mcpName, version, description, and localServerConfig, or you can create a detailed McpServerBasicInfo yourself.

Response Parameters

Parameter TypeDescription
StringMCP service ID returned after successful creation.

Request Example

try {
String result = aiMaintainerService.createLocalMcpServer("test", "1.0.0");
result = aiMaintainerService.createLocalMcpServer("test", "1.0.0", "test for mcp server");
result = aiMaintainerService.createLocalMcpServer("test", "1.0.0", "test for mcp server", null);
result = aiMaintainerService.createLocalMcpServer("test", "1.0.0", "test for mcp server", Collections.emptyMap(), null);
McpServerBasicInfo mcpSpec = new McpServerBasicInfo();
mcpSpec.setName("test");
mcpSpec.setProtocol(AiConstants.Mcp.MCP_PROTOCOL_STDIO);
mcpSpec.setDescription("test for mcp server");
mcpSpec.setLocalServerConfig(Collections.emptyMap());
ServerVersionDetail versionDetail = new ServerVersionDetail();
versionDetail.setVersion("1.0.0");
mcpSpec.setVersionDetail(versionDetail);
result = aiMaintainerService.createLocalMcpServer("test", mcpSpec, null);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

6.5. Create a Remote (SSE, Streamable, etc.) MCP Service

Description

Creates an MCP service of Remote type, such as SSE or streamable.

String createRemoteMcpServer(String mcpName, String version, String protocol, McpEndpointSpec endpointSpec) throws NacosException;
String createRemoteMcpServer(String mcpName, String version, String protocol, McpServerRemoteServiceConfig remoteServiceConfig, McpEndpointSpec endpointSpec) throws NacosException;
String createRemoteMcpServer(String mcpName, String version, String description, String protocol, McpServerRemoteServiceConfig remoteServiceConfig, McpEndpointSpec endpointSpec) throws NacosException;
String createRemoteMcpServer(String mcpName, String version, String description, String protocol, McpServerRemoteServiceConfig remoteServiceConfig, McpEndpointSpec endpointSpec, McpToolSpecification toolSpec) throws NacosException;
String createRemoteMcpServer(String mcpName, McpServerBasicInfo serverSpec, McpEndpointSpec endpointSpec) throws NacosException;
String createRemoteMcpServer(String mcpName, McpServerBasicInfo serverSpec, McpToolSpecification toolSpec, McpEndpointSpec endpointSpec) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
mcpNameStringName of the MCP service to create.
versionStringVersion of the MCP service to create.
descriptionStringMCP service description.
protocolStringProtocol types supported by the MCP service. Currently, protocols such as SSE and streamable are supported.
endpointSpecMcpEndpointSpecRemote endpoint definition content of the MCP service. Configure it with optional REF or DIRECT type.
remoteServiceConfigMcpServerRemoteServiceConfigConfig information of the SSE or streamable MCP service. Configure it by referring to the startup config of this MCP service.
toolSpecMcpToolSpecificationTool definition content supported by the MCP service.
serverSpecMcpServerBasicInfoDefinition content of the MCP service. It can be composed of mcpName, version, description, and localServerConfig, or you can create a detailed McpServerBasicInfo yourself.

Response Parameters

Parameter TypeDescription
StringMCP service ID returned after successful creation.

Request Example

try {
McpEndpointSpec mcpEndpointSpec = new McpEndpointSpec();
mcpEndpointSpec.setType(AiConstants.Mcp.MCP_ENDPOINT_TYPE_DIRECT);
mcpEndpointSpec.getData().put("address", "127.0.0.1");
mcpEndpointSpec.getData().put("port", "8080");
String result = aiMaintainerService.createRemoteMcpServer("test", "1.0.0", AiConstants.Mcp.MCP_PROTOCOL_SSE, mcpEndpointSpec);
result = aiMaintainerService.createRemoteMcpServer("test", "1.0.0", AiConstants.Mcp.MCP_PROTOCOL_SSE, new McpServerRemoteServiceConfig(), mcpEndpointSpec);
result = aiMaintainerService.createRemoteMcpServer("test", "1.0.0", "test for mcp server", AiConstants.Mcp.MCP_PROTOCOL_SSE, new McpServerRemoteServiceConfig(), mcpEndpointSpec);
result = aiMaintainerService.createRemoteMcpServer("test", "1.0.0", "test for mcp server", AiConstants.Mcp.MCP_PROTOCOL_SSE, new McpServerRemoteServiceConfig(), mcpEndpointSpec, null);
McpServerBasicInfo mcpSpec = new McpServerBasicInfo();
mcpSpec.setName("test");
mcpSpec.setDescription("test for mcp server");
mcpSpec.setProtocol(AiConstants.Mcp.MCP_PROTOCOL_SSE);
mcpSpec.setRemoteServerConfig(new McpServerRemoteServiceConfig());
ServerVersionDetail versionDetail = new ServerVersionDetail();
versionDetail.setVersion("1.0.0");
mcpSpec.setVersionDetail(versionDetail);
result = aiMaintainerService.createRemoteMcpServer("test", mcpSpec, mcpEndpointSpec);
result = aiMaintainerService.createRemoteMcpServer("test", mcpSpec, null, mcpEndpointSpec);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

6.6. Update MCP Service

Description

Updates the specified MCP service.

boolean updateMcpServer(String mcpName, McpServerBasicInfo serverSpec, McpToolSpecification toolSpec, McpEndpointSpec endpointSpec) throws NacosException;
boolean updateMcpServer(String mcpName, boolean isLatest, McpServerBasicInfo serverSpec, McpToolSpecification toolSpec, McpEndpointSpec endpointSpec) throws NacosException;
boolean updateMcpServer(String namespaceId, String mcpName, boolean isLatest, McpServerBasicInfo serverSpec, McpToolSpecification toolSpec, McpEndpointSpec endpointSpec) throws NacosException;
boolean updateMcpServer(String namespaceId, String mcpName, boolean isLatest, McpServerBasicInfo serverSpec, McpToolSpecification toolSpec, McpEndpointSpec endpointSpec, boolean overrideExisting) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
mcpNameStringMCP service name
namespaceIdStringNamespace ID to which the MCP service belongs. The default value is public.
isLatestbooleanWhether the updated MCP service version is the latest version. The default value is true.
serverSpecMcpServerBasicInfoService definition content of the new MCP service version.
toolSpecMcpToolSpecificationTool definition content of the new MCP service version.
endpointSpecMcpEndpointSpecEndpoint definition content of the new MCP service version.
overrideExistingbooleanWhether to overwrite existing information of the same version. The default value is false. This is valid only for the seven-parameter overload.

Response Parameters

Parameter TypeDescription
booleantrue if update succeeds, otherwise false.

Request Example

try {
McpServerBasicInfo mcpSpec = new McpServerBasicInfo();
mcpSpec.setName("test");
mcpSpec.setDescription("test for mcp server");
mcpSpec.setProtocol(AiConstants.Mcp.MCP_PROTOCOL_STDIO);
Map<String, Object> localServerConfig = Collections.singletonMap("test", new HashMap<>());
mcpSpec.setLocalServerConfig(localServerConfig);
ServerVersionDetail versionDetail = new ServerVersionDetail();
versionDetail.setVersion("1.0.1");
mcpSpec.setVersionDetail(versionDetail);
boolean result = aiMaintainerService.updateMcpServer("test", mcpSpec, null, null);
result = aiMaintainerService.updateMcpServer("test", true, null, null, null);
result = aiMaintainerService.updateMcpServer("public", "test", true, null, null, null);
result = aiMaintainerService.updateMcpServer("public", "test", true, null, null, null, false);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

6.7. Delete MCP Service

Description

Deletes the specified MCP service.

boolean deleteMcpServer(String mcpName) throws NacosException;
boolean deleteMcpServer(String namespaceId, String mcpName, String mcpId, String version) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
mcpNameStringMCP service name
namespaceIdStringNamespace ID to which the MCP service belongs. The default value is public.
mcpIdStringMCP service ID. If not specified, pass null.
versionStringMCP service version. If not specified, pass null. When null is passed, all versions under this service are deleted.

Response Parameters

Parameter TypeDescription
booleantrue if deletion succeeds, otherwise false.

Request Example

try {
boolean result = aiMaintainerService.deleteMcpServer("test");
result = aiMaintainerService.deleteMcpServer("public", "test", null, null);
result = aiMaintainerService.deleteMcpServer("public", "test", null, "1.0.0");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

6.8. Create MCP Service (Unified API)

Description

Create MCP server in the given namespace (Local or Remote via McpServerBasicInfo and McpEndpointSpec). Omit namespaceId for default namespace; omit endpointSpec for Local(stdio).

String createMcpServer(String mcpName, McpServerBasicInfo serverSpec, McpToolSpecification toolSpec, McpEndpointSpec endpointSpec) throws NacosException;
String createMcpServer(String namespaceId, String mcpName, McpServerBasicInfo serverSpec, McpToolSpecification toolSpec, McpEndpointSpec endpointSpec) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID. The default value is public.
mcpNamestringMCP service name.
serverSpecMcpServerBasicInfoMCP service basic information, such as name, version, description, protocol, and localServerConfig.
toolSpecMcpToolSpecificationTool definition. For Local type, null can be passed.
endpointSpecMcpEndpointSpecEndpoint specification. Null indicates Local (stdio), and non-null indicates Remote (SSE, streamable, etc.).

Response Parameters

Parameter TypeDescription
StringCreation result description.

Request Example

try {
McpServerBasicInfo serverSpec = new McpServerBasicInfo();
serverSpec.setName("my-mcp");
serverSpec.setProtocol(AiConstants.Mcp.MCP_PROTOCOL_STDIO);
ServerVersionDetail versionDetail = new ServerVersionDetail();
versionDetail.setVersion("1.0.0");
serverSpec.setVersionDetail(versionDetail);
String result = aiMaintainerService.createMcpServer("my-mcp", serverSpec, null, null);
result = aiMaintainerService.createMcpServer(Constants.DEFAULT_NAMESPACE_ID, "my-mcp", serverSpec, null, null);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

7. A2A Registry

Compatibility and migration guidance: A2aMaintainerService in this chapter is the legacy A2A management interface and remains available during the compatibility window. The protocol-neutral AgentMaintainerService, obtained from aiMaintainerService.agent(), will replace these APIs over time. New users and SDK integrations should prefer the Agent Management APIs in Chapter 11 and avoid adding new dependencies on the legacy A2A management interface.

7.1. Publish AgentCard

Description

Publishes an AgentCard to the specified namespace.

boolean registerAgent(AgentCard agentCard) throws NacosException;
boolean registerAgent(AgentCard agentCard, String namespaceId) throws NacosException;
boolean registerAgent(AgentCard agentCard, String namespaceId, String registrationType) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
agentCardAgentCardAgentCard object.
namespaceIdStringNamespace ID to which the AgentCard belongs. The default value is public.
registrationTypeStringRegistration type. Optional values are URL and SERVICE. The default value is URL. It sets the default way to obtain the url of this AgentCard. URL means directly reading the url from registration, and SERVICE means generating the url based on the endpoint registered in Nacos.

Response Parameters

Parameter TypeDescription
booleantrue if registration succeeds, otherwise false.

Request Example

try {
AgentCard agentCard = new AgentCard();
agentCard.setName("test");
agentCard.setDescription("test for agent card");
agentCard.setUrl("http://localhost:8848");
agentCard.setVersion("1.0.0");
agentCard.setProtocolVersion("0.3.0");
boolean result = aiMaintainerService.registerAgent(agentCard);
result = aiMaintainerService.registerAgent(agentCard, "public");
result = aiMaintainerService.registerAgent(agentCard, "public", "URL");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

7.2. Query AgentCard

Description

Queries the AgentCard under the specified namespace.

AgentCardDetailInfo getAgentCard(String agentName) throws NacosException;
AgentCardDetailInfo getAgentCard(String agentName, String namespaceId) throws NacosException;
AgentCardDetailInfo getAgentCard(String agentName, String namespaceId, String registrationType) throws NacosException;
AgentCardDetailInfo getAgentCard(String agentName, String namespaceId, String registrationType, String version) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
agentNameStringAgentCard name.
namespaceIdStringNamespace ID to which the AgentCard belongs. The default value is public.
registrationTypeStringRegistration type. Optional values are URL and SERVICE. The default value is URL. This field is optional. If empty, the url is automatically selected based on the registrationType set when this AgentCard was registered.
versionStringAgentCard version. If not specified, pass an empty string to return the default version.

Response Parameters

Parameter TypeDescription
AgentCardDetailInfoAgentCard detail object.

Request Example

try {
AgentCardDetailInfo result = aiMaintainerService.getAgentCard("test");
result = aiMaintainerService.getAgentCard("test", "public");
result = aiMaintainerService.getAgentCard("test", "public", "URL");
result = aiMaintainerService.getAgentCard("test", "public", "URL", "1.0.0");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

7.3. Update AgentCard

Description

Updates the AgentCard under the specified namespace.

boolean updateAgentCard(AgentCard agentCard) throws NacosException;
boolean updateAgentCard(AgentCard agentCard, String namespaceId) throws NacosException;
boolean updateAgentCard(AgentCard agentCard, String namespaceId, boolean setAsLatest) throws NacosException;
boolean updateAgentCard(AgentCard agentCard, String namespaceId, boolean setAsLatest, String registrationType) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
agentCardAgentCardAgentCard object.
namespaceIdStringNamespace ID to which the AgentCard belongs. The default value is public.
setAsLatestbooleanWhether to set this AgentCard as the latest version.
registrationTypeStringRegistration type. Optional values are URL and SERVICE. The default value is URL. It sets the default way to obtain the url of this AgentCard. URL means directly reading the url from registration, and SERVICE means generating the url based on the endpoint registered in Nacos.

Response Parameters

Parameter TypeDescription
booleantrue if update succeeds, otherwise false.

Request Example

try {
AgentCard agentCard = new AgentCard();
agentCard.setName("test");
agentCard.setDescription("test for agent card");
agentCard.setUrl("http://localhost:8848");
agentCard.setVersion("1.0.0");
agentCard.setProtocolVersion("0.3.0");
boolean result = aiMaintainerService.updateAgentCard(agentCard);
result = aiMaintainerService.updateAgentCard(agentCard, "public");
result = aiMaintainerService.updateAgentCard(agentCard, "public", true);
result = aiMaintainerService.updateAgentCard(agentCard, "public", true, "URL");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

7.4. Delete AgentCard

Description

Deletes the AgentCard under the specified namespace.

boolean deleteAgent(String agentName) throws NacosException;
boolean deleteAgent(String agentName, String namespaceId) throws NacosException;
boolean deleteAgent(String agentName, String namespaceId, String version) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
agentNameStringAgentCard name.
namespaceIdStringNamespace ID to which the AgentCard belongs. The default value is public.
versionStringAgentCard version. If empty, all versions are deleted.

Response Parameters

Parameter TypeDescription
booleantrue if deletion succeeds, otherwise false.

Request Example

try {
boolean result = aiMaintainerService.deleteAgent("test");
result = aiMaintainerService.deleteAgent("test", "public");
result = aiMaintainerService.deleteAgent("test", "public", "");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

7.5. Query All Versions of a Specified AgentCard

Description

Queries all versions of the specified AgentCard under the specified namespace.

List<AgentVersionDetail> listAllVersionOfAgent(String agentName) throws NacosException;
List<AgentVersionDetail> listAllVersionOfAgent(String agentName, String namespaceId) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
agentNameStringAgentCard name.
namespaceIdStringNamespace ID to which the AgentCard belongs. The default value is public.

Response Parameters

Parameter TypeDescription
ListList of all AgentCard versions.

Request Example

try {
List<AgentVersionDetail> result = aiMaintainerService.listAllVersionOfAgent("test");
result = aiMaintainerService.listAllVersionOfAgent("test", "public");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

7.6. Search AgentCard by AgentCard Name

Description

Searches AgentCards by AgentCard name. Only AgentCards under one namespace can be searched at a time.

Page<AgentCardVersionInfo> searchAgentCardsByName(String agentNamePattern) throws NacosException;
default Page<AgentCardVersionInfo> searchAgentCardsByName(String agentNamePattern, int pageNo, int pageSize) throws NacosException;
Page<AgentCardVersionInfo> searchAgentCardsByName(String namespaceId, String agentNamePattern, int pageNo, int pageSize) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
agentNamePatternStringPattern matching string for the AgentCard name.
namespaceIdStringNamespace ID to which the AgentCard belongs. The default value is public.
pageNointPage number. The default value is 1.
pageSizeintPage size. The default value is 100.

Response Parameters

Parameter TypeDescription
PagePaginated search result.

Request Example

try {
Page<AgentCardVersionInfo> result = aiMaintainerService.searchAgentCardsByName("test");
result = aiMaintainerService.searchAgentCardsByName("test", 1, 100);
result = aiMaintainerService.searchAgentCardsByName("test", "public", 1, 100);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

7.7. Query AgentCard List with Pagination

Description

Queries the AgentCard list with pagination. Only AgentCards under one namespace can be queried at a time.

Page<AgentCardVersionInfo> listAgentCards() throws NacosException;
Page<AgentCardVersionInfo> listAgentCards(int pageNo, int pageSize) throws NacosException;
Page<AgentCardVersionInfo> listAgentCards(String namespaceId, int pageNo, int pageSize) throws NacosException;
Page<AgentCardVersionInfo> listAgentCards(String namespaceId, String agentName, int pageNo, int pageSize) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdStringNamespace ID to which the AgentCard belongs. The default value is public.
pageNointPage number. The default value is 1.
pageSizeintPage size. The default value is 100.
agentNameStringAgentCard name for exact matching. If empty, all AgentCards are queried.

Response Parameters

Parameter TypeDescription
PagePaginated query result.

Request Example

try {
Page<AgentCardVersionInfo> result = aiMaintainerService.listAgentCards();
result = aiMaintainerService.listAgentCards(1, 100);
result = aiMaintainerService.listAgentCards("public", 1, 100);
result = aiMaintainerService.listAgentCards("test", "public", 1, 100);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when reading the config times out or a network exception occurs.

8. Prompt Capabilities

8.1. Query Prompt List with Pagination

Description

List prompts with pagination by namespace, promptKey pattern, search mode, and biz tags.

Page<PromptMetaSummary> listPrompts(String namespaceId, String promptKey, String search, String bizTags, int pageNo, int pageSize) throws NacosException;
Page<PromptMetaSummary> listPrompts(String promptKey, int pageNo, int pageSize) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID. The default value is public.
promptKeystringPrompt key pattern filter.
searchstringSearch mode: accurate for exact search or blur for fuzzy search.
bizTagsstringBusiness tag filter, separated by commas (optional).
pageNointPage number.
pageSizeintNumber of items per page.

Response Parameters

Parameter TypeDescription
Page<PromptMetaSummary>Paginated Prompt list.

Request Example

try {
PromptMaintainerService promptMaintainerService = aiMaintainerService.prompt();
Page<PromptMetaSummary> result = promptMaintainerService.listPrompts("public", "my-prompt", "blur", null, 1, 100);
result = promptMaintainerService.listPrompts("my-prompt", 1, 100);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the operation fails.

8.2. Get Prompt Metadata

Description

Get prompt meta by namespace and promptKey.

PromptMetaInfo getPromptMeta(String namespaceId, String promptKey) throws NacosException;
PromptMetaInfo getPromptMeta(String promptKey) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID.
promptKeystringPrompt key.

Response Parameters

Parameter TypeDescription
PromptMetaInfoPrompt metadata.

Request Example

try {
PromptMaintainerService promptMaintainerService = aiMaintainerService.prompt();
PromptMetaInfo meta = promptMaintainerService.getPromptMeta("public", "my-prompt");
meta = promptMaintainerService.getPromptMeta("my-prompt");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the operation fails.

8.3. Query Prompt Version Details

Description

Query prompt version detail by namespace, promptKey, version, and label.

PromptVersionInfo queryPromptDetail(String namespaceId, String promptKey, String version, String label) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID.
promptKeystringPrompt key.
versionstringVersion number.
labelstringLabel (optional).

Response Parameters

Parameter TypeDescription
PromptVersionInfoPrompt version details.

Request Example

try {
PromptMaintainerService promptMaintainerService = aiMaintainerService.prompt();
PromptVersionInfo detail = promptMaintainerService.queryPromptDetail("public", "my-prompt", "1.0.0", null);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the operation fails.

8.4. Bind Prompt Label

Description

Bind a label to a prompt version.

boolean bindLabel(String namespaceId, String promptKey, String label, String version) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID.
promptKeystringPrompt key.
labelstringLabel name.
versionstringVersion number.

Response Parameters

Parameter TypeDescription
booleanWhether binding succeeds.

Request Example

try {
PromptMaintainerService promptMaintainerService = aiMaintainerService.prompt();
boolean ok = promptMaintainerService.bindLabel("public", "my-prompt", "stable", "1.0.0");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the operation fails.

8.5. Unbind Prompt Label

Description

Unbind a label from a prompt.

boolean unbindLabel(String namespaceId, String promptKey, String label) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID.
promptKeystringPrompt key.
labelstringLabel name.

Response Parameters

Parameter TypeDescription
booleanWhether unbinding succeeds.

Request Example

try {
PromptMaintainerService promptMaintainerService = aiMaintainerService.prompt();
boolean ok = promptMaintainerService.unbindLabel("public", "my-prompt", "stable");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the operation fails.

8.6. Publish Prompt Version

Description

Publish a new prompt version with optional description and biz tags.

boolean publishPrompt(String namespaceId, String promptKey, String version, String template, String commitMsg, String description, String bizTags, String variables) throws NacosException;
boolean publishPrompt(String namespaceId, String promptKey, String version, String template, String commitMsg, String description, String bizTags) throws NacosException;
boolean publishPrompt(String namespaceId, String promptKey, String version, String template, String commitMsg, String description) throws NacosException;
boolean publishPrompt(String promptKey, String version, String template, String commitMsg) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID.
promptKeystringPrompt key.
versionstringVersion number, which must be greater than the current version.
templatestringTemplate content.
commitMsgstringCommit message.
descriptionstringDescription (optional).
bizTagsstringBusiness tags, separated by commas (optional).
variablesstringVariable definition JSON (optional).

Response Parameters

Parameter TypeDescription
booleanWhether publishing succeeds.

Request Example

try {
PromptMaintainerService promptMaintainerService = aiMaintainerService.prompt();
boolean ok = promptMaintainerService.publishPrompt("public", "my-prompt", "1.0.1", "Hello {{name}}", "init", "desc", null, "{\"name\":\"string\"}");
ok = promptMaintainerService.publishPrompt("public", "my-prompt", "1.0.1", "Hello {{name}}", "init", "desc", null);
ok = promptMaintainerService.publishPrompt("my-prompt", "1.0.1", "Hello {{name}}", "init");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the operation fails.

8.7. Delete Prompt

Description

Delete a prompt in the given namespace.

boolean deletePrompt(String namespaceId, String promptKey) throws NacosException;
boolean deletePrompt(String promptKey) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID.
promptKeystringPrompt key.

Response Parameters

Parameter TypeDescription
booleanWhether deletion succeeds.

Request Example

try {
PromptMaintainerService promptMaintainerService = aiMaintainerService.prompt();
boolean ok = promptMaintainerService.deletePrompt("public", "my-prompt");
ok = promptMaintainerService.deletePrompt("my-prompt");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the operation fails.

8.8. Query Prompt Version List with Pagination

Description

List prompt versions with pagination.

Page<PromptVersionSummary> listPromptVersions(String namespaceId, String promptKey, int pageNo, int pageSize) throws NacosException;
Page<PromptVersionSummary> listPromptVersions(String promptKey, int pageNo, int pageSize) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID.
promptKeystringPrompt key.
pageNointPage number.
pageSizeintNumber of items per page.

Response Parameters

Parameter TypeDescription
Page<PromptVersionSummary>Paginated version list.

Request Example

try {
PromptMaintainerService promptMaintainerService = aiMaintainerService.prompt();
Page<PromptVersionSummary> result = promptMaintainerService.listPromptVersions("public", "my-prompt", 1, 100);
result = promptMaintainerService.listPromptVersions("my-prompt", 1, 100);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the operation fails.

8.9. Update Prompt Metadata

Description

Update prompt description and biz tags.

boolean updatePromptMetadata(String namespaceId, String promptKey, String description, String bizTags) throws NacosException;
boolean updatePromptMetadata(String namespaceId, String promptKey, String description) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID.
promptKeystringPrompt key.
descriptionstringNew description.
bizTagsstringNew business tags, separated by commas (optional).

Response Parameters

Parameter TypeDescription
booleanWhether the update succeeds.

Request Example

try {
PromptMaintainerService promptMaintainerService = aiMaintainerService.prompt();
boolean ok = promptMaintainerService.updatePromptMetadata("public", "my-prompt", "new desc", "tag1,tag2");
ok = promptMaintainerService.updatePromptMetadata("public", "my-prompt", "new desc");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the operation fails.

8.10. Get Prompt Governance Detail

Description

Get Prompt governance detail by namespace and promptKey, including version governance information and all version summaries.

PromptMetaInfo getPromptGovernanceDetail(String namespaceId, String promptKey) throws NacosException;

Request Parameters

NameTypeDescription
namespaceIdstringNamespace ID.
promptKeystringPrompt key.

Response

TypeDescription
PromptMetaInfoPrompt governance detail.

Example

try {
PromptMaintainerService promptMaintainerService = aiMaintainerService.prompt();
PromptMetaInfo detail = promptMaintainerService.getPromptGovernanceDetail("public", "my-prompt");
} catch (NacosException e) {
e.printStackTrace();
}

Exceptions

Throws NacosException when the operation fails.

8.11. Get Prompt Version Detail

Description

Get Prompt version detail by namespace, promptKey, and version.

PromptVersionInfo getVersionDetail(String namespaceId, String promptKey, String version) throws NacosException;

Request Parameters

NameTypeDescription
namespaceIdstringNamespace ID.
promptKeystringPrompt key.
versionstringPrompt version.

Response

TypeDescription
PromptVersionInfoPrompt version detail.

Example

try {
PromptMaintainerService promptMaintainerService = aiMaintainerService.prompt();
PromptVersionInfo detail = promptMaintainerService.getVersionDetail("public", "my-prompt", "1.0.0");
} catch (NacosException e) {
e.printStackTrace();
}

Exceptions

Throws NacosException when the operation fails.

8.12. Create Prompt Draft

Description

Create a Prompt draft version. It can fork from an existing version and optionally specify the target version, template, variables, commit message, description, and biz tags.

String createDraft(String namespaceId, String promptKey, String basedOnVersion, String targetVersion, String template, String variables, String commitMsg, String description, String bizTags) throws NacosException;

Request Parameters

NameTypeDescription
namespaceIdstringNamespace ID.
promptKeystringPrompt key.
basedOnVersionstringBase version to fork from, optional.
targetVersionstringTarget draft version, optional.
templatestringPrompt template content.
variablesstringVariable definition JSON, optional.
commitMsgstringCommit message, optional.
descriptionstringPrompt description, optional when first created.
bizTagsstringBiz tags JSON, optional when first created.

Response

TypeDescription
StringCreated draft version.

Example

try {
PromptMaintainerService promptMaintainerService = aiMaintainerService.prompt();
String version = promptMaintainerService.createDraft("public", "my-prompt", "1.0.0", "1.0.1-draft",
"Hello {{name}}", "{\"name\":\"string\"}", "update prompt", "desc", "[\"ai\"]");
} catch (NacosException e) {
e.printStackTrace();
}

Exceptions

Throws NacosException when the operation fails.

8.13. Update Prompt Draft

Description

Update the current Prompt draft content.

void updateDraft(String namespaceId, String promptKey, String template, String variables, String commitMsg) throws NacosException;

Request Parameters

NameTypeDescription
namespaceIdstringNamespace ID.
promptKeystringPrompt key.
templatestringUpdated template content.
variablesstringVariable definition JSON, optional.
commitMsgstringCommit message, optional.

Response

None.

Example

try {
PromptMaintainerService promptMaintainerService = aiMaintainerService.prompt();
promptMaintainerService.updateDraft("public", "my-prompt", "Hello {{name}}", "{\"name\":\"string\"}", "update template");
} catch (NacosException e) {
e.printStackTrace();
}

Exceptions

Throws NacosException when the operation fails.

8.14. Delete Prompt Draft

Description

Delete the current draft version of a Prompt.

void deleteDraft(String namespaceId, String promptKey) throws NacosException;

Request Parameters

NameTypeDescription
namespaceIdstringNamespace ID.
promptKeystringPrompt key.

Response

None.

Example

try {
PromptMaintainerService promptMaintainerService = aiMaintainerService.prompt();
promptMaintainerService.deleteDraft("public", "my-prompt");
} catch (NacosException e) {
e.printStackTrace();
}

Exceptions

Throws NacosException when the operation fails.

8.15. Submit Prompt Version

Description

Submit a Prompt version for release review.

String submit(String namespaceId, String promptKey, String version) throws NacosException;

Request Parameters

NameTypeDescription
namespaceIdstringNamespace ID.
promptKeystringPrompt key.
versionstringVersion to submit, optional; the server may use the current draft.

Response

TypeDescription
StringSubmitted version.

Example

try {
PromptMaintainerService promptMaintainerService = aiMaintainerService.prompt();
String version = promptMaintainerService.submit("public", "my-prompt", "1.0.1");
} catch (NacosException e) {
e.printStackTrace();
}

Exceptions

Throws NacosException when the operation fails.

8.16. Publish Prompt Version

Description

Publish a reviewed Prompt Version. The latest label is server-managed.

void publish(String namespaceId, String promptKey, String version, Boolean updateLatestLabel) throws NacosException;

Request Parameters

NameTypeDescription
namespaceIdstringNamespace ID.
promptKeystringPrompt key.
versionstringVersion to publish.
updateLatestLabelbooleanCompatibility parameter retained and ignored by the server.

Response

None.

Example

try {
PromptMaintainerService promptMaintainerService = aiMaintainerService.prompt();
promptMaintainerService.publish("public", "my-prompt", "1.0.1", true);
} catch (NacosException e) {
e.printStackTrace();
}

Exceptions

Throws NacosException when the operation fails.

8.17. Force Publish Prompt Version

Description

Force-publish a Prompt Version without release review. The latest label is server-managed.

void forcePublish(String namespaceId, String promptKey, String version, Boolean updateLatestLabel) throws NacosException;

Request Parameters

NameTypeDescription
namespaceIdstringNamespace ID.
promptKeystringPrompt key.
versionstringVersion to publish.
updateLatestLabelbooleanCompatibility parameter retained and ignored by the server.

Response

None.

Example

try {
PromptMaintainerService promptMaintainerService = aiMaintainerService.prompt();
promptMaintainerService.forcePublish("public", "my-prompt", "1.0.1", true);
} catch (NacosException e) {
e.printStackTrace();
}

Exceptions

Throws NacosException when the operation fails.

8.18. Redraft Prompt Version

Description

Move a reviewed Prompt version back to draft status for further editing.

boolean redraft(String namespaceId, String promptKey, String version) throws NacosException;

Request Parameters

NameTypeDescription
namespaceIdstringNamespace ID.
promptKeystringPrompt key.
versionstringVersion to redraft.

Response

TypeDescription
booleanWhether redraft succeeds.

Example

try {
PromptMaintainerService promptMaintainerService = aiMaintainerService.prompt();
boolean ok = promptMaintainerService.redraft("public", "my-prompt", "1.0.1");
} catch (NacosException e) {
e.printStackTrace();
}

Exceptions

Throws NacosException when the operation fails.

8.19. Change Prompt Online Status

Description

Bring a Prompt version online or offline.

void changeOnlineStatus(String namespaceId, String promptKey, String version, boolean online) throws NacosException;

Request Parameters

NameTypeDescription
namespaceIdstringNamespace ID.
promptKeystringPrompt key.
versionstringVersion.
onlinebooleantrue to bring online, false to take offline.

Response

None.

Example

try {
PromptMaintainerService promptMaintainerService = aiMaintainerService.prompt();
promptMaintainerService.changeOnlineStatus("public", "my-prompt", "1.0.1", true);
} catch (NacosException e) {
e.printStackTrace();
}

Exceptions

Throws NacosException when the operation fails.

8.20. Update Prompt Labels

Description

Update Prompt labels JSON to maintain label-to-version mappings.

void updateLabels(String namespaceId, String promptKey, String labels) throws NacosException;

Request Parameters

NameTypeDescription
namespaceIdstringNamespace ID.
promptKeystringPrompt key.
labelsstringLabels JSON.

Response

None.

Example

try {
PromptMaintainerService promptMaintainerService = aiMaintainerService.prompt();
promptMaintainerService.updateLabels("public", "my-prompt", "{\"latest\":\"1.0.1\"}");
} catch (NacosException e) {
e.printStackTrace();
}

Exceptions

Throws NacosException when the operation fails.

8.21. Update Prompt Description

Description

Update Prompt description.

void updateDescription(String namespaceId, String promptKey, String description) throws NacosException;

Request Parameters

NameTypeDescription
namespaceIdstringNamespace ID.
promptKeystringPrompt key.
descriptionstringNew description.

Response

None.

Example

try {
PromptMaintainerService promptMaintainerService = aiMaintainerService.prompt();
promptMaintainerService.updateDescription("public", "my-prompt", "new desc");
} catch (NacosException e) {
e.printStackTrace();
}

Exceptions

Throws NacosException when the operation fails.

8.22. Update Prompt Biz Tags

Description

Update Prompt biz tags JSON.

void updateBizTags(String namespaceId, String promptKey, String bizTags) throws NacosException;

Request Parameters

NameTypeDescription
namespaceIdstringNamespace ID.
promptKeystringPrompt key.
bizTagsstringBiz tags JSON.

Response

None.

Example

try {
PromptMaintainerService promptMaintainerService = aiMaintainerService.prompt();
promptMaintainerService.updateBizTags("public", "my-prompt", "[\"ai\",\"ops\"]");
} catch (NacosException e) {
e.printStackTrace();
}

Exceptions

Throws NacosException when the operation fails.

9. Skill Capabilities

9.1. Delete Skill

Description

Delete a skill in the given namespace.

boolean deleteSkill(String namespaceId, String skillName) throws NacosException;
boolean deleteSkill(String skillName) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID.
skillNamestringSkill name.

Response Parameters

Parameter TypeDescription
booleanWhether deletion succeeds.

Request Example

try {
SkillMaintainerService skillMaintainerService = aiMaintainerService.skill();
boolean ok = skillMaintainerService.deleteSkill("public", "my-skill");
ok = skillMaintainerService.deleteSkill("my-skill");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the operation fails.

9.2. Query Skill List with Pagination

Description

List skills with pagination by namespace, name pattern, and search mode.

Page<SkillSummary> listSkills(String namespaceId, String skillName, String search, int pageNo, int pageSize) throws NacosException;
Page<SkillSummary> listSkills(String namespaceId, String skillName, String search, String orderBy, String owner, String scope, int pageNo, int pageSize) throws NacosException;
Page<SkillSummary> listSkills(String namespaceId, String skillName, String search, String orderBy, String owner, String scope, String bizTag, int pageNo, int pageSize) throws NacosException;
Page<SkillSummary> listSkills(String skillName, int pageNo, int pageSize) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID.
skillNamestringSkill name pattern filter.
searchstringSearch mode: accurate for exact search or blur for fuzzy search.
orderBystringOptional sort field.
ownerstringOptional resource owner filter.
scopestringOptional visibility scope filter.
bizTagstringOptional business tag filter.
pageNointPage number.
pageSizeintNumber of items per page.

Response Parameters

Parameter TypeDescription
Page<SkillSummary>Skill page result.

SkillSummary.writable indicates whether the current requester can modify the Skill.

Request Example

try {
SkillMaintainerService skillMaintainerService = aiMaintainerService.skill();
Page<SkillSummary> result = skillMaintainerService.listSkills("public", "my-skill", "blur", 1, 100);
result = skillMaintainerService.listSkills("public", "my-skill", "blur", "download_count", "nacos", "PUBLIC", 1, 100);
result = skillMaintainerService.listSkills("public", "my-skill", "blur", "download_count", "nacos", "PUBLIC", "ops", 1, 100);
result = skillMaintainerService.listSkills("my-skill", 1, 100);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the operation fails.

9.3. Upload Skill from ZIP

Description

Upload and register a skill from ZIP bytes in the given namespace.

String uploadSkillFromZip(String namespaceId, byte[] zipBytes, boolean overwrite) throws NacosException;
String uploadSkillFromZip(String namespaceId, byte[] zipBytes, boolean overwrite, String targetVersion) throws NacosException;
String uploadSkillFromZip(String namespaceId, byte[] zipBytes, boolean overwrite, String targetVersion, String commitMsg) throws NacosException;
String uploadSkillFromZip(String namespaceId, byte[] zipBytes, boolean overwrite, String targetVersion, String commitMsg, String uploadAction) throws NacosException;
String uploadSkillFromZip(String namespaceId, byte[] zipBytes) throws NacosException;
String uploadSkillFromZip(byte[] zipBytes) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID.
zipBytesbyte[]Bytes of the Skill ZIP package.
overwritebooleanWhether to overwrite the current editable draft when the Skill already exists.
targetVersionstringOptional target version, used when the ZIP content has no version.
commitMsgstringOptional version commit message.
uploadActionstringOptional upload action selected after precheck: CREATE_DRAFT, OVERWRITE_DRAFT, or DELETE_DRAFT_AND_CREATE.

Response Parameters

Parameter TypeDescription
StringSkill name.

Request Example

try {
SkillMaintainerService skillMaintainerService = aiMaintainerService.skill();
byte[] zipBytes = Files.readAllBytes(Paths.get("my-skill.zip"));
String name = skillMaintainerService.uploadSkillFromZip("public", zipBytes, true);
name = skillMaintainerService.uploadSkillFromZip("public", zipBytes, true, "1.0.1");
name = skillMaintainerService.uploadSkillFromZip("public", zipBytes, true, "1.0.1", "upload skill");
// To resolve a draft conflict explicitly after precheck, use:
// String name = skillMaintainerService.uploadSkillFromZip("public", zipBytes, true, "1.0.1", "upload skill", "OVERWRITE_DRAFT");
name = skillMaintainerService.uploadSkillFromZip("public", zipBytes);
name = skillMaintainerService.uploadSkillFromZip(zipBytes);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the operation fails.

9.4. Get Skill metadata

Description

Get skill metadata in default namespace or specified namespace.

SkillMeta getSkillMeta(String skillName) throws NacosException;
SkillMeta getSkillMeta(String namespaceId, String skillName) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID.
skillNamestringSkill name.

Response Parameters

Parameter TypeDescription
SkillMetaSkill metadata.

Request Example

try {
SkillMaintainerService skillMaintainerService = aiMaintainerService.skill();
SkillMeta meta = skillMaintainerService.getSkillMeta("my-skill");
meta = skillMaintainerService.getSkillMeta("public", "my-skill");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the operation fails.

9.5. Get Skill version detail

Description

Get detail for a specific skill version.

Skill getSkillVersionDetail(String skillName, String version) throws NacosException;
Skill getSkillVersionDetail(String namespaceId, String skillName, String version) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID.
skillNamestringSkill name.
versionstringSkill version.

Response Parameters

Parameter TypeDescription
SkillSkill detail object of the specified version.

Request Example

try {
SkillMaintainerService skillMaintainerService = aiMaintainerService.skill();
Skill detail = skillMaintainerService.getSkillVersionDetail("my-skill", "1.0.0");
detail = skillMaintainerService.getSkillVersionDetail("public", "my-skill", "1.0.0");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the operation fails.

9.6. Create Skill draft

Description

Create a new skill draft, optionally forked from an existing version.

String createDraft(String namespaceId, String skillCard) throws NacosException;
String createDraft(String namespaceId, String skillName, String basedOnVersion) throws NacosException;
String createDraft(String namespaceId, String skillName, String basedOnVersion, String targetVersion) throws NacosException;
String createDraft(String namespaceId, String skillName, String basedOnVersion, String targetVersion, String skillCard) throws NacosException;
String createDraft(String namespaceId, String skillName, String basedOnVersion, String targetVersion, String skillCard, String commitMsg) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID.
skillNamestringSkill name, required when forking.
basedOnVersionstringVersion on which the fork is based (optional).
targetVersionstringTarget draft version (optional).
skillCardstringComplete Skill JSON, usually required in non-fork scenarios.
commitMsgstringOptional version commit message.

Response Parameters

Parameter TypeDescription
StringCreated draft version number.

Request Example

try {
SkillMaintainerService skillMaintainerService = aiMaintainerService.skill();
String version = skillMaintainerService.createDraft("public", "{\"name\":\"my-skill\"}");
version = skillMaintainerService.createDraft("public", "my-skill", "1.0.0");
version = skillMaintainerService.createDraft("public", "my-skill", "1.0.0", "1.0.1-draft");
version = skillMaintainerService.createDraft("public", "my-skill", "1.0.0", "1.0.1-draft", "{\"name\":\"my-skill\"}");
version = skillMaintainerService.createDraft("public", "my-skill", "1.0.0", "1.0.1-draft", "{\"name\":\"my-skill\"}", "update skill");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the operation fails.

9.7. Update Skill draft

Description

Update current draft content.

boolean updateDraft(String namespaceId, String skillCard, Boolean setAsLatest) throws NacosException;
boolean updateDraft(String namespaceId, String skillCard, Boolean setAsLatest, String commitMsg) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID.
skillCardstringComplete Skill JSON.
setAsLatestbooleanWhether to set the latest label (optional).
commitMsgstringOptional version commit message.

Response Parameters

Parameter TypeDescription
booleanWhether the update succeeds.

Request Example

try {
SkillMaintainerService skillMaintainerService = aiMaintainerService.skill();
boolean ok = skillMaintainerService.updateDraft("public", "{\"name\":\"my-skill\"}", true);
ok = skillMaintainerService.updateDraft("public", "{\"name\":\"my-skill\"}", true, "update skill");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the operation fails.

9.8. Delete Skill draft

Description

Delete current draft of a skill.

boolean deleteDraft(String namespaceId, String skillName) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID.
skillNamestringSkill name.

Response Parameters

Parameter TypeDescription
booleanWhether deletion succeeds.

Request Example

try {
SkillMaintainerService skillMaintainerService = aiMaintainerService.skill();
boolean ok = skillMaintainerService.deleteDraft("public", "my-skill");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the operation fails.

9.9. Submit Skill version

Description

Submit a skill version into review pipeline.

String submit(String namespaceId, String skillName, String version) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID.
skillNamestringSkill name.
versionstringVersion number (optional). The server can automatically select the current draft.

Response Parameters

Parameter TypeDescription
StringSubmit result, such as pipelineId.

Request Example

try {
SkillMaintainerService skillMaintainerService = aiMaintainerService.skill();
String result = skillMaintainerService.submit("public", "my-skill", "1.0.1");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the operation fails.

9.10. Publish Skill version

Description

Publish a reviewed Skill Version. The latest label is server-managed.

boolean publish(String namespaceId, String skillName, String version, Boolean updateLatestLabel) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID.
skillNamestringSkill name.
versionstringVersion to publish.
updateLatestLabelbooleanCompatibility parameter retained and ignored by the server.

Response Parameters

Parameter TypeDescription
booleanWhether publishing succeeds.

Request Example

try {
SkillMaintainerService skillMaintainerService = aiMaintainerService.skill();
boolean ok = skillMaintainerService.publish("public", "my-skill", "1.0.1", false);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the operation fails.

9.11. Force publish Skill version

Description

Force publish skill version without review check.

boolean forcePublish(String namespaceId, String skillName, String version, Boolean updateLatestLabel) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID.
skillNamestringSkill name.
versionstringVersion to publish.
updateLatestLabelbooleanCompatibility parameter retained and ignored by the server.

Response Parameters

Parameter TypeDescription
booleanWhether force publish succeeds.

Request Example

try {
SkillMaintainerService skillMaintainerService = aiMaintainerService.skill();
boolean ok = skillMaintainerService.forcePublish("public", "my-skill", "1.0.1", false);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the operation fails.

9.12. Update Skill labels

Description

Update runtime label mapping JSON.

boolean updateLabels(String namespaceId, String skillName, String labels) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID.
skillNamestringSkill name.
labelsstringlabels JSON.

Response Parameters

Parameter TypeDescription
booleanWhether the update succeeds.

Request Example

try {
SkillMaintainerService skillMaintainerService = aiMaintainerService.skill();
boolean ok = skillMaintainerService.updateLabels("public", "my-skill", "{\"stable\":\"1.0.1\"}");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the operation fails.

9.13. Update Skill biz tags

Description

Update biz tags JSON of a skill.

boolean updateBizTags(String namespaceId, String skillName, String bizTags) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID.
skillNamestringSkill name.
bizTagsstringbizTags JSON.

Response Parameters

Parameter TypeDescription
booleanWhether the update succeeds.

Request Example

try {
SkillMaintainerService skillMaintainerService = aiMaintainerService.skill();
boolean ok = skillMaintainerService.updateBizTags("public", "my-skill", "[\"ai\",\"ops\"]");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the operation fails.

9.14. Change Skill online status

Description

Online/offline a skill or a specific version.

boolean changeOnlineStatus(String namespaceId, String skillName, String scope, String version, boolean online) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID.
skillNamestringSkill name.
scopestringScope. skill indicates Skill level, and other values indicate version level.
versionstringVersion number, used for version-level operations.
onlinebooleantrue means online, and false means offline.

Response Parameters

Parameter TypeDescription
booleanWhether the operation succeeds.

Request Example

try {
SkillMaintainerService skillMaintainerService = aiMaintainerService.skill();
boolean ok = skillMaintainerService.changeOnlineStatus("public", "my-skill", "skill", null, true);
ok = skillMaintainerService.changeOnlineStatus("public", "my-skill", "version", "1.0.1", false);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the operation fails.

9.15. Update Skill scope

Description

Update visibility scope of a skill, e.g. PUBLIC / PRIVATE.

boolean updateScope(String namespaceId, String skillName, String scope) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID.
skillNamestringSkill name.
scopestringVisibility scope.

Response Parameters

Parameter TypeDescription
booleanWhether the update succeeds.

Request Example

try {
SkillMaintainerService skillMaintainerService = aiMaintainerService.skill();
boolean ok = skillMaintainerService.updateScope("public", "my-skill", "PUBLIC");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the operation fails.

9.16. Batch Upload Skills from ZIP

Description

Batch upload Skills from a ZIP package containing multiple Skill directories.

BatchUploadResult batchUploadSkillsFromZip(byte[] zipBytes) throws NacosException;
BatchUploadResult batchUploadSkillsFromZip(String namespaceId, byte[] zipBytes, boolean overwrite) throws NacosException;

Request Parameters

NameTypeDescription
namespaceIdstringNamespace ID.
zipBytesbyte[]ZIP bytes containing multiple Skill directories.
overwritebooleanWhether to overwrite existing drafts.

Response

TypeDescription
BatchUploadResultBatch upload result containing per-item structured results and compatibility fields.

The main fields of BatchUploadResult are as follows:

NameTypeDescription
resultsList<BatchUploadItemResult>Structured result for each Skill or candidate directory.
succeededList<String>Names of successfully uploaded Skills (compatibility field).
failedList<FailedItem>Failed Skill items (compatibility field).

BatchUploadItemResult contains name, success, errorCode, errorMessage, and owner.

Example

try {
SkillMaintainerService skillMaintainerService = aiMaintainerService.skill();
byte[] zipBytes = Files.readAllBytes(Paths.get("skills.zip"));
BatchUploadResult result = skillMaintainerService.batchUploadSkillsFromZip(zipBytes);
result = skillMaintainerService.batchUploadSkillsFromZip("public", zipBytes, true);
} catch (NacosException e) {
e.printStackTrace();
}

Exceptions

Throws NacosException when the operation fails.

9.17. Redraft Skill Version

Description

Move a reviewed Skill version back to draft status for further editing.

boolean redraft(String namespaceId, String skillName, String version) throws NacosException;

Request Parameters

NameTypeDescription
namespaceIdstringNamespace ID.
skillNamestringSkill name.
versionstringVersion to redraft.

Response

TypeDescription
booleanWhether redraft succeeds.

Example

try {
SkillMaintainerService skillMaintainerService = aiMaintainerService.skill();
boolean ok = skillMaintainerService.redraft("public", "my-skill", "1.0.1");
} catch (NacosException e) {
e.printStackTrace();
}

Exceptions

Throws NacosException when the operation fails.

9.18. Precheck Skill ZIP Upload

Description

Check one or more Skills in a ZIP before applying the upload. The result reports version conflicts, permission checks, and the available upload action for each item. A caller can use the result to select uploadAction for uploadSkillFromZip.

List<SkillUploadPrecheckResult> precheckUploadSkillFromZip(byte[] zipBytes) throws NacosException;
List<SkillUploadPrecheckResult> precheckUploadSkillFromZip(String namespaceId, byte[] zipBytes) throws NacosException;

Request Parameters

NameTypeDescription
namespaceIdstringNamespace ID. The default is public when omitted.
zipBytesbyte[]ZIP bytes containing one or more Skills.

Response Parameters

TypeDescription
List<SkillUploadPrecheckResult>Precheck result for every Skill or candidate directory in the ZIP.

The main fields of SkillUploadPrecheckResult are as follows:

NameTypeDescription
namespaceIdstringNamespace ID.
entryPathstringCandidate directory path in the ZIP.
skillNamestringDetected Skill name.
reasonstringPrecheck result description.
ownerstringOwner of an existing Skill.
maxPublishedVersionstringCurrent maximum published version.
parsedVersionstringVersion parsed from the ZIP content.
targetVersionstringTarget version selected by precheck.
existsbooleanWhether the Skill already exists.
editingVersionstringCurrent draft version.
reviewingVersionstringCurrent reviewing version.
precheckCodestringResult code, such as READY, VERSION_ADJUSTED, DRAFT_EXISTS, REVIEWING_EXISTS, NO_PERMISSION, NOT_A_SKILL, or INVALID_SKILL.

Request Example

try {
SkillMaintainerService skillMaintainerService = aiMaintainerService.skill();
byte[] zipBytes = Files.readAllBytes(Paths.get("skills.zip"));
List<SkillUploadPrecheckResult> results = skillMaintainerService.precheckUploadSkillFromZip(zipBytes);
results = skillMaintainerService.precheckUploadSkillFromZip("public", zipBytes);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the precheck request fails unexpectedly. Business validation failures are returned as per-item results.

10. AgentSpec Capabilities

10.1. Get AgentSpec detail

Description

Get current AgentSpec detail.

AgentSpec getAgentSpecDetail(String namespaceId, String agentSpecName) throws NacosException;
AgentSpec getAgentSpecDetail(String agentSpecName) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID.
agentSpecNamestringAgentSpec name.

Response Parameters

Parameter TypeDescription
AgentSpecAgentSpec detail object.

Request Example

try {
AgentSpecMaintainerService agentSpecMaintainerService = aiMaintainerService.agentSpec();
AgentSpec detail = agentSpecMaintainerService.getAgentSpecDetail("public", "test-agent-spec");
detail = agentSpecMaintainerService.getAgentSpecDetail("test-agent-spec");
} catch (NacosException e) {
e.printStackTrace();
}

10.2. Get AgentSpec admin detail

Description

Get AgentSpec admin metadata detail.

AgentSpecMeta getAgentSpecAdminDetail(String namespaceId, String agentSpecName) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID.
agentSpecNamestringAgentSpec name.

Response Parameters

Parameter TypeDescription
AgentSpecMetaAgentSpec admin metadata object.

Request Example

try {
AgentSpecMaintainerService agentSpecMaintainerService = aiMaintainerService.agentSpec();
AgentSpecMeta meta = agentSpecMaintainerService.getAgentSpecAdminDetail("public", "test-agent-spec");
} catch (NacosException e) {
e.printStackTrace();
}

10.3. Get AgentSpec version detail

Description

Get specific version detail of AgentSpec.

AgentSpec getAgentSpecVersionDetail(String namespaceId, String agentSpecName, String version) throws NacosException;
AgentSpec getAgentSpecVersionDetail(String agentSpecName, String version) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID.
agentSpecNamestringAgentSpec name.
versionstringAgentSpec version.

Response Parameters

Parameter TypeDescription
AgentSpecAgentSpec version detail object.

Request Example

try {
AgentSpecMaintainerService agentSpecMaintainerService = aiMaintainerService.agentSpec();
AgentSpec detail = agentSpecMaintainerService.getAgentSpecVersionDetail("public", "test-agent-spec", "1.0.0");
detail = agentSpecMaintainerService.getAgentSpecVersionDetail("test-agent-spec", "1.0.0");
} catch (NacosException e) {
e.printStackTrace();
}

10.4. Delete AgentSpec

Description

Delete target AgentSpec.

boolean deleteAgentSpec(String namespaceId, String agentSpecName) throws NacosException;
boolean deleteAgentSpec(String agentSpecName) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID.
agentSpecNamestringAgentSpec name.

Response Parameters

Parameter TypeDescription
booleanWhether deletion succeeds.

Request Example

try {
AgentSpecMaintainerService agentSpecMaintainerService = aiMaintainerService.agentSpec();
boolean ok = agentSpecMaintainerService.deleteAgentSpec("public", "test-agent-spec");
ok = agentSpecMaintainerService.deleteAgentSpec("test-agent-spec");
} catch (NacosException e) {
e.printStackTrace();
}

10.5. List AgentSpecs with pagination

Description

List AgentSpec basic items with pagination.

Page<AgentSpecBasicInfo> listAgentSpecs(String namespaceId, String agentSpecName, String search, int pageNo, int pageSize) throws NacosException;
Page<AgentSpecBasicInfo> listAgentSpecs(String agentSpecName, int pageNo, int pageSize) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID.
agentSpecNamestringAgentSpec name pattern.
searchstringSearch mode: accurate or blur.
pageNointPage number.
pageSizeintPage size.

Response Parameters

Parameter TypeDescription
Page<AgentSpecBasicInfo>Paged AgentSpec basic list.

Request Example

try {
AgentSpecMaintainerService agentSpecMaintainerService = aiMaintainerService.agentSpec();
Page<AgentSpecBasicInfo> list = agentSpecMaintainerService.listAgentSpecs("public", "test-agent-spec", "blur", 1, 100);
list = agentSpecMaintainerService.listAgentSpecs("test-agent-spec", 1, 100);
} catch (NacosException e) {
e.printStackTrace();
}

10.6. List AgentSpec admin items with pagination

Description

List AgentSpec admin items with pagination.

Page<AgentSpecSummary> listAgentSpecAdminItems(String namespaceId, String agentSpecName, String search, int pageNo, int pageSize) throws NacosException;
Page<AgentSpecSummary> listAgentSpecAdminItems(String namespaceId, String agentSpecName, String search, String orderBy, String owner, String scope, int pageNo, int pageSize) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID.
agentSpecNamestringAgentSpec name pattern.
searchstringSearch mode: accurate or blur.
orderBystringOptional sort field.
ownerstringOptional resource owner filter.
scopestringOptional visibility scope filter.
pageNointPage number.
pageSizeintPage size.

Response Parameters

Parameter TypeDescription
Page<AgentSpecSummary>Paged AgentSpec admin list.

AgentSpecSummary.owner identifies the resource owner, and AgentSpecSummary.writable indicates whether the current requester can modify the AgentSpec.

Request Example

try {
AgentSpecMaintainerService agentSpecMaintainerService = aiMaintainerService.agentSpec();
Page<AgentSpecSummary> adminList = agentSpecMaintainerService.listAgentSpecAdminItems("public", "test-agent-spec", "blur", 1, 100);
adminList = agentSpecMaintainerService.listAgentSpecAdminItems("public", "test-agent-spec", "blur", "download_count", "nacos", "PUBLIC", 1, 100);
} catch (NacosException e) {
e.printStackTrace();
}

10.7. Upload AgentSpec from ZIP

Description

Upload AgentSpec from ZIP bytes.

String uploadAgentSpecFromZip(String namespaceId, byte[] zipBytes, boolean overwrite) throws NacosException;
String uploadAgentSpecFromZip(String namespaceId, byte[] zipBytes) throws NacosException;
String uploadAgentSpecFromZip(byte[] zipBytes) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID.
zipBytesbyte[]AgentSpec ZIP bytes.
overwritebooleanWhether to overwrite current editable draft when AgentSpec exists.

Response Parameters

Parameter TypeDescription
StringAgentSpec name.

Request Example

try {
AgentSpecMaintainerService agentSpecMaintainerService = aiMaintainerService.agentSpec();
byte[] zipBytes = Files.readAllBytes(Paths.get("test-agent-spec.zip"));
String name = agentSpecMaintainerService.uploadAgentSpecFromZip("public", zipBytes, true);
name = agentSpecMaintainerService.uploadAgentSpecFromZip("public", zipBytes);
name = agentSpecMaintainerService.uploadAgentSpecFromZip(zipBytes);
} catch (NacosException e) {
e.printStackTrace();
}

10.8. Create AgentSpec draft

Description

Create a new draft based on an existing version.

String createDraft(String namespaceId, String agentSpecName, String basedOnVersion) throws NacosException;
String createDraft(String namespaceId, String agentSpecName, String basedOnVersion, String targetVersion) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID.
agentSpecNamestringAgentSpec name.
basedOnVersionstringBase version (optional).
targetVersionstringTarget draft version, optional; auto-incremented when blank.

Response Parameters

Parameter TypeDescription
StringCreated draft version.

Request Example

try {
AgentSpecMaintainerService agentSpecMaintainerService = aiMaintainerService.agentSpec();
String version = agentSpecMaintainerService.createDraft("public", "test-agent-spec", "1.0.0");
version = agentSpecMaintainerService.createDraft("public", "test-agent-spec", "1.0.0", "1.0.1-draft");
} catch (NacosException e) {
e.printStackTrace();
}

10.9. Update AgentSpec draft

Description

Update current draft content.

boolean updateDraft(String namespaceId, String agentSpecCard, Boolean setAsLatest) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID.
agentSpecCardstringAgentSpec full JSON.
setAsLatestbooleanWhether to update latest label.

Response Parameters

Parameter TypeDescription
booleanWhether update succeeds.

Request Example

try {
AgentSpecMaintainerService agentSpecMaintainerService = aiMaintainerService.agentSpec();
boolean ok = agentSpecMaintainerService.updateDraft("public", "{\"name\":\"test-agent-spec\"}", true);
} catch (NacosException e) {
e.printStackTrace();
}

10.10. Delete AgentSpec draft

Description

Delete current draft version.

boolean deleteDraft(String namespaceId, String agentSpecName) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID.
agentSpecNamestringAgentSpec name.

Response Parameters

Parameter TypeDescription
booleanWhether deletion succeeds.

Request Example

try {
AgentSpecMaintainerService agentSpecMaintainerService = aiMaintainerService.agentSpec();
boolean ok = agentSpecMaintainerService.deleteDraft("public", "test-agent-spec");
} catch (NacosException e) {
e.printStackTrace();
}

10.11. Submit AgentSpec version

Description

Submit AgentSpec version for review workflow.

String submit(String namespaceId, String agentSpecName, String version) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID.
agentSpecNamestringAgentSpec name.
versionstringTarget version.

Response Parameters

Parameter TypeDescription
StringSubmit result (for example pipelineId).

Request Example

try {
AgentSpecMaintainerService agentSpecMaintainerService = aiMaintainerService.agentSpec();
String result = agentSpecMaintainerService.submit("public", "test-agent-spec", "1.0.1");
} catch (NacosException e) {
e.printStackTrace();
}

10.12. Publish AgentSpec version

Description

Publish the target AgentSpec Version. The latest label is server-managed.

boolean publish(String namespaceId, String agentSpecName, String version, Boolean updateLatestLabel) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID.
agentSpecNamestringAgentSpec name.
versionstringTarget version.
updateLatestLabelbooleanCompatibility parameter retained and ignored by the server.

Response Parameters

Parameter TypeDescription
booleanWhether publish succeeds.

Request Example

try {
AgentSpecMaintainerService agentSpecMaintainerService = aiMaintainerService.agentSpec();
boolean ok = agentSpecMaintainerService.publish("public", "test-agent-spec", "1.0.1", false);
} catch (NacosException e) {
e.printStackTrace();
}

10.13. Force-publish AgentSpec version

Description

Force-publish the target AgentSpec Version. The latest label is server-managed.

boolean forcePublish(String namespaceId, String agentSpecName, String version, Boolean updateLatestLabel) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID.
agentSpecNamestringAgentSpec name.
versionstringTarget version.
updateLatestLabelbooleanCompatibility parameter retained and ignored by the server.

Response Parameters

Parameter TypeDescription
booleanWhether force publish succeeds.

Request Example

try {
AgentSpecMaintainerService agentSpecMaintainerService = aiMaintainerService.agentSpec();
boolean ok = agentSpecMaintainerService.forcePublish("public", "test-agent-spec", "1.0.1", false);
} catch (NacosException e) {
e.printStackTrace();
}

10.14. Update AgentSpec labels

Description

Update labels JSON of AgentSpec.

boolean updateLabels(String namespaceId, String agentSpecName, String labels) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID.
agentSpecNamestringAgentSpec name.
labelsstringLabels JSON.

Response Parameters

Parameter TypeDescription
booleanWhether update succeeds.

Request Example

try {
AgentSpecMaintainerService agentSpecMaintainerService = aiMaintainerService.agentSpec();
boolean ok = agentSpecMaintainerService.updateLabels("public", "test-agent-spec", "{\"latest\":\"1.0.1\"}");
} catch (NacosException e) {
e.printStackTrace();
}

10.15. Update AgentSpec biz tags

Description

Update biz tags JSON of AgentSpec.

boolean updateBizTags(String namespaceId, String agentSpecName, String bizTags) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID.
agentSpecNamestringAgentSpec name.
bizTagsstringBiz tags JSON.

Response Parameters

Parameter TypeDescription
booleanWhether update succeeds.

Request Example

try {
AgentSpecMaintainerService agentSpecMaintainerService = aiMaintainerService.agentSpec();
boolean ok = agentSpecMaintainerService.updateBizTags("public", "test-agent-spec", "[\"ai\",\"ops\"]");
} catch (NacosException e) {
e.printStackTrace();
}

10.16. Change AgentSpec online status

Description

Online/offline operation at AgentSpec-level or version-level.

boolean changeOnlineStatus(String namespaceId, String agentSpecName, String scope, String version, boolean online) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID.
agentSpecNamestringAgentSpec name.
scopestringScope (for example agentspec or version).
versionstringVersion for version-level operation.
onlinebooleantrue for online, false for offline.

Response Parameters

Parameter TypeDescription
booleanWhether operation succeeds.

Request Example

try {
AgentSpecMaintainerService agentSpecMaintainerService = aiMaintainerService.agentSpec();
boolean ok = agentSpecMaintainerService.changeOnlineStatus("public", "test-agent-spec", "agentspec", null, true);
ok = agentSpecMaintainerService.changeOnlineStatus("public", "test-agent-spec", "version", "1.0.1", false);
} catch (NacosException e) {
e.printStackTrace();
}

10.17. Update AgentSpec scope

Description

Update AgentSpec visibility scope, for example PUBLIC / PRIVATE.

boolean updateScope(String namespaceId, String agentSpecName, String scope) throws NacosException;

Request Parameters

Parameter NameParameter TypeDescription
namespaceIdstringNamespace ID.
agentSpecNamestringAgentSpec name.
scopestringVisibility scope.

Response Parameters

Parameter TypeDescription
booleanWhether update succeeds.

Request Example

try {
AgentSpecMaintainerService agentSpecMaintainerService = aiMaintainerService.agentSpec();
boolean ok = agentSpecMaintainerService.updateScope("public", "test-agent-spec", "PUBLIC");
} catch (NacosException e) {
e.printStackTrace();
}

10.18. Get AgentSpec Version Metadata

Description

Get AgentSpec version metadata. The response contains the main content and a resource list with only resource name and type, avoiding full resource content reads.

AgentSpec getAgentSpecVersionMeta(String namespaceId, String agentSpecName, String version) throws NacosException;
AgentSpec getAgentSpecVersionMeta(String agentSpecName, String version) throws NacosException;

Request Parameters

NameTypeDescription
namespaceIdstringNamespace ID.
agentSpecNamestringAgentSpec name.
versionstringAgentSpec version.

Response

TypeDescription
AgentSpecAgentSpec version metadata.

Example

try {
AgentSpecMaintainerService agentSpecMaintainerService = aiMaintainerService.agentSpec();
AgentSpec meta = agentSpecMaintainerService.getAgentSpecVersionMeta("public", "test-agent-spec", "1.0.0");
meta = agentSpecMaintainerService.getAgentSpecVersionMeta("test-agent-spec", "1.0.0");
} catch (NacosException e) {
e.printStackTrace();
}

10.19. Redraft AgentSpec Version

Description

Move a reviewed AgentSpec version back to draft status for further editing.

boolean redraft(String namespaceId, String agentSpecName, String version) throws NacosException;

Request Parameters

NameTypeDescription
namespaceIdstringNamespace ID.
agentSpecNamestringAgentSpec name.
versionstringVersion to redraft.

Response

TypeDescription
booleanWhether redraft succeeds.

Example

try {
AgentSpecMaintainerService agentSpecMaintainerService = aiMaintainerService.agentSpec();
boolean ok = agentSpecMaintainerService.redraft("public", "test-agent-spec", "1.0.1");
} catch (NacosException e) {
e.printStackTrace();
}

11. Agent Management

Agent Management is the new protocol-neutral primary entry point and will replace the legacy A2A management APIs in the future. During the compatibility window, aiMaintainerService.a2a() remains available. New users and SDK integrations should prioritize AgentMaintainerService, obtained from aiMaintainerService.agent().

AgentMaintainerService is not bound to a namespace. Every operation provides an explicit-namespaceId form and a convenience overload that uses the default namespace public. Request and Command objects do not contain namespaceId. There is no separate Agent creation method: the first createDraft call creates both Agent metadata and the initial draft Version.

Note: This chapter uses the new Agent Management models in com.alibaba.nacos.api.ai.model.agent. Chapter 7 uses legacy A2A models in com.alibaba.nacos.api.ai.model.a2a. The packages contain same-named types such as AgentVersionDetail, so verify imports when copying examples.

11.1. Get Agent Overview

Description

Get Agent metadata together with the first bounded page of Version summaries.

AgentOverview getAgent(String namespaceId, String agentName) throws NacosException;
AgentOverview getAgent(String agentName) throws NacosException;

Request Parameters

NameTypeDescription
namespaceIdstringNamespace ID. The default is public when omitted.
agentNamestringExact Agent name.

Response Parameters

TypeDescription
AgentOverviewAgent overview containing agent metadata and the versionPage summary page.

Request Example

try {
AgentMaintainerService agentMaintainerService = aiMaintainerService.agent();
AgentOverview overview = agentMaintainerService.getAgent("public", "demo-agent");
overview = agentMaintainerService.getAgent("demo-agent");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the request fails.

11.2. Update Agent Metadata

Description

Completely replace the writable Agent metadata. Presentation fields, tags, extensions, and enabled status are writable; identity, owner, scope, Version content, labels, and the derived catalog are not.

Agent updateAgent(String namespaceId, AgentUpdateRequest request) throws NacosException;
Agent updateAgent(AgentUpdateRequest request) throws NacosException;

Request Parameters

NameTypeDescription
namespaceIdstringNamespace ID. The default is public when omitted.
requestAgentUpdateRequestAgent metadata update request.

AgentUpdateRequest has the following fields:

NameTypeDescription
agentNamestringAgent name. Required.
displayNamestringDisplay name.
descriptionstringDescription.
iconUrlstringIcon URL.
providerAgentProviderProvider information with name and url.
tagsList<String>Agent tags.
extensionsMap<String, Object>Extension properties.
statusstringWritable status. Required; only enable or disable is accepted.

Response Parameters

TypeDescription
AgentUpdated Agent.

Request Example

try {
AgentMaintainerService agentMaintainerService = aiMaintainerService.agent();
AgentUpdateRequest request = new AgentUpdateRequest();
request.setAgentName("demo-agent");
request.setDisplayName("Demo Agent");
request.setDescription("Agent for SDK examples");
request.setTags(Arrays.asList("demo", "java"));
request.setStatus("enable");
Agent agent = agentMaintainerService.updateAgent("public", request);
// Default-namespace alternative: Agent agent = agentMaintainerService.updateAgent(request);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when parameters are invalid or the update fails.

11.3. Delete Agent

Description

Delete an Agent definition and all of its Version content. This operation does not delete runtime publications owned by independent Publishers.

void deleteAgent(String namespaceId, String agentName) throws NacosException;
void deleteAgent(String agentName) throws NacosException;

Request Parameters

NameTypeDescription
namespaceIdstringNamespace ID. The default is public when omitted.
agentNamestringExact Agent name.

Response Parameters

No return value.

Request Example

try {
AgentMaintainerService agentMaintainerService = aiMaintainerService.agent();
agentMaintainerService.deleteAgent("public", "demo-agent");
// Default-namespace alternative: agentMaintainerService.deleteAgent("demo-agent");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when deletion fails.

11.4. List Agents with Pagination

Description

Filter Agent summaries by name, business tag, scope, and owner, then return stable pagination. The name and single business-tag filters use fuzzy matching.

Page<AgentSummary> listAgents(String namespaceId, String agentName, String bizTag, String scope, String owner, String orderBy, int pageNo, int pageSize) throws NacosException;
Page<AgentSummary> listAgents(String agentName, String bizTag, String scope, String owner, String orderBy, int pageNo, int pageSize) throws NacosException;

Request Parameters

NameTypeDescription
namespaceIdstringNamespace ID. The default is public when omitted.
agentNamestringOptional fuzzy Agent-name filter.
bizTagstringOptional single fuzzy business-tag filter.
scopestringOptional visibility-scope filter.
ownerstringOptional owner filter.
orderBystringOptional order field. The initial contract accepts download_count.
pageNointPage number.
pageSizeintNumber of items per page.

Response Parameters

TypeDescription
Page<AgentSummary>Page of Agent summaries.

Request Example

try {
AgentMaintainerService agentMaintainerService = aiMaintainerService.agent();
Page<AgentSummary> page = agentMaintainerService.listAgents(
"public", "demo", "java", "PUBLIC", null, "download_count", 1, 20);
page = agentMaintainerService.listAgents(
"demo", "java", "PUBLIC", null, "download_count", 1, 20);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the query fails.

11.5. List Agent Versions with Pagination

Description

List Version summaries for an Agent, optionally filtered by Version status.

Page<AgentVersionSummary> listAgentVersions(String namespaceId, String agentName, String status, int pageNo, int pageSize) throws NacosException;
Page<AgentVersionSummary> listAgentVersions(String agentName, String status, int pageNo, int pageSize) throws NacosException;

Request Parameters

NameTypeDescription
namespaceIdstringNamespace ID. The default is public when omitted.
agentNamestringExact Agent name.
statusstringOptional Version-status filter.
pageNointPage number.
pageSizeintNumber of items per page.

Response Parameters

TypeDescription
Page<AgentVersionSummary>Page of Agent Version summaries.

Request Example

try {
AgentMaintainerService agentMaintainerService = aiMaintainerService.agent();
Page<AgentVersionSummary> page =
agentMaintainerService.listAgentVersions("public", "demo-agent", "online", 1, 20);
page = agentMaintainerService.listAgentVersions("demo-agent", null, 1, 20);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the query fails.

11.6. Get an Agent Version

Description

Get one exact Agent Version definition.

AgentVersionDetail getAgentVersion(String namespaceId, String agentName, String version) throws NacosException;
AgentVersionDetail getAgentVersion(String agentName, String version) throws NacosException;

Request Parameters

NameTypeDescription
namespaceIdstringNamespace ID. The default is public when omitted.
agentNamestringExact Agent name.
versionstringExact Version.

Response Parameters

TypeDescription
AgentVersionDetailVersion detail containing status, callInterfaces, author, change description, content digest, and timestamps.

Request Example

try {
AgentMaintainerService agentMaintainerService = aiMaintainerService.agent();
AgentVersionDetail detail =
agentMaintainerService.getAgentVersion("public", "demo-agent", "1.0.0");
detail = agentMaintainerService.getAgentVersion("demo-agent", "1.0.0");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the query fails.

11.7. Get Agent Runtime Endpoints

Description

Get the complete runtime Endpoint snapshot for a protocol, optionally filtered by Agent Version. Omitting version returns all bindings for each natural Endpoint key; supplying it retains only matching bindings. The items list is empty when no runtime instance exists.

RuntimeEndpointSnapshot getRuntimeEndpoints(String namespaceId, String agentName, String protocol, String version) throws NacosException;
RuntimeEndpointSnapshot getRuntimeEndpoints(String agentName, String protocol, String version) throws NacosException;

Request Parameters

NameTypeDescription
namespaceIdstringNamespace ID. The default is public when omitted.
agentNamestringExact Agent name.
protocolstringProtocol token. Required.
versionstringOptional Agent Version filter.

Response Parameters

TypeDescription
RuntimeEndpointSnapshotRuntime snapshot with namespaceId, agentName, protocol, version, and Endpoint items.

Each RuntimeEndpointSnapshotItem contains an Endpoint, Version bindings, runtime state, enabled and healthy flags, and the last update time.

Request Example

try {
AgentMaintainerService agentMaintainerService = aiMaintainerService.agent();
RuntimeEndpointSnapshot snapshot =
agentMaintainerService.getRuntimeEndpoints("public", "demo-agent", "a2a", "1.0.0");
snapshot = agentMaintainerService.getRuntimeEndpoints("demo-agent", "a2a", null);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the query fails.

11.8. Create Agent Draft

Description

Create an initial or subsequent Agent draft. When the Agent does not exist, this is the only creation entry and the request must contain direct callInterfaces, not basedOnVersion. For an existing Agent, provide either direct callInterfaces or one exact basedOnVersion, but never both.

AgentVersionDetail createDraft(String namespaceId, AgentDraftCreateRequest request) throws NacosException;
AgentVersionDetail createDraft(AgentDraftCreateRequest request) throws NacosException;

Request Parameters

NameTypeDescription
namespaceIdstringNamespace ID. The default is public when omitted.
requestAgentDraftCreateRequestDraft creation request.

AgentDraftCreateRequest has the following fields:

NameTypeDescription
agentNamestringAgent name. Required.
displayNamestringOptional display name for initial creation.
descriptionstringOptional description for initial creation.
iconUrlstringOptional icon URL for initial creation.
providerAgentProviderOptional provider for initial creation.
tagsList<String>Optional tags for initial creation.
extensionsMap<String, Object>Optional extensions for initial creation.
versionstringExact Version to create. Required.
callInterfacesList<AgentCallInterface>Direct Version content; mutually exclusive with basedOnVersion.
authorstringVersion author.
changeDescriptionstringVersion change description.
basedOnVersionstringExact existing Version to copy; mutually exclusive with callInterfaces.

Response Parameters

TypeDescription
AgentVersionDetailCreated draft detail.

Request Example

try {
AgentMaintainerService agentMaintainerService = aiMaintainerService.agent();
AgentCallInterface callInterface = new AgentCallInterface();
callInterface.setProtocol("a2a");
callInterface.setProtocolVersion("0.3.0");
callInterface.setDescriptorMediaType("application/json");
com.alibaba.nacos.api.ai.model.a2a.AgentCard a2aDescriptor =
new com.alibaba.nacos.api.ai.model.a2a.AgentCard();
a2aDescriptor.setName("demo-agent");
a2aDescriptor.setDescription("Agent for SDK examples");
a2aDescriptor.setUrl("https://example.com/a2a");
a2aDescriptor.setVersion("1.0.0");
a2aDescriptor.setProtocolVersion("0.3.0");
callInterface.setNativeDescriptor(a2aDescriptor);
callInterface.setEndpointSourceOrder(Collections.singletonList(EndpointSource.RUNTIME));
AgentDraftCreateRequest request = new AgentDraftCreateRequest();
request.setAgentName("demo-agent");
request.setDisplayName("Demo Agent");
request.setVersion("1.0.0");
request.setCallInterfaces(Collections.singletonList(callInterface));
request.setAuthor("nacos");
request.setChangeDescription("initial version");
AgentVersionDetail draft = agentMaintainerService.createDraft("public", request);
// Default-namespace alternative: AgentVersionDetail draft = agentMaintainerService.createDraft(request);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the content source is ambiguous, the Version is invalid, or creation fails.

11.9. Update Agent Draft

Description

Completely replace the CallInterface content and change description of one exact draft. This operation never creates a missing Agent or Version and does not update Agent metadata.

AgentVersionDetail updateDraft(String namespaceId, AgentDraftUpdateRequest request) throws NacosException;
AgentVersionDetail updateDraft(AgentDraftUpdateRequest request) throws NacosException;

Request Parameters

NameTypeDescription
namespaceIdstringNamespace ID. The default is public when omitted.
requestAgentDraftUpdateRequestDraft update request.

AgentDraftUpdateRequest contains required agentName, exact version, and non-null callInterfaces, plus optional changeDescription.

Response Parameters

TypeDescription
AgentVersionDetailUpdated draft detail.

Request Example

try {
AgentMaintainerService agentMaintainerService = aiMaintainerService.agent();
AgentCallInterface callInterface = new AgentCallInterface();
callInterface.setProtocol("a2a");
callInterface.setProtocolVersion("0.3.0");
callInterface.setDescriptorMediaType("application/json");
com.alibaba.nacos.api.ai.model.a2a.AgentCard a2aDescriptor =
new com.alibaba.nacos.api.ai.model.a2a.AgentCard();
a2aDescriptor.setName("demo-agent");
a2aDescriptor.setDescription("Updated Agent descriptor");
a2aDescriptor.setUrl("https://example.com/a2a");
a2aDescriptor.setVersion("1.0.0");
a2aDescriptor.setProtocolVersion("0.3.0");
callInterface.setNativeDescriptor(a2aDescriptor);
callInterface.setEndpointSourceOrder(Collections.singletonList(EndpointSource.RUNTIME));
AgentDraftUpdateRequest request = new AgentDraftUpdateRequest();
request.setAgentName("demo-agent");
request.setVersion("1.0.0");
request.setCallInterfaces(Collections.singletonList(callInterface));
request.setChangeDescription("update descriptor");
AgentVersionDetail draft = agentMaintainerService.updateDraft("public", request);
// Default-namespace alternative: AgentVersionDetail draft = agentMaintainerService.updateDraft(request);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the target is not a draft, the request is invalid, or the update fails.

11.10. Delete Agent Draft

Description

Delete one exact Agent draft Version.

void deleteDraft(String namespaceId, String agentName, String version) throws NacosException;
void deleteDraft(String agentName, String version) throws NacosException;

Request Parameters

NameTypeDescription
namespaceIdstringNamespace ID. The default is public when omitted.
agentNamestringExact Agent name.
versionstringExact draft Version.

Response Parameters

No return value.

Request Example

try {
AgentMaintainerService agentMaintainerService = aiMaintainerService.agent();
agentMaintainerService.deleteDraft("public", "demo-agent", "1.0.0");
// Default-namespace alternative: agentMaintainerService.deleteDraft("demo-agent", "1.0.0");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when deletion fails.

11.11. Submit Agent Version

Description

Submit one exact Agent Version for the draft -> reviewing transition or the shared no-Pipeline transition.

AgentVersionSummary submit(String namespaceId, AgentVersionCommand command) throws NacosException;
AgentVersionSummary submit(AgentVersionCommand command) throws NacosException;

Request Parameters

NameTypeDescription
namespaceIdstringNamespace ID. The default is public when omitted.
commandAgentVersionCommandVersion command containing required agentName and exact version.

Response Parameters

TypeDescription
AgentVersionSummaryResulting Version summary.

Request Example

try {
AgentMaintainerService agentMaintainerService = aiMaintainerService.agent();
AgentVersionCommand command = new AgentVersionCommand();
command.setAgentName("demo-agent");
command.setVersion("1.0.0");
AgentVersionSummary summary = agentMaintainerService.submit("public", command);
// Default-namespace alternative: AgentVersionSummary summary = agentMaintainerService.submit(command);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the state transition is not allowed or submission fails.

11.12. Publish Agent Version

Description

Move one exact reviewed Agent Version from reviewed to online.

AgentVersionSummary publish(String namespaceId, AgentVersionCommand command) throws NacosException;
AgentVersionSummary publish(AgentVersionCommand command) throws NacosException;

Request Parameters

NameTypeDescription
namespaceIdstringNamespace ID. The default is public when omitted.
commandAgentVersionCommandVersion command containing required agentName and exact version.

Response Parameters

TypeDescription
AgentVersionSummaryOnline Version summary.

Request Example

try {
AgentMaintainerService agentMaintainerService = aiMaintainerService.agent();
AgentVersionCommand command = new AgentVersionCommand();
command.setAgentName("demo-agent");
command.setVersion("1.0.0");
AgentVersionSummary summary = agentMaintainerService.publish("public", command);
// Default-namespace alternative: AgentVersionSummary summary = agentMaintainerService.publish(command);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the Version has not been reviewed or publication fails.

11.13. Force-publish Agent Version

Description

Bypass the Pipeline with auditing and move one exact Agent Version to online.

AgentVersionSummary forcePublish(String namespaceId, AgentVersionCommand command) throws NacosException;
AgentVersionSummary forcePublish(AgentVersionCommand command) throws NacosException;

Request Parameters

NameTypeDescription
namespaceIdstringNamespace ID. The default is public when omitted.
commandAgentVersionCommandVersion command containing required agentName and exact version.

Response Parameters

TypeDescription
AgentVersionSummaryOnline Version summary.

Request Example

try {
AgentMaintainerService agentMaintainerService = aiMaintainerService.agent();
AgentVersionCommand command = new AgentVersionCommand();
command.setAgentName("demo-agent");
command.setVersion("1.0.0");
AgentVersionSummary summary = agentMaintainerService.forcePublish("public", command);
// Default-namespace alternative: AgentVersionSummary summary = agentMaintainerService.forcePublish(command);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when force publication fails.

11.14. Redraft Agent Version

Description

Move one exact reviewed Agent Version from reviewed back to draft.

AgentVersionSummary redraft(String namespaceId, AgentVersionCommand command) throws NacosException;
AgentVersionSummary redraft(AgentVersionCommand command) throws NacosException;

Request Parameters

NameTypeDescription
namespaceIdstringNamespace ID. The default is public when omitted.
commandAgentVersionCommandVersion command containing required agentName and exact version.

Response Parameters

TypeDescription
AgentVersionSummaryDraft Version summary.

Request Example

try {
AgentMaintainerService agentMaintainerService = aiMaintainerService.agent();
AgentVersionCommand command = new AgentVersionCommand();
command.setAgentName("demo-agent");
command.setVersion("1.0.0");
AgentVersionSummary summary = agentMaintainerService.redraft("public", command);
// Default-namespace alternative: AgentVersionSummary summary = agentMaintainerService.redraft(command);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the state transition is not allowed or the operation fails.

11.15. Bring Agent Version Online

Description

Move one exact Agent Version from offline to online.

AgentVersionSummary online(String namespaceId, AgentVersionCommand command) throws NacosException;
AgentVersionSummary online(AgentVersionCommand command) throws NacosException;

Request Parameters

NameTypeDescription
namespaceIdstringNamespace ID. The default is public when omitted.
commandAgentVersionCommandVersion command containing required agentName and exact version.

Response Parameters

TypeDescription
AgentVersionSummaryOnline Version summary.

Request Example

try {
AgentMaintainerService agentMaintainerService = aiMaintainerService.agent();
AgentVersionCommand command = new AgentVersionCommand();
command.setAgentName("demo-agent");
command.setVersion("1.0.0");
AgentVersionSummary summary = agentMaintainerService.online("public", command);
// Default-namespace alternative: AgentVersionSummary summary = agentMaintainerService.online(command);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the state transition is not allowed or the operation fails.

11.16. Take Agent Version Offline

Description

Move one exact Agent Version from online to offline.

AgentVersionSummary offline(String namespaceId, AgentVersionCommand command) throws NacosException;
AgentVersionSummary offline(AgentVersionCommand command) throws NacosException;

Request Parameters

NameTypeDescription
namespaceIdstringNamespace ID. The default is public when omitted.
commandAgentVersionCommandVersion command containing required agentName and exact version.

Response Parameters

TypeDescription
AgentVersionSummaryOffline Version summary.

Request Example

try {
AgentMaintainerService agentMaintainerService = aiMaintainerService.agent();
AgentVersionCommand command = new AgentVersionCommand();
command.setAgentName("demo-agent");
command.setVersion("1.0.0");
AgentVersionSummary summary = agentMaintainerService.offline("public", command);
// Default-namespace alternative: AgentVersionSummary summary = agentMaintainerService.offline(command);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the state transition is not allowed or the operation fails.

11.17. Update Agent Custom Labels

Description

Completely replace custom Agent Version labels. Label values must target exact Versions. latest is server-managed and cannot be updated as a custom label.

Agent updateLabels(String namespaceId, AgentLabelsUpdateRequest request) throws NacosException;
Agent updateLabels(AgentLabelsUpdateRequest request) throws NacosException;

Request Parameters

NameTypeDescription
namespaceIdstringNamespace ID. The default is public when omitted.
requestAgentLabelsUpdateRequestLabels update request.

AgentLabelsUpdateRequest contains required agentName and non-null labels (Map<String, String>, mapping label names to exact Versions). Pass an empty map to clear all custom labels.

Response Parameters

TypeDescription
AgentAgent after the label update.

Request Example

try {
AgentMaintainerService agentMaintainerService = aiMaintainerService.agent();
AgentLabelsUpdateRequest request = new AgentLabelsUpdateRequest();
request.setAgentName("demo-agent");
request.setLabels(Collections.singletonMap("stable", "1.0.0"));
Agent agent = agentMaintainerService.updateLabels("public", request);
// Default-namespace alternative: Agent agent = agentMaintainerService.updateLabels(request);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when labels are invalid, a target Version does not exist, or the update fails.

12. Pipeline Management

Obtain PipelineMaintainerService from aiMaintainerService.pipeline(). New code should prefer the typed methods that return Result, allowing callers to inspect the server business code and message explicitly. The legacy JsonNode methods remain only for compatibility.

12.1. Get Pipeline Execution Detail

Description

Get typed Pipeline execution detail by execution ID.

Result<PipelineExecution> getPipelineDetail(String pipelineId) throws NacosException;

Request Parameters

NameTypeDescription
pipelineIdstringPipeline execution ID.

Response Parameters

TypeDescription
ResultServer result wrapper with code, message, and data.

PipelineExecution contains executionId, resourceType, resourceName, namespaceId, version, status, node results in pipeline, createTime, and updateTime.

Request Example

try {
PipelineMaintainerService pipelineMaintainerService = aiMaintainerService.pipeline();
Result<PipelineExecution> result =
pipelineMaintainerService.getPipelineDetail("pipeline-execution-id");
if (ErrorCode.SUCCESS.getCode().equals(result.getCode())) {
PipelineExecution execution = result.getData();
}
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown for transport or HTTP failures such as a connection error, an unparseable response, or an unavailable response body. A business failure in an HTTP 200 response is returned through Result.code and Result.message.

12.2. List Pipeline Executions with Pagination

Description

List Pipeline execution records by resource type and optional resource identity filters.

Result<Page<PipelineExecution>> listPipelineExecutions(String resourceType, String resourceName, String namespaceId, String version, int pageNo, int pageSize) throws NacosException;

Request Parameters

NameTypeDescription
resourceTypestringResource type. Required.
resourceNamestringOptional resource name.
namespaceIdstringOptional namespace ID.
versionstringOptional resource Version.
pageNointPage number.
pageSizeintNumber of items per page.

Response Parameters

TypeDescription
Result<Page>Server result wrapper whose data is a page of Pipeline executions.

Request Example

try {
PipelineMaintainerService pipelineMaintainerService = aiMaintainerService.pipeline();
Result<Page<PipelineExecution>> result =
pipelineMaintainerService.listPipelineExecutions(
"agent", "demo-agent", "public", "1.0.0", 1, 20);
if (ErrorCode.SUCCESS.getCode().equals(result.getCode())) {
Page<PipelineExecution> page = result.getData();
}
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown for transport or HTTP failures. Business failures are returned in Result.

12.3. Get Pipeline Execution Detail (Compatibility Method)

Description

Legacy JsonNode accessor for Pipeline execution detail. This method has been deprecated since 3.2.1. New code should use getPipelineDetail.

@Deprecated
JsonNode getPipeline(String pipelineId) throws NacosException;

Request Parameters

NameTypeDescription
pipelineIdstringPipeline execution ID.

Response Parameters

TypeDescription
JsonNodePipeline execution data JSON from a successful result.

Request Example

try {
PipelineMaintainerService pipelineMaintainerService = aiMaintainerService.pipeline();
JsonNode execution = pipelineMaintainerService.getPipeline("pipeline-execution-id");
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the request fails or the server returns a non-success business result.

12.4. List Pipeline Executions (Compatibility Method)

Description

Legacy JsonNode accessor for Pipeline execution pagination. This method has been deprecated since 3.2.1. New code should use listPipelineExecutions.

@Deprecated
JsonNode listPipelines(String resourceType, String resourceName, String namespaceId, String version, int pageNo, int pageSize) throws NacosException;

Request Parameters

NameTypeDescription
resourceTypestringResource type. Required.
resourceNamestringOptional resource name.
namespaceIdstringOptional namespace ID.
versionstringOptional resource Version.
pageNointPage number.
pageSizeintNumber of items per page.

Response Parameters

TypeDescription
JsonNodePipeline execution page data JSON from a successful result.

Request Example

try {
PipelineMaintainerService pipelineMaintainerService = aiMaintainerService.pipeline();
JsonNode page = pipelineMaintainerService.listPipelines(
"agent", "demo-agent", "public", "1.0.0", 1, 20);
} catch (NacosException e) {
e.printStackTrace();
}

Exception Description

A NacosException is thrown when the request fails or the server returns a non-success business result.