Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5456bfb

Browse files
committed
Initial commit of Resource Manager API
1 parent b0aef16 commit 5456bfb

14 files changed

+1290
-1
lines changed

docs/_static/js/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ $('.headerlink').parent().each(function() {
1616
$('.side-nav').children('ul:nth-child(2)').children().each(function() {
1717
var itemName = $(this).text();
1818
if (itemName !== 'Datastore' && itemName !== 'Storage' &&
19-
itemName !== 'Pub/Sub') {
19+
itemName !== 'Pub/Sub' && itemName !== 'Resource Manager') {
2020
$(this).css('padding-left','2em');
2121
}
2222
});

docs/index.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
pubsub-usage
1919
pubsub-subscription
2020
pubsub-topic
21+
resource-manager-api
22+
resource-manager-client
23+
resource-manager-project
2124

2225

2326
Getting started

docs/resource-manager-api.rst

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
.. toctree::
2+
:maxdepth: 1
3+
:hidden:
4+
5+
Resource Manager
6+
----------------
7+
8+
Overview
9+
~~~~~~~~
10+
11+
The Cloud Resource Manager API provides methods that you can use
12+
to programmatically manage your projects in the Google Cloud Platform.
13+
With this API, you can do the following:
14+
15+
- Get a list of all projects associated with an account
16+
- Create new projects
17+
- Update existing projects
18+
- Delete projects
19+
- Undelete, or recover, projects that you don't want to delete
20+
21+
.. note::
22+
23+
Don't forget to look at the **Authentication** section below.
24+
It's slightly different from the rest of this library.
25+
26+
Here's a quick example of the full life-cycle::
27+
28+
>>> from gcloud import resource_manager
29+
30+
>>> # List all projects you have access to
31+
>>> client = resource_manager.Client()
32+
>>> for project in client.list_projects():
33+
... print project
34+
35+
>>> # Create a new project
36+
>>> new_project = client.project('your-project-id-here')
37+
>>> new_project.name = 'My new project'
38+
>>> new_project.create()
39+
40+
>>> # Update an existing project
41+
>>> project = client.get_project('my-existing-project')
42+
>>> print project
43+
<Project: Existing Project (my-existing-project)>
44+
>>> project.name = 'Modified name'
45+
>>> project.update()
46+
>>> print project
47+
<Project: Modified name (my-existing-project)>
48+
49+
>>> # Delete a project
50+
>>> project = client.get_project('my-existing-project')
51+
>>> project.delete()
52+
53+
>>> # Undelete a project
54+
>>> project = client.get_project('my-existing-project')
55+
>>> project.undelete()
56+
57+
Authentication
58+
~~~~~~~~~~~~~~
59+
60+
Unlike the other APIs, the Resource Manager API is focused on managing your
61+
various projects inside Google Cloud Platform. What this means (currently) is
62+
that you can't use a Service Account to work with some parts of this API
63+
(for example, creating projects).
64+
65+
The reason is actually pretty simple: if your API call is trying to do
66+
something like create a project, what project's Service Account can you use?
67+
Currently none.
68+
69+
This means that for this API you should always use the credentials
70+
provided by the Cloud SDK, which you can get by running ``gcloud auth login``
71+
(if you're not familiar with this, take a look at http://cloud.google.com/sdk).
72+
73+
Once you run that command, ``gcloud`` will automatically pick up the
74+
credentials from the Cloud SDK, and you can use the "automatic discovery"
75+
feature of the library.
76+
77+
Start by authenticating::
78+
79+
$ gcloud auth login
80+
81+
And then simply create a client::
82+
83+
>>> from gcloud import resource_manager
84+
>>> client = resource_manager.Client()

docs/resource-manager-client.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.. toctree::
2+
:maxdepth: 0
3+
:hidden:
4+
5+
Client
6+
------
7+
8+
.. automodule:: gcloud.resource_manager.client
9+
:members:
10+
:undoc-members:
11+
:show-inheritance:
12+
13+
Connection
14+
~~~~~~~~~~
15+
16+
.. automodule:: gcloud.resource_manager.connection
17+
:members:
18+
:undoc-members:
19+
:show-inheritance:

docs/resource-manager-project.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Projects
2+
~~~~~~~~
3+
4+
.. automodule:: gcloud.resource_manager.project
5+
:members:
6+
:undoc-members:
7+
:show-inheritance:

gcloud/exceptions.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
_HTTP_CODE_TO_EXCEPTION = {} # populated at end of module
2525

2626

27+
class MissingClientError(Exception):
28+
"""Exception for a missing client."""
29+
pass
30+
31+
2732
class GCloudError(Exception):
2833
"""Base error class for gcloud errors (abstract).
2934
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright 2015 Google Inc. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""Cloud ResourceManager API wrapper.
16+
17+
18+
The main concepts with this API are:
19+
20+
- :class:`gcloud.resource_manager.project.Project` represents
21+
a Google Cloud project.
22+
"""
23+
24+
from gcloud.resource_manager.client import Client
25+
from gcloud.resource_manager.connection import SCOPE
26+
from gcloud.resource_manager.project import Project

0 commit comments

Comments
 (0)