记忆

huawei-cloud-obs-dir-count

试用

Counts the number of directories (folders) inside a Huawei Cloud OBS (Object Storage Service) bucket and returns ONLY the numeric count. Supports counting the immediate subdirectories under the bucket (or a given prefix) as well as all nested directories recursively. Uses the KooCLI obsutil-backed `hcloud OBS ls -d` command (primary) or the huaweicloudsdkobs Python SDK (fallback). Read-only — never creates, modifies or deletes any resource. Use this skill whenever the user wants to know how many directories/folders an OBS bucket contains, e.g. for inventory, capacity review or structure checks. Triggers include: "count OBS directories", "OBS directory count", "number of directories in bucket", "OBS folder count", "how many folders in bucket", "OBS目录数量", "查询OBS目录数量", "OBS目录数", "桶目录数量", "目录数量", "文件夹数量", "统计目录", "目录统计".

它能做什么

Counts the number of directories (folders) inside a Huawei Cloud OBS (Object Storage Service) bucket and returns ONLY the numeric count. Supports counting the immediate subdirectories under the bucket (or a given prefix) as well as all nested directories recursively. Uses the KooCLI obsutil-backed `hcloud OBS ls -d` command (primary) or the huaweicloudsdkobs Python SDK (fallback). Read-only — never creates, modifies or deletes any resource. Use this skill whenever the user wants to know how many directories/folders an OBS bucket contains, e.g. for inventory, capacity review or structure checks. Triggers include: "count OBS directories", "OBS directory count", "number of directories in bucket", "OBS folder count", "how many folders in bucket", "OBS目录数量", "查询OBS目录数量", "OBS目录数", "桶目录数量", "目录数量", "文件夹数量", "统计目录", "目录统计".

技能文档

Huawei Cloud OBS Directory Count Skill

Overview

This skill counts the number of directories (folders) in a Huawei Cloud OBS bucket and returns only the count (a single integer). It is a read-only statistics skill: it never creates, modifies, or deletes buckets, directories, or objects.

Architecture:

Agent → hcloud CLI (KooCLI OBS / obsutil, primary) → Huawei Cloud OBS API
       ↘ huaweicloudsdkobs Python SDK (fallback)            ↗

Two counting modes:

ModeDescriptionExample
Immediate (default)Number of subdirectories directly under the bucket (or a given prefix)obs://bucket/ → 11
Recursive (--recursive)Total number of directories at all nesting levelsall directories in the bucket → 203

Applicable Scenarios:

  • Inventory: "how many directories does this bucket have?"
  • Structure review: verify a bucket layout matches expectations
  • Capacity/storage planning: estimate directory-level layout before migration
  • Compliance auditing: detect unexpected directories

能力边界(Capability Boundary): 本 Skill 仅统计目录(文件夹 / common prefixes)数量不统计文件或对象(objects/files)数量。 若用户询问"桶里有多少个文件/对象"、总存储量或对象总大小,请明确告知本 Skill 不提供该能力, 并引导使用其他 OBS 技能或华为云控制台 OBS 监控页。

Prerequisites

  1. hcloud CLI (KooCLI) installed and authenticated — See references/cli-installation-guide.md
  2. obsutil installed — required by the hcloud OBS ls command (bundled with KooCLI or standalone)
  3. OBS credentials configured for obsutilhcloud OBS ls reads AK/SK/endpoint from the obsutil config file (.obsutilconfig in the user home directory), which is separate from the KooCLI account credentials
  4. Python 3.8+ with huaweicloudsdkobs package (SDK fallback) — pip install huaweicloudsdkobs
  5. IAM permissionsobs:bucket:ListBucket, obs:object:List — See references/iam-policies.md

OBS credentials are separate. Before running, check whether obsutil credentials are configured:

hcloud OBS ls -s -limit=1

If the output is Please set ak, sk and endpoint in the configuration file! or an InvalidAccessKeyId error, obsutil credentials are not configured. Ask the user to configure them in their own terminal (never ask the user to paste AK/SK into the conversation). Provide the following example command:

hcloud obs config -i= -k= -e=obs..myhuaweicloud.com

Example (cn-north-4): hcloud obs config -i= -k= -e=obs.cn-north-4.myhuaweicloud.com

Workflow

  1. Confirm the bucket name — ask the user which OBS bucket to inspect (and optionally a subdirectory prefix)
  2. Verify prerequisiteshcloud version, hcloud OBS ls -s -limit=1 to confirm obsutil credentials
  3. Run the count — use the script scripts/count_obs_directories.py (primary) with the appropriate flags
  4. Return the count — the script prints a single integer; relay that integer to the user
  5. Handle errors — if the script fails (e.g. bucket not found, invalid AK/SK, missing credentials), the script prints a clear Chinese error hint on stderr with configuration guidance; relay that hint to the user

