
# 查询AddonTemplates列表 - ListAddonTemplates
#### 功能介绍
插件模板查询接口，查询插件信息。
#### 调用方法
请参见[如何调用API](https://support.huaweicloud.com/api-cce/cce_02_0099.html)。
#### 授权信息
账号具备所有API的调用权限，如果使用账号下的IAM用户调用当前API，该IAM用户需具备调用API所需的权限。
- 如果使用角色与策略授权，具体权限要求请参见[权限和授权项](https://support.huaweicloud.com/api-cce/cce_02_0395.html)。
- 如果使用身份策略授权，需具备如下身份策略权限。
  
  | 授权项              | 访问级别 | 资源类型（\*为必须） | 条件键 | 别名 | 依赖的授权项 |
  |:---|:---|:---|:---|:---|:---|
  | cce:cluster:list | List | cluster \*  | -   | -  | -      |
     
  
 
#### URI
GET /api/v3/addontemplates
表1Query参数 
| 参数                  | 是否必选 | 参数类型   | 描述                                                                                                                                                                                                                                                                                                                                                  |
|:---|:---|:---|:---|
| addon_template_name | 否    | String | **参数解释**： 指定的插件名称或插件别名，不填写则查询列表。 **约束限制**： 不涉及 **取值范围**： 以字母或数字开头和结尾，支持字母、数字、连字符(-)、下划线(_)和点号(.)，长度范围2\~30位。 **默认取值**： 不涉及 |
   
#### 请求参数
表2请求Header参数 
| 参数           | 是否必选 | 参数类型   | 描述                                                                                                                                                                                                                                                                                                                                                                                                                |
|:---|:---|:---|:---|
| Content-Type | 是    | String | **参数解释：** 消息体的类型（格式），默认为application/json，有其他取值时会在具体接口中专门说明。 **约束限制：** GET方法不做校验 **取值范围：** 不涉及 **默认取值：** 不涉及                                                                              |
| X-Auth-Token | 是    | String | **参数解释：** 调用接口的认证方式分为Token和AK/SK两种，如果您使用的Token方式，此参数为必填，请填写Token的值，获取方式请参见[获取token](https://support.huaweicloud.com/api-cce/cce_02_0004.html)。 **约束限制：** 不涉及 **取值范围：** 不涉及 **默认取值：** 不涉及 |
   
#### 响应参数
**状态码：200**
表3响应Body参数 
| 参数         | 参数类型                                                                   | 描述                                                                                                                                                                                                                                                                                                 |
|:---|:---|:---|
| kind       | String                                                                 | **参数解释**： API类型，固定值"Addon"，该值不可修改。 **取值范围**： - Addon    |
| apiVersion | String                                                                 | **参数解释**： API版本，固定值"v3"，该值不可修改。 **取值范围**： - v3          |
| items      | Array of [AddonTemplate] objects | **参数解释**： 插件模板列表。 **取值范围**： 不涉及                                                                                                                                                                       |
   
 表4AddonTemplate 
| 参数         | 参数类型                                                         | 描述                                                                                                                                                                                                                                                                                                 |
|:---|:---|:---|
| kind       | String                                                       | **参数解释**： API类型，固定值"Addon"，该值不可修改。 **取值范围**： - Addon    |
| apiVersion | String                                                       | **参数解释**： API版本，固定值"v3"，该值不可修改。 **取值范围**： - v3          |
| metadata   | [AddonMetadata] object | **参数解释**： 插件基本信息，集合类的元素类型，包含一组由不同名称定义的属性。 **取值范围**： 不涉及                                                                                                                                               |
| spec       | [Templatespec] object   | **参数解释**： spec是集合类的元素类型，内容为插件模板具体信息，插件模板的详细描述主体部分都在spec中给出。 **取值范围**： 不涉及                                                                                                                             |
   
 表5AddonMetadata 
| 参数                | 参数类型                 | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
|:---|:---|:---|
| uid               | String               | **参数解释**： 插件实例唯一ID标识，创建成功后系统自动生成。 **取值范围**： 不涉及                                                                                                                                                                                                                                                                                                                                              |
| name              | String               | **参数解释**： 插件名称 **取值范围**： 不涉及                                                                                                                                                                                                                                                                                                                                                                 |
| alias             | String               | **参数解释**： 插件别名。 **取值范围**： 不涉及                                                                                                                                                                                                                                                                                                                                                                |
| labels            | Map\<String,String\> | **参数解释**： 插件标签，key/value对格式，接口保留字段，填写不会生效。 **取值范围**： 不涉及                                                                                                                                                                                                                                                                                                                                     |
| annotations       | Map\<String,String\> | **参数解释**： 插件注解，由key/value组成。 **取值范围**： - 安装时固定值为{"addon.install/type":"install"}   - 升级时固定值为{"addon.upgrade/type":"upgrade"}    |
| updateTimestamp   | String               | **参数解释**： 更新时间 **取值范围**： 不涉及                                                                                                                                                                                                                                                                                                                                                                 |
| creationTimestamp | String               | **参数解释**： 创建时间，创建成功后系统自动生成，填写无效。 **取值范围**： 不涉及                                                                                                                                                                                                                                                                                                                                               |
   
 表6Templatespec 
| 参数          | 参数类型                                                         | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                     |
|:---|:---|:---|
| type        | String                                                       | **参数解释**： 插件模板类型。 **取值范围**： - helm：表示使用Helm包进行部署的模板类型   - static：表示静态模板类型    |
| require     | Boolean                                                      | **参数解释**： 是否为必安装插件。 **取值范围**： - true：必安装插件   - false：非必安装插件                  |
| labels      | Array of strings                                             | **参数解释**： 模板所属分组。 **取值范围**： 不涉及                                                                                                                                                                                                                                                                                                           |
| logoURL     | String                                                       | **参数解释**： Logo图片地址。 **取值范围**： 不涉及                                                                                                                                                                                                                                                                                                         |
| readmeURL   | String                                                       | **参数解释**： 插件详情描述及使用说明。 **取值范围**： 不涉及                                                                                                                                                                                                                                                                                                      |
| description | String                                                       | **参数解释**： 模板描述。 **取值范围**： 不涉及                                                                                                                                                                                                                                                                                                             |
| versions    | Array of [Versions] objects | **参数解释**： 模板具体版本详情。 **取值范围**： 不涉及                                                                                                                                                                                                                                                                                                         |
   
 表7Versions 
| 参数                | 参数类型                                                                       | 描述                                                                                                                                                                                                                                                                                                                                                                                                                    |
|:---|:---|:---|
| version           | String                                                                     | **参数解释**： 插件版本号。 **取值范围**： 不涉及                                                                                                                                                                                                                                                                                           |
| input             | Object                                                                     | **参数解释**： 插件安装参数。 **取值范围**： 不涉及                                                                                                                                                                                                                                                                                          |
| stable            | Boolean                                                                    | **参数解释**： 是否为稳定版本。 **取值范围**： - true：稳定版本   - false：非稳定版本    |
| translate         | Object                                                                     | **参数解释**： 供界面使用的翻译信息。 **取值范围**： 不涉及                                                                                                                                                                                                                                                                                      |
| supportVersions   | Array of [SupportVersions] objects | **参数解释**： 支持集群版本号。 **取值范围**： 不涉及                                                                                                                                                                                                                                                                                         |
| creationTimestamp | String                                                                     | **参数解释**： 创建时间。 **取值范围**： 不涉及                                                                                                                                                                                                                                                                                            |
| updateTimestamp   | String                                                                     | **参数解释**： 更新时间。 **取值范围**： 不涉及                                                                                                                                                                                                                                                                                            |
   
 表8SupportVersions 
| 参数             | 参数类型             | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
|:---|:---|:---|
| clusterType    | String           | **参数解释**： 支持的集群类型。 **取值范围**： - VirtualMachine：CCE集群，控制节点架构为X86   - ARM64：鲲鹏集群，控制节点架构为鲲鹏                                                                                                                                 |
| clusterVersion | Array of strings | **参数解释**： 支持的集群版本（正则表达式）。 **取值范围**： 不涉及                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| category       | Array of strings | **参数解释**： 作用的集群类型。 **取值范围**： - CCE：CCE Standard集群   - Turbo：CCE Turbo集群   - Autopilot：CCE Autopilot集群    |
   
#### 请求示例
无
#### 响应示例
**状态码：200**
表示查询插件模板列表成功。
```
{
  "kind" : "Addon",
  "apiVersion" : "v3",
  "items" : [ {
    "kind" : "Addon",
    "apiVersion" : "v3",
    "metadata" : {
      "uid" : "coredns",
      "name" : "coredns",
      "alias" : "coredns",
      "creationTimestamp" : "2018-11-04T16:15:56Z",
      "updateTimestamp" : "2022-01-11T14:32:10Z"
    },
    "spec" : {
      "type" : "helm",
      "require" : true,
      "labels" : [ "ServiceDiscovery" ],
      "logoURL" : "",
      "description" : "CoreDNS is a DNS server that chains plugins and provides Kubernetes DNS Services",
      "versions" : [ {
        "version" : "1.13.6",
        "input" : {
          "basic" : {
            "cluster_ip" : "10.247.3.10",
            "ipv6" : false,
            "platform" : "linux-amd64",
            "swr_addr" : "100.125.16.65:20202",
            "swr_user" : "hwofficial"
          },
          "parameters" : {
            "custom" : {
              "stub_domains" : "",
              "upstream_nameservers" : ""
            },
            "flavor1" : {
              "name" : 2500,
              "replicas" : 2,
              "resources" : [ {
                "limitsCpu" : "500m",
                "limitsMem" : "512Mi",
                "name" : "coredns",
                "requestsCpu" : "500m",
                "requestsMem" : "512Mi"
              } ]
            },
            "flavor2" : {
              "name" : 5000,
              "replicas" : 2,
              "resources" : [ {
                "limitsCpu" : "1000m",
                "limitsMem" : "1024Mi",
                "name" : "coredns",
                "requestsCpu" : "1000m",
                "requestsMem" : "1024Mi"
              } ]
            },
            "flavor3" : {
              "name" : 10000,
              "replicas" : 2,
              "resources" : [ {
                "limitsCpu" : "2000m",
                "limitsMem" : "2048Mi",
                "name" : "coredns",
                "requestsCpu" : "2000m",
                "requestsMem" : "2048Mi"
              } ]
            },
            "flavor4" : {
              "name" : 20000,
              "replicas" : 4,
              "resources" : [ {
                "limitsCpu" : "2000m",
                "limitsMem" : "2048Mi",
                "name" : "coredns",
                "requestsCpu" : "2000m",
                "requestsMem" : "2048Mi"
              } ]
            }
          }
        },
        "stable" : true,
        "translate" : {
          "en_US" : {
            "addon" : {
              "changeLog" : "Support for clusters with new version",
              "description" : "CoreDNS is a DNS server that chains plugins and provides Kubernetes DNS Services"
            },
            "description" : {
              "Parameters.custom.stub_domains" : "The target nameserver may itself be a Kubernetes service. For instance, you can run your own copy of dnsmasq to export custom DNS names into the ClusterDNS namespace, a JSON map using a DNS suffix key (e.g. “acme.local”) and a value consisting of a JSON array of DNS IPs.",
              "Parameters.custom.upstream_nameservers" : "If specified, then the values specified replace the nameservers taken by default from the node’s /etc/resolv.conf. Limits:a maximum of three upstream nameservers can be specified, A JSON array of DNS IPs.",
              "Parameters.flavor1.description" : "Concurrent domain name resolution ability  -  External domain name：2500 qps,  Internal domain name：10000 qps",
              "Parameters.flavor1.name" : 2500,
              "Parameters.flavor2.description" : "Concurrent domain name resolution ability  -  External domain name：5000 qps, Internal domain name：20000 qps",
              "Parameters.flavor2.name" : 5000,
              "Parameters.flavor3.description" : "Concurrent domain name resolution ability  -  External domain name：10000 qps, Internal domain name：40000 qps",
              "Parameters.flavor3.name" : 10000,
              "Parameters.flavor4.description" : "Concurrent domain name resolution ability  -  External domain name：20000 qps, Internal domain name：80000 qps",
              "Parameters.flavor4.name" : 20000
            },
            "key" : {
              "Parameters.custom.stub_domains" : "stub domain",
              "Parameters.custom.upstream_nameservers" : "upstream nameservers"
            }
          },
          "fr_FR" : {
            "addon" : {
              "changeLog" : "Prise en charge des clusters avec une nouvelle version",
              "description" : "Un serveur DNS qui enchaîne les plug-ins et fournit des services DNS Kubernetes."
            },
            "description" : {
              "Parameters.custom.stub_domains" : "Le serveur de noms cible peut lui-même être un service Kubernetes. Par exemple, vous pouvez exécuter votre propre copie de dnsmasq pour exporter des noms DNS personnalisés dans l'espace de noms ClusterDNS, une carte JSON à l'aide d'une clé de suffixe DNS (par exemple, «acme.local») et une valeur constituée d'un tableau JSON d'adresses IP DNS.",
              "Parameters.custom.upstream_nameservers" : "Si spécifié, les valeurs spécifiées remplacent les serveurs de noms pris par défaut dans le fichier /etc/resolv.conf du nœud. Limites: un maximum de trois serveurs de noms en amont peuvent être spécifiés, un tableau JSON d'adresses IP DNS.",
              "Parameters.flavor1.description" : "Capacité de résolution de nom de domaine simultanée - Nom de domaine externe: 2500 qps, Nom de domaine interne: 10000 qp",
              "Parameters.flavor1.name" : 2500,
              "Parameters.flavor2.description" : "Capacité de résolution de nom de domaine simultanée - Nom de domaine externe: 5000 qps, Nom de domaine interne: 20000 qp",
              "Parameters.flavor2.name" : 5000,
              "Parameters.flavor3.description" : "Capacité de résolution de nom de domaine simultanée - Nom de domaine externe: 10000 qps, Nom de domaine interne: 40000 qp",
              "Parameters.flavor3.name" : 10000,
              "Parameters.flavor4.description" : "Capacité de résolution de nom de domaine simultanée - Nom de domaine externe: 20000 qps, Nom de domaine interne: 80000 qp",
              "Parameters.flavor4.name" : 20000
            },
            "key" : {
              "Parameters.custom.stub_domains" : "stub domain",
              "Parameters.custom.upstream_nameservers" : "serveurs de noms en amont"
            }
          },
          "zh_CN" : {
            "addon" : {
              "changeLog" : "",
              "description" : ""
            },
            "description" : {
              "Parameters.custom.stub_domains" : "",
              "Parameters.custom.upstream_nameservers" : "",
              "Parameters.flavor1.description" : "",
              "Parameters.flavor1.name" : 2500,
              "Parameters.flavor2.description" : "",
              "Parameters.flavor2.name" : 5000,
              "Parameters.flavor3.description" : "",
              "Parameters.flavor3.name" : 10000,
              "Parameters.flavor4.description" : "",
              "Parameters.flavor4.name" : 20000
            },
            "key" : {
              "Parameters.custom.stub_domains" : "",
              "Parameters.custom.upstream_nameservers" : ""
            }
          }
        },
        "supportVersions" : [ {
          "clusterType" : "VirtualMachine",
          "clusterVersion" : [ "v1.13.*" ]
        }, {
          "clusterType" : "BareMetal",
          "clusterVersion" : [ "v1.13.*" ]
        }, {
          "clusterType" : "ARM64",
          "clusterVersion" : [ "v1.13.*" ]
        } ],
        "creationTimestamp" : "2021-03-18T12:51:05Z",
        "updateTimestamp" : "2021-03-18T12:51:05Z"
      } ]
    }
  } ]
}
```
#### 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.cce.v3.region.CceRegion;
  import com.huaweicloud.sdk.cce.v3.*;
  import com.huaweicloud.sdk.cce.v3.model.*;
  public class ListAddonTemplatesSolution {
      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");
          ICredential auth = new BasicCredentials()
                  .withAk(ak)
                  .withSk(sk);
          CceClient client = CceClient.newBuilder()
                  .withCredential(auth)
                  .withRegion(CceRegion.valueOf("<YOUR REGION>"))
                  .build();
          ListAddonTemplatesRequest request = new ListAddonTemplatesRequest();
          try {
              ListAddonTemplatesResponse response = client.listAddonTemplates(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 huaweicloudsdkcce.v3.region.cce_region import CceRegion
  from huaweicloudsdkcore.exceptions import exceptions
  from huaweicloudsdkcce.v3 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"]
      credentials = BasicCredentials(ak, sk)
      client = CceClient.new_builder() \
          .with_credentials(credentials) \
          .with_region(CceRegion.value_of("<YOUR REGION>")) \
          .build()
      try:
          request = ListAddonTemplatesRequest()
          response = client.list_addon_templates(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"
      cce "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cce/v3"
  "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cce/v3/model"
      region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cce/v3/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")
      auth, err := basic.NewCredentialsBuilder().
          WithAk(ak).
          WithSk(sk).
          SafeBuild()
      if err != nil {
          fmt.Println(err)
          return
      }
      hcClient, err := cce.CceClientBuilder().
           WithRegion(region.ValueOf("<YOUR REGION>")).
           WithCredential(auth).
           SafeBuild()
      if err != nil {
          fmt.Println(err)
          return
      }
      client := cce.NewCceClient(hcClient)
      request := &model.ListAddonTemplatesRequest{}
  response, err := client.ListAddonTemplates(request)
  if err == nil {
          fmt.Printf("%+v\n", response)
      } else {
          fmt.Println(err)
      }
  }
  ```
- [更多]
  更多编程语言的SDK代码示例，请参见[API Explorer](https://console.huaweicloud.com/apiexplorer/#/openapi/CCE/sdk?api=ListAddonTemplates)的代码示例页签，可生成自动对应的SDK代码示例。
#### 状态码
| 状态码 | 描述            |
|:---|:---|
| 200 | 表示查询插件模板列表成功。 |
   
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-cce/ErrorCode.html)。
