更新时间:2023-12-14 GMT+08:00

查询开发环境实例列表

功能介绍

该接口用于查询开发环境实例列表,用户可按需查询满足条件的开发环境实例列表。

URI

GET /v1/{project_id}/demanager/instances?de_type={de_type}&provision_type={provision_type}&status={status}&sortby={sortby}&order={order}&offset={offset}&limit={limit}

Path参数说明如表1所示。
表1 参数说明

参数

是否必选

参数类型

说明

project_id

String

用户项目ID。获取方法请参见获取项目ID和名称

表2 query请求参数

参数

是否必选

参数类型

说明

de_type

String

开发环境类型,当前仅支持Notebook,严格区分大小写。

provision_type

String

部署类型,当前仅支持Docker。

status

String

实例状态,缺省时返回全部状态。包括:

  • CREATE_QUEUING,免费资源创建排队中
  • CREATING,创建中
  • CREATE_FAILED,创建失败
  • START_QUEUING,免费资源启动排队中
  • READY_TO_START,免费资源等待启动
  • STARTING,启动中
  • RESTARTING,重启中
  • START_FAILED,启动失败
  • RUNNING,运行中
  • STOPPING,停止中
  • STOPPED,停止
  • UNAVAILABLE,故障
  • DELETED,已删除
  • RESIZING,规格变更中
  • RESIZE_FAILED,规格变更失败

sortby

String

分类标准,支持“name”“creation_timestamp”。默认为“name”

order

String

排序方式,支持“asc”“desc”,默认为“asc”

offset

Integer

起始索引,默认为“0”

limit

Integer

限制本次返回的结果数据条数,取值范围(0,∞),默认值为“0”,返回全部。

workspace_id

String

工作空间id。未创建工作空间时取值默认值为0,存在创建并使用的工作空间,以实际取值为准。

show_self

string

只显示自己,默认值是True。

ai_project

String

AI项目ID。

pool_id

String

专属资源池ID。查询该专属资源池下的所有实例信息。

请求消息

无。

响应消息

响应参数如表3所示。
表3 响应参数

参数

参数类型

说明

total_count

Integer

总的开发环境数量。

instances

Array

配置列表,如表4所示。

表4 instances字段响应参数说明

参数

参数类型

说明

id

String

实例ID。

name

String

实例名称。

description

String

实例描述。

status

String

实例状态。

creation_timestamp

String

实例的创建时间。

profile

Object

规格信息,如表5所示。

flavor

String

机器规格。

spec

Object

实例定义。Notebook类型实例,数据结构如表9 notebook字段数据结构说明所示。

workspace

Object

工作空间,如表18所示。

latest_update_timestamp

String

实例的更新时间。

flavor_details

Object

机器规格详情,如表9所示。

pool

Object

专属资源池,如表10所示。

ai_project

Object

AI项目。如表11所示。

error_code

String

错误码。请参考错误码

queuing_info

Object

排队信息,如表19所示。

user

Object

用户信息,如表20所示。

repository

Object

Git仓库信息,如表21所示。该字段不支持使用,在调用接口时会自动返回。

表5 profile字段数据结构说明

参数

参数类型

描述

id

String

配置ID。

name

String

配置名称。

description

String

配置描述。

de_type

String

开发环境类型,当前仅支持Notebook。

provision

Object

部署信息,如表6所示。

labels

Map<String,String>

标签信息,可扩展字段。

flavor_type

String

硬件类型。支持CPU,GPU,Ascend。

表6 provision字段数据结构说明

参数

参数类型

说明

type

String

部署类型,当前仅支持Docker。

spec

Object

部署详情,如表7所示。

annotations

Map<String,String>

注解信息,可扩展字段,缺省值为NULL。

表7 spec字段数据结构说明

参数

参数类型

说明

engine

String

部署引擎,当前仅支持CCE。

params

Object

部署参数,当前仅支持Docker,如表8所示。

表8 Docker部署参数数据结构说明

参数

参数类型

说明

namespace

String

SWR组织名称,全局唯一。

image_name

String

镜像名称。

image_tag

String

镜像标签。

annotations

Map<String,String>

注解信息,可扩展字段,缺省值为NULL。

表9 flavor_details参数说明

参数

参数类型

描述

name

String

规格名称。

status

String

规格销售状态。当前支持:

  • onSale
  • soldOut

queuing_num

Integer

“promo_type”“Free”“status”“soldOut”时,该参数必选。

queue_left_time

Integer

排到队的剩余时间,单位为秒。

“promo_type”“Free”“status”“soldOut”时,该参数必选。

storage_list

Array< storageType >

支持的存储类型。默认为全部。

is_permitted

Boolean

当前用户是否有权限使用该规格。

type

String

规格状态。当前支持:

  • GPU
  • CPU
  • ASCEND

params

Dict

描述规格的参数。

promo_type

String

促销类型。包括:

  • Free
  • NoDiscount

instance_num

Integer

当前用户创建地该规格实例的数量。

duration

Integer

