Updated on 2024-09-30 GMT+08:00

Listing Add-on Templates

Function

This API is used to obtain an add-on template.

Calling Method

For details, see Calling APIs.

URI

GET /autopilot/v3/addontemplates

Table 1 Query Parameters

Parameter

Mandatory

Type

Description

addon_template_name

No

String

Add-on name or alias. If this parameter is not specified, all the add-ons will be obtained.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

Content-Type

Yes

String

Message body type (format).

X-Auth-Token

Yes

String

Requests for calling an API can be authenticated using either a token or AK/SK. If token-based authentication is used, this parameter is mandatory and must be set to a user token. For details, see Obtaining a User Token.

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

kind

String

API type. The value is fixed at Addon and cannot be changed.

apiVersion

String

API version. The value is fixed at v3 and cannot be changed.

items

Array of AddonTemplate objects

List of add-on templates.

Table 4 AddonTemplate

Parameter

Type

Description

kind

String

API type. The value is fixed at Addon and cannot be changed.

apiVersion

String

API version. The value is fixed at v3 and cannot be changed.

metadata

AddonMetadata object

Basic information about the object. Metadata is a collection of attributes.

spec

Templatespec object

Detailed description of the add-on template.

Table 5 AddonMetadata

Parameter

Type

Description

uid

String

Unique ID

name

String

Add-on name

alias

String

Add-on alias

labels

Map<String,String>

Add-on labels in key-value pairs. This is a reserved field and does not take effect.

annotations

Map<String,String>

Add-on annotations in the format of key-value pairs.

  • For add-on installation, the value is fixed at {"addon.install/type":"install"}.

  • For add-on upgrade, the value is fixed at {"addon.upgrade/type":"upgrade"}.

updateTimestamp

String

Updated at

creationTimestamp

String

Created at

Table 6 Templatespec

Parameter

Type

Description

type

String

Template type. The value is helm or static.

require

Boolean

Whether the add-on is mandatory.

labels

Array of strings

Group to which the template belongs.

logoURL

String

URL of the logo image.

readmeURL

String

Add-on details and usage description.

description

String

Description

versions

Array of Versions objects

Template version details.

Table 7 Versions

Parameter

Type

Description

version

String

Add-on version.

input

Object

Add-on installation parameters.

stable

Boolean

Whether the add-on version is a stable release.

translate

Object

Translation information used by the GUI.

supportVersions

Array of SupportVersions objects

Cluster versions that support the add-on.

creationTimestamp

String

Creation time.

updateTimestamp

String

Update time.

Table 8 SupportVersions

Parameter

Type

Description

clusterType

String

Cluster type that supports the add-on.

clusterVersion

Array of strings

Cluster versions that support the add-on. The value is a regular expression.

Example Requests

None

Example Responses

Status code: 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 clusters are supported.",
              "description" : "kube-prometheus-stack uses Prometheus-operator and Prometheus to provide easy-to-use, end-to-end Kubernetes cluster monitoring capabilities. *Note: kube-prometheus-stack is a system monitoring add-on. When cluster resources are insufficient, Kubernetes prioritizes the scheduling of add-on pods."
            },
            "description" : {
              "Parameters.autopilot-flavor1.description" : "Use this specification when the number of containers in a cluster does not exceed 2,000.",
              "Parameters.autopilot-flavor1.name" : "Small (≤ 2,000 containers)",
              "Parameters.autopilot-flavor2.description" : "Use this specification when the number of containers in a cluster does not exceed 5,000.",
              "Parameters.autopilot-flavor2.name" : "Medium (≤ 5,000 containers)",
              "Parameters.autopilot-flavor3.description" : "Use this specification when the number of containers in a cluster exceeds 5,000.",
              "Parameters.autopilot-flavor3.name" : "Large (> 5,000 containers)",
              "Parameters.autopilot-flavor4.description" : "Customize resource configurations.",
              "Parameters.autopilot-flavor4.name" : "Custom",
              "Parameters.autopilot-flavor5.description" : "Use this specification when the number of containers in a cluster does not exceed 2,000.",
              "Parameters.autopilot-flavor5.name" : "Small (≤ 2,000 containers)",
              "Parameters.autopilot-flavor6.description" : "Use this specification when the number of containers in a cluster does not exceed 5,000.",
              "Parameters.autopilot-flavor6.name" : "Medium (≤ 5,000 containers)",
              "Parameters.autopilot-flavor7.description" : "Use this specification when the number of containers in a cluster exceeds 5,000.",
              "Parameters.autopilot-flavor7.name" : "Large (> 5,000 containers)",
              "Parameters.autopilot-flavor8.description" : "Customize resource configurations.",
              "Parameters.autopilot-flavor8.name" : "Custom",
              "Parameters.custom.deploy_mode" : "Prometheus deployment mode",
              "Parameters.custom.highAvailability" : "Deploy the Prometheus and Kubernetes event collection and reporting services in HA mode. In this case, two available nodes are required to deploy instances with two pods.",
              "Parameters.custom.region" : "AZ",
              "Parameters.custom.retention" : "Retention period of the Prometheus monitoring data",
              "Parameters.custom.shards" : "Number of Prometheus service shards. Each shard is assigned a different collection target.",
              "Parameters.custom.storage_size" : "Persistent volume size of the Prometheus server",
              "Parameters.custom.storage_type" : "Persistent volume types available for storing the Prometheus data",
              "Parameters.custom.zone" : "AZ",
              "Parameters.flavor1.description" : "This specification is suitable for experience and function demonstration environments where Prometheus occupies few resources and has limited processing capabilities. Use this specification when the number of containers in a cluster does not exceed 100.",
              "Parameters.flavor1.name" : "Demo (≤ 100 containers)",
              "Parameters.flavor2.description" : "Use this specification when the number of containers in a cluster does not exceed 2,000.",
              "Parameters.flavor2.name" : "Small (≤ 2,000 containers)",
              "Parameters.flavor3.description" : "Use this specification when the number of containers in a cluster does not exceed 5,000.",
              "Parameters.flavor3.name" : "Medium (≤ 5,000 containers)",
              "Parameters.flavor4.description" : "Use this specification when the number of containers in a cluster exceeds 5,000.",
              "Parameters.flavor4.name" : "Large (> 5,000 containers)",
              "Parameters.flavor5.description" : "Customize resource configurations.",
              "Parameters.flavor5.name" : "Custom",
              "Parameters.flavor6.description" : "Configure the default resource settings.",
              "Parameters.flavor6.name" : "Default",
              "Parameters.flavor7.description" : "Customize resource configurations.",
              "Parameters.flavor7.name" : "Custom"
            },
            "key" : {
              "Parameters.custom.deploy_mode" : "Prometheus deployment mode",
              "Parameters.custom.highAvailability" : "HA",
              "Parameters.custom.region" : "AZ",
              "Parameters.custom.retention" : "Data retention period",
              "Parameters.custom.storage_size" : "Persistent volume size",
              "Parameters.custom.storage_type" : "Persistent volume type",
              "Parameters.custom.zone" : "AZ"
            }
          }
        },
        "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 Sample Code

The SDK sample code is as follows.

 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)
    }
}

For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.

Status Codes

Status Code

Description

200

OK

Error Codes

See Error Codes.