Skip to main content
Nous publions des mises à jour fréquentes de notre documentation, et la traduction de cette page peut encore être en cours. Pour obtenir les informations les plus actuelles, consultez la documentation anglaise.
L’API REST est maintenant versionnée. Pour plus d’informations, consultez « À propos des versions de l’API ».

Machines Codespaces

Utilisez l’API REST pour gérer la disponibilité des types d’ordinateurs pour un codespace.

À propos des ordinateurs Codespaces

Vous pouvez déterminer quels types d’ordinateur sont disponibles pour créer un codespace, soit sur un dépôt donné, soit en tant qu’utilisateur authentifié. Pour plus d’informations, consultez « Modification du type de machine pour votre espace de code ».

Vous pouvez également utiliser ces informations lors de la modification de la machine d’un espace de code existant en mettant à jour sa propriété machine. La mise à jour de la machine aura lieu la prochaine fois que l’espace de code est redémarré. Pour plus d’informations, consultez « Modification du type de machine pour votre espace de code ».

List available machine types for a repository

Compatible avec GitHub Apps

List the machine types available for a given repository based on its configuration.

You must authenticate using an access token with the codespace scope to use this endpoint.

GitHub Apps must have write access to the codespaces_metadata repository permission to use this endpoint.

Paramètres pour « List available machine types for a repository »

En-têtes
Nom, Type, Description
accept string

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

Paramètres de chemin d’accès
Nom, Type, Description
owner string Obligatoire

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

repo string Obligatoire

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

Paramètres de requête
Nom, Type, 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

Codes d’état de la réponse HTTP pour « List available machine types for a repository »

Code d’étatDescription
200

OK

304

Not modified

401

Requires authentication

403

Forbidden

404

Resource not found

500

Internal Error

Exemples de code pour « 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, 8 GB RAM, 64 GB storage", "operating_system": "linux", "storage_in_bytes": 68719476736, "memory_in_bytes": 8589934592, "cpus": 4 }, { "name": "premiumLinux", "display_name": "8 cores, 16 GB RAM, 64 GB storage", "operating_system": "linux", "storage_in_bytes": 68719476736, "memory_in_bytes": 17179869184, "cpus": 8 } ] }

List machine types for a codespace

List the machine types a codespace can transition to use.

You must authenticate using an access token with the codespace scope to use this endpoint.

GitHub Apps must have read access to the codespaces_metadata repository permission to use this endpoint.

Paramètres pour « List machine types for a codespace »

En-têtes
Nom, Type, Description
accept string

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

Paramètres de chemin d’accès
Nom, Type, Description
codespace_name string Obligatoire

The name of the codespace.

Codes d’état de la réponse HTTP pour « List machine types for a codespace »

Code d’étatDescription
200

OK

304

Not modified

401

Requires authentication

403

Forbidden

404

Resource not found

500

Internal Error

Exemples de code pour « 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, 8 GB RAM, 64 GB storage", "operating_system": "linux", "storage_in_bytes": 68719476736, "memory_in_bytes": 8589934592, "cpus": 4 }, { "name": "premiumLinux", "display_name": "8 cores, 16 GB RAM, 64 GB storage", "operating_system": "linux", "storage_in_bytes": 68719476736, "memory_in_bytes": 17179869184, "cpus": 8 } ] }