启动后设置的自动停止时间,单位为秒。

store_time

Integer

该规格实例处于非活跃状态,在数据库最长保存的时长。单位为小时。

默认为“-1”, 表示可以无限制保存。

billing_flavor

String

计费规格。当该字段为空时,使用规格名称计费。

billing_params

Integer

计费倍率。当billing_flavor不为空时,该字段必选。

表10 pool参数说明

参数

参数类型

描述

id

String

资源池ID。

name

String

资源池名称。

type

String

资源池类型。主要区分类型:USER_DEFINED,表明为专属资源池。

owner

Object

“type”“USER_DEFINED”时是必选项。如表12所示。

表11 AIProject

参数

参数类型

描述

id

String

AI项目ID。

表12 owner参数说明

参数

参数类型

描述

project_id

String

项目ID。

表13 notebook字段数据结构说明

参数

参数类型

说明

extend_storage

Array<Storage>

扩展存储列表,如表14所示。扩展存储当前仅支持type为“obsfs”的类型,且仅对部分专属资源池开放。

storage

Object

存储路径。表14

auto_stop

Object

自动停止参数,如表10 auto_stop字段数据结构说明所示。

annotations

Map<String,String>

注解信息。

其中,生成的url信息,不可直接访问使用。

failed_reasons

Object

创建、启动失败失败原因,如表16所示。

extend_params

Map<String,String>

扩展参数。

表14 storage定义数据结构说明

参数

是否必选

参数类型

说明

type

String

存储类型,当前支持“obs”“obsfs”“evs”,其中,obsfs类型当前仅支持部分专属资源池。若您需要挂载OBS并行文件系统,请提工单。

location

Object

存储位置,如果type为“obs”类型,该参数必须填写,如表15所示数据结构,如缺省值为“NULL”

表15 location定义数据结构说明

参数

是否必选

参数类型

说明

path

String

存储路径。

  • 如果type为“obs”类型,该值必须填写,该值需为有效的OBS桶路径,且以“/”结束。不能指定为OBS桶的根目录,需指定为OBS桶下的具体目录。
  • 如果type为“obsfs”类型,该值需为有效的OBS并行文件系统的桶名(当前CCE不支持挂载子目录)。
  • 如果type为“evs”类型,该值不需要填写。

volume_size

Integer

EVS存储盘大小,最小为5GB,最大为4096GB,缺省值为5GB;如果type为OBS类型,该值不需要填写。

mount_path

String

Notebook内的挂载路径,仅type为“obsfs”类型,该字段有效。

默认值为“/home/ma-user/work”

若希望挂载到指定路径,建议填写“/home/ma-user/work”的子目录,否则可能因权限等问题导致挂载失败或读写异常。

access_modes

String

挂载文件的访问权限,支持读写和只读两种方式,仅type为“obsfs”类型,该字段有效。可选值:

  • ReadOnlyMany:只读方式
  • ReadWriteMany:读写方式(默认值)
表16 failed_reasons字段数据结构说明

参数

参数类型

说明

code

String

错误码。

message

String

错误信息。

detail

Map<String,String>

错误详情。

表17 auto_stop字段数据结构说明

参数

参数类型

说明

enable

Boolean

是否开启自动停止功能。

duration

Integer

运行时长,单位为秒。

prompt

Boolean

是否需要再次弹框提醒,提供给console使用。

stop_timestamp

Integer

实例停止时间点, 13位时间戳。

remain_time

Integer

实际停止剩余时间,单位为秒。

表18 workspace字段数据结构说明

参数

参数类型

说明

id

String

工作空间ID。

表19 queuing_info参数说明

参数

参数类型

描述

id

String

实例ID。

name

String

实例名称。

de_type

String

开发环境类型,缺省时返回全部类型。

当前仅支持Notebook。

flavor

String

实例的机器规格,缺省时返回全部类型。现在支持的有:

  • modelarts.vm.cpu.free
  • modelarts.vm.gpu.free

flavor_details

Object

规格详情,用于展示规格信息,以及查询规格是否售罄。请参见表9

status

String

实例状态,缺省时返回全部类型。包括:

  • CREATE_QUEUING
  • START_QUEUING

begin_timestamp

Integer

实例排队的开始时间,13位时间戳。

remain_time

Integer

排到队的剩余时间,单位为秒。

end_timestamp

Integer

实例排队的预计停止时间,13位时间戳。

rank

Integer

实例在队列中的排位。

表20 user字段数据结构说明

参数

参数类型

说明

id

String

用户ID。

name

String

用户名。

表21 repository字段数据结构说明

参数

参数类型

说明

id

String

仓库ID。

branch

String

仓库分支。

user_name

String

仓库配置用户名。

user_email

String

仓库配置用户邮箱。

type

String

仓库类型。CodeClub,GitHub。

connection_info

Object

仓库链接信息。请参见表22

表22 connection_info字段数据结构说明

参数

参数类型

说明

protocol

String

链接仓库协议。当前支持:ssh,https。

url

String

