//native
type Segment = {
token: string;
baseUrl: string;
};
/**
* Create Source
* Creates a new Source.
• When called, this endpoint may generate the `Source Created` event in the audit trail.
*/
export async function main(
auth: Segment,
body: {
slug: string;
enabled: false | true;
metadataId: string;
settings?: {};
disconnectAllWarehouses?: false | true;
},
) {
const url = new URL(`${auth.baseUrl}/sources`);
const response = await fetch(url, {
method: "POST",
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 235 days ago