Documents

huawei-cloud-gaussdb-count

Try it

Count the number of Huawei Cloud GaussDB instances in a region and output the count. Covers both GaussDB for openGauss and GaussDB (MySQL-compatible) instances. Returns the authoritative total_count from the list API, so the reported number is always correct. Read-only — never creates, modifies or deletes any resource. Use for GaussDB database inventory, daily inspection, or cost review. Triggers include: count GaussDB, GaussDB count, GaussDB instance count, how many GaussDB instances, GaussDB数量, GaussDB实例数量, 查询GaussDB数量, GaussDB总数, 统计GaussDB实例数.

What it does

Count the number of Huawei Cloud GaussDB instances in a region and output the count. Covers both GaussDB for openGauss and GaussDB (MySQL-compatible) instances. Returns the authoritative total_count from the list API, so the reported number is always correct. Read-only — never creates, modifies or deletes any resource. Use for GaussDB database inventory, daily inspection, or cost review. Triggers include: count GaussDB, GaussDB count, GaussDB instance count, how many GaussDB instances, GaussDB数量, GaussDB实例数量, 查询GaussDB数量, GaussDB总数, 统计GaussDB实例数.

The skill document

Huawei Cloud GaussDB Count Skill

Overview

This skill queries the total number of Huawei Cloud GaussDB instances in a region and outputs the count. It supports both GaussDB product families:

  • GaussDB for openGauss — primary/standby (Ha) and distributed (Enterprise) instances, queried via the GaussDBforopenGauss service.
  • GaussDB (MySQL-compatible) — instances queried via the GaussDB service.

The count is taken from the authoritative total_count field returned by the list API, so the result is exact regardless of page size — no pagination sum is needed for the count itself.

Architecture:

Agent → hcloud CLI (primary) → Huawei Cloud GaussDB API
       ↘ Python SDK (fallback) ↗

Applicable Scenarios:

  • Daily inspection: how many GaussDB instances exist in a region
  • Database inventory and cost review
  • Capacity planning and pre-migration verification

Prerequisites

  1. hcloud CLI installed and authenticated — See references/cli-installation-guide.md
  2. Python 3.8+ with huaweicloudsdkgaussdbforopengauss and huaweicloudsdkgaussdb packages (SDK fallback)
  3. Huawei Cloud AK/SK configured via environment variables or the hcloud CLI profile
  4. IAM permissions — read-only access to GaussDB instances — See references/iam-policies.md

Workflow

  1. Identify query scope — Decide which region to query
  2. Select execution mode — Use the hcloud CLI by default; fall back to the Python SDK if the CLI is unavailable
  3. Execute the query — Run the count commands and capture total_count from each response
  4. Present results — Output the GaussDB instance count to the user

Core Commands

Count GaussDB for openGauss Instances

PurposeCommand
Count all GaussDB for openGauss instanceshcloud GaussDBforopenGauss ListInstances --cli-region={region} --limit=100

Count GaussDB (MySQL-compatible) Instances

PurposeCommand
Count all GaussDB (MySQL) instanceshcloud GaussDB ListGaussMySqlInstances --cli-region={region} --limit=100

Count-Only Lookup (jq)

To return just the numeric count:

hcloud GaussDBforopenGauss ListInstances --cli-region={region} --limit=100 | jq -r '.total_count'
hcloud GaussDB ListGaussMySqlInstances --cli-region={region} --limit=100 | jq -r '.total_count'

SDK Fallback Examples

When the CLI is unavailable, use the Python SDK:

import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkgaussdbforopengauss.v3.region.gaussdbforopengauss_region import GaussDBforopenGaussRegion
from huaweicloudsdkgaussdbforopengauss.v3 import GaussDBforopenGaussClient, ListInstancesRequest

credentials = BasicCredentials().with_ak(os.getenv("HUAWEI_ACCESS_KEY")) \
                                .with_sk(os.getenv("HUAWEI_SECRET_KEY"))

client = GaussDBforopenGaussClient.new_builder() \
    .with_credentials(credentials) \
    .with_region(GaussDBforopenGaussRegion.value_of("{region}")) \
    .build()

response = client.list_instances(ListInstancesRequest(limit=100))
print(response.total_count)
import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkgaussdb.v3.region.gaussdb_region import GaussDBRegion
from huaweicloudsdkgaussdb.v3 import GaussDBClient, ListGaussMySqlInstancesRequest

credentials = BasicCredentials().with_ak(os.getenv("HUAWEI_ACCESS_KEY")) \
                                .with_sk(os.getenv("HUAWEI_SECRET_KEY"))

