-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit of Resource Manager API
- Loading branch information
Showing
14 changed files
with
1,285 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
.. toctree:: | ||
:maxdepth: 1 | ||
:hidden: | ||
|
||
Resource Manager | ||
---------------- | ||
|
||
Overview | ||
~~~~~~~~ | ||
|
||
The Cloud Resource Manager API provides methods that you can use | ||
to programmatically manage your projects in the Google Cloud Platform. | ||
With this API, you can do the following: | ||
|
||
- Get a list of all projects associated with an account | ||
- Create new projects | ||
- Update existing projects | ||
- Delete projects | ||
- Undelete, or recover, projects that you don't want to delete | ||
|
||
.. note:: | ||
|
||
Don't forget to look at the **Authentication** section below. | ||
It's slightly different from the rest of this library. | ||
|
||
Here's a quick example of the full life-cycle:: | ||
|
||
>>> from gcloud import resource_manager | ||
|
||
>>> # List all projects you have access to | ||
>>> client = resource_manager.Client() | ||
>>> for project in client.list_projects(): | ||
... print project | ||
|
||
>>> # Create a new project | ||
>>> new_project = client.project('your-project-id-here') | ||
>>> new_project.name = 'My new project' | ||
>>> new_project.create() | ||
|
||
>>> # Update an existing project | ||
>>> project = client.get_project('my-existing-project') | ||
>>> print project | ||
<Project: Existing Project (my-existing-project)> | ||
>>> project.name = 'Modified name' | ||
>>> project.update() | ||
>>> print project | ||
<Project: Modified name (my-existing-project)> | ||
|
||
>>> # Delete a project | ||
>>> project = client.get_project('my-existing-project') | ||
>>> project.delete() | ||
|
||
>>> # Undelete a project | ||
>>> project = client.get_project('my-existing-project') | ||
>>> project.undelete() | ||
|
||
Authentication | ||
~~~~~~~~~~~~~~ | ||
|
||
Unlike the other APIs, the Resource Manager API is focused on managing your | ||
various projects inside Google Cloud Platform. What this means (currently) is | ||
that you can't use a Service Account to work with some parts of this API | ||
(for example, creating projects). | ||
|
||
The reason is actually pretty simple: if your API call is trying to do | ||
something like create a project, what project's Service Account can you use? | ||
Currently none. | ||
|
||
This means that for this API you should always use the credentials | ||
provided by the Cloud SDK, which you can get by running ``gcloud auth login`` | ||
(if you're not familiar with this, take a look at http://cloud.google.com/sdk). | ||
|
||
Once you run that command, ``gcloud`` will automatically pick up the | ||
credentials from the Cloud SDK, and you can use the "automatic discovery" | ||
feature of the library. | ||
|
||
Start by authenticating:: | ||
|
||
$ gcloud auth login | ||
|
||
And then simply create a client:: | ||
|
||
>>> from gcloud import resource_manager | ||
>>> client = resource_manager.Client() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
.. toctree:: | ||
:maxdepth: 0 | ||
:hidden: | ||
|
||
Client | ||
------ | ||
|
||
.. automodule:: gcloud.resource_manager.client | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
Connection | ||
~~~~~~~~~~ | ||
|
||
.. automodule:: gcloud.resource_manager.connection | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Projects | ||
~~~~~~~~ | ||
|
||
.. automodule:: gcloud.resource_manager.project | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Copyright 2015 Google Inc. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
"""Cloud ResourceManager API wrapper. | ||
The main concepts with this API are: | ||
- :class:`gcloud.resource_manager.project.Project` represents | ||
a Google Cloud project. | ||
""" | ||
|
||
from gcloud.resource_manager.client import Client | ||
from gcloud.resource_manager.connection import SCOPE | ||
from gcloud.resource_manager.project import Project |
Oops, something went wrong.