First npm i googleapis
(I'm using v68.0.0)
import { google } from 'googleapis';
const compute = google.compute('v1');
const urlMapName = 'my-cdn-name';
const invalidateCache = async (path: string) => {
const authClient = await google.auth.getClient({
scopes: ['https://www.googleapis.com/auth/cloud-platform', 'https://www.googleapis.com/auth/compute'],
});
const projectId = await google.auth.getProjectId();
await compute.urlMaps.invalidateCache({
auth: authClient,
project: projectId,
urlMap: urlMapName,
requestBody: {
path,
},
});
};
call like this: await invalidateCache('/my/route')
obvi you need client credentials configured