//native
type Netlify = {
token: string;
};
/**
* Create site
* **Note:** Environment variable keys and values have moved from `build_settings.env` and `repo.env` to a new endpoint. Please use [createEnvVars](#tag/environmentVariables/operation/createEnvVars) to create environment variables for a site.
*/
export async function main(
auth: Netlify,
configure_dns: string | undefined,
body: {
id?: string;
state?: string;
plan?: string;
name?: string;
custom_domain?: string;
domain_aliases?: string[];
branch_deploy_custom_domain?: string;
deploy_preview_custom_domain?: string;
password?: string;
notification_email?: string;
url?: string;
ssl_url?: string;
admin_url?: string;
screenshot_url?: string;
created_at?: string;
updated_at?: string;
user_id?: string;
session_id?: string;
ssl?: false | true;
force_ssl?: false | true;
managed_dns?: false | true;
deploy_url?: string;
published_deploy?: {
id?: string;
site_id?: string;
user_id?: string;
build_id?: string;
state?: string;
name?: string;
url?: string;
ssl_url?: string;
admin_url?: string;
deploy_url?: string;
deploy_ssl_url?: string;
screenshot_url?: string;
review_id?: number;
draft?: false | true;
required?: string[];
required_functions?: string[];
error_message?: string;
branch?: string;
commit_ref?: string;
commit_url?: string;
skipped?: false | true;
created_at?: string;
updated_at?: string;
published_at?: string;
title?: string;
context?: string;
locked?: false | true;
review_url?: string;
framework?: string;
function_schedules?: { name?: string; cron?: string }[];
};
account_id?: string;
account_name?: string;
account_slug?: string;
git_provider?: string;
deploy_hook?: string;
capabilities?: {};
processing_settings?: { html?: { pretty_urls?: false | true } };
build_settings?: {
id?: number;
provider?: string;
deploy_key_id?: string;
repo_path?: string;
repo_branch?: string;
dir?: string;
functions_dir?: string;
cmd?: string;
allowed_branches?: string[];
public_repo?: false | true;
private_logs?: false | true;
repo_url?: string;
env?: {};
installation_id?: number;
stop_builds?: false | true;
};
id_domain?: string;
default_hooks_data?: { access_token?: string };
build_image?: string;
prerender?: string;
functions_region?: string;
} & {
repo?: {
id?: number;
provider?: string;
deploy_key_id?: string;
repo_path?: string;
repo_branch?: string;
dir?: string;
functions_dir?: string;
cmd?: string;
allowed_branches?: string[];
public_repo?: false | true;
private_logs?: false | true;
repo_url?: string;
env?: {};
installation_id?: number;
stop_builds?: false | true;
};
},
) {
const url = new URL(`https://api.netlify.com/api/v1/sites`);
for (const [k, v] of [["configure_dns", configure_dns]]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
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