type Github = {
token: string;
};
/**
* Update a codespace for the authenticated user
* Updates a codespace owned by the authenticated user. Currently only the codespace's machine type and recent folders can be modified using this endpoint.
If you specify a new machine type it will be applied the next time your codespace is started.
You must authenticate using an access token with the `codespace` scope to use this endpoint.
GitHub Apps must have write access to the `codespaces` repository permission to use this endpoint.
*/
export async function main(
auth: Github,
codespace_name: string,
body: {
display_name?: string;
machine?: string;
recent_folders?: string[];
[k: string]: unknown;
}
) {
const url = new URL(
`https://api.github.com/user/codespaces/${codespace_name}`
);
const response = await fetch(url, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 367 days ago
type Github = {
token: string;
};
/**
* Update a codespace for the authenticated user
* Updates a codespace owned by the authenticated user. Currently only the codespace's machine type and recent folders can be modified using this endpoint.
If you specify a new machine type it will be applied the next time your codespace is started.
You must authenticate using an access token with the `codespace` scope to use this endpoint.
GitHub Apps must have write access to the `codespaces` repository permission to use this endpoint.
*/
export async function main(
auth: Github,
codespace_name: string,
body: {
display_name?: string;
machine?: string;
recent_folders?: string[];
[k: string]: unknown;
}
) {
const url = new URL(
`https://api.github.com/user/codespaces/${codespace_name}`
);
const response = await fetch(url, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 927 days ago