GCP : How to get disk price for missing region in

2019-06-07 02:58发布

问题:

We are working in one of the customer module. With the help of this module, we are calculating price for google cloud components like images, boot disk, region, snapshot, Network, VPC, Ingress, Egress, load balance, forwording rule, Pubsub etc.

We got to know that JSON link was removed from GCP calculator page

So one of the stack overflow answer suggested us to use Catalog APIS.

As mentioned in Catalog API, we created a URL by putting service id (compute engine) and api key in URL : https://cloudbilling.googleapis.com/v1/services/<<service_id>>/skus?key=<<API_key>> We are getting a JSONs. But we observed data is missing in the JSON.

We observed they are covering only 9 regions for resource group - PDStandard (in resource family storage for service compute engine) We found pricing data only for following 9 regions for PDStandard :

"asia-southeast1"
"asia-south1"
"australia-southeast1"
"europe-west3"
"us-east4"
"northamerica-northeast1"
"asia-northeast1"
"europe-west4"
"europe-west2"

We also observed they are covering only 11 regions for resource group - SSD (in resource family storage for service compute engine) We found pricing data only for following 11 regions for SSD :

"southamerica-east1"
"europe-west4"
"europe-west3"
"europe-west2"
"asia-northeast1"
"us-east4"
 "us-central1",
"us-east1",
"us-west1",
"asia-east1",
"europe-west1"
"australia-southeast1"
"northamerica-northeast1"

There are total 15 regions across the globe as per GCP document of region list Where can we find pricing data for remaining regions to get disk price?

回答1:

I found that GCP is showing result in pagination format.

"nextPageToken": "<<some key>>"

If we are seeing nextPageToken key at the end of page, probably GCP showing remaining data in next page.

For getting next page data, we have to modify URL with appending next page token key in previous URL as:

https://cloudbilling.googleapis.com/v1/services/<<service_id>>/skus?key=<<API_key>>&pageToken=<<nextpagetoken key>>

So we are getting complete result.