链接仓库地址。

credential

Object

证书信息,请参见表23

表23 credential字段数据结构说明

参数

参数类型

说明

ssh_private_key

String

ssh私有证书。

access_token

String

GitHub的oauth token。

请求示例

如下以查询开发环境类型为Notebook的实例列表为例。
GET https://endpoint/v1/{project_id}/demanager/instances?de_type=Notebook

响应示例

  • 成功响应示例
    {
        "instances": [
            {
                "ai_project": {
                    "id": "default-ai-project"
                },
                "creation_timestamp": "1594887749962",
                "description": "",
                "flavor": "modelarts.bm.gpu.v100NV32",
                "flavor_details": {
                    "name": "modelarts.bm.gpu.v100NV32",
                    "params": {
                        "CPU": 8,
                        "GPU": 1,
                        "gpu_type": "v100NV32",
                        "memory": "64GiB"
                    },
                    "status": "onSale",
                    "type": "GPU"
                },
                "id": "DE-7d558ef8-c73d-11ea-964c-0255ac100033",
                "latest_update_timestamp": "1594887749962",
                "name": "notebook-c6fd",
                "profile": {
                    "de_type": "Notebook",
                    "description": "multi engine, gpu, python 3.6 for notebook",
                    "flavor_type": "GPU",
                    "id": "Multi-Engine 1.0 (python3)-gpu",
                    "name": "Multi-Engine 1.0 (python3)-gpu",
                    "provision": {
                        "annotations": {
                            "category": "Multi-Engine 1.0 (python3)",
                            "type": "system"
                        },
                        "spec": {
                            "engine": "CCE",
                            "params": {
                                "annotations": null,
                                "image_name": "mul-kernel-gpu-cuda-cp36",
                                "image_tag": "2.0.5-B003",
                                "namespace": "atelier"
                            }
                        },
                        "type": "Docker"
                    }
                },
                "spec": {
                    "annotations": {
                        "target_domain": "https://modelarts-notebook-2.xxxxxx.com",
                        "url": "https://modelarts-lvs-common-lb.xxxxxx.com:32000/modelarts/hubv100/notebook/user/DE-7d558ef8-c73d-11ea-964c-0255ac100033"
                    },
                    "auto_stop": {
                        "duration": 3600,
                        "enable": true,
                        "prompt": true,
                        "remain_time": 3450,
                        "stop_timestamp": 1594891408723
                    },
                    "extend_params": null,
                    "failed_reasons": null,
                    "extend_storage": null,
                    "storage": {
                        "location": {
                            "path": "/home/ma-user/work",
                            "volume_size": 5
                        },
                        "type": "evs"
                    }
                },
                "status": "RUNNING",
                "user": {
                    "id": "15dda26361214ca2a5953917d2f48ffb",
                    "name": "ops_dev_env"
                },
                "workspace": {
                    "id": "0"
                }
            },
            {
                "ai_project": {
                    "id": "default-ai-project"
                },
                "creation_timestamp": "1594883877728",
                "description": "",
                "flavor": "modelarts.vm.cpu.2u",
                "flavor_details": {
                    "name": "modelarts.vm.cpu.2u",
                    "params": {
                        "CPU": 2,
                        "GPU": 0,
                        "memory": "8GiB"
                    },
                    "status": "onSale",
                    "type": "CPU"
                },
                "id": "DE-7936a360-c734-11ea-a72b-0255ac100033",
                "latest_update_timestamp": "1594883877728",
                "name": "notebook-b1b8",
                "profile": {
                    "de_type": "Notebook",
                    "description": "multi engine, cpu, python 3.6 for notebook",
                    "flavor_type": "CPU",
                    "id": "Multi-Engine 1.0 (python3)-cpu",
                    "name": "Multi-Engine 1.0 (python3)-cpu",
                    "provision": {
                        "annotations": {
                            "category": "Multi-Engine 1.0 (python3 推荐)",
                            "type": "system"
                        },
                        "spec": {
                            "engine": "CCE",
                            "params": {
                                "annotations": null,
                                "image_name": "mul-kernel-cpu-cp36",
                                "image_tag": "2.0.5-B003",
                                "namespace": "atelier"
                            }
                        },
                        "type": "Docker"
                    }
                },
                "spec": {
                    "annotations": {
                        "target_domain": "https://modelarts-notebook.xxxxxx.com",
                        "url": ""
                    },
                    "auto_stop": {
                        "duration": 3600,
                        "enable": true,
                        "prompt": true
                    },
                    "extend_params": null,
                    "failed_reasons": null,
                    "storage": {
                        "location": {
                            "path": "/home/ma-user/work",
                            "volume_size": 5
                        },
                        "type": "evs"
                    }
                },
                "status": "STOPPED",
                "user": {
                    "id": "15dda26361214ca2a5953917d2f48ffb",
                    "name": "ops_dev_env"
                },
                "workspace": {
                    "id": "0"
                }
            }],
        "total_count": 2
    }

状态码

状态码请参见状态码