//native
type Box = {
token: string;
};
/**
* Get metadata template by name
* Retrieves a metadata template by its `scope` and `templateKey` values.
To find the `scope` and `templateKey` for a template, list all templates for
an enterprise or globally, or list all templates applied to a file or folder.
*/
export async function main(
auth: Box,
scope: "global" | "enterprise",
template_key: string,
) {
const url = new URL(
`https://api.box.com/2.0/metadata_templates/${scope}/${template_key}/schema`,
);
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago