![Blog](https://camo.githubusercontent.com/32328fbe1c9b4fd8f7348acfb0020ae44e3254312ea3ca7372895186d057350e/68747470733a2f2f666c61742e62616467656e2e6e65742f7374617469632f626c6f672f6f64696e73616d2e636f6d)
{
"ColaWebApi": [
{
"ClientName": "ColaNacos",
"BaseUri": "http://192.168.202.132:8848",
"TimeOut": 5000,
"Cert": {
"CertFilePath": "",
"CertFilePwd": ""
},
/* 默认压缩方式 None,GZip,Deflate,Brotli,All */
"Decompression": "All"
}
],
"ColaNacos": {
// 子节点,名称可以自定义
"public": {
"EndPoint": "",
"Listeners": [
{
"Optional": false,
"DataId": "DEFAULT_ID",
"Group": "DEFAULT_GROUP"
}
],
"ServerAddresses": [ "http://192.168.202.132:8848" ],
"Namespace": "",
"ConfigUseRpc": false,
"NamingUseRpc": false
}
}
}
// 必须注入核心组件
builder.Services.AddColaCore();
// 必须注入webapi
builder.Services.AddColaHttpClient(config);
// list 为 ColaNacos 的子节点,名称可以自定义
builder.Services.AddColaNacos(config, new List<string>() { "public" });
public interface IColaNacos
{
#region 命名空间管理接口
/// <summary>
/// 查询当前所有的命名空间
/// </summary>
/// <param name="clientName">clientName</param>
/// <returns>ApiResult<List<NamespaceList>></returns>
ApiResult<List<NacosNamespaceInfo>>? NamespaceQuery(string clientName);
/// <summary>
/// 查询具体命名空间的信息 为空查询public命名空间
/// </summary>
/// <param name="clientName">clientName</param>
/// <param name="namespaceId">namespaceId</param>
/// <returns>ApiResult<NamespaceList></returns>
ApiResult<NacosNamespaceInfo>? NamespaceQueryById(string clientName, string? namespaceId);
/// <summary>
/// 创建一个命名空间, 命名空间已存在时会报错
/// </summary>
/// <param name="clientName">clientName</param>
/// <param name="nacosNamespace">nacosNamespace</param>
/// <returns>success true</returns>
ApiResult<bool>? CreateNamespace(string clientName, NacosNamespace nacosNamespace);
/// <summary>
/// 编辑命名空间信息
/// </summary>
/// <param name="clientName">clientName</param>
/// <param name="nacosNamespace">nacosNamespace</param>
/// <returns>success true</returns>
ApiResult<bool>? UpdateNamespace(string clientName, NacosNamespace nacosNamespace);
/// <summary>
/// 删除指定命名空间
/// </summary>
/// <param name="clientName">clientName</param>
/// <param name="namespaceId">namespaceId</param>
/// <returns>success true</returns>
ApiResult<bool>? DeleteNamespace(string clientName, string namespaceId);
#endregion
}