Skip to main content
REST API теперь версия. Дополнительные сведения см. в разделе "О управлении версиями API".

Конечные точки REST API для компьютеров Codespaces

Используйте REST API для управления доступностью типов компьютеров для пространства кода.

Сведения о компьютерах с данными Codespaces

Вы можете определить, какие типы компьютеров доступны для создания пространства кода в заданном репозитории или в качестве пользователя, прошедшего проверку подлинности. Дополнительные сведения см. в разделе Изменение типа компьютера для codespace.

Эти сведения также можно использовать при изменении компьютера существующего кодового пространства, обновив его свойство machine. Обновление компьютера будет выполнено при следующем перезапуске кодового пространства. Дополнительные сведения см. в разделе Изменение типа компьютера для 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:read

Параметры для "List available machine types for a repository"

Заголовки
Имя., Тип, Description
accept string

Setting to application/vnd.github+json is recommended.

Параметры пути
Имя., Тип, Description
owner string Обязательное поле

The account owner of the repository. The name is not case sensitive.

repo string Обязательное поле

The name of the repository without the .git extension. The name is not case sensitive.

Параметры запроса
Имя., Тип, Description
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.

Коды состояния http-ответа для "List available machine types for a repository"

Код состоянияОписание
200

OK

304

Not modified

401

Requires authentication

403

Forbidden

404

Resource not found

500

Internal Error

Примеры кода для "List available machine types for a repository"

Пример запроса

get/repos/{owner}/{repo}/codespaces/machines
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:read

Параметры для "List machine types for a codespace"

Заголовки
Имя., Тип, Description
accept string

Setting to application/vnd.github+json is recommended.

Параметры пути
Имя., Тип, Description
codespace_name string Обязательное поле

The name of the codespace.

Коды состояния http-ответа для "List machine types for a codespace"

Код состоянияОписание
200

OK

304

Not modified

401

Requires authentication

403

Forbidden

404

Resource not found

500

Internal Error

Примеры кода для "List machine types for a codespace"

Пример запроса

get/user/codespaces/{codespace_name}/machines
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 } ] }