# 查询网格列表 - ListMeshes
#### 功能介绍
该API用于获取用户所有网格的详细信息
#### 调用方法
请参见[如何调用API](https://support.huaweicloud.com/api-asm/asm_api_0008.html)。
#### 授权信息
账号具备所有API的调用权限，如果使用账号下的IAM用户调用当前API，该IAM用户需具备调用API所需的权限。
- 如果使用角色与策略授权，具体权限要求请参见[权限和授权项](https://support.huaweicloud.com/api-asm/asm_api_0030.html)。
- 如果使用身份策略授权，需具备如下身份策略权限。
  
  | 授权项           | 访问级别 | 资源类型（\*为必须） | 条件键 | 别名 | 依赖的授权项 |
  |:---|:---|:---|:---|:---|:---|
  | asm:mesh:list | List | mesh \*     | -   | -  | -      |
     
  
 
#### URI
GET /v1/{project_id}/meshes
表1路径参数 
| 参数         | 是否必选 | 参数类型   | 描述    |
|:---|:---|:---|:---|
| project_id | 是    | String | 项目ID。 |
   
#### 请求参数
表2请求Header参数 
| 参数           | 是否必选 | 参数类型   | 描述                                                        |
|:---|:---|:---|:---|
| X-Auth-Token | 是    | String | 调用接口的认证方式分为Token和AK/SK两种，如果您使用的Token方式，此参数为必填，请填写Token的值。 |
   
#### 响应参数
**状态码：200**
表3响应Body参数 
| 参数         | 参数类型                                                | 描述                         |
|:---|:---|:---|
| apiVersion | String                                              | API版本，固定值"v1"，该值不可修改       |
| kind       | String                                              | API类型，固定值"MeshList"，该值不可修改 |
| items      | Array of [Mesh] objects | 网格列表                       |
   
 表4Mesh 
| 参数         | 参数类型                                                      | 描述                                                                           |
|:---|:---|:---|
| apiVersion | String                                                    | API版本，固定值"v1"，该值不可修改                                                         |
| kind       | String                                                    | API类型，固定值"Mesh"或"mesh"，该值不可修改                                                |
| metadata   | [MeshMetadata] object | 网格的基本信息，为集合类的元素类型，包含一组由不同名称定义的属性                                             |
| spec       | [MeshSpec] object         | 集合类的元素类型，您对需要管理的网格对象进行详细描述的主体部分都在spec中给出。ASM通过spec的描述来创建或更新对象                |
| status     | [MeshStatus] object     | 集合类的元素类型，用于记录对象在系统中的当前状态信息。 该对象为系统自动生成，不需要用户填写 |
   
 表5MeshMetadata 
| 参数                | 参数类型   | 描述                                                                                        |
|:---|:---|:---|
| name              | String | 网格名称。 命名规则：以小写字母开头，由小写字母、数字、中划线(-)组成，长度范围4-64位，且不能以中划线(-)结尾 |
| uid               | String | 网格ID，资源唯一标识，创建成功后自动生成，填写无效                                                                |
| creationTimestamp | String | 网格创建时间                                                                                    |
   
 表6MeshSpec 
| 参数           | 参数类型                                                              | 描述                                                                                                                                                                                                                                                                      |
|:---|:---|:---|
| type         | String                                                            | 网格类型。 取值范围： - InCluster: 集群内控制平面形态，基础版网格取值为InCluster。目前仅支持该类型。    |
| version      | String                                                            | **参数解释：** 网格版本，与Istio社区基线版本保持一致，建议选择最新商用版本。 在ASM控制台支持创建多种版本的网格。可登录ASM控制台创建网格，在"版本"处获取到网格版本。 **取值范围：** 不涉及                                       |
| extendParams | [MeshExtendParams] object | 服务网格扩展信息。                                                                                                                                                                                                                                                               |
| ipv6Enable   | Boolean                                                           | 网格是否支持IPV6                                                                                                                                                                                                                                                              |
| tags         | Array of [MeshTags] objects       | 网格资源标签。如果需要配置资源标签，请确认当前region的TMS服务已上线。                                                                                                                                                                                                                                 |
| config       | [MeshConfig] object             | 网格配置。                                                                                                                                                                                                                                                                   |
   
 表7MeshExtendParams 
| 参数       | 参数类型                                                              | 描述      |
|:---|:---|:---|
| clusters | Array of [MeshCluster] objects | 网格内集群信息 |
   
 表8MeshCluster 
| 参数           | 参数类型                                                                  | 描述                         |
|:---|:---|:---|
| clusterID    | String                                                                | 集群ID，资源唯一标识，通过该ID查询需要添加的集群 |
| injection    | [InjectionConfig] object       | sidecar注入配置                |
| installation | [InstallationConfig] object | 网格组件安装配置                   |
   
 表9InjectionConfig 
| 参数         | 参数类型                                              | 描述        |
|:---|:---|:---|
| namespaces | [Selector] object | 需要注入的命名空间 |
   
 表10InstallationConfig 
| 参数    | 参数类型                                              | 描述        |
|:---|:---|:---|
| nodes | [Selector] object | 安装网格组件的节点 |
   
 表11Selector 
| 参数            | 参数类型                                                        | 描述    |
|:---|:---|:---|
| fieldSelector | [FieldSelector] object | 字段选择器 |
   
 表12FieldSelector 
| 参数       | 参数类型             | 描述            |
|:---|:---|:---|
| key      | String           | Key值          |
| operator | String           | 操作符，仅支持取值"In" |
| values   | Array of strings | Value值        |
   
 表13MeshTags 
| 参数    | 参数类型   | 描述                                                                                                                                                                                                   |
|:---|:---|:---|
| key   | String | Key值。 不能为空，最多支持128个字符 可用UTF-8格式表示的汉字、字母、数字和空格 支持部分特殊字符：_.:/=+-@ 不能以"*sys*"开头 |
| value | String | Value值。 可以为空但不能缺省，最多支持255个字符 可用UTF-8格式表示的汉字、字母、数字和空格 支持部分特殊字符：_.:/=+-@                                     |
   
 表14MeshConfig 
| 参数              | 参数类型                                                            | 描述        |
|:---|:---|:---|
| proxyConfig     | [ProxyConfig] object         | 网格数据面配置   |
| telemetryConfig | [TelemetryConfig] object | 网格的可观测性配置 |
   
 表15ProxyConfig 
| 参数                   | 参数类型   | 描述                              |
|:---|:---|:---|
| includeIPRanges      | String | 拦截对外访问的地址范围，以半角英文逗号（,）分隔的IP网段   |
| excludeIPRanges      | String | 排除拦截对外访问的地址范围，以半角英文逗号（,）分隔的IP网段 |
| excludeOutboundPorts | String | 排除拦截对外访问端口，以半角英文逗号（,）分隔的出站端口列表  |
| excludeInboundPorts  | String | 排除拦截访问服务的端口，以半角英文逗号（,）分隔的入站端口列表 |
| includeOutboundPorts | String | 拦截对外访问端口，以半角英文逗号（,）分隔的出站端口列表    |
| includeInboundPorts  | String | 拦截访问服务的端口，以半角英文逗号（,）分隔的入站端口列表   |
   
 表16TelemetryConfig 
| 参数            | 参数类型                                                        | 描述                                                          |
|:---|:---|:---|
| metrics       | [Metric] object               | 应用指标配置，用于上报ASM网格指标数据。如果要启用该配置，集群需安装云原生监控插件。                 |
| accessLogging | [AccessLogging] object | AccessLog配置，用于上报ASM网格内Istio代理的访问日志。如果要启用该配置，集群需安装云原生日志采集插件。 |
| tracing       | [Tracing] object             | Tracing配置，用于上报ASM网格内的调用链数据。                                 |
   
 表17Metric 
| 参数  | 参数类型                                              | 描述       |
|:---|:---|:---|
| aom | Array of [Aom] objects | AOM实例配置。 |
   
 表18Aom 
| 参数         | 参数类型   | 描述       |
|:---|:---|:---|
| instanceID | String | AOM实例ID。 |
   
 表19AccessLogging 
| 参数  | 参数类型                                                          | 描述    |
|:---|:---|:---|
| lts | Array of [LtsConfig] objects | LTS配置 |
   
 表20LtsConfig 
| 参数          | 参数类型   | 描述               |
|:---|:---|:---|
| logGroupID  | String | AccessLog日志组ID   |
| logStreamID | String | AccessLog输出日志流ID |
   
 表21Tracing 
| 参数                       | 参数类型                                                                                        | 描述                                                                                                                                                                 |
|:---|:---|:---|
| randomSamplingPercentage | Float                                                                                       | tracing采样率                                                                                                                                                         |
| defaultProviders         | Array of strings                                                                            | tracing默认上报的provider名称，必须与extensionProviders中的name字段匹配，或使用ASM预设的provider "apm-otel"。 如果使用"apm-otel"，需确认当前region已支持APM2.0且网格版本大于1.18。 |
| extensionProviders       | Array of [TracingExtensionProvider] objects | 用户自配置provider，目前支持zipkin协议。 如果用户配置zipkin协议的provider，请保证网格版本大于等于1.15。                                                                 |
   
 表22TracingExtensionProvider 
| 参数     | 参数类型                                                                        | 描述                   |
|:---|:---|:---|
| name   | String                                                                      | provider实例name       |
| zipkin | [ZipkinTracingProvider] object | zipkin协议provider自有配置 |
   
 表23ZipkinTracingProvider 
| 参数      | 参数类型    | 描述         |
|:---|:---|:---|
| service | String  | zipkin服务地址 |
| port    | Integer | zipkin服务端口 |
   
 表24MeshStatus 
| 参数              | 参数类型   | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
|:---|:---|:---|
| phase           | String | 网格状态，取值如下 - Running：运行中，表示网格处于正常运行状态   - Creating：创建中，表示网格正处于创建过程中   - CreateFailed：创建失败   - Deleting：删除中，表示网格正处于删除过程中   - DeleteFailed：删除失败   - Upgrading：升级中，表示网格正处于升级过程中   - UpgradeFailed：升级失败   - RollingBack：回滚中，表示网格正处于回滚过程中   - RollbackFailed：回滚失败    |
| updateTimestamp | String | 网格更新时间                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
   
**状态码：400**
表25响应Body参数 
| 参数        | 参数类型   | 描述   |
|:---|:---|:---|
| errorCode | String | 错误码  |
| errorMsg  | String | 错误描述 |
   
**状态码：500**
表26响应Body参数 
| 参数        | 参数类型   | 描述   |
|:---|:---|:---|
| errorCode | String | 错误码  |
| errorMsg  | String | 错误描述 |
   
#### 请求示例
无
#### 响应示例
**状态码：200**
```
{
  "kind" : "MeshList",
  "apiVersion" : "v1",
  "items" : [ {
    "kind" : "Mesh",
    "apiVersion" : "v1",
    "metadata" : {
      "name" : "mesh-test-api",
      "uid" : "a1efdc3e-xxxx-xxxx-xxxx-94bef433347e",
      "creationTimestamp" : "2025-04-10T07:48:37Z"
    },
    "spec" : {
      "type" : "InCluster",
      "version" : "1.18.7-r5",
      "config" : {
        "telemetryConfig" : {
          "metrics" : {
            "aom" : [ {
              "instanceID" : "602a5b7e-xxxx-xxxx-xxxx-4268c35b0424"
            } ]
          },
          "accessLogging" : {
            "lts" : [ {
              "logGroupID" : "b884eaeb-xxxx-xxxx-xxxx-f442de73c392",
              "logStreamID" : "362e11e8-xxxx-xxxx-xxxx-0afdc68da7d2"
            } ]
          },
          "tracing" : {
            "randomSamplingPercentage" : 1,
            "defaultProviders" : [ "zipkin" ],
            "extensionProviders" : [ {
              "name" : "zipkin",
              "zipkin" : {
                "service" : "zipkin.monitoring.svc.cluster.local",
                "port" : 9411
              }
            } ]
          }
        },
        "proxyConfig" : {
          "includeIPRanges" : "10.247.0.0/16"
        }
      },
      "extendParams" : {
        "clusters" : [ {
          "clusterID" : "cb0ef541-xxxx-xxxx-xxxx-0255ac1001b7"
        } ]
      }
    },
    "status" : {
      "phase" : "Running",
      "updateTimestamp" : "2025-04-10T07:58:43Z"
    }
  } ]
}
```
#### SDK代码示例
SDK代码示例如下。
#### Java
```
package com.huaweicloud.sdk.test;
import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.BasicCredentials;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
import com.huaweicloud.sdk.asm.v1.region.AsmRegion;
import com.huaweicloud.sdk.asm.v1.*;
import com.huaweicloud.sdk.asm.v1.model.*;
public class ListMeshesSolution {
    public static void main(String[] args) {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        String ak = System.getenv("CLOUD_SDK_AK");
        String sk = System.getenv("CLOUD_SDK_SK");
        String projectId = "{project_id}";
        ICredential auth = new BasicCredentials()
                .withProjectId(projectId)
                .withAk(ak)
                .withSk(sk);
        AsmClient client = AsmClient.newBuilder()
                .withCredential(auth)
                .withRegion(AsmRegion.valueOf("<YOUR REGION>"))
                .build();
        ListMeshesRequest request = new ListMeshesRequest();
        try {
            ListMeshesResponse response = client.listMeshes(request);
            System.out.println(response.toString());
        } catch (ConnectionException e) {
            e.printStackTrace();
        } catch (RequestTimeoutException e) {
            e.printStackTrace();
        } catch (ServiceResponseException e) {
            e.printStackTrace();
            System.out.println(e.getHttpStatusCode());
            System.out.println(e.getRequestId());
            System.out.println(e.getErrorCode());
            System.out.println(e.getErrorMsg());
        }
    }
}
```
#### Python
```
# coding: utf-8
import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkasm.v1.region.asm_region import AsmRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkasm.v1 import *
if __name__ == "__main__":
    # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak = os.environ["CLOUD_SDK_AK"]
    sk = os.environ["CLOUD_SDK_SK"]
    projectId = "{project_id}"
    credentials = BasicCredentials(ak, sk, projectId)
    client = AsmClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(AsmRegion.value_of("<YOUR REGION>")) \
        .build()
    try:
        request = ListMeshesRequest()
        response = client.list_meshes(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)
```
#### Go
```
package main
import (
"fmt"
"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    asm "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/asm/v1"
"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/asm/v1/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/asm/v1/region"
)
func main() {
    // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak := os.Getenv("CLOUD_SDK_AK")
    sk := os.Getenv("CLOUD_SDK_SK")
    projectId := "{project_id}"
    auth, err := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        WithProjectId(projectId).
        SafeBuild()
    if err != nil {
        fmt.Println(err)
        return
    }
    hcClient, err := asm.AsmClientBuilder().
         WithRegion(region.ValueOf("<YOUR REGION>")).
         WithCredential(auth).
         SafeBuild()
    if err != nil {
        fmt.Println(err)
        return
    }
    client := asm.NewAsmClient(hcClient)
    request := &model.ListMeshesRequest{}
response, err := client.ListMeshes(request)
if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}
```
#### 更多
更多编程语言的SDK代码示例，请参见[API Explorer](https://console.huaweicloud.com/apiexplorer/#/openapi/ASM/sdk?api=ListMeshes)的代码示例页签，可生成自动对应的SDK代码示例。
#### 状态码
| 状态码 | 描述               |
|:---|:---|
| 200 | 表示获取网格列表成功       |
| 400 | 用户提供的参数有问题，未通过校验 |
| 500 | 查询过程中出现问题        |
   
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-asm/ErrorCode.html)。
