Coding

huawei-cloud-bss-account-balance

Try it

Query the Huawei Cloud account balance (cash/credit account available amount and debt) and the account change records (recharge/consume/refund/adjust) over a configurable time window, defaulting to the last 6 months. Uses the BSS (Business Support System) customer API via the huaweicloudsdkbss SDK, consistent with the console Billing Center. Use when the user wants to: (1) check the current Huawei Cloud account balance, (2) review income/expense records for the last ~half year, (3) verify recharge/consume history, (4) monitor account funds before deployments or renewals. Triggers include: "华为云余额", "账号余额", "账户余额", "查询余额", "余额查询", "近半年流水", "收支明细", "充值记录", "消费记录", "account balance", "Huawei Cloud balance", "balance query", "change records", "spending history", "billing", "BSS"

What it does

Query the Huawei Cloud account balance (cash/credit account available amount and debt) and the account change records (recharge/consume/refund/adjust) over a configurable time window, defaulting to the last 6 months. Uses the BSS (Business Support System) customer API via the huaweicloudsdkbss SDK, consistent with the console Billing Center. Use when the user wants to: (1) check the current Huawei Cloud account balance, (2) review income/expense records for the last ~half year, (3) verify recharge/consume history, (4) monitor account funds before deployments or renewals. Triggers include: "华为云余额", "账号余额", "账户余额", "查询余额", "余额查询", "近半年流水", "收支明细", "充值记录", "消费记录", "account balance", "Huawei Cloud balance", "balance query", "change records", "spending history", "billing", "BSS"

The skill document

Huawei Cloud BSS Account Balance Query

Query the Huawei Cloud account balance and the account change records (recharge / consumption / refund / adjustment) over the last 6 months by default, using the BSS customer API (huaweicloudsdkbss SDK). The data returned is consistent with the Billing Center console.

Overview

This skill wraps two read-only BSS customer APIs:

FeatureSDK methodREST endpoint (verified from SDK source)
Current account balanceshow_customer_account_balancesGET /v2/accounts/customer-accounts/balances
Account change records (income/expense)list_customer_account_change_recordsGET /v2/accounts/customer-accounts/account-change-records

Both endpoints were verified from the huaweicloudsdkbss v2 SDK source (bss_client.py _http_info). BSS is a global service: the client must use GlobalCredentials + with_endpoints(["https://bss.myhuaweicloud.com"]).

Applicable scenarios:

  • "How much balance does my Huawei Cloud account have?" — quick funds check
  • "Show my income/expense records for the last 6 months" — half-year financial review
  • "Verify my recent recharges / consumption" — reconciliation before renewal or deployment

Architecture

Huawei Cloud BSS Account Balance Query
└── QueryBssAccountBalance (read-only)
    └── scripts/bss_balance_query.py
        ├── huaweicloudsdkbss SDK (show_customer_account_balances,
        │        list_customer_account_change_records)
        └── scripts/skill_quality_sdk.py (quality reporting, non-blocking)

Prerequisites

Prerequisite check: Python3 + huaweicloudsdkbss required

python3 --version  # Python3 >= 3.8
python3 -c "import huaweicloudsdkbss; print('OK')"  # BSS SDK

If the SDK is not installed: pip3 install --user huaweicloudsdkbss


Authentication

Prerequisite check: Huawei Cloud credentials required

Security rules (must be followed):

  • Prohibited from reading, echoing, or printing AK/SK values
  • Prohibited from asking the user to input AK/SK directly in the conversation
  • Prohibited from accepting AK/SK directly provided by the user in the conversation
  • Only allowed to read credentials from environment variables or a credentials file

⚠️ Important: Handling user-provided credentials

If a user attempts to provide AK/SK directly (e.g. "my AK is xxx, SK is yyy"):

  1. Stop immediately - Do not execute any commands

  2. Politely refuse and return the following message:

    For account security, please do not provide Huawei Cloud Access Key ID and Access Key Secret directly in the conversation.
    
    Please use one of the following secure methods to configure credentials:
    
    Method 1: Environment variables
        export HW_ACCESS_KEY=
        export HW_SECRET_KEY=
        (also supported: HUAWEI_ACCESS_KEY/HUAWEI_SECRET_KEY, HUAWEICLOUD_SDK_AK/HUAWEICLOUD_SDK_SK)
    
    Method 2: Credentials file
        Create a file (e.g., ~/aksk.txt) with AK on line 1, SK on line 2.
        Then use: --credentials-file ~/aksk.txt
    
  3. Do not continue executing any Huawei Cloud operations until credentials are configured

