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:
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-onlyoutput 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
huaweicloudsdkfunctiongraphv2 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
- KooCLI (
hcloud) installed — see references/cli-installation-guide.md. Alternative:pip install huaweicloudsdkcore huaweicloudsdkfunctiongraphto enable the SDK fallback path. - 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.
- IAM permission — read-only
functiongraph:function:list; least-privilege policy in references/iam-policies.md. - Python 3.8+ (standard library only — argparse / json / subprocess).
- 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
- Confirm the target region (default
cn-north-4); the function list is project-scoped and region-scoped. - Confirm KooCLI readiness (optional, read-only) by listing the active credential profile.
- Run the list script with the desired output mode and filters.
- Read the result — table for humans,
--jsonfor downstream tooling,--names-onlyfor a compact inventory; results are sorted by function name. - 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.
# 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_idis a required path parameter ofListFunctions, but KooCLI fills it automatically from the credential profile /cli-project-idconfig, so the script never emits it.
KooCLI Command Format Standard
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(huaweicloudsdkfunctiongraphv2_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 fromnext_marker),--maxitems(page size, max 400, default 400). There is no server-side sort parameter, so the script sorts byfunc_nameclient-side.
Write-Intent Guard
- The script scans all user arguments plus the
--operationvalue for mutating vocabulary (create,delete,update,modify,publish,invoke,import,export,remove,destroy, and FunctionGraph operation names such asCreateFunction,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 SDKlist_functionscall in the fallback path — is ever constructed bybuild_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):
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 | Least-privilege read-only IAM policy |
| references/cli-installation-guide.md | KooCLI installation and credential configuration |
| references/verification-method.md | How the skill and its tests were verified |
| references/dataflow-diagram.md | Mermaid data flow diagram |
| references/acceptance-criteria.md | Acceptance criteria checklist |
