alicloud-compute-swas-open by cinience/alicloud-skills
npx skills add https://github.com/cinience/alicloud-skills --skill alicloud-compute-swas-openCategory: service
使用 SWAS-OPEN OpenAPI 管理完整的轻量应用服务器资源:实例、磁盘、快照、镜像、密钥对、防火墙、云助手、监控、标签和轻量数据库。
ALICLOUD_REGION_ID 可用作默认区域;如果未设置,则选择最合理的区域,如果不明确请询问用户。建议使用虚拟环境(避免 PEP 668 系统安装限制)。
python3 -m venv .venv
. .venv/bin/activate
python -m pip install alibabacloud_swas_open20200601 alibabacloud_tea_openapi alibabacloud_credentials
import os
from alibabacloud_swas_open20200601.client import Client as SwasClient
from alibabacloud_swas_open20200601 import models as swas_models
from alibabacloud_tea_openapi import models as open_api_models
def create_client(region_id: str) -> SwasClient:
config = open_api_models.Config(
region_id=region_id,
endpoint=f"swas.{region_id}.aliyuncs.com",
)
ak = os.getenv("ALICLOUD_ACCESS_KEY_ID") or os.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID")
sk = os.getenv("ALICLOUD_ACCESS_KEY_SECRET") or os.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET")
if ak and sk:
config.access_key_id = ak
config.access_key_secret = sk
return SwasClient(config)
def list_regions():
client = create_client("cn-hangzhou")
resp = client.list_regions(swas_models.ListRegionsRequest())
return [r.region_id for r in resp.body.regions]
def list_instances(region_id: str):
client = create_client(region_id)
resp = client.list_instances(swas_models.ListInstancesRequest(region_id=region_id))
return resp.body.instances
def main():
for region_id in list_regions():
for inst in list_instances(region_id):
ip = getattr(inst, "public_ip_address", None) or getattr(inst, "inner_ip_address", None)
spec = getattr(inst, "plan_name", None) or getattr(inst, "plan_id", None)
print(inst.instance_id, ip or "-", spec or "-", region_id)
if __name__ == "__main__":
main()
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
scripts/list_instances_all_regions.pyscripts/summary_instances_by_plan.pyscripts/summary_instances_by_status.pyscripts/fix_ssh_access.pyscripts/get_ssh_port.pyaliyun CLI 可能未将 swas-open 公开为产品名称;建议使用 Python SDK。如果必须使用 CLI,请先在 OpenAPI Explorer 中生成请求示例,然后迁移到 CLI。references/api_overview.md 中识别 API 组和操作。ListInstances、StartInstance(s)、StopInstance(s)、RebootInstance(s)RunCommand 或 CreateCommand + InvokeCommand;使用 DescribeInvocations/DescribeInvocationResultListFirewallRules/CreateFirewallRule(s)/ModifyFirewallRule/EnableFirewallRule/DisableFirewallRuleCreateSnapshot、ResetDisk、CreateCustomImage 等。InstallCloudAssistant)。DescribeInvocations 或 DescribeInvocationResult 获取状态和输出。详情请参阅 references/command-assistant.md。
如果需要保存结果或响应,请写入:output/compute-swas-open/
mkdir -p output/alicloud-compute-swas-open
for f in skills/compute/swas/alicloud-compute-swas-open/scripts/*.py; do
python3 -m py_compile "$f"
done
echo "py_compile_ok" > output/alicloud-compute-swas-open/validate.txt
通过标准:命令退出码为 0 且生成 output/alicloud-compute-swas-open/validate.txt 文件。
output/alicloud-compute-swas-open/ 目录下。ALICLOUD_ACCESS_KEY_ID、ALICLOUD_ACCESS_KEY_SECRET,可选的 ALICLOUD_REGION_ID。references/api_overview.mdreferences/endpoints.mdreferences/command-assistant.mdreferences/sources.md每周安装次数
241
代码仓库
GitHub 星标数
363
首次出现
2026年2月26日
安全审计
安装于
gemini-cli238
github-copilot238
codex238
kimi-cli238
amp238
cursor238
Category: service
Use SWAS-OPEN OpenAPI to manage full SAS resources: instances, disks, snapshots, images, key pairs, firewall, Cloud Assistant, monitoring, tags, and lightweight databases.
ALICLOUD_REGION_ID can be used as default region; if unset choose the most reasonable region, ask user if unclear.Virtual environment is recommended (avoid PEP 668 system install restrictions).
python3 -m venv .venv
. .venv/bin/activate
python -m pip install alibabacloud_swas_open20200601 alibabacloud_tea_openapi alibabacloud_credentials
import os
from alibabacloud_swas_open20200601.client import Client as SwasClient
from alibabacloud_swas_open20200601 import models as swas_models
from alibabacloud_tea_openapi import models as open_api_models
def create_client(region_id: str) -> SwasClient:
config = open_api_models.Config(
region_id=region_id,
endpoint=f"swas.{region_id}.aliyuncs.com",
)
ak = os.getenv("ALICLOUD_ACCESS_KEY_ID") or os.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID")
sk = os.getenv("ALICLOUD_ACCESS_KEY_SECRET") or os.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET")
if ak and sk:
config.access_key_id = ak
config.access_key_secret = sk
return SwasClient(config)
def list_regions():
client = create_client("cn-hangzhou")
resp = client.list_regions(swas_models.ListRegionsRequest())
return [r.region_id for r in resp.body.regions]
def list_instances(region_id: str):
client = create_client(region_id)
resp = client.list_instances(swas_models.ListInstancesRequest(region_id=region_id))
return resp.body.instances
def main():
for region_id in list_regions():
for inst in list_instances(region_id):
ip = getattr(inst, "public_ip_address", None) or getattr(inst, "inner_ip_address", None)
spec = getattr(inst, "plan_name", None) or getattr(inst, "plan_id", None)
print(inst.instance_id, ip or "-", spec or "-", region_id)
if __name__ == "__main__":
main()
scripts/list_instances_all_regions.pyscripts/summary_instances_by_plan.pyscripts/summary_instances_by_status.pyscripts/fix_ssh_access.pyscripts/get_ssh_port.pyaliyun CLI may not expose swas-open as product name; prefer Python SDK. If CLI is mandatory, generate request examples in OpenAPI Explorer first, then migrate to CLI.references/api_overview.md.ListInstances、StartInstance(s)、StopInstance(s)、RebootInstance(s)RunCommand or CreateCommand + InvokeCommand; use DescribeInvocations/DescribeInvocationResultListFirewallRules/CreateFirewallRule(s)///InstallCloudAssistant).DescribeInvocations or DescribeInvocationResult to fetch status and outputs.See references/command-assistant.md for details.
If you need to save results or responses, write to: output/compute-swas-open/
mkdir -p output/alicloud-compute-swas-open
for f in skills/compute/swas/alicloud-compute-swas-open/scripts/*.py; do
python3 -m py_compile "$f"
done
echo "py_compile_ok" > output/alicloud-compute-swas-open/validate.txt
Pass criteria: command exits 0 and output/alicloud-compute-swas-open/validate.txt is generated.
output/alicloud-compute-swas-open/.ALICLOUD_ACCESS_KEY_ID, ALICLOUD_ACCESS_KEY_SECRET, optional ALICLOUD_REGION_ID.references/api_overview.mdreferences/endpoints.mdreferences/command-assistant.mdreferences/sources.mdWeekly Installs
241
Repository
GitHub Stars
363
First Seen
Feb 26, 2026
Security Audits
Gen Agent Trust HubWarnSocketPassSnykPass
Installed on
gemini-cli238
github-copilot238
codex238
kimi-cli238
amp238
cursor238
Azure Data Explorer (Kusto) 查询技能:KQL数据分析、日志遥测与时间序列处理
102,600 周安装
ModifyFirewallRuleEnableFirewallRuleDisableFirewallRuleCreateSnapshot、ResetDisk、CreateCustomImage etc.