can we use any google API which can provide information about the total charges spent using Google Cloud Platform? i have tried few APIs (detail shown in code).
API 1:
var google = require('googleapis');
var cloudbilling = google.cloudbilling('v1');
google.auth.getApplicationDefault(function(err, authClient) {
if (err) {
console.log('Authentication failed because of ', err);
return;
}
if (authClient.createScopedRequired &&
authClient.createScopedRequired()) {
var scopes = ['https://www.googleapis.com/auth/cloud-platform'];
authClient = authClient.createScoped(scopes);
}
var request = {
name: "projects/<your-project-id>",
// Auth client
auth: authClient
};
cloudbilling.projects.getBillingInfo(request, function(err, result) {
if (err) {
console.log(err);
} else {
console.log(result);
}
});
});
What i am getting in json (about billing information) is:
data:
{ name: 'projects/<your-project-name>/billingInfo',
projectId: '<project-Id>',
billingAccountName: 'billingAccounts/<your-billing-id>',
billingEnabled: true }
}
Now i have tried other APIs too, but they are also not providing the total charges spent!. Is there a way i can find the bills?