//native
type Vercel = {
token: string;
};
/**
* Import Resource
* This endpoint imports (upserts) a resource to Vercel's installation. This may be needed if resources can be independently created on the partner's side and need to be synchronized to Vercel.
*/
export async function main(
auth: Vercel,
integrationConfigurationId: string,
resourceId: string,
body: {
productId: string;
name: string;
status:
| "ready"
| "pending"
| "suspended"
| "resumed"
| "uninstalled"
| "error";
metadata?: {};
billingPlan?: {
id: string;
type: "prepayment" | "subscription";
name: string;
paymentMethodRequired?: false | true;
};
notification?: {
level: "error" | "info" | "warn";
title: string;
message?: string;
href?: string;
};
secrets?: { name: string; value: string; prefix?: string }[];
},
) {
const url = new URL(
`https://api.vercel.com/v1/installations/${integrationConfigurationId}/resources/${resourceId}`,
);
const response = await fetch(url, {
method: "PUT",
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 428 days ago