更新时间:2024-09-30 GMT+08:00

查询AddonTemplates列表

功能介绍

插件模板查询接口,查询插件信息。

调用方法

请参见如何调用API

URI

GET /autopilot/v3/addontemplates

表1 Query参数

参数

是否必选

参数类型

描述

addon_template_name

String

指定的插件名称或插件别名,不填写则查询列表。

请求参数

表2 请求Header参数

参数

是否必选

参数类型

描述

Content-Type

String

参数解释:

消息体的类型(格式)

约束限制:

GET方法不做校验

取值范围:

  • application/json

  • application/json;charset=utf-8

  • application/x-pem-file

默认取值:

不涉及

X-Auth-Token

String

参数解释:

调用接口的认证方式分为Token和AK/SK两种,如果您使用的Token方式,此参数为必填,请填写Token的值,获取方式请参见获取token

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

响应参数

状态码: 200

表3 响应Body参数

参数

参数类型

描述

kind

String

API类型,固定值“Addon”,该值不可修改。

apiVersion

String

API版本,固定值“v3”,该值不可修改。

items

Array of AddonTemplate objects

插件模板列表

表4 AddonTemplate

参数

参数类型

描述

kind

String

API类型,固定值“Addon”,该值不可修改。

apiVersion

String

API版本,固定值“v3”,该值不可修改。

metadata

AddonMetadata object

基本信息,为集合类的元素类型,包含一组由不同名称定义的属性

spec

Templatespec object

spec是集合类的元素类型,内容为插件模板具体信息,插件模板的详细描述主体部分都在spec中给出

表5 AddonMetadata

参数

参数类型

描述

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

创建时间

表6 Templatespec

参数

参数类型

描述

type

String

模板类型(helm,static)

require

Boolean

是否为必安装插件

labels

Array of strings

模板所属分组

logoURL

String

Logo图片地址

readmeURL

String

插件详情描述及使用说明

description

String

模板描述

versions

Array of Versions objects

模板具体版本详情

表7 Versions

参数

参数类型

描述

version

String

插件版本号

input

Object

插件安装参数

stable

Boolean

是否为稳定版本

translate

Object

供界面使用的翻译信息

supportVersions

Array of SupportVersions objects

支持集群版本号

creationTimestamp

String

创建时间

updateTimestamp

String

更新时间

表8 SupportVersions

参数

参数类型

描述

clusterType

String

支持的集群类型

clusterVersion

Array of strings

支持的集群版本(正则表达式)

请求示例

响应示例

状态码: 200

OK

