获取 Environment

更新时间:
复制 MD 格式

根据环境 ID 返回完整配置,包括沙箱类型、预装依赖与网络策略。

前提

已完成 Endpoint 与鉴权配置,详见API 总览与认证。

接口

GET/environments/{environment_id}

路径参数

environment_idstring必填

环境 ID,格式 env_<ULID>

响应字段

响应为 Environment 对象。字段如下:

idstring

环境 ID,格式 env_<ULID>

typestring

固定为 environment

namestring

环境名称

descriptionstring

环境用途说明

scopestring

作用域。organization:工作空间全部成员可见与复用

configobject

完整运行时配置。包含以下子字段:

typestring

cloud 云端容器

packagesobject

预装依赖,按包管理器分组。键为 apt / pip / npm,值为包名数组

aptarray<string>

Debian/Ubuntu 包名列表

piparray<string>

Python 包名列表

npmarray<string>

Node.js 包名列表

networkingobject

网络策略对象,结构 {"type": "unrestricted"}

typestring

目前仅支持 unrestricted

metadataobject

业务自定义键值,不影响运行行为

archived_atstring / null

归档时间,未归档时为 null

created_atstring

创建时间,ISO 8601

updated_atstring

最近更新时间,ISO 8601

request_idstring

本次请求的唯一标识

请求示例

curl "$AGENTSTUDIO_URL/environments/env_xxx" \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY"
env = client.environments.retrieve("env_xxx")
Environment env = client.environments().retrieve("env_xxx");

响应示例

{
  "id": "env_xxx",
  "type": "environment",
  "name": "data-sandbox",
  "description": "数据分析沙箱",
  "config": {
    "type": "cloud",
    "packages": {"apt": ["ffmpeg"], "pip": ["pandas", "numpy", "matplotlib"]},
    "networking": {"type": "unrestricted"}
  },
  "metadata": {"team": "infra"},
  "scope": "organization",
  "archived_at": null,
  "created_at": "2026-06-16T12:45:34+08:00",
  "updated_at": "2026-06-16T12:45:34+08:00",
  "request_id": "xxx"
}