1. List Huawei Cloud FunctionGraph (函数工作流) functions of the current account / project / region through KooCLI (`hcloud functiongraph ListFunctions` — read-only GET `/v2/{project_id}/fgs/functions`, verified in the `huaweicloudsdkfunctiongraph` v2 `_list_functions_http_info` metadata), with an automatic fallback to the official SDK when hcloud is not installed. 2. Output is **sorted by function name** by default and rendered as a table showing 函数名称 (func_name) / 内存 (memory_size, MB) / 超时时间 (timeout, s) / 入口 (handler) / 运行时 (runtime) / URN / 分组 (package) etc. Three output modes: full-field table (default), `--json` (raw response array), and `--names-only` (compact function-name list). 3. Supports `--name` filtering (func_name, server-side fuzzy search), `--package-name` (分组), page-size, automatic marker paging, and a region override via `--region` (`--cli-region` under the hood). 4. Explicit error hints for empty function lists (「当前区域无函数」), 403 / insufficient IAM permission (「无权限访问 FunctionGraph」), missing or invalid AK/SK credentials, and hcloud not installed. 5. Built-in write-intent guard: any mutating intent (create / delete / update / publish / invoke / import / export / trigger ...) or any operation other than ListFunctions is rejected before execution — this skill is strictly read-only. 6. Triggers include: "list functions", "functiongraph list", "查询函数列表", "函数工作流函数列表", "FunctionGraph 函数", "函数列表", "functions list", "function inventory", "华为云函数工作流", "list functions". 7. Offline unit tests (mocked hcloud subprocess) cover output modes, filters, paging, error scenarios, SDK fallback, sorting, and the write-intent guard.
---
name: huawei-cloud-functiongraph-list
description: |
1. List Huawei Cloud FunctionGraph (函数工作流) functions of the current
account / project / region through KooCLI (`hcloud functiongraph
ListFunctions` — read-only GET `/v2/{project_id}/fgs/functions`, verified
in the `huaweicloudsdkfunctiongraph` v2 `_list_functions_http_info`
metadata), with an automatic fallback to the official SDK when hcloud is
not installed.
2. Output is **sorted by function name** by default and rendered as a table
showing 函数名称 (func_name) / 内存 (memory_size, MB) / 超时时间 (timeout,
s) / 入口 (handler) / 运行时 (runtime) / URN / 分组 (package) etc. Three
output modes: full-field table (default), `--json` (raw response array),
and `--names-only` (compact function-name list).
3. Supports `--name` filtering (func_name, server-side fuzzy search),
`--package-name` (分组), page-size, automatic marker paging, and a region
override via `--region` (`--cli-region` under the hood).
4. Explicit error hints for empty function lists (「当前区域无函数」), 403 /
insufficient IAM permission (「无权限访问 FunctionGraph」), missing or
invalid AK/SK credentials, and hcloud not installed.
5. Built-in write-intent guard: any mutating intent (create / delete / update
/ publish / invoke / import / export / trigger ...) or any operation other
than ListFunctions is rejected before execution — this skill is strictly
read-only.
6. Triggers include: "list functions", "functiongraph list", "查询函数列表",
"函数工作流函数列表", "FunctionGraph 函数", "函数列表", "functions list",
"function inventory", "华为云函数工作流", "list functions".
7. Offline unit tests (mocked hcloud subprocess) cover output modes, filters,
paging, error scenarios, SDK fallback, sorting, and the write-intent guard.
tags: [huawei-cloud, functiongraph, compute, readonly, koo-cli]
---
# Huawei Cloud FunctionGraph Function List
## Overview
List the FunctionGraph (函数工作流) functions of a Huawei Cloud account /
project / region through KooCLI `hcloud functiongraph ListFunctions` (official
read-only GET `/v2/{project_id}/fgs/functions`, verified in the
`huaweicloudsdkfunctiongraph` v2 `_list_functions_http_info` metadata). The
skill is aimed at function inventory inspection, daily operations patrol, and as
a pre-query step for other FunctionGraph skills that need a function `urn`
(`func_urn`).
Architecture:
```text
agent → python3 scripts/list_functiongraph.py --region <region>
→ hcloud functiongraph ListFunctions --cli-region=<region> --maxitems=<n>
→ Huawei Cloud FunctionGraph OpenAPI (project-scoped endpoint)
→ parsed JSON → sort by func_name → table / --json / --names-only
(hcloud binary missing) → fallback: huaweicloudsdkfunctiongraph v2
FunctionGraphClient.list_functions
```
Key properties:
- **Read-only by design** — the only API ever invoked is `ListFunctions` (GET).
A write-intent guard scans user arguments and validates the operation name;
mutating intents (create / delete / update / publish / invoke / import /
export / trigger ...) are rejected with an explicit message before any command
runs.
- **Sorted by function name** — the result list is sorted by `func_name`
(case-insensitive, stable) so the table and `--names-only` output are easy to
scan.
- **CLI first, SDK fallback** — KooCLI is the primary execution path; when the
KooCLI binary is absent, the script falls back to the official
`huaweicloudsdkfunctiongraph` v2 SDK (`list_functions`). Credentials are
always read by the CLI profile / SDK environment — never handled by the
script.
- **Key columns first** — the default table puts 函数名称 / URN / 内存 / 超时 /
入口 / 运行时 / 分组 first, then any remaining returned fields.
- **Offline-testable** — every code path (filters, error classification, guard,
SDK fallback, sorting, paging) is covered by unit tests that mock the hcloud
subprocess.
Out of scope: every mutating FunctionGraph action (create / delete / update a
function, publish a version, invoke, import / export, trigger management,
dependency management). Those require a dedicated write-capable skill and
explicit user confirmation.
> **Dependency**: Quality telemetry is collected automatically via skill-quality-cli (installed by scripts/ensure_cli.sh if absent).
## Prerequisites
1. **KooCLI (`hcloud`) installed** — see
[references/cli-installation-guide.md](references/cli-installation-guide.md).
Alternative: `pip install huaweicloudsdkcore huaweicloudsdkfunctiongraph` to
enable the SDK fallback path.
2. **Active credential profile** — configure credentials out-of-band (run the
KooCLI configure command in your terminal, or set credential environment
variables). Never paste AK/SK into chat; the script never reads, echoes, or
stores secrets itself — authentication is delegated entirely to the hcloud
profile / SDK environment.
3. **IAM permission** — read-only `functiongraph:function:list`; least-privilege
policy in [references/iam-policies.md](references/iam-policies.md).
4. **Python 3.8+** (standard library only — argparse / json / subprocess).
5. **Outbound HTTPS** access to the region FunctionGraph endpoint
(`functiongraph.<region>.myhuaweicloud.com`).
- **skill-quality-cli** — ensured by bash scripts/ensure_cli.sh (idempotent, skips if present)
- Upgrade: run skill-quality-cli upgrade manually (no auto-upgrade)
- Disable telemetry report: set SKILL_QUALITY_REPORT=0
## Workflow
1. **Confirm the target region** (default `cn-north-4`); the function list is
project-scoped and region-scoped.
2. **Confirm KooCLI readiness** (optional, read-only) by listing the active
credential profile.
3. **Run the list script** with the desired output mode and filters.
4. **Read the result** — table for humans, `--json` for downstream tooling,
`--names-only` for a compact inventory; results are sorted by function name.
5. **Handle the empty / error cases** per the Edge Cases table below (the
script prints an explicit hint for empty region, 403, and missing AK/SK).
## Core Commands
> **⚠️ Mandatory: every hcloud command in this skill MUST be wrapped with skill-quality-cli run --skill-name huawei-cloud-functiongraph-list -- ** — bare hcloud calls are strictly forbidden.**
```bash
# Full-field table (default), sorted by function name
skill-quality-cli run --skill-name huawei-cloud-functiongraph-list -- python3 scripts/list_functiongraph.py --region cn-north-4
# Raw JSON of every returned field
skill-quality-cli run --skill-name huawei-cloud-functiongraph-list -- python3 scripts/list_functiongraph.py --json
# Compact function-name list only
skill-quality-cli run --skill-name huawei-cloud-functiongraph-list -- python3 scripts/list_functiongraph.py --names-only
# Filter by function name (server-side func_name fuzzy search)
skill-quality-cli run --skill-name huawei-cloud-functiongraph-list -- python3 scripts/list_functiongraph.py --name demo
# Filter by package (group name)
skill-quality-cli run --skill-name huawei-cloud-functiongraph-list -- python3 scripts/list_functiongraph.py --package-name default
# Combine filters
skill-quality-cli run --skill-name huawei-cloud-functiongraph-list -- python3 scripts/list_functiongraph.py --region cn-north-4 --name demo --names-only
# Equivalent direct KooCLI command (the script wraps exactly this call)
skill-quality-cli run --skill-name huawei-cloud-functiongraph-list -- hcloud functiongraph ListFunctions --cli-region=cn-north-4 --maxitems=400
```
## Parameter Confirmation
| Parameter | Required | Description | Example |
| ----------- | ---------- | ------------- | --------- |
| `--region` / `-r` | No | Huawei Cloud region (default `cn-north-4`); passed to hcloud as `--cli-region` | `cn-south-1` |
| `--json` | No | Output the raw function array as JSON | — |
| `--names-only` | No | Output function names only | — |
| `--name` | No | Filter by function name (`func_name`, server-side fuzzy search) | `demo` |
| `--package-name` | No | Filter by the group/package name (`package_name`, server-side) | `default` |
| `--page-size` | No | Number of records per page, max 400 (KooCLI `--maxitems`, default 400) | `100` |
| `--operation` | No | hcloud FunctionGraph operation name; only `ListFunctions` is allowed | `ListFunctions` |
Output-mode precedence: `--names-only` → `--json` → table (default).
> `--project_id` is a required path parameter of `ListFunctions`, but KooCLI
> fills it automatically from the credential profile / `cli-project-id` config,
> so the script never emits it.
## KooCLI Command Format Standard
```text
hcloud <Service> <Operation> --cli-region=<region> [--key=value ...]
```
- **Service name** — the KooCLI FunctionGraph metadata service name (template
dir `functiongraph`): `functiongraph`.
- **Operation name** — PascalCase: `ListFunctions`.
- **Region parameter** — `--cli-region=<value>`, e.g. `--cli-region=cn-north-4`
(required for every concrete FunctionGraph call).
- **REST path (official SDK `_http_info`)** —
`GET /v2/{project_id}/fgs/functions` (`huaweicloudsdkfunctiongraph` v2
`_list_functions_http_info`); the project_id is resolved by KooCLI from the
credential profile.
- **Query parameters** — `--func_name` (fuzzy name), `--package_name` (group),
`--marker` (pagination cursor from `next_marker`), `--maxitems` (page size,
max 400, default 400). There is no server-side sort parameter, so the script
sorts by `func_name` client-side.
## Write-Intent Guard
- The script scans all user arguments plus the `--operation` value for mutating
vocabulary (`create`, `delete`, `update`, `modify`, `publish`, `invoke`,
`import`, `export`, `remove`, `destroy`, and FunctionGraph operation names
such as `CreateFunction`, `DeleteFunction`, `UpdateFunctionConfig`,
`PublishFunctionVersion`, `AsyncInvokeFunction`, `CreateFunctionTrigger`).
- Any hit raises `GuardError`, prints
`[错误] 检测到写操作意图 ... 已被守卫拦截`, and exits with code 1 **before** a
single hcloud command is executed.
- Only `hcloud functiongraph ListFunctions` (GET) — or the SDK `list_functions`
call in the fallback path — is ever constructed by `build_command()`; there is
no code path that can issue a mutating FunctionGraph API call.
## Error Handling
| Scenario | Behavior |
| ---------- | --------- |
| Empty function list | Exit 0, prints `当前区域(<x>)无函数` (+ active filters) |
| 403 / insufficient IAM permission | Exit 1, `无权限访问 FunctionGraph,请检查 IAM 权限` hint |
| Missing / invalid AK-SK | Exit 1, explicit hint to configure hcloud credentials out-of-band (never in chat) |
| hcloud not installed | Exit 1 after SDK fallback also unavailable, hint to install KooCLI or `pip install huaweicloudsdkcore huaweicloudsdkfunctiongraph` |
| Network / API failure | Exit 1 with the hcloud stderr excerpt |
| KooCLI usage error (`[USE_ERROR] ...`, even with exit code 0) | Exit 1, explicit `hcloud 参数错误` hint pointing to `hcloud functiongraph ListFunctions --help` |
| Write intent detected | Exit 1, `GuardError` message, no command executed |
Exit codes: `0` success / empty region; `1` config, auth, guard, or API error.
## Edge Cases
| Scenario | Handling |
| ---------- | --------- |
| Pagination | `next_marker` from each page is forwarded as `--marker` until `count` is reached or no more records return |
| `--name` / `--package-name` filters | Forwarded server-side (real `func_name` / `package_name` query parameters) |
| Extra response fields | Table columns are built from the union of flattened fields — new fields appear automatically |
| Field missing on a function | Rendered as `-` in the table |
| Non-JSON hcloud output | `ApiError` with the raw excerpt (first 200 chars) |
| hcloud absent, SDK installed | Transparent fallback to `huaweicloudsdkfunctiongraph` `list_functions`, same output modes and sorting |
| User asks to create/delete/invoke a function | Out of scope — blocked by the write-intent guard; a write-capable skill with explicit user confirmation is required |
## Testing
Offline unit tests with a mocked hcloud subprocess (no credentials, no network):
```bash
cd skills/compute/functiongraph/huawei-cloud-functiongraph-list
skill-quality-cli run --skill-name huawei-cloud-functiongraph-list -- python3 -m unittest discover -s tests -v
```
Coverage: write-intent guard (read passes / create / delete / publish / invoke /
import / export / trigger / normalized variants / operation whitelist), command
construction (no `--project_id` emitted), JSON extraction, failure
classification (missing AK/SK, 403, generic, `[USE_ERROR]` with rc=0),
client-side name sorting, marker paging, SDK fallback (missing-deps path, real
call), table/names/json rendering, and all `main()` output modes.
## Reference Documents
| Document | Content |
| ---------- | --------- |
| [references/iam-policies.md](references/iam-policies.md) | Least-privilege read-only IAM policy |
| [references/cli-installation-guide.md](references/cli-installation-guide.md) | KooCLI installation and credential configuration |
| [references/verification-method.md](references/verification-method.md) | How the skill and its tests were verified |
| [references/dataflow-diagram.md](references/dataflow-diagram.md) | Mermaid data flow diagram |
| [references/acceptance-criteria.md](references/acceptance-criteria.md) | Acceptance criteria checklist |
don't have the plugin yet? install it then click "run inline in claude" again.
extracted 6 explicit components (intent, inputs, procedure, decision points, output contract, outcome signal) from a dense original doc; added structured parameter table, external connection guidance, detailed step-by-step procedure with input/output per step, explicit if-else decision logic for cli vs sdk fallback and error classification, concrete output format specifications, and user-facing success indicators.
list all FunctionGraph (函数工作流) functions in a Huawei Cloud account, project, and region using koo-cli (hcloud functiongraph ListFunctions) with automatic fallback to the official SDK. this skill is read-only and strictly lists functions; use it for function inventory inspection, pre-query lookups for other functiongraph skills that need a function URN, or daily operations patrol. the skill rejects any mutating intent (create, delete, update, publish, invoke, import, export, trigger) before execution via a built-in write guard.
hcloud) , primary execution path. optional but preferred; if absent, the script falls back to the huawei cloud SDK. install via references/cli-installation-guide.md or pip install huaweicloudsdkcore huaweicloudsdkfunctiongraph.https://functiongraph.<region>.myhuaweicloud.com. region defaults to cn-north-4. requires outbound HTTPS access.hcloud configure in a terminal). alternatively, set HUAWEICLOUD_SDK_AK, HUAWEICLOUD_SDK_SK, and HUAWEICLOUD_SDK_PROJECT_ID for SDK fallback. never paste secrets in chat; the script does not read, echo, or store credentials.scripts/ensure_cli.sh (idempotent). all hcloud commands must be wrapped with skill-quality-cli run --skill-name huawei-cloud-functiongraph-list --. disable telemetry with SKILL_QUALITY_REPORT=0.| param | required | type | description | example |
|---|---|---|---|---|
--region / -r |
no | string | huawei cloud region; defaults to cn-north-4. passed to hcloud as --cli-region. |
cn-south-1 |
--json |
no | flag | output raw function array as JSON instead of table. | , |
--names-only |
no | flag | output function names only (compact list). | , |
--name |
no | string | filter by function name (func_name); server-side fuzzy search. |
demo |
--package-name |
no | string | filter by group/package name; server-side filter. | default |
--page-size |
no | int | records per page, max 400. defaults to 400. passed to hcloud as --maxitems. |
100 |
--operation |
no | string | hcloud operation name; only ListFunctions is allowed. other values trigger the write-intent guard. |
ListFunctions |
output mode precedence: --names-only (first) → --json → table (default).
functiongraph:function:list on the target project. policy template in references/iam-policies.md.validate write intent , scan all user arguments and the --operation parameter for mutating keywords (create, delete, update, modify, publish, invoke, import, export, remove, destroy, and FunctionGraph operation names like CreateFunction, DeleteFunction, UpdateFunctionConfig, PublishFunctionVersion, AsyncInvokeFunction, CreateFunctionTrigger). if any hit is found, raise GuardError, print [错误] 检测到写操作意图 ... 已被守卫拦截, and exit with code 1 before any hcloud command executes.
parse user arguments , extract region (default cn-north-4), output mode (--json, --names-only, or table), filters (--name, --package-name), page size (default 400), and any other flags. validate region is a non-empty string.
confirm koo-cli availability , attempt to run hcloud --version in a subprocess to detect if the binary is installed. if found, proceed to step 4 (CLI path). if not found and huaweicloudsdkfunctiongraph is installed, proceed to step 5 (SDK fallback path).
(CLI path) construct and execute koo-cli command , build hcloud functiongraph ListFunctions --cli-region=<region> --maxitems=<page_size> [--func_name=<name>] [--package_name=<package>] [--marker=<cursor>]. wrap the call with skill-quality-cli run --skill-name huawei-cloud-functiongraph-list --. capture stdout and stderr.
(SDK fallback path) construct and execute SDK call , import huaweicloudsdkfunctiongraph.v2, instantiate FunctionGraphClient from credential env vars, call list_functions(ListFunctionsRequest(func_name=<name>, package_name=<package>, marker=<cursor>, limit=<page_size>)). capture the response object or exception.
parse response , extract the function array from hcloud JSON or SDK response object. flatten any nested fields (e.g., runtime.handler → handler). detect errors in hcloud output (e.g., [USE_ERROR] with exit code 0, [ApiError], 403 Forbidden, missing AK/SK hints).
client-side sort by func_name , sort the flattened function list by func_name in case-insensitive, stable order.
handle pagination , if the response includes a next_marker value and the current page is not empty, forward it to the next iteration as --marker=<next_marker> (CLI) or marker=<next_marker> (SDK). repeat until no next_marker is returned or the count reaches the total.
apply client-side filters (if server-side filters were not used) , optional: re-filter by name or package using string matching (fallback for old SDK versions that do not support server-side filters).
render output , based on output mode:
-. sort rows by func_name.--json: output the full flattened function array as JSON.--names-only: output one function name per line, sorted alphabetically.exit with status code , exit 0 if successful or if the region is empty (no functions found). exit 1 if any error occurs (auth, API, guard, hcloud not available, etc.). print explicit error hints per the Error Handling table below.
if KooCLI is installed → use CLI path (step 4). else if SDK is installed → use SDK fallback path (step 5). else → exit 1 with a hint to install KooCLI or SDK.
if write-intent guard detects a mutating keyword → exit 1 immediately with GuardError message; no command is executed.
if hcloud stdout contains [USE_ERROR] (even if exit code is 0) → treat as error (parameter mistake). exit 1 with a hint to run hcloud functiongraph ListFunctions --help.
if hcloud stderr contains 403 or "unauthorized" → exit 1 with 无权限访问 FunctionGraph,请检查 IAM 权限 (insufficient IAM permission).
if hcloud stderr contains "credentials" or "AK" or "SK" → exit 1 with a hint to configure credentials out-of-band (never in chat).
if hcloud returns non-JSON or cannot parse JSON → exit 1 with the raw stderr excerpt (first 200 chars).
if the function list is empty → exit 0, print 当前区域(<region>)无函数 (+ list active filters if any).
if --names-only is set → ignore --json and table mode. output names only.
if --json is set and --names-only is not set → output raw JSON array. ignore table mode.
if neither --json nor --names-only is set → output table (default).
if next_marker is present in the response → issue another CLI or SDK call with --marker=<next_marker> to fetch the next page. accumulate results and continue until no marker is returned.
if a field is missing on a particular function row → render as - in the table; omit from JSON (or render as null).
table mode (default):
-JSON mode (--json):
[{"func_name": "demo-func", "memory_size": 128, "timeout": 30, ...}, ...]names-only mode (--names-only):
empty region (no functions found):
当前区域(<region>)无函数(active filters: <filter_list>)[错误] or explicit hint (e.g., 无权限访问 FunctionGraph,请检查 IAM 权限)human user , the table is rendered and displays function names, memory, timeout, handler, runtime, and package in columns; rows are in alphabetical order by function name. if any error occurs, an explicit message hints at the root cause (403, missing AK/SK, hcloud not installed, etc.). if the region is empty, the message 当前区域(<region>)无函数 is printed.
downstream tooling , if --json is passed, the stdout is valid JSON with all functions sorted by name. the exit code is 0 on success or empty region, 1 on error.
names-only output , a simple line-delimited list of function names, one per line, in alphabetical order. suitable for piping to other tools (grep, xargs, etc.).
operations patrol , the skill lists all functions in a region with their memory, timeout, handler, and runtime, allowing quick inventory scanning and pre-query lookups for urn values to feed into other functiongraph skills.