//native
type Digitalocean = {
token: string;
};
/**
* Update a Domain Record
* To update an existing record, send a PUT request to
`/v2/domains/$DOMAIN_NAME/records/$DOMAIN_RECORD_ID`. Any attribute valid for
the record type can be set to a new value for the record.
See the [attribute table](#tag/Domain-Records) for details regarding record
types and their respective attributes.
*/
export async function main(
auth: Digitalocean,
domain_name: string,
domain_record_id: string,
body: {
id?: number;
type: string;
name?: string;
data?: string;
priority?: number;
port?: number;
ttl?: number;
weight?: number;
flags?: number;
tag?: string;
},
) {
const url = new URL(
`https://api.digitalocean.com/v2/domains/${domain_name}/records/${domain_record_id}`,
);
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 537 days ago