type Github = {
token: string;
};
/**
* Restore a package for an organization
* Restores an entire package in an organization.
*/
export async function main(
auth: Github,
package_type: "npm" | "maven" | "rubygems" | "docker" | "nuget" | "container",
package_name: string,
org: string,
token: string | undefined
) {
const url = new URL(
`https://api.github.com/orgs/${org}/packages/${package_type}/${package_name}/restore`
);
for (const [k, v] of [["token", token]]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "POST",
headers: {
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.text();
}
Submitted by hugo697 407 days ago