0

I am using this gcloud command to stop my sql instance following this

   gcloud sql instances patch my-sql-instance --activation-policy NEVER

how can I achieve the same in nodejs code?

is there a google library for the sql api in npm?

dina
  • 4,039
  • 6
  • 39
  • 67

1 Answers1

1

using googleapis
see also the api reference

const {google} = require('googleapis');
const {auth} = require('google-auth-library');
const sqladmin = google.sqladmin('v1beta4');

auth.getApplicationDefault((_err, authRes) => {
    var req = {
        auth: authRes.credential,
        project: "my-project-id",
        instance: "my-instance",
        requestBody: {
            "settings": {
                "activationPolicy": "NEVER"
            }
        }
    };
    sqladmin.instances.patch(req, (err, res) => {
        if (err) console.error(err);
        if (res) console.info(res);
    })
});
dina
  • 4,039
  • 6
  • 39
  • 67