Python Code to create Google Project -
is possible create new google developer/cloud project(for existing google account) automatically using python script ?
if possible, can please redirect me helpful links/references ?
thanks,
is possible?: yes, using app engine's admin api or cloud resource manager apis although functionality in beta of time of writing (08-24-2016). can access them directly or through client library.
directly via rest api:
app engine admin api v1beta5:
create post /v1beta5/apps
creates app engine application google cloud platform project. requires project excludes app engine application...
more: https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1beta5/apps/create
cloud resource manager api v1beta1:
post https://cloudresourcemanager.googleapis.com/v1beta1/projects/
creates project resource.
and example request:
{ "name": "project name", "projectid": "project-id-1", "labels": { "environment": "dev" }, }
more here: https://cloud.google.com/resource-manager/reference/rest/v1beta1/projects/create
via python client library:
there's the google python client library
pip install --upgrade google-api-python-client
then you'll have build authenticated service api. every other thing you'll need request can found in this doc
-
ideally though, , personal favorite, you'll want use client library build such script
pip install --upgrade gcloud
then you'll create new project with:
from gcloud import resource_manager client = resource_manager.client() # re-doing above rest example project = client.new_project('project-id-1', name='project name', labels={'environment': 'dev'}) project.create()
Comments
Post a Comment