Codespaces 计算机的 REST API 终结点
使用 REST API 管理可用于 codespace 的计算机类型。
关于 Codespaces 计算机
可以确定哪些计算机类型可用于创建 codespace,无论是在给定的存储库上还是作为经过身份验证的用户。 有关详细信息,请参阅“更改代码空间的计算机类型”。
还可以通过更新其 machine
属性来更改现有 codespace 的机器时使用此信息。 计算机更新将在下次重新启动 codespace 时进行。 有关详细信息,请参阅“更改代码空间的计算机类型”。
List available machine types for a repository
List the machine types available for a given repository based on its configuration.
OAuth app tokens and personal access tokens (classic) need the codespace
scope to use this endpoint.
“List available machine types for a repository”的细粒度访问令牌
此端点支持以下精细令牌类型:
精细令牌必须具有以下权限集:
- "Codespaces metadata" repository permissions (read)
“List available machine types for a repository”的参数
名称, 类型, 说明 |
---|
accept string Setting to |
名称, 类型, 说明 |
---|
owner string 必须The account owner of the repository. The name is not case sensitive. |
repo string 必须The name of the repository without the |
名称, 类型, 说明 |
---|
location string The location to check for available machines. Assigned by IP if not provided. |
client_ip string IP for location auto-detection when proxying a request |
ref string The branch or commit to check for prebuild availability and devcontainer restrictions. |
“List available machine types for a repository”的 HTTP 响应状态代码
状态代码 | 说明 |
---|---|
200 | OK |
304 | Not modified |
401 | Requires authentication |
403 | Forbidden |
404 | Resource not found |
500 | Internal Error |
“List available machine types for a repository”的示例代码
请求示例
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/OWNER/REPO/codespaces/machines
Response
Status: 200
{
"total_count": 2,
"machines": [
{
"name": "standardLinux",
"display_name": "4 cores, 16 GB RAM, 64 GB storage",
"operating_system": "linux",
"storage_in_bytes": 68719476736,
"memory_in_bytes": 17179869184,
"cpus": 4
},
{
"name": "premiumLinux",
"display_name": "8 cores, 32 GB RAM, 64 GB storage",
"operating_system": "linux",
"storage_in_bytes": 68719476736,
"memory_in_bytes": 34359738368,
"cpus": 8
}
]
}
List machine types for a codespace
List the machine types a codespace can transition to use.
OAuth app tokens and personal access tokens (classic) need the codespace
scope to use this endpoint.
“List machine types for a codespace”的细粒度访问令牌
此端点支持以下精细令牌类型:
精细令牌必须具有以下权限集:
- "Codespaces metadata" repository permissions (read)
“List machine types for a codespace”的参数
名称, 类型, 说明 |
---|
accept string Setting to |
名称, 类型, 说明 |
---|
codespace_name string 必须The name of the codespace. |
“List machine types for a codespace”的 HTTP 响应状态代码
状态代码 | 说明 |
---|---|
200 | OK |
304 | Not modified |
401 | Requires authentication |
403 | Forbidden |
404 | Resource not found |
500 | Internal Error |
“List machine types for a codespace”的示例代码
请求示例
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/user/codespaces/CODESPACE_NAME/machines
Response
Status: 200
{
"total_count": 2,
"machines": [
{
"name": "standardLinux",
"display_name": "4 cores, 16 GB RAM, 64 GB storage",
"operating_system": "linux",
"storage_in_bytes": 68719476736,
"memory_in_bytes": 17179869184,
"cpus": 4
},
{
"name": "premiumLinux",
"display_name": "8 cores, 32 GB RAM, 64 GB storage",
"operating_system": "linux",
"storage_in_bytes": 68719476736,
"memory_in_bytes": 34359738368,
"cpus": 8
}
]
}