Core Commands

Count Immediate Subdirectories (Primary)

Returns the number of subdirectories directly under the bucket:

python3 scripts/count_obs_directories.py --bucket 

Count Subdirectories Under a Prefix

Counts the subdirectories directly under a given directory prefix:

python3 scripts/count_obs_directories.py --bucket  --prefix 

Count All Directories Recursively

Counts every directory at every nesting level under the bucket (or prefix):

python3 scripts/count_obs_directories.py --bucket  --recursive

Force SDK Executor

If the CLI/obsutil path is unavailable, force the Python SDK:

python3 scripts/count_obs_directories.py --bucket  --executor sdk

Direct CLI Command (for reference)

The underlying obsutil command the script uses for immediate counts is hcloud OBS ls obs:/// -d. The Folder number: N line at the end of the output is the immediate directory count. Prefer the script commands above; use the raw obsutil command only for manual inspection.

Parameter Confirmation

ParameterRequiredDescriptionExample
--bucketYesOBS bucket namemy-bucket
--prefixNoDirectory prefix to count underphotos
--recursiveNoCount all nested directories (all levels)--recursive
--regionNoHuawei Cloud region (SDK fallback only)cn-north-4
--executorNoauto (default), cli, or sdk--executor sdk

Reference Documents

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

KooCLI Command Format Standard

The hcloud OBS module is backed by obsutil. The -d flag lists only directories (common prefixes) at the requested level:

FeatureDescriptionExample
Service nameOBS (obsutil-backed)hcloud OBS ls
Operation nameLowercase obsutil commandls
List directories only-d flag limits output to common prefixes (directories)hcloud OBS ls obs://bucket/ -d
Simple parameter-flag / -key=value for obsutil optionshcloud OBS ls -limit=100
Credentialsobsutil config file (.obsutilconfig)-i=AK -k=SK -e=endpoint

相关技能

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 次安装

Lists the Huawei Cloud OBS (Object Storage Service) buckets of the current tenant and returns the FOLDER names inside a bucket — both the top-level folders of a bucket and the sub-folders under a given prefix. Uses the KooCLI obsutil-backed command `hcloud OBS ls` (primary, parses the "Folder list" section of obsutil output) or the huaweicloudsdkobs Python SDK (fallback, ListObjects with delimiter=/). Read-only — never creates, modifies or deletes any bucket, folder or object. Use this skill whenever the user wants to see which OBS buckets exist or which folders a bucket (or a folder inside it) contains, e.g. for daily inspection, inventory, data organization review or troubleshooting. Triggers include: "list OBS buckets", "OBS bucket list", "list folders in bucket", "OBS folder names", "查询OBS列表", "OBS桶列表", "OBS文件夹名称", "桶里有哪些文件夹", "查询obs列表", "返回obs列表中文件夹名称", "OBS目录列表".

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

作者 huaweicloud-skills-team1 次安装

Queries the total storage size of Huawei Cloud OBS (Object Storage Service) buckets and returns ONLY the size value — a single number, in bytes by default. Supports querying the total size of one bucket or the combined total across all buckets under the account. Uses the KooCLI obsutil-backed `hcloud OBS ls ... -du -bf=raw` command (primary) or the huaweicloudsdkobs Python SDK (fallback). Read-only — never creates, modifies or deletes any resource. Use this skill whenever the user wants to know the total size of an OBS bucket or the overall OBS storage usage, e.g. for capacity review, cost estimation or storage planning. Triggers include: OBS total size, OBS bucket size, total storage usage, bucket capacity, OBS大小, OBS总大小, OBS容量, 桶大小, 查询OBS大小, 存储占用, OBS存储量.

Upload local files or directories to Huawei Cloud OBS (Object Storage Service) buckets, list OBS buckets with capacity and object count, and schedule periodic uploads via crontab. Use this skill when the user wants to: (1) upload a local file or directory to an OBS bucket, (2) list OBS buckets and check their storage capacity and object count, (3) set up a scheduled/periodic upload task to automatically sync a local directory to an OBS bucket. Trigger: user mentions "OBS", "object storage", "bucket list", "bucket capacity", "upload to OBS", "upload file", "upload directory", "scheduled upload", "periodic upload", "sync to bucket", "对象存储", "桶列表", "桶容量", "上传文件", "上传目录", "定时上传", "OBS管理"

作者 huaweicloud-skills-team

Skill specialized for creating buckets on Huawei Cloud OBS. Use this skill when users need to create OBS buckets, set bucket properties, configure access per...

作者 huaweicloud-skills-team1 次安装