Google cloud platform 为什么不';没有任何SDK可以调用云SQL API吗?

Google cloud platform 为什么不';没有任何SDK可以调用云SQL API吗?,google-cloud-platform,google-cloud-sql,Google Cloud Platform,Google Cloud Sql,我想从云函数调用下面描述的云SQL API 我找到了调用GCPAPI的库 然而,似乎没有任何用于云SQL的模块 我想知道为什么它没有实现。API相对较新的原因是什么?或者我误解了库的用途,实际上它不应该在库中实现?您可以使用gcloud sdk调用API。如果您只是希望导出数据库,请查看以下文档:在页面底部,您将找到一个不同语言的示例代码,用于通过构建客户端来调用该API。例如,Node.js的示例代码如下所示: const {google} = require('googleap

我想从云函数调用下面描述的云SQL API

我找到了调用GCPAPI的库

然而,似乎没有任何用于云SQL的模块


我想知道为什么它没有实现。API相对较新的原因是什么?或者我误解了库的用途,实际上它不应该在库中实现?

您可以使用gcloud sdk调用API。如果您只是希望导出数据库,请查看以下文档:

在页面底部,您将找到一个不同语言的示例代码,用于通过构建客户端来调用该API。例如,
Node.js
的示例代码如下所示:

const {google} = require('googleapis');
var sqlAdmin = google.sqladmin('v1beta4');

authorize(function(authClient) {
  var request = {
    // Project ID of the project that contains the instance to be exported.
    project: 'my-project',  // TODO: Update placeholder value.

    // Cloud SQL instance ID. This does not include the project ID.
    instance: 'my-instance',  // TODO: Update placeholder value.

    resource: {
      // TODO: Add desired properties to the request body.
    },

    auth: authClient,
  };

  sqlAdmin.instances.export(request, function(err, response) {
    if (err) {
      console.error(err);
      return;
    }

    // TODO: Change code below to process the `response` object:
    console.log(JSON.stringify(response, null, 2));
  });
});

function authorize(callback) {
  google.auth.getApplicationDefault(function(err, authClient) {
    if (err) {
      console.error('authentication failed: ', err);
      return;
    }
    if (authClient.createScopedRequired && authClient.createScopedRequired()) {
      var scopes = ['https://www.googleapis.com/auth/cloud-platform'];
      authClient = authClient.createScoped(scopes);
    }
    callback(authClient);
  });
}

要从云函数连接到云SQL实例,请按照文档操作。

谢谢您的回答。据我了解,库google cloud node/google cloud go与sdk具有相同的功能。我想知道为什么有些函数库没有,而sdk有。由于我想在云函数中调用api,所以最好直接从JS或Go等处使用它。谢谢,我完全错过了它,现在我发现不是google Cloud node,而是google api nodejs客户端具有调用api的接口。我不完全理解其中的区别,但无论如何,现在我可以试试了。再次感谢。