client = GaussDBClient.new_builder() \
    .with_credentials(credentials) \
    .with_region(GaussDBRegion.value_of("{region}")) \
    .build()

response = client.list_gauss_my_sql_instances(ListGaussMySqlInstancesRequest(limit=100))
print(response.total_count)

A ready-to-run helper script is provided in scripts/count_gaussdb_instances.py covering both product families. The script catches ClientRequestException/SdkException and prints a concise, actionable error message (credential / region / IAM-permission hint) then exits non-zero — it never dumps a raw traceback.

Parameter Confirmation

ParameterRequiredDescriptionExample
{region}YesHuawei Cloud regioncn-north-4
{limit}NoMax records per page (1-100, default 100); does not affect total_count100

Reference Documents

  • CLI Installation Guide
  • IAM Policies
  • Verification Method
  • Data Flow Diagram
  • Acceptance Criteria

KooCLI Command Format Standard

hcloud   --cli-region= [--key=value ...]
FeatureDescriptionExample
Service nameGaussDBforopenGauss, GaussDBhcloud GaussDBforopenGauss ListInstances --cli-region={region}
Operation namePascalCaseListInstances, ListGaussMySqlInstances
Region parameter--cli-region=--cli-region=cn-north-4
Simple parameter--key=value--limit=100

Related skills

Count the number of Huawei Cloud DCS (Distributed Cache Service) instances — managed Redis and Memcached — in a region and output the count. Returns the authoritative instance_num from the ListInstances API, so the reported number is always exact regardless of page size. Supports counting all instances, counting Redis-only (or Memcached-only) instances via the per-engine breakdown, filtering by status (RUNNING, FROZEN, etc.), and a per-status count breakdown via ListNumberOfInstancesInDifferentStatus. Read-only — never creates, modifies or deletes any resource. Use for Redis/DCS instance inventory, daily inspection, or cost review. Triggers include: count Redis, Redis count, DCS instance count, how many Redis instances, number of Redis instances, Redis数量, DCS实例数量, Redis实例数量, 查询Redis数量, 查询redis数量, 缓存实例数量, DCS数量, 统计Redis实例数, redis实例个数.

Query the total number of Huawei Cloud services available through KooCLI offline metadata. Returns the count of all supported cloud services from the cached service catalog. Triggers include: "how many Huawei Cloud services", "count Huawei Cloud services", "华为云服务总数", "华为云有多少个服务", "查询华为云服务数量".

1 installs

Read-only query of Huawei Cloud ECS, BMS, IMS, and AS resources via local Python scripts.

by huaweicloud-skills-team2 installs

Counts the total number of files (objects) inside a Huawei Cloud OBS (Object Storage Service) bucket and returns ONLY the numeric count. Supports counting all files in a whole bucket or all files under a given prefix (folder). Zero-byte folder-marker keys (ending with '/') are excluded — only real files/objects are counted. Uses the KooCLI obsutil-backed `hcloud OBS ls ... -limit=0` command (primary, parses the "File number" line) or the huaweicloudsdkobs Python SDK (fallback, paginated ListObjects). Read-only — never creates, modifies or deletes any resource. Use this skill whenever the user wants to know how many files or objects an OBS bucket (or a folder inside it) contains, e.g. for inventory, capacity review, migration planning or compliance checks. Triggers include: "count OBS files", "OBS file count", "number of files in bucket", "how many objects in bucket", "OBS object count", "OBS文件数量", "查询OBS文件总数", "OBS文件总数", "桶里有多少个文件", "统计文件数量", "对象数量", "查询对象总数".

1 installs

Query Huawei Cloud OBS (Object Storage Service) statistics: list buckets with capacity and object counts, query extranet/intranet download traffic with month...

by huaweicloud-skills-team1 installs

Query the list of Huawei Cloud RDS (Relational Database Service, 云数据库) instances under the current tenant / project and return the RDS instance NAMES. By default the skill prints only the instance names (one per line); with extra flags it also returns id, status, engine type, flavor, private IPs and created time. Supports filtering by instance name, id, type (Single/Ha/Replica), datastore engine (MySQL/PostgreSQL/SQLServer/MariaDB) and VPC, plus pagination via limit/offset. Uses the KooCLI command `hcloud RDS ListInstances --cli-region={region}` (primary) or the huaweicloudsdkrds Python SDK (fallback). Read-only — never creates, modifies, deletes, restarts or stops any RDS instance. Use this skill whenever the user wants to list/inspect the RDS instances of the tenant or query the RDS instance name list, e.g. for database inventory, daily inspection, or cost review. Triggers include: "list RDS", "RDS list", "query RDS names", "RDS实例列表", "查询RDS", "RDS实例名称", "rds list", "how many RDS", "