I'm trying to get billingInfo for a google cloud project using python 3.6 I have done with request to billing API but the response is not expected, As Google's documentation for Billing Api says that it returns Name, ProjectId, billingAccountName & billingEnabled. But it only returns name and projectId even for a project which doesn't associate with a billing account. Here's my code:
projectName = form.cleaned_data['project_id']
# Get billing Info of selected project
auth = getauth()
service = discovery.build('cloudbilling', 'v1', http=auth, cache_discovery=False)
name = 'projects/' + projectName
billing_request = service.projects().getBillingInfo(name=name,)
billing_response = billing_request.execute()
data = billing_response
print(json.dumps(data))
if data['name']:
return HttpResponse(json.dumps(data), content_type='application/json')
else:
data = []
return HttpResponse(json.dumps(data), content_type='application/json')
and it returns the response as :
{"name": "projects/docker-184805/billingInfo", "projectId": "docker-184805"}
Even billing is not enabled for this project.
How can I get the proper billing info for a project on google cloud platform using API python client?
Help me, please!
Thanks in advance!