1

According to the documentation https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions/patch we should be able to stop an app engine instance by changing the serviceStatus to STOPPED.

However, the documentation is ambiguous. Does anyone understand how to stop an app engine instance via the API?

Unclear elements:

  1. "Name of the resource to update. Example: apps/myapp/services/default/versions/1." How can you find the "name of the resource"?
  2. What should the "updateMask" look like? Is it in json?
Rage
  • 127
  • 5

1 Answers1

3

Here is the example how you can stop/serve your App Engine version using API, just replace the PROJECTID,SERVICEID and VERSIONID:

curl --request PATCH \
"https://appengine.googleapis.com/v1/apps/PROJECTID/services/SERVICEID/versions/VERSIONID?updateMask=servingStatus" \
  --header "Authorization: Bearer $(gcloud auth print-access-token)" \
  --header "Accept: application/json" \
  --header "Content-Type: application/json" \
  --data '{"servingStatus":"STOPPED"}' \
  --compressed

For you to fully understand how it builds, there's an API Explorer or a panel. It has a title "Try this API" in the right side of screen, click the box icon to maximize or click this link to redirect. Fill the required fields:

  1. appsId - your PROJECT ID.
  2. servicesId - go to App Engine > Services or execute gcloud command: gcloud app services list to see your App Engine Services. The default name or servicesID of your App Engine Services is default.
  3. versionsId - go to App Engine > Versions or execute gcloud command: gcloud app versions list to see the App Engine versions deployed and copy the VERSION ID you want to update.
  4. updateMask - the configuration in App Engine version you want to update, example: servingStatus or instanceClass

To know more about fields and its definition in API, visit this table of contents. It will help you a lot how you can configure your App Engine Versions via API.

NOTE : You cannot stop the App Engine Version if your apps is configured in automatic scaling.

JM Gelilio
  • 212
  • 1
  • 8