//native
/**
* Save config
* Copy the running configuration to the startup configuration (write memory) by invoking the cisco-ia:save-config RPC.
*/
export async function main(auth: RT.CiscoIosxe) {
// The RPC has no input, so the request carries no body (RFC 8040 section 3.6.1).
const response = await fetch(
new URL(
`${auth.base_url.replace(/\/+$/, "")}/restconf/operations/cisco-ia:save-config`
),
{
method: "POST",
headers: {
Authorization: `Basic ${btoa(`${auth.username}:${auth.password}`)}`,
Accept: "application/yang-data+json",
},
}
)
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
if (response.status === 204) return { success: true }
return await response.json()
}
Submitted by hugo989 2 hours ago