huaweicloud-devkit 1.0.2-dev.9 → 1.0.2-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/plugins/marketplace.json +20 -20
- package/LICENSE +201 -201
- package/README.md +163 -138
- package/README.zh-CN.md +161 -138
- package/bin/setup.cjs +8 -8
- package/integrations/opencode/commands/huaweicloud-doctor.md +14 -14
- package/integrations/opencode/opencode.json +14 -14
- package/integrations/opencode/skills/huaweicloud-core/SKILL.md +32 -32
- package/package.json +46 -44
- package/plugins/huaweicloud-core/.claude-plugin/plugin.json +44 -44
- package/plugins/huaweicloud-core/.codex-plugin/plugin.json +43 -43
- package/plugins/huaweicloud-core/.cursor-plugin/plugin.json +44 -44
- package/plugins/huaweicloud-core/.mcp.json +15 -15
- package/plugins/huaweicloud-core/.workbuddy-plugin/plugin.json +44 -44
- package/plugins/huaweicloud-core/hooks/hooks.json +26 -26
- package/plugins/huaweicloud-core/hooks/huaweicloud-safety.py +136 -136
- package/plugins/huaweicloud-core/safety/policy.json +99 -99
- package/plugins/huaweicloud-core/safety/rules/cloud-risk-rules.json +199 -199
- package/plugins/huaweicloud-core/skills/huawei-apig/SKILL.md +164 -164
- package/plugins/huaweicloud-core/skills/huawei-billing/SKILL.md +48 -48
- package/plugins/huaweicloud-core/skills/huawei-cbr/SKILL.md +50 -50
- package/plugins/huaweicloud-core/skills/huawei-cce/SKILL.md +101 -101
- package/plugins/huaweicloud-core/skills/huawei-cloud-eye/SKILL.md +90 -90
- package/plugins/huaweicloud-core/skills/huawei-cloud-find-skills/SKILL.md +190 -190
- package/plugins/huaweicloud-core/skills/huawei-cloud-find-skills/scripts/search-skills.mjs +124 -124
- package/plugins/huaweicloud-core/skills/huawei-cts/SKILL.md +55 -55
- package/plugins/huaweicloud-core/skills/huawei-dds-dcs/SKILL.md +70 -70
- package/plugins/huaweicloud-core/skills/huawei-deployment/SKILL.md +56 -56
- package/plugins/huaweicloud-core/skills/huawei-dew/SKILL.md +97 -97
- package/plugins/huaweicloud-core/skills/huawei-dew/references/csms-usage.md +29 -29
- package/plugins/huaweicloud-core/skills/huawei-dew/references/kms-usage.md +23 -23
- package/plugins/huaweicloud-core/skills/huawei-ecs/SKILL.md +185 -185
- package/plugins/huaweicloud-core/skills/huawei-ecs/references/create-instance.md +133 -133
- package/plugins/huaweicloud-core/skills/huawei-ecs/references/evs.md +31 -31
- package/plugins/huaweicloud-core/skills/huawei-ecs/references/flavors.md +55 -55
- package/plugins/huaweicloud-core/skills/huawei-ecs/references/troubleshooting.md +52 -52
- package/plugins/huaweicloud-core/skills/huawei-functiongraph/SKILL.md +131 -131
- package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/apig-event-format.md +58 -58
- package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/create-function.md +71 -71
- package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/deploy-workflow.md +119 -119
- package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/triggers.md +142 -142
- package/plugins/huaweicloud-core/skills/huawei-gaussdb/SKILL.md +56 -56
- package/plugins/huaweicloud-core/skills/huawei-getting-started/SKILL.md +65 -65
- package/plugins/huaweicloud-core/skills/huawei-iam/SKILL.md +111 -111
- package/plugins/huaweicloud-core/skills/huawei-iam/references/policy-examples.md +122 -122
- package/plugins/huaweicloud-core/skills/huawei-iam/references/quick-ref.md +56 -56
- package/plugins/huaweicloud-core/skills/huawei-modelarts/SKILL.md +65 -65
- package/plugins/huaweicloud-core/skills/huawei-obs/SKILL.md +133 -127
- package/plugins/huaweicloud-core/skills/huawei-obs/references/bucket-create.md +49 -49
- package/plugins/huaweicloud-core/skills/huawei-obs/references/bucket-lifecycle.md +26 -26
- package/plugins/huaweicloud-core/skills/huawei-obs/references/common-pitfalls.md +100 -100
- package/plugins/huaweicloud-core/skills/huawei-obs/references/single-file-share.md +40 -40
- package/plugins/huaweicloud-core/skills/huawei-obs/references/static-website.md +56 -56
- package/plugins/huaweicloud-core/skills/huawei-rds/SKILL.md +224 -224
- package/plugins/huaweicloud-core/skills/huawei-sandbox/SKILL.md +135 -134
- package/plugins/huaweicloud-core/skills/huawei-smn-dms/SKILL.md +69 -69
- package/plugins/huaweicloud-core/skills/huawei-vpc/SKILL.md +84 -84
- package/plugins/huaweicloud-core/skills/huawei-vpc/references/network.md +76 -76
- package/plugins/huaweicloud-core/skills/huawei-vpc/references/security-group.md +59 -59
- package/plugins/huaweicloud-core/skills/huawei-vpc/references/subnet.md +50 -50
- package/plugins/huaweicloud-core/skills/huawei-waf-aad/SKILL.md +63 -63
- package/plugins/huaweicloud-core/skills/huaweicloud-api-and-sdk/SKILL.md +56 -56
- package/plugins/huaweicloud-core/skills/huaweicloud-api-and-sdk/agents/openai.yaml +4 -4
- package/plugins/huaweicloud-core/skills/huaweicloud-capability-discovery/SKILL.md +51 -47
- package/plugins/huaweicloud-core/skills/huaweicloud-capability-discovery/agents/openai.yaml +4 -4
- package/plugins/huaweicloud-core/skills/huaweicloud-cli-and-auth/SKILL.md +128 -128
- package/plugins/huaweicloud-core/skills/huaweicloud-cli-and-auth/agents/openai.yaml +4 -4
- package/plugins/huaweicloud-core/skills/huaweicloud-core/SKILL.md +110 -95
- package/plugins/huaweicloud-core/skills/huaweicloud-core/agents/openai.yaml +4 -4
- package/plugins/huaweicloud-core/skills/huaweicloud-core/references/report-issue.md +19 -19
- package/plugins/huaweicloud-core/skills/huaweicloud-core/references/select.md +27 -27
- package/plugins/huaweicloud-core/skills/huaweicloud-safety/SKILL.md +60 -60
- package/plugins/huaweicloud-core/skills/huaweicloud-safety/agents/openai.yaml +4 -4
- package/plugins/huaweicloud-core/skills/huaweicloud-troubleshooting/SKILL.md +83 -83
- package/plugins/huaweicloud-core/skills/huaweicloud-troubleshooting/agents/openai.yaml +4 -4
- package/plugins/huaweicloud-core/src/auth/agent-registration.mjs +105 -87
- package/plugins/huaweicloud-core/src/auth/credentials.mjs +95 -95
- package/plugins/huaweicloud-core/src/auth/service.mjs +63 -63
- package/plugins/huaweicloud-core/src/hcloud-cli.mjs +265 -265
- package/plugins/huaweicloud-core/src/mcp-server.mjs +129 -129
- package/plugins/huaweicloud-core/src/proxy/proxy-agent.mjs +155 -0
- package/plugins/huaweicloud-core/src/proxy/proxy-config.mjs +87 -0
- package/plugins/huaweicloud-core/src/risk-rule-engine.mjs +137 -137
- package/plugins/huaweicloud-core/src/safety-policy.mjs +302 -302
- package/plugins/huaweicloud-core/src/sandbox/hdkitservice-api.mjs +91 -87
- package/plugins/huaweicloud-core/src/sandbox/hwlink-api.mjs +162 -153
- package/plugins/huaweicloud-core/src/sandbox/session-manager.mjs +112 -105
- package/plugins/huaweicloud-core/src/search-market.mjs +174 -169
- package/plugins/huaweicloud-core/src/setup-cli.mjs +2017 -1594
- package/plugins/huaweicloud-core/src/tools.mjs +1008 -993
- package/plugins/huaweicloud-core/src/ws-exec/hwlink-exec-client.js +427 -427
- package/plugins/huaweicloud-core/src/ws-exec/hwlink-fair-queue.js +132 -132
- package/plugins/huaweicloud-core/src/ws-exec/hwlink-multiplexer.js +227 -227
- package/plugins/huaweicloud-core/src/ws-exec/hwlink-packet.js +202 -202
- package/plugins/huaweicloud-core/src/ws-exec/hwlink-terminal-channel.js +158 -158
- package/plugins/huaweicloud-core/src/ws-exec/index.js +19 -19
- package/plugins/huaweicloud-core/src/ws-exec/ws-exec-client.js +338 -338
|
@@ -1,131 +1,131 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: huawei-functiongraph
|
|
3
|
-
description: "Use when creating, deploying, or managing serverless functions on FunctionGraph. Covers triggers (APIG/OBS/timer/SMN), cold start, reserved concurrency. Triggers: FunctionGraph, serverless, function, Lambda, trigger. NOT for: CCE containers (use huawei-cce)."
|
|
4
|
-
version: 1
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Huawei Cloud FunctionGraph
|
|
8
|
-
|
|
9
|
-
**STOP - Do not answer from general knowledge.** Follow the procedure below.
|
|
10
|
-
|
|
11
|
-
## Overview
|
|
12
|
-
|
|
13
|
-
Domain expertise for Huawei Cloud FunctionGraph. Covers function lifecycle, code deployment, trigger configuration, and troubleshooting.
|
|
14
|
-
|
|
15
|
-
## How to Use This Skill
|
|
16
|
-
|
|
17
|
-
1. This skill tells you the **correct service/operation names** and **non-obvious traps**.
|
|
18
|
-
2. **Parameters are discovered via `--help`, not hardcoded.** Always run `hcloud FunctionGraph <Operation> --help` before constructing commands.
|
|
19
|
-
3. Detailed examples are in `references/` — load them only when needed.
|
|
20
|
-
|
|
21
|
-
## Critical Warnings
|
|
22
|
-
|
|
23
|
-
| Trap | Why |
|
|
24
|
-
|------|-----|
|
|
25
|
-
| Service name is `FunctionGraph` | NOT `FGS`. KooCLI 7.x uses the full service name |
|
|
26
|
-
| CLI requires `project_id` | Get it: `hcloud IAM KeystoneListProjects` or extract from URN `urn:fss:<region>:<project_id>:...` |
|
|
27
|
-
| Cold start 100ms-2s | Reserve concurrency for latency-sensitive workloads |
|
|
28
|
-
| Max execution 900s | Use ECS/CCE for long-running tasks |
|
|
29
|
-
| Env vars plaintext | Use DEW for secrets |
|
|
30
|
-
| **ZIP upload is unreliable** | `CreateFunction --code_type=zip --code_filename=xxx.zip` succeeds even with a nonexistent file — the function is created with empty code. Prefer `code_type=inline` for simple functions. If using zip, verify `code_size` > placeholder after creation and run `InvokeFunction` to confirm output. |
|
|
31
|
-
| **DeleteFunction strip `:latest`** | Passing `urn:fss:...:function:xxx:latest` causes FSS.0400. Strip `:latest` suffix (DeleteFunction only — UpdateApiV2 needs the full URN). |
|
|
32
|
-
| **DeleteFunctionTrigger does NOT cascade** | Deleting a DEDICATEDGATEWAY trigger leaves the API in APIG. Manually clean up: `hcloud APIG DeleteApiV2 --instance_id=<id> --api_id=<api-id>`. |
|
|
33
|
-
|
|
34
|
-
## Prerequisites
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
hcloud configure list # confirm a profile exists
|
|
38
|
-
hcloud FunctionGraph --help # confirm service is available
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
## IAM Permissions
|
|
42
|
-
|
|
43
|
-
If you see `FSS.0403 Forbidden`, the user needs these permissions:
|
|
44
|
-
|
|
45
|
-
| Operation | Required Permission |
|
|
46
|
-
|-----------|---------------------|
|
|
47
|
-
| Create function | `functiongraph:function:createFunction` |
|
|
48
|
-
| List functions | `functiongraph:function:list` |
|
|
49
|
-
| Delete function | `functiongraph:function:deleteFunction` |
|
|
50
|
-
| Invoke function | `functiongraph:function:invoke` |
|
|
51
|
-
| Create trigger | `functiongraph:trigger:*` |
|
|
52
|
-
|
|
53
|
-
Grant via IAM console (`FunctionGraph FullAccess` role) or ask project admin.
|
|
54
|
-
|
|
55
|
-
## Operations
|
|
56
|
-
|
|
57
|
-
Always discover parameters with `--help` before executing. These are the correct operation names:
|
|
58
|
-
|
|
59
|
-
| Task | Operation | Gotchas |
|
|
60
|
-
|------|-----------|---------|
|
|
61
|
-
| List functions | `ListFunctions` | |
|
|
62
|
-
| Show function | `ShowFunctionConfig` | |
|
|
63
|
-
| Create function | `CreateFunction` | references/create-function.md |
|
|
64
|
-
| Delete function | `DeleteFunction` | Strip `:latest` from URN |
|
|
65
|
-
| Invoke function | `InvokeFunction` | Requires body param (`--name=<value>` becomes event body). Use `--x_cff_request_version=v0` for raw output, `v1` for APIG-wrapped. |
|
|
66
|
-
| Create trigger | `CreateFunctionTrigger` | references/triggers.md |
|
|
67
|
-
| List triggers | `ListFunctionTriggers` | |
|
|
68
|
-
| Delete trigger | `DeleteFunctionTrigger` | |
|
|
69
|
-
|
|
70
|
-
Discover exact parameters:
|
|
71
|
-
```bash
|
|
72
|
-
hcloud FunctionGraph CreateFunction --help
|
|
73
|
-
hcloud FunctionGraph CreateFunctionTrigger --help
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
## Deployment Workflow
|
|
77
|
-
|
|
78
|
-
```
|
|
79
|
-
Write code → zip → CreateFunction → InvokeFunction → CreateFunctionTrigger
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
See `references/deploy-workflow.md` for a step-by-step example with code templates.
|
|
83
|
-
|
|
84
|
-
## Troubleshooting
|
|
85
|
-
|
|
86
|
-
| Error | Root Cause -> Fix |
|
|
87
|
-
|-------|------------------|
|
|
88
|
-
| `不支持的服务名称:FGS` | Use `FunctionGraph`, not `FGS` |
|
|
89
|
-
| `不支持的operation:CreateTrigger` | Use `CreateFunctionTrigger` |
|
|
90
|
-
| `FSS.0403` / Forbidden | Missing IAM permissions — see IAM Permissions above |
|
|
91
|
-
| `缺少必填参数:{*}` on Invoke | Add body param: `--name=<value>` |
|
|
92
|
-
| APIG/EOM trigger error | `trigger_type_code=APIG` deprecated — use `DEDICATEDGATEWAY` |
|
|
93
|
-
| `event_data` parse error | Use dotted format: `--event_data.key=value`, NOT JSON string |
|
|
94
|
-
| FSS.1078 / code upload fails | `--code_filename` is filename-only, no path. `cd` to zip directory first |
|
|
95
|
-
| DeleteFunction with `:latest` | Strip `:latest` version suffix from URN |
|
|
96
|
-
| Code too large | Inline limit 10KB — use `zip`/`obs` code type |
|
|
97
|
-
| Cold start slow | Set reserved instances for critical functions |
|
|
98
|
-
| Auth failure | Run `npx huaweicloud-devkit auth init` |
|
|
99
|
-
|
|
100
|
-
## Security Considerations
|
|
101
|
-
|
|
102
|
-
- MUST use DEW for secrets, never hardcode in environment variables
|
|
103
|
-
- MUST use `--app_xrole` (agency) for cross-service access
|
|
104
|
-
- SHOULD enable CTS audit logging for function invocations
|
|
105
|
-
- MUST NOT expose AK/SK in function code
|
|
106
|
-
|
|
107
|
-
## MCP Tools
|
|
108
|
-
|
|
109
|
-
- `huaweicloud_list_operations` service=FunctionGraph
|
|
110
|
-
- `huaweicloud_run_readonly_command` for discovery
|
|
111
|
-
- `huaweicloud_run_approved_command` for writes
|
|
112
|
-
|
|
113
|
-
## Without MCP
|
|
114
|
-
|
|
115
|
-
Fall back to hcloud CLI. State: "MCP unavailable, using local hcloud CLI."
|
|
116
|
-
|
|
117
|
-
## Cross-Skill References
|
|
118
|
-
|
|
119
|
-
- **APIG trigger setup**: See `huawei-apig` for API group creation and publishing
|
|
120
|
-
- **OBS trigger setup**: See `huawei-obs` for bucket and object event configuration
|
|
121
|
-
- **DEW secrets**: See `huawei-dew` for managing function secrets
|
|
122
|
-
- **SMN notifications**: See `huawei-smn-dms` for notification topics
|
|
123
|
-
- **VPC configuration**: See `huawei-vpc` for network settings
|
|
124
|
-
|
|
125
|
-
## References
|
|
126
|
-
|
|
127
|
-
- FunctionGraph Docs: https://support.huaweicloud.com/functiongraph/
|
|
128
|
-
- Create function: references/create-function.md
|
|
129
|
-
- Triggers: references/triggers.md
|
|
130
|
-
- Deploy workflow: references/deploy-workflow.md
|
|
131
|
-
- APIG event format: references/apig-event-format.md
|
|
1
|
+
---
|
|
2
|
+
name: huawei-functiongraph
|
|
3
|
+
description: "Use when creating, deploying, or managing serverless functions on FunctionGraph. Covers triggers (APIG/OBS/timer/SMN), cold start, reserved concurrency. Triggers: FunctionGraph, serverless, function, Lambda, trigger. NOT for: CCE containers (use huawei-cce)."
|
|
4
|
+
version: 1
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Huawei Cloud FunctionGraph
|
|
8
|
+
|
|
9
|
+
**STOP - Do not answer from general knowledge.** Follow the procedure below.
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
Domain expertise for Huawei Cloud FunctionGraph. Covers function lifecycle, code deployment, trigger configuration, and troubleshooting.
|
|
14
|
+
|
|
15
|
+
## How to Use This Skill
|
|
16
|
+
|
|
17
|
+
1. This skill tells you the **correct service/operation names** and **non-obvious traps**.
|
|
18
|
+
2. **Parameters are discovered via `--help`, not hardcoded.** Always run `hcloud FunctionGraph <Operation> --help` before constructing commands.
|
|
19
|
+
3. Detailed examples are in `references/` — load them only when needed.
|
|
20
|
+
|
|
21
|
+
## Critical Warnings
|
|
22
|
+
|
|
23
|
+
| Trap | Why |
|
|
24
|
+
|------|-----|
|
|
25
|
+
| Service name is `FunctionGraph` | NOT `FGS`. KooCLI 7.x uses the full service name |
|
|
26
|
+
| CLI requires `project_id` | Get it: `hcloud IAM KeystoneListProjects` or extract from URN `urn:fss:<region>:<project_id>:...` |
|
|
27
|
+
| Cold start 100ms-2s | Reserve concurrency for latency-sensitive workloads |
|
|
28
|
+
| Max execution 900s | Use ECS/CCE for long-running tasks |
|
|
29
|
+
| Env vars plaintext | Use DEW for secrets |
|
|
30
|
+
| **ZIP upload is unreliable** | `CreateFunction --code_type=zip --code_filename=xxx.zip` succeeds even with a nonexistent file — the function is created with empty code. Prefer `code_type=inline` for simple functions. If using zip, verify `code_size` > placeholder after creation and run `InvokeFunction` to confirm output. |
|
|
31
|
+
| **DeleteFunction strip `:latest`** | Passing `urn:fss:...:function:xxx:latest` causes FSS.0400. Strip `:latest` suffix (DeleteFunction only — UpdateApiV2 needs the full URN). |
|
|
32
|
+
| **DeleteFunctionTrigger does NOT cascade** | Deleting a DEDICATEDGATEWAY trigger leaves the API in APIG. Manually clean up: `hcloud APIG DeleteApiV2 --instance_id=<id> --api_id=<api-id>`. |
|
|
33
|
+
|
|
34
|
+
## Prerequisites
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
hcloud configure list # confirm a profile exists
|
|
38
|
+
hcloud FunctionGraph --help # confirm service is available
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## IAM Permissions
|
|
42
|
+
|
|
43
|
+
If you see `FSS.0403 Forbidden`, the user needs these permissions:
|
|
44
|
+
|
|
45
|
+
| Operation | Required Permission |
|
|
46
|
+
|-----------|---------------------|
|
|
47
|
+
| Create function | `functiongraph:function:createFunction` |
|
|
48
|
+
| List functions | `functiongraph:function:list` |
|
|
49
|
+
| Delete function | `functiongraph:function:deleteFunction` |
|
|
50
|
+
| Invoke function | `functiongraph:function:invoke` |
|
|
51
|
+
| Create trigger | `functiongraph:trigger:*` |
|
|
52
|
+
|
|
53
|
+
Grant via IAM console (`FunctionGraph FullAccess` role) or ask project admin.
|
|
54
|
+
|
|
55
|
+
## Operations
|
|
56
|
+
|
|
57
|
+
Always discover parameters with `--help` before executing. These are the correct operation names:
|
|
58
|
+
|
|
59
|
+
| Task | Operation | Gotchas |
|
|
60
|
+
|------|-----------|---------|
|
|
61
|
+
| List functions | `ListFunctions` | |
|
|
62
|
+
| Show function | `ShowFunctionConfig` | |
|
|
63
|
+
| Create function | `CreateFunction` | references/create-function.md |
|
|
64
|
+
| Delete function | `DeleteFunction` | Strip `:latest` from URN |
|
|
65
|
+
| Invoke function | `InvokeFunction` | Requires body param (`--name=<value>` becomes event body). Use `--x_cff_request_version=v0` for raw output, `v1` for APIG-wrapped. |
|
|
66
|
+
| Create trigger | `CreateFunctionTrigger` | references/triggers.md |
|
|
67
|
+
| List triggers | `ListFunctionTriggers` | |
|
|
68
|
+
| Delete trigger | `DeleteFunctionTrigger` | |
|
|
69
|
+
|
|
70
|
+
Discover exact parameters:
|
|
71
|
+
```bash
|
|
72
|
+
hcloud FunctionGraph CreateFunction --help
|
|
73
|
+
hcloud FunctionGraph CreateFunctionTrigger --help
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Deployment Workflow
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
Write code → zip → CreateFunction → InvokeFunction → CreateFunctionTrigger
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
See `references/deploy-workflow.md` for a step-by-step example with code templates.
|
|
83
|
+
|
|
84
|
+
## Troubleshooting
|
|
85
|
+
|
|
86
|
+
| Error | Root Cause -> Fix |
|
|
87
|
+
|-------|------------------|
|
|
88
|
+
| `不支持的服务名称:FGS` | Use `FunctionGraph`, not `FGS` |
|
|
89
|
+
| `不支持的operation:CreateTrigger` | Use `CreateFunctionTrigger` |
|
|
90
|
+
| `FSS.0403` / Forbidden | Missing IAM permissions — see IAM Permissions above |
|
|
91
|
+
| `缺少必填参数:{*}` on Invoke | Add body param: `--name=<value>` |
|
|
92
|
+
| APIG/EOM trigger error | `trigger_type_code=APIG` deprecated — use `DEDICATEDGATEWAY` |
|
|
93
|
+
| `event_data` parse error | Use dotted format: `--event_data.key=value`, NOT JSON string |
|
|
94
|
+
| FSS.1078 / code upload fails | `--code_filename` is filename-only, no path. `cd` to zip directory first |
|
|
95
|
+
| DeleteFunction with `:latest` | Strip `:latest` version suffix from URN |
|
|
96
|
+
| Code too large | Inline limit 10KB — use `zip`/`obs` code type |
|
|
97
|
+
| Cold start slow | Set reserved instances for critical functions |
|
|
98
|
+
| Auth failure | Run `npx huaweicloud-devkit auth init` |
|
|
99
|
+
|
|
100
|
+
## Security Considerations
|
|
101
|
+
|
|
102
|
+
- MUST use DEW for secrets, never hardcode in environment variables
|
|
103
|
+
- MUST use `--app_xrole` (agency) for cross-service access
|
|
104
|
+
- SHOULD enable CTS audit logging for function invocations
|
|
105
|
+
- MUST NOT expose AK/SK in function code
|
|
106
|
+
|
|
107
|
+
## MCP Tools
|
|
108
|
+
|
|
109
|
+
- `huaweicloud_list_operations` service=FunctionGraph
|
|
110
|
+
- `huaweicloud_run_readonly_command` for discovery
|
|
111
|
+
- `huaweicloud_run_approved_command` for writes
|
|
112
|
+
|
|
113
|
+
## Without MCP
|
|
114
|
+
|
|
115
|
+
Fall back to hcloud CLI. State: "MCP unavailable, using local hcloud CLI."
|
|
116
|
+
|
|
117
|
+
## Cross-Skill References
|
|
118
|
+
|
|
119
|
+
- **APIG trigger setup**: See `huawei-apig` for API group creation and publishing
|
|
120
|
+
- **OBS trigger setup**: See `huawei-obs` for bucket and object event configuration
|
|
121
|
+
- **DEW secrets**: See `huawei-dew` for managing function secrets
|
|
122
|
+
- **SMN notifications**: See `huawei-smn-dms` for notification topics
|
|
123
|
+
- **VPC configuration**: See `huawei-vpc` for network settings
|
|
124
|
+
|
|
125
|
+
## References
|
|
126
|
+
|
|
127
|
+
- FunctionGraph Docs: https://support.huaweicloud.com/functiongraph/
|
|
128
|
+
- Create function: references/create-function.md
|
|
129
|
+
- Triggers: references/triggers.md
|
|
130
|
+
- Deploy workflow: references/deploy-workflow.md
|
|
131
|
+
- APIG event format: references/apig-event-format.md
|
package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/apig-event-format.md
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
# APIG DEDICATEDGATEWAY Event Format
|
|
2
|
-
|
|
3
|
-
When APIG calls FunctionGraph via DEDICATEDGATEWAY trigger, the event structure is NOT the standard HTTP event. Key differences:
|
|
4
|
-
|
|
5
|
-
## Event Structure
|
|
6
|
-
|
|
7
|
-
```json
|
|
8
|
-
{
|
|
9
|
-
"isBase64Encoded": true,
|
|
10
|
-
"body": "<Base64-encoded request body>",
|
|
11
|
-
"httpMethod": "POST",
|
|
12
|
-
"requestContext": {
|
|
13
|
-
"apiId": "xxx",
|
|
14
|
-
"requestId": "xxx",
|
|
15
|
-
"stage": "RELEASE"
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## Critical: body is Base64 Encoded
|
|
21
|
-
|
|
22
|
-
`event["body"]` is Base64 encoded. You MUST decode it:
|
|
23
|
-
|
|
24
|
-
**Python handler template:**
|
|
25
|
-
```python
|
|
26
|
-
import json, base64
|
|
27
|
-
|
|
28
|
-
def handler(event, context):
|
|
29
|
-
body = event.get("body", "")
|
|
30
|
-
if event.get("isBase64Encoded"):
|
|
31
|
-
body = base64.b64decode(body).decode("utf-8")
|
|
32
|
-
data = json.loads(body) if body else {}
|
|
33
|
-
return {
|
|
34
|
-
"statusCode": 200,
|
|
35
|
-
"body": json.dumps({"message": "ok", "received": data}),
|
|
36
|
-
"headers": {"Content-Type": "application/json"}
|
|
37
|
-
}
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
**Node.js handler template:**
|
|
41
|
-
```js
|
|
42
|
-
exports.handler = async (event, context) => {
|
|
43
|
-
let body = event.body || "";
|
|
44
|
-
if (event.isBase64Encoded) {
|
|
45
|
-
body = Buffer.from(body, "base64").toString("utf8");
|
|
46
|
-
}
|
|
47
|
-
const data = body ? JSON.parse(body) : {};
|
|
48
|
-
return {
|
|
49
|
-
statusCode: 200,
|
|
50
|
-
body: JSON.stringify({ message: "ok", received: data }),
|
|
51
|
-
headers: { "Content-Type": "application/json" }
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
## Missing Fields vs Standard HTTP
|
|
57
|
-
|
|
58
|
-
Fields NOT in DEDICATEDGATEWAY event: `event.path`, `event.headers`, `event.queryStringParameters`. Use `event.httpMethod` for method detection.
|
|
1
|
+
# APIG DEDICATEDGATEWAY Event Format
|
|
2
|
+
|
|
3
|
+
When APIG calls FunctionGraph via DEDICATEDGATEWAY trigger, the event structure is NOT the standard HTTP event. Key differences:
|
|
4
|
+
|
|
5
|
+
## Event Structure
|
|
6
|
+
|
|
7
|
+
```json
|
|
8
|
+
{
|
|
9
|
+
"isBase64Encoded": true,
|
|
10
|
+
"body": "<Base64-encoded request body>",
|
|
11
|
+
"httpMethod": "POST",
|
|
12
|
+
"requestContext": {
|
|
13
|
+
"apiId": "xxx",
|
|
14
|
+
"requestId": "xxx",
|
|
15
|
+
"stage": "RELEASE"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Critical: body is Base64 Encoded
|
|
21
|
+
|
|
22
|
+
`event["body"]` is Base64 encoded. You MUST decode it:
|
|
23
|
+
|
|
24
|
+
**Python handler template:**
|
|
25
|
+
```python
|
|
26
|
+
import json, base64
|
|
27
|
+
|
|
28
|
+
def handler(event, context):
|
|
29
|
+
body = event.get("body", "")
|
|
30
|
+
if event.get("isBase64Encoded"):
|
|
31
|
+
body = base64.b64decode(body).decode("utf-8")
|
|
32
|
+
data = json.loads(body) if body else {}
|
|
33
|
+
return {
|
|
34
|
+
"statusCode": 200,
|
|
35
|
+
"body": json.dumps({"message": "ok", "received": data}),
|
|
36
|
+
"headers": {"Content-Type": "application/json"}
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**Node.js handler template:**
|
|
41
|
+
```js
|
|
42
|
+
exports.handler = async (event, context) => {
|
|
43
|
+
let body = event.body || "";
|
|
44
|
+
if (event.isBase64Encoded) {
|
|
45
|
+
body = Buffer.from(body, "base64").toString("utf8");
|
|
46
|
+
}
|
|
47
|
+
const data = body ? JSON.parse(body) : {};
|
|
48
|
+
return {
|
|
49
|
+
statusCode: 200,
|
|
50
|
+
body: JSON.stringify({ message: "ok", received: data }),
|
|
51
|
+
headers: { "Content-Type": "application/json" }
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Missing Fields vs Standard HTTP
|
|
57
|
+
|
|
58
|
+
Fields NOT in DEDICATEDGATEWAY event: `event.path`, `event.headers`, `event.queryStringParameters`. Use `event.httpMethod` for method detection.
|
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
# FunctionGraph Function Creation Reference
|
|
2
|
-
|
|
3
|
-
## Runtime Options
|
|
4
|
-
|
|
5
|
-
| Runtime | Handler Format | Example |
|
|
6
|
-
|---------|---------------|---------|
|
|
7
|
-
| Python3.9 | `index.handler` | `def handler(event, context): return {"statusCode": 200}` |
|
|
8
|
-
| Python3.10 | `index.handler` | Same as 3.9 |
|
|
9
|
-
| Node.js 18 | `index.handler` | `exports.handler = async (event, context) => ({statusCode: 200})` |
|
|
10
|
-
| Java 8/11/17 | `com.example.Handler::handleRequest` | Java class method |
|
|
11
|
-
| Go 1.x | `handler` | Go function name |
|
|
12
|
-
| C# (.NET Core) | `CsharpDemo::CsharpDemo.Function::Handler` | Namespace.Class::Method |
|
|
13
|
-
|
|
14
|
-
## Create Function (inline)
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
hcloud FunctionGraph CreateFunction \
|
|
18
|
-
--func_name=<name> \
|
|
19
|
-
--package=default \
|
|
20
|
-
--runtime=Python3.10 \
|
|
21
|
-
--handler=index.handler \
|
|
22
|
-
--memory_size=128 \
|
|
23
|
-
--timeout=3 \
|
|
24
|
-
--code_type=inline \
|
|
25
|
-
--func_code.file=<base64-encoded-code> \
|
|
26
|
-
--cli-region=<region>
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
| Param | Required | Range/Default |
|
|
30
|
-
|-------|----------|---------------|
|
|
31
|
-
| `--func_name` | Yes | 1-60 chars |
|
|
32
|
-
| `--runtime` | Yes | See runtime options above |
|
|
33
|
-
| `--handler` | Yes | Per runtime |
|
|
34
|
-
| `--memory_size` | No | 128-4096 MB, default 128 |
|
|
35
|
-
| `--timeout` | No | 1-900s, default 3 |
|
|
36
|
-
|
|
37
|
-
## ZIP Upload Warning
|
|
38
|
-
|
|
39
|
-
`--code_type=zip --code_filename=xxx.zip` **succeeds even with non-existent file** — function created with empty code. Prefer `code_type=inline` for simple functions. If using zip, verify `code_size > 0` after creation and invoke the function to confirm output.
|
|
40
|
-
|
|
41
|
-
## Required IAM Permissions
|
|
42
|
-
|
|
43
|
-
- `functiongraph:function:createFunction` — Create
|
|
44
|
-
- `functiongraph:function:list` — List
|
|
45
|
-
- `functiongraph:function:getConfig` — Read config
|
|
46
|
-
- `functiongraph:function:invoke` — Invoke
|
|
47
|
-
|
|
48
|
-
Grant `FunctionGraph FullAccess` role or custom policy.
|
|
49
|
-
|
|
50
|
-
## Error Codes
|
|
51
|
-
|
|
52
|
-
| Error | Root Cause -> Fix |
|
|
53
|
-
|-------|-------------------|
|
|
54
|
-
| FSS.0400 | `:latest` suffix on URN. Strip it |
|
|
55
|
-
| FSS.1417 | Missing DEDICATEDGATEWAY params |
|
|
56
|
-
| FSS.0403 | Insufficient IAM permission |
|
|
57
|
-
| FSS.1020 | Missing `--app_xrole` when binding VPC. Create IAM agency with `trust_domain_name=functiongraph`. See `huawei-iam` skill → Agencies section |
|
|
58
|
-
|
|
59
|
-
## VPC + Agency Configuration
|
|
60
|
-
|
|
61
|
-
To access VPC-internal resources from FunctionGraph:
|
|
62
|
-
|
|
63
|
-
```bash
|
|
64
|
-
# 1. Create agency (see huawei-iam skill)
|
|
65
|
-
hcloud IAM CreateAgency --agency_name=<name> --trust_domain_name=functiongraph
|
|
66
|
-
# 2. Grant role (e.g., VPC Administrator)
|
|
67
|
-
hcloud IAM GrantRoleToAgency --agency_name=<name> --role_id=<role-id>
|
|
68
|
-
# 3. Use in CreateFunction
|
|
69
|
-
hcloud FunctionGraph CreateFunction --func_vpc.vpc_id=<vpc> --func_vpc.subnet_id=<subnet> --app_xrole=<name> ...
|
|
70
|
-
```
|
|
71
|
-
| QuotaExceeded | Max 10 functions per project per region |
|
|
1
|
+
# FunctionGraph Function Creation Reference
|
|
2
|
+
|
|
3
|
+
## Runtime Options
|
|
4
|
+
|
|
5
|
+
| Runtime | Handler Format | Example |
|
|
6
|
+
|---------|---------------|---------|
|
|
7
|
+
| Python3.9 | `index.handler` | `def handler(event, context): return {"statusCode": 200}` |
|
|
8
|
+
| Python3.10 | `index.handler` | Same as 3.9 |
|
|
9
|
+
| Node.js 18 | `index.handler` | `exports.handler = async (event, context) => ({statusCode: 200})` |
|
|
10
|
+
| Java 8/11/17 | `com.example.Handler::handleRequest` | Java class method |
|
|
11
|
+
| Go 1.x | `handler` | Go function name |
|
|
12
|
+
| C# (.NET Core) | `CsharpDemo::CsharpDemo.Function::Handler` | Namespace.Class::Method |
|
|
13
|
+
|
|
14
|
+
## Create Function (inline)
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
hcloud FunctionGraph CreateFunction \
|
|
18
|
+
--func_name=<name> \
|
|
19
|
+
--package=default \
|
|
20
|
+
--runtime=Python3.10 \
|
|
21
|
+
--handler=index.handler \
|
|
22
|
+
--memory_size=128 \
|
|
23
|
+
--timeout=3 \
|
|
24
|
+
--code_type=inline \
|
|
25
|
+
--func_code.file=<base64-encoded-code> \
|
|
26
|
+
--cli-region=<region>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
| Param | Required | Range/Default |
|
|
30
|
+
|-------|----------|---------------|
|
|
31
|
+
| `--func_name` | Yes | 1-60 chars |
|
|
32
|
+
| `--runtime` | Yes | See runtime options above |
|
|
33
|
+
| `--handler` | Yes | Per runtime |
|
|
34
|
+
| `--memory_size` | No | 128-4096 MB, default 128 |
|
|
35
|
+
| `--timeout` | No | 1-900s, default 3 |
|
|
36
|
+
|
|
37
|
+
## ZIP Upload Warning
|
|
38
|
+
|
|
39
|
+
`--code_type=zip --code_filename=xxx.zip` **succeeds even with non-existent file** — function created with empty code. Prefer `code_type=inline` for simple functions. If using zip, verify `code_size > 0` after creation and invoke the function to confirm output.
|
|
40
|
+
|
|
41
|
+
## Required IAM Permissions
|
|
42
|
+
|
|
43
|
+
- `functiongraph:function:createFunction` — Create
|
|
44
|
+
- `functiongraph:function:list` — List
|
|
45
|
+
- `functiongraph:function:getConfig` — Read config
|
|
46
|
+
- `functiongraph:function:invoke` — Invoke
|
|
47
|
+
|
|
48
|
+
Grant `FunctionGraph FullAccess` role or custom policy.
|
|
49
|
+
|
|
50
|
+
## Error Codes
|
|
51
|
+
|
|
52
|
+
| Error | Root Cause -> Fix |
|
|
53
|
+
|-------|-------------------|
|
|
54
|
+
| FSS.0400 | `:latest` suffix on URN. Strip it |
|
|
55
|
+
| FSS.1417 | Missing DEDICATEDGATEWAY params |
|
|
56
|
+
| FSS.0403 | Insufficient IAM permission |
|
|
57
|
+
| FSS.1020 | Missing `--app_xrole` when binding VPC. Create IAM agency with `trust_domain_name=functiongraph`. See `huawei-iam` skill → Agencies section |
|
|
58
|
+
|
|
59
|
+
## VPC + Agency Configuration
|
|
60
|
+
|
|
61
|
+
To access VPC-internal resources from FunctionGraph:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# 1. Create agency (see huawei-iam skill)
|
|
65
|
+
hcloud IAM CreateAgency --agency_name=<name> --trust_domain_name=functiongraph
|
|
66
|
+
# 2. Grant role (e.g., VPC Administrator)
|
|
67
|
+
hcloud IAM GrantRoleToAgency --agency_name=<name> --role_id=<role-id>
|
|
68
|
+
# 3. Use in CreateFunction
|
|
69
|
+
hcloud FunctionGraph CreateFunction --func_vpc.vpc_id=<vpc> --func_vpc.subnet_id=<subnet> --app_xrole=<name> ...
|
|
70
|
+
```
|
|
71
|
+
| QuotaExceeded | Max 10 functions per project per region |
|