Question

I'm getting familiarized with Cloud SQL API (v1beta1). I'm trying to update authorizedNetworks (sql.instances.update) and I'm using API explorer. I think my my request body is alright except for 'settingsVersion'. According to the docs it should be:

The version of instance settings. This is a required field for update method to make sure concurrent updates are handled properly. During update, use the most recent settingsVersion value for this instance and do not try to update this value. Source: https://developers.google.com/cloud-sql/docs/admin-api/v1beta3/instances/update

I have not found anything useful related to settingsVersion. When I try with different srings, instead of receiving 200 and the response, I get 400 and:

"message": "Invalid value for: Expected a signed long, got '' (class java.lang.String)"

If a insert random number, I get 412 (Precondition failed) and:

"message": "Condition does not match."

Where do I obtain versionSettings and what is a signed long string?

Was it helpful?

Solution

You should do a GET operation on your instance and fetch the current settings, those settings will contain the current version number, you should use that value.

This is done to avoid unintentional settings overwrites.

For example, if two people get the current instance status which has version 1, and they both try to change something different (for example, one wants to change the tier and the other wants to change the pricingPlan) by doing an Update operation, the second one to send the request would undo the change of the first one if the operation was permitted. However, since the version number is increased every time an update operation is performed, once the first person updates the instance, the second person's request will fail because the version number does not match anymore.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top