Skip to main content
Glama
gcp.js1.28 kB
const { google } = require('googleapis'); const compute = google.compute('v1'); const auth = new google.auth.GoogleAuth({ scopes: ['https://www.googleapis.com/auth/cloud-platform'], }); async function getAuthClient() { return await auth.getClient(); } async function startInstance({ project, zone, instance }) { const authClient = await getAuthClient(); const res = await compute.instances.start({ project, zone, instance, auth: authClient, }); return res.data; } async function stopInstance({ project, zone, instance }) { const authClient = await getAuthClient(); const res = await compute.instances.stop({ project, zone, instance, auth: authClient, }); return res.data; } async function setMetadata({ project, zone, instance, metadata }) { const authClient = await getAuthClient(); // Get fingerprint first const getRes = await compute.instances.get({ project, zone, instance, auth: authClient }); const fingerprint = getRes.data.metadata.fingerprint; const body = { metadata: { ...metadata, fingerprint } }; const res = await compute.instances.setMetadata({ project, zone, instance, auth: authClient, requestBody: body }); return res.data; } module.exports = { startInstance, stopInstance, setMetadata };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/rpavez/ssh-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server