{
  "kind" : "Addon",
  "apiVersion" : "v3",
  "items" : [ {
    "kind" : "Addon",
    "apiVersion" : "v3",
    "metadata" : {
      "uid" : "cie-collector",
      "name" : "cie-collector",
      "alias" : "kube-prometheus-stack",
      "creationTimestamp" : "2024-01-26T09:06:25Z",
      "updateTimestamp" : "2024-01-26T09:06:26Z"
    },
    "spec" : {
      "type" : "helm",
      "labels" : [ "CloudNativeObservability" ],
      "description" : "kube-prometheus-stack collects Kubernetes manifests, Prometheus rules combined with documentation and scripts to provide easy to operate end-to-end Kubernetes cluster monitoring with Prometheus using the Prometheus Operator.",
      "versions" : [ {
        "version" : "3.9.3",
        "input" : {
          "basic" : {
            "aom_url" : "100.79.29.98:8149",
            "region_id" : "cn-north-7",
            "swr_addr" : "swr.cn-north-7.myhuaweicloud.com",
            "swr_user" : "autopilot-official"
          },
          "parameters" : {
            "autopilot-flavor1" : {
              "category" : [ "Autopilot" ],
              "deploy_mode" : "server",
              "description" : "Recommanded when the number of containers in the cluster does not exceed 2000.",
              "name" : "Autopilot-Small(<=2000 containers)",
              "resources" : [ {
                "limitsCpu" : "500m",
                "limitsMem" : "1Gi",
                "name" : "prometheusOperator"
              }, {
                "limitsCpu" : "8",
                "limitsMem" : "32Gi",
                "name" : "prometheus"
              }, {
                "limitsCpu" : "1",
                "limitsMem" : "2Gi",
                "name" : "thanosSidecar"
              }, {
                "limitsCpu" : "4",
                "limitsMem" : "16Gi",
                "name" : "thanosQuery"
              }, {
                "limitsCpu" : "4",
                "limitsMem" : "16Gi",
                "name" : "adapter"
              }, {
                "limitsCpu" : "500m",
                "limitsMem" : "1Gi",
                "name" : "kubeStateMetrics"
              } ]
            },
            "autopilot-flavor2" : {
              "category" : [ "Autopilot" ],
              "deploy_mode" : "server",
              "description" : "Recommanded when the number of containers in the cluster does not exceed 5000.",
              "name" : "Autopilot-Medium(<=5000 containers)",
              "resources" : [ {
                "limitsCpu" : "500m",
                "limitsMem" : "1Gi",
                "name" : "prometheusOperator"
              }, {
                "limitsCpu" : "16",
                "limitsMem" : "64Gi",
                "name" : "prometheus"
              }, {
                "limitsCpu" : "2",
                "limitsMem" : "4Gi",
                "name" : "thanosSidecar"
              }, {
                "limitsCpu" : "8",
                "limitsMem" : "32Gi",
                "name" : "thanosQuery"
              }, {
                "limitsCpu" : "4",
                "limitsMem" : "32Gi",
                "name" : "adapter"
              }, {
                "limitsCpu" : "1",
                "limitsMem" : "2Gi",
                "name" : "kubeStateMetrics"
              } ]
            },
            "autopilot-flavor4" : {
              "category" : [ "Autopilot" ],
              "deploy_mode" : "server",
              "description" : "Custom configuration for this addon.",
              "name" : "custom-resources-autopilot-server",
              "resources" : [ {
                "limitsCpu" : "500m",
                "limitsMem" : "1Gi",
                "name" : "prometheusOperator"
              }, {
                "limitsCpu" : "16",
                "limitsMem" : "64Gi",
                "name" : "prometheus"
              }, {
                "limitsCpu" : "2",
                "limitsMem" : "4Gi",
                "name" : "thanosSidecar"
              }, {
                "limitsCpu" : "8",
                "limitsMem" : "32Gi",
                "name" : "thanosQuery"
              }, {
                "limitsCpu" : "4",
                "limitsMem" : "32Gi",
                "name" : "adapter"
              }, {
                "limitsCpu" : "1",
                "limitsMem" : "2Gi",
                "name" : "kubeStateMetrics"
              } ]
            },
            "autopilot-flavor5" : {
              "category" : [ "Autopilot" ],
              "deploy_mode" : "agent",
              "description" : "Recommanded flavor for agent mode when the number of containers in the cluster does not exceed 2000.",
              "is_default" : true,
              "name" : "Autopilot-Agent-Small(<=2000 containers)",
              "resources" : [ {
                "limitsCpu" : "1",
                "limitsMem" : "1Gi",
                "name" : "prometheusOperator",
                "requestsCpu" : "1",
                "requestsMem" : "1Gi"
              }, {
                "limitsCpu" : "1800m",
                "limitsMem" : "2900Mi",
                "name" : "prometheus",
                "requestsCpu" : "1800m",
                "requestsMem" : "2900Mi"
              }, {
                "limitsCpu" : "1",
                "limitsMem" : "1Gi",
                "name" : "kubeStateMetrics",
                "requestsCpu" : "1",
                "requestsMem" : "1Gi"
              }, {
                "limitsMem" : "500Mi",
                "name" : "nodeExporter",
                "requestsMem" : "100m"
              } ]
            },
            "autopilot-flavor6" : {
              "category" : [ "Autopilot" ],
              "deploy_mode" : "agent",
              "description" : "Recommanded flavor for agent mode when the number of containers in the cluster does not exceed 5000.",
              "name" : "Autopilot-Agent-Medium(<=5000 containers)",
              "resources" : [ {
                "limitsCpu" : "500m",
                "limitsMem" : "1Gi",
                "name" : "prometheusOperator"
              }, {
                "limitsCpu" : "4",
                "limitsMem" : "8Gi",
                "name" : "prometheus"
              }, {
                "limitsCpu" : "500m",
                "limitsMem" : "1Gi",
                "name" : "kubeStateMetrics"
              } ]
            },
            "autopilot-flavor8" : {
              "category" : [ "Autopilot" ],
              "deploy_mode" : "agent",
              "description" : "Custom flavor for agent mode",
              "name" : "custom-resources-autopilot-agent",
              "resources" : [ {
                "limitsCpu" : "500m",
                "limitsMem" : "1Gi",
                "name" : "prometheusOperator"
              }, {
                "limitsCpu" : "4",
                "limitsMem" : "8Gi",
                "name" : "prometheus"
              }, {
                "limitsCpu" : "500m",
                "limitsMem" : "1Gi",
                "name" : "kubeStateMetrics"
              } ]
            },
            "custom" : {
              "aom_app_key" : "",
              "aom_app_secret" : "",
              "aom_asm_app_key" : "",
              "aom_asm_app_secret" : "",
              "aom_asm_enable" : false,
              "aom_asm_insecure_skip_verify" : true,
              "aom_asm_instance_id" : "",
              "aom_asm_keep_regexp" : "istio.*",
              "aom_asm_project_id" : "",
              "aom_asm_remote_write_url" : "",
              "aom_auth_type" : "Bearer",
              "aom_enable" : false,
              "aom_insecure_skip_verify" : true,
              "aom_instance_id" : "",
              "aom_project_id" : "",
              "aom_region_id" : "",
              "aom_remote_read_url" : "",
              "aom_remote_write_url" : "",
              "appCode" : "",
              "appConfig" : {
                "adapter" : {
                  "nodeAffinity_key" : "",
                  "nodeAffinity_values" : "",
                  "tolerations_effect" : "NoSchedule",
                  "tolerations_key" : "",
                  "tolerations_operator" : "Exists"
                },
                "alertmanager" : {
                  "nodeAffinity_key" : "",
                  "nodeAffinity_values" : "",
                  "tolerations_effect" : "NoSchedule",
                  "tolerations_key" : "",
                  "tolerations_operator" : "Exists"
                },
                "kubeEventExporter" : {
                  "nodeAffinity_key" : "",
                  "nodeAffinity_values" : "",
                  "tolerations_effect" : "NoSchedule",
                  "tolerations_key" : "",
                  "tolerations_operator" : "Exists"
                },
                "kubeStateMetrics" : {
                  "nodeAffinity_key" : "",
                  "nodeAffinity_values" : "",
                  "tolerations_effect" : "NoSchedule",
                  "tolerations_key" : "",
                  "tolerations_operator" : "Exists"
                },
                "prometheusOperator" : {
                  "nodeAffinity_key" : "",
                  "nodeAffinity_values" : "",
                  "tolerations_effect" : "NoSchedule",
                  "tolerations_key" : "",
                  "tolerations_operator" : "Exists"
                },
                "prometheusServer" : {
                  "nodeAffinity_key" : "",
                  "nodeAffinity_values" : "",
                  "tolerations_effect" : "NoSchedule",
                  "tolerations_key" : "",
                  "tolerations_operator" : "Exists"
                },
                "thanosQuery" : {
                  "nodeAffinity_key" : "",
                  "nodeAffinity_values" : "",
                  "tolerations_effect" : "NoSchedule",
                  "tolerations_key" : "",
                  "tolerations_operator" : "Exists"
                }
              },
              "basic_auth_password_third" : "",
              "basic_auth_username_third" : "",
              "bearer_token" : "",
              "caCert" : "",
              "certFile" : "",
              "cieInstanceId" : "",
              "cie_url" : "",
              "cluster" : "",
              "clusterId" : "",
              "cluster_category" : "CCE",
              "crd_install" : true,
              "deploy_mode" : "agent",
              "emptydir" : {
                "enabled" : false,
                "sizeLimit" : "10G"
              },
              "enableGcrypto" : true,
              "enableRemote" : false,
              "enableRemoteWrite" : false,
              "enable_autopilot" : true,
              "enable_cpd" : true,
              "enable_custom_metrics" : true,
              "enable_grafana" : true,
              "enable_nodeAffinity" : false,
              "enable_tolerations" : false,
              "enablethird" : false,
              "grafana_pvc_exist" : false,
              "highAvailability" : false,
              "insecureSkipVerify" : false,
              "insecure_skip_verify_third" : false,
              "install_with_cluster" : false,
              "keyFile" : "",
              "ksm_shards" : 1,
              "lightweight" : true,
              "lightweight_sts" : true,
              "lightweight_sts_use_pvc" : false,
              "local_hpa" : false,
              "max_wal_time" : "30m",
              "min_wal_time" : "1m",
              "nodeAffinity_key" : "",
              "nodeAffinity_values" : "",
              "projectId" : "",
              "region" : "cn-north-7",
              "retention" : "1d",
              "scrapeInterval" : "15s",
              "scrape_insecure_skip_verify" : true,
              "shards" : 1,
              "storage_class" : "csi-disk-topology",
              "storage_size" : "10Gi",
              "storage_type" : "SAS",
              "subnetId" : "",
              "supportServerModeSharding" : false,
              "tolerations_effect" : "NoSchedule",
              "tolerations_key" : "",
              "tolerations_operator" : "Exists",
              "truncate_frequency" : "30m",
              "url_third" : ""
            }
          },
          "scenarios" : [ {
            "category" : [ "Autopilot" ],
            "custom" : {
              "cluster_category" : "Autopilot",
              "enableGcrypto" : false,
              "enable_cpd" : false,
              "storage_class" : "csi-disk"
            },
            "name" : "autopilot-config"
          } ]
        },
        "stable" : true,
        "translate" : {
          "en_US" : {
            "addon" : {
              "changeLog" : "The Autopilot cluster is supported.",
              "description" : "kube-prometheus-stack collects Kubernetes manifests, Grafana dashboards, and Prometheus rules combined with documentation and scripts to provide easy to operate end-to-end Kubernetes cluster monitoring with Prometheus using the Prometheus Operator. *Attention:kube-prometheus-stack is system monitoring component, When resources are insufficient, Kubernetes preferentially ensures pod scheduling."
            },
            "description" : {
              "Parameters.autopilot-flavor1.description" : "Recommanded when the number of containers in the cluster does not exceed 2000.",
              "Parameters.autopilot-flavor1.name" : "Small(<=2000 containers)",
              "Parameters.autopilot-flavor2.description" : "Recommanded when the number of containers in the cluster does not exceed 5000.",
              "Parameters.autopilot-flavor2.name" : "Medium(<=5000 containers)",
              "Parameters.autopilot-flavor3.description" : "Recommanded when the number of containers in the cluster exceeds 5000.",
              "Parameters.autopilot-flavor3.name" : "Large(>5000 containers)",
              "Parameters.autopilot-flavor4.description" : "Custom configuration for this addon.",
              "Parameters.autopilot-flavor4.name" : "Custom",
              "Parameters.autopilot-flavor5.description" : "Recommanded when the number of containers in the cluster does not exceed 2000.",
              "Parameters.autopilot-flavor5.name" : "Small(<=2000 containers)",
              "Parameters.autopilot-flavor6.description" : "Recommanded when the number of containers in the cluster does not exceed 5000.",
              "Parameters.autopilot-flavor6.name" : "Medium(<=5000 containers)",
              "Parameters.autopilot-flavor7.description" : "Recommanded when the number of containers in the cluster exceeds 5000.",
              "Parameters.autopilot-flavor7.name" : "Large(>5000 containers)",
              "Parameters.autopilot-flavor8.description" : "Custom configuration for this addon.",
              "Parameters.autopilot-flavor8.name" : "Custom",
              "Parameters.custom.deploy_mode" : "prometheus deploy mode",
              "Parameters.custom.highAvailability" : "high availability of prometheus and kube-event-exporter",
              "Parameters.custom.region" : "Availability region",
              "Parameters.custom.retention" : "Prometheus data retention period",
              "Parameters.custom.shards" : "Number of prometheus shards to distribute targets onto",
              "Parameters.custom.storage_size" : "Prometheus server data Persistent Volume size",
              "Parameters.custom.storage_type" : "Prometheus server data Persistent Volume Storage Class",
              "Parameters.custom.zone" : "Availability zone",
              "Parameters.flavor1.description" : "Just a demo for this addon. Recommanded when the number of containers in the cluster does not exceed 100.",
              "Parameters.flavor1.name" : "Demo(<=100 containers)",
              "Parameters.flavor2.description" : "Recommanded when the number of containers in the cluster does not exceed 2000.",
              "Parameters.flavor2.name" : "Small(<=2000 containers)",
              "Parameters.flavor3.description" : "Recommanded when the number of containers in the cluster does not exceed 5000.",
              "Parameters.flavor3.name" : "Medium(<=5000 containers)",
              "Parameters.flavor4.description" : "Recommanded when the number of containers in the cluster exceeds 5000.",
              "Parameters.flavor4.name" : "Large(>5000 containers)",
              "Parameters.flavor5.description" : "Custom configuration for this addon.",
              "Parameters.flavor5.name" : "custom-resources",
              "Parameters.flavor6.description" : "Default configuration for this addon.",
              "Parameters.flavor6.name" : "Default",
              "Parameters.flavor7.description" : "Custom configuration for this addon.",
              "Parameters.flavor7.name" : "Custom"
            },
            "key" : {
              "Parameters.custom.deploy_mode" : "prometheus deploy mode",
              "Parameters.custom.highAvailability" : "high availability",
              "Parameters.custom.region" : "availability region",
              "Parameters.custom.retention" : "data retention period",
              "Parameters.custom.storage_size" : "data Persistent Volume size",
              "Parameters.custom.storage_type" : "data Persistent Volume Storage Class",
              "Parameters.custom.zone" : "availability zone"
            }
          },
          "zh_CN" : {
            "addon" : {
              "changeLog" : "新增支持autopilot集群。",
              "description" : "kube-prometheus-stack通过使用Prometheus-operator和Prometheus,提供简单易用的端到端Kubernetes集群监控能力。*注意:kube-prometheus-stack为系统监控插件,当集群资源不足时,Kubernetes会优先保证插件pod的调度。"
            },
            "description" : {
              "Parameters.autopilot-flavor1.description" : "建议在集群中的容器数目不超过2000时使用。",
              "Parameters.autopilot-flavor1.name" : "小规格(2000容器以内)",
              "Parameters.autopilot-flavor2.description" : "建议在集群中的容器数目不超过5000时使用。",
              "Parameters.autopilot-flavor2.name" : "中规格(5000容器以内)",
              "Parameters.autopilot-flavor3.description" : "建议集群中容器数目超过5000时使用此规格。",
              "Parameters.autopilot-flavor3.name" : "大规格(超过5000容器)",
              "Parameters.autopilot-flavor4.description" : "自定义资源配置",
              "Parameters.autopilot-flavor4.name" : "自定义",
              "Parameters.autopilot-flavor5.description" : "建议在集群中的容器数目不超过2000时使用。",
              "Parameters.autopilot-flavor5.name" : "小规格(2000容器以内)",
              "Parameters.autopilot-flavor6.description" : "建议在集群中的容器数目不超过5000时使用。",
              "Parameters.autopilot-flavor6.name" : "中规格(5000容器以内)",
              "Parameters.autopilot-flavor7.description" : "建议集群中容器数目超过5000时使用此规格。",
              "Parameters.autopilot-flavor7.name" : "大规格(超过5000容器)",
              "Parameters.autopilot-flavor8.description" : "自定义资源配置",
              "Parameters.autopilot-flavor8.name" : "自定义",
              "Parameters.custom.deploy_mode" : "Prometheus部署模式",
              "Parameters.custom.highAvailability" : "高可用方式部署普罗米修斯服务与k8s事件采集上报服务,高可用场景下需要两个可用节点来部署双pod实例",
              "Parameters.custom.region" : "可用区域",
              "Parameters.custom.retention" : "普罗米修斯监控数据保留期",
              "Parameters.custom.shards" : "普罗米修斯服务分片数,每个分片被分配不同的采集目标",
              "Parameters.custom.storage_size" : "普罗米修斯服务器数据持久卷大小",
              "Parameters.custom.storage_type" : "普罗米修斯数据存储可用的持久卷类型",
              "Parameters.custom.zone" : "可用区",
              "Parameters.flavor1.description" : "适用于体验和功能演示环境,该规模下prometheus占用资源较少,但处理能力有限。建议在集群内容器数目不超过100时使用。",
              "Parameters.flavor1.name" : "演示规格(100容器以内)",
              "Parameters.flavor2.description" : "建议在集群中的容器数目不超过2000时使用。",
              "Parameters.flavor2.name" : "小规格(2000容器以内)",
              "Parameters.flavor3.description" : "建议在集群中的容器数目不超过5000时使用。",
              "Parameters.flavor3.name" : "中规格(5000容器以内)",
              "Parameters.flavor4.description" : "建议集群中容器数目超过5000时使用此规格。",
              "Parameters.flavor4.name" : "大规格(超过5000容器)",
              "Parameters.flavor5.description" : "自定义资源配置",
              "Parameters.flavor5.name" : "自定义",
              "Parameters.flavor6.description" : "默认资源配置",
              "Parameters.flavor6.name" : "默认",
              "Parameters.flavor7.description" : "自定义资源配置",
              "Parameters.flavor7.name" : "自定义"
            },
            "key" : {
              "Parameters.custom.deploy_mode" : "Prometheus部署模式",
              "Parameters.custom.highAvailability" : "高可用",
              "Parameters.custom.region" : "可用区域",
              "Parameters.custom.retention" : "数据保留期",
              "Parameters.custom.storage_size" : "数据持久卷大小",
              "Parameters.custom.storage_type" : "数据持久卷类型",
              "Parameters.custom.zone" : "可用区"
            }
          }
        },
        "supportVersions" : [ {
          "clusterType" : "VirtualMachine",
          "clusterVersion" : [ "v1.(27|28).*", "v1.(27|28).*" ],
          "category" : [ "Autopilot" ]
        } ],
        "creationTimestamp" : "2024-01-26T09:06:25Z",
        "updateTimestamp" : "2024-01-26T09:06:25Z"
      } ]
    }
  } ]
}

SDK代码示例

SDK代码示例如下。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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 ListAutopilotAddonTemplatesSolution {

    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();
        ListAutopilotAddonTemplatesRequest request = new ListAutopilotAddonTemplatesRequest();
        try {
            ListAutopilotAddonTemplatesResponse response = client.listAutopilotAddonTemplates(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());
        }
    }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# 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 = ListAutopilotAddonTemplatesRequest()
        response = client.list_autopilot_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)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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 := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        Build()

    client := cce.NewCceClient(
        cce.CceClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.ListAutopilotAddonTemplatesRequest{}
	response, err := client.ListAutopilotAddonTemplates(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。

状态码

状态码

描述

200

OK

错误码

请参见错误码