type Cloudflare = {
token: string;
email: string;
key: string;
};
/**
* Update GRE Tunnel
* Updates a specific GRE tunnel. Use `?validate_only=true` as an optional query parameter to only run validation without persisting changes.
*/
export async function main(
auth: Cloudflare,
tunnel_identifier: string,
account_identifier: string,
body: {
cloudflare_gre_endpoint: string;
customer_gre_endpoint: string;
description?: string;
health_check?: {
direction?: "unidirectional" | "bidirectional";
enabled?: boolean;
rate?: "low" | "mid" | "high";
target?: string;
type?: "reply" | "request";
[k: string]: unknown;
};
interface_address: string;
mtu?: number;
name: string;
ttl?: number;
[k: string]: unknown;
}
) {
const url = new URL(
`https://api.cloudflare.com/client/v4/accounts/${account_identifier}/magic/gre_tunnels/${tunnel_identifier}`
);
const response = await fetch(url, {
method: "PUT",
headers: {
"X-AUTH-EMAIL": auth.email,
"X-AUTH-KEY": auth.key,
"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 383 days ago
type Cloudflare = {
token: string;
email: string;
key: string;
};
/**
* Update GRE Tunnel
* Updates a specific GRE tunnel. Use `?validate_only=true` as an optional query parameter to only run validation without persisting changes.
*/
export async function main(
auth: Cloudflare,
tunnel_identifier: string,
account_identifier: string,
body: {
cloudflare_gre_endpoint: string;
customer_gre_endpoint: string;
description?: string;
health_check?: {
direction?: "unidirectional" | "bidirectional";
enabled?: boolean;
rate?: "low" | "mid" | "high";
target?: string;
type?: "reply" | "request";
[k: string]: unknown;
};
interface_address: string;
mtu?: number;
name: string;
ttl?: number;
[k: string]: unknown;
}
) {
const url = new URL(
`https://api.cloudflare.com/client/v4/accounts/${account_identifier}/magic/gre_tunnels/${tunnel_identifier}`
);
const response = await fetch(url, {
method: "PUT",
headers: {
"X-AUTH-EMAIL": auth.email,
"X-AUTH-KEY": auth.key,
"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 920 days ago