Check environment variables:

echo $HW_ACCESS_KEY  # Check if AK is set

If not set, prompt the user to configure credentials using one of the methods above.


IAM Permission Policies

Ensure the IAM user has the required permissions. See references/iam-policies.md for details.

Minimum required permissions:

  • bss:balance:view — Query account balance
  • bss:bill:view — Query account change records / bills

Core Workflow

Task 1: Query Current Account Balance (FP-01)

python3 scripts/bss_balance_query.py --balance-type BALANCE_TYPE_DEBIT

Task 2: Query Last-6-Months Change Records (FP-02)

# Default: last 6 months, cash account
python3 scripts/bss_balance_query.py

# Explicit time window (e.g. last 6 months)
python3 scripts/bss_balance_query.py \
  --begin $(date -d '6 months ago' +%Y-%m-%d) --end $(date +%Y-%m-%d)

# Credit account / pagination
python3 scripts/bss_balance_query.py --balance-type BALANCE_TYPE_CREDIT --offset 0 --limit 100

Both queries run together in one invocation and print a combined JSON result:

  • balance.account_balances[] — amount / currency / credit_amount per account type
  • balance.debt_amount — outstanding debt
  • change_records.records[] — trade_time / trade_id / trade_detail_type / change_amount / balance_after_change / type
  • change_records.total_count — total matching records in the window

Core Commands

# 1. Quick balance check (cash account, last 6 months)
python3 scripts/bss_balance_query.py --balance-type BALANCE_TYPE_DEBIT

# 2. Balance + change records with explicit 6-month range
python3 scripts/bss_balance_query.py \
  --begin 2026-02-10 --end 2026-08-10 --limit 100

# 3. Credit account query
python3 scripts/bss_balance_query.py --balance-type BALANCE_TYPE_CREDIT --months 6

# 4. Raw API response (debugging)
python3 scripts/bss_balance_query.py --raw

Parameter Confirmation

ParameterRequiredDescriptionDefault
--balance-typeNoBALANCE_TYPE_DEBIT (cash account) or BALANCE_TYPE_CREDIT (credit account); other values are rejectedBALANCE_TYPE_DEBIT
--monthsNoQuery window in months (half a year = 6); must be a positive integer6
--begin / --endNoExplicit date range YYYY-MM-DD; must be provided together, otherwise the script exits with a clear errorauto (last N months)
--offsetNoPage offset for change records0
--limitNoPage size for change records, 1–100 (BSS caps at 100; larger values are rejected with a hint)100
--rawNoPrint raw API response instead of the summaryoff

Input validation: the script validates --begin/--end pairing, date format (YYYY-MM-DD), --begin <= --end, --balance-type enum, --limit range and --months positivity before calling the API. Invalid input prints a readable Error: message on stderr and exits with code 1 (argparse type errors exit with code 2). SDK errors (ClientRequestException) are rendered as BSS API error: code=..., message=... with a fix suggestion instead of a raw traceback.

Verification

See references/verification-method.md.

Quick verification:

export HW_ACCESS_KEY=
export HW_SECRET_KEY=
# 或使用标准华为云环境变量: HUAWEI_ACCESS_KEY/HUAWEI_SECRET_KEY 或 HUAWEICLOUD_SDK_AK/HUAWEICLOUD_SDK_SK
python3 scripts/bss_balance_query.py --balance-type BALANCE_TYPE_DEBIT --months 6

Quality reporting: every run of scripts/bss_balance_query.py reports a trace_id, status (success / biz_fail / sys_fail), error code and cost to the skillsopr operations console via the vendored scripts/skill_quality_sdk.py. Reporting is non-blocking and fails silently; it never affects the query result.


References

DocumentDescription
iam-policies.mdLeast-privilege IAM permission policies
verification-method.mdVerification steps
dataflow-diagram.mdMermaid data flow diagram
acceptance-criteria.mdCorrect/error pattern comparison
bss-account-balance-api.mdVerified BSS API and parameter details
bss_balance_query.pyBalance + change records query script
skill_quality_sdk.pyVendored quality reporting SDK (non-blocking)

Related skills

Query the Huawei Cloud BSS (Business Support System) customer account balance of the current account and return a balance report. Returns the currency, total debt amount, and per-account balances (cash/balance account, credit account, reward account, deposit account) with amounts. Uses the huaweicloudsdkbss Python SDK (`show_customer_account_balances`, v2 API `GET /v2/accounts/customer-accounts/balances`) — KooCLI does NOT support the BSS service, so the SDK is the only execution path. The shipped scripts/query_account_balance.py integrates the execution-quality reporting SDK and reports every run to the skillsopr operations console. Read-only — never creates, modifies or deletes any billing resource. Use this skill whenever the user wants to check the personal Huawei Cloud account balance, remaining balance, debt, or billing account status, e.g. for cost review, before creating pay-per-use resources, or daily inspection. Triggers include: "账户余额", "余额查询", "查询余额", "账单余额", "我的余额", "欠费",

Query the Huawei Cloud BSS (Business Support System) account balance and its history across different time periods, and return a report. Supports three read-only queries: (1) current customer account balance (currency, total debt amount, per-account balances for cash/credit/reward/deposit), (2) balance change records (income/expense detail: recharge, consumption, refund, freeze, etc.) within a user-specified date range, and (3) monthly consumption summary for a user-specified billing cycle (YYYY-MM). Uses the huaweicloudsdkbss Python SDK (show_customer_account_balances, list_customer_account_change_records, show_customer_monthly_sum; v2 API GET /v2/accounts/customer-accounts/balances, /v2/accounts/customer-accounts/account-change-records, /v2/bills/customer-bills/monthly-sum) — KooCLI does NOT support the BSS service, so the SDK is the only execution path. The shipped scripts/query_balance_history.py integrates the execution-quality reporting SDK and reports every run to the skillsopr

Huawei Cloud BSS billing (not AWS/Azure/other clouds; refuses pricing quotes, real-name review, and any non-billing scope): balance, spend, attribution, reconciliation, coupons, stored-value cards, enterprise/partner billing. One-page briefing via hcloud. Use only when the user explicitly mentions 华为云 / Huawei Cloud / BSS and 余额/账单/对账/资源包/代金券/储值卡/企业或伙伴账务; refuses pay, renew, refund, delete.

by huaweicloud-skills-team

Query the Huawei Cloud BSS (Business Support System) bills and fees of the current account within ONE billing cycle (one month). Supports three read-only queries: (1) bill fee records (账单费用记录/账单明细) for a billing cycle (YYYY-MM), (2) resource fee records / 流水账单 for a billing cycle, and (3) monthly cost breakdown (月度成本分析). Uses the huaweicloudsdkbss Python SDK (list_customer_bills_fee_records, list_customerself_resource_records, list_customer_bills_monthly_break_down; v2 API GET /v2/bills/customer-bills/fee-records, /v2/bills/customer-bills/res-fee-records, /v2/costs/cost-analysed-bills/monthly-breakdown) — KooCLI does NOT support the BSS service, so the SDK is the only execution path. The shipped scripts/query_bills.py integrates the execution-quality reporting SDK and reports every run to the skillsopr operations console. Time scope is limited to one month (the current month by default) — no multi-month or unbounded range queries. Read-only — never creates, modifies or deletes any bill

Queries Huawei Cloud billing and fee details only when Terraform needs a billing or pricing inquiry. Covers balances, bills, coupons, cash coupons, stored-value cards, orders, refunds, costs, free resources, resource usage, enterprise accounts, and on-demand/period/ELB/NAT/DCS pricing. No write operations. Use this skill only when Terraform requires billing details, invoice/bill summaries, coupon or balance status, refund/order billing status, or pricing inquiry. Triggers: Terraform 账单查询, Terraform 费用查询, Terraform 价格询价, Terraform 询价, Terraform billing query, Terraform pricing inquiry, Terraform price quote, Terraform bill summary.

by huaweiclouddev-dev

Queries Huawei Cloud billing and pricing. Covers balances, bills, coupons, cash coupons, stored-value cards, orders, refunds, costs, free resources, resource...

1 installs