-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #77 - Initialized cloud dns. #78
Closed
Closed
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
3472e22
Fix #43 - Swapped project_name for project.
kleyow 86b886e
Fix #86 - Entity objects from a fetched query have a proper Dataset r…
jgeewax 9654c3b
Merge pull request #87 from jgeewax/86-fix-dataset-reference
jgeewax 2cf60d4
Fix #80 - Added support for ancestor queries.
jgeewax 6ce841a
Merge pull request #85 from jgeewax/master
jgeewax ad1f0f7
Merge pull request #74 from kleyow/swap
jgeewax 6c999c0
Fix #65 - Added force parameter to delete non empty buckets.
kleyow 70069c5
gcloud-python is not a generic Google APIs client, fixing wording.
rakyll 4ea692b
Merge pull request #88 from rakyll/docs-gix
jgeewax fbdff58
Merge pull request #73 from kleyow/force
jgeewax f32f10e
Fix #89 - Made README more user friendly.
jgeewax f1c5491
Added simplest CI build file.
aliafshar f715070
Added simplest CI build file.
aliafshar 6e196cf
Added simplest CI build file.
aliafshar 21ec3c9
Add build badge
b22da80
Update README.rst
be94dff
Update README.rst
87c3e73
Update README.rst
4dd8f67
Don't assume that httplib2 responses contain any preset attributes, s…
aliafshar af92e74
Merge pull request #94 from aliafshar/93
c021a0d
Fix #77 - Initialized gcloud dns.
kleyow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
language: python | ||
python: | ||
- "2.6" | ||
- "2.7" | ||
# command to install dependencies | ||
install: "pip install . unittest2" | ||
# command to run tests | ||
script: nosetests |
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
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,92 @@ | ||
"""Shortcut methods for getting set up with Google Cloud DNS. | ||
|
||
You'll typically use these to get started with the API: | ||
|
||
>>> import gcloud.dns | ||
>>> zone = gcloud.dns.get_zone('zone-name-here', | ||
'long-email@googleapis.com', | ||
'/path/to/private.key') | ||
|
||
The main concepts with this API are: | ||
|
||
- :class:`gcloud.dns.connection.Connection` | ||
which represents a connection between your machine | ||
and the Cloud DNS API. | ||
|
||
- :class:`gcloud.dns.zone.Zone` | ||
which represents a particular zone. | ||
""" | ||
|
||
|
||
__version__ = '0.1' | ||
|
||
# TODO: Allow specific scopes and authorization levels. | ||
SCOPE = ('https://www.googleapis.com/auth/cloud-platform', | ||
'https://www.googleapis.com/auth/ndev.clouddns.readonly', | ||
'https://www.googleapis.com/auth/ndev.clouddns.readwrite') | ||
"""The scope required for authenticating as a Cloud DNS consumer.""" | ||
|
||
|
||
def get_connection(project, client_email, private_key_path): | ||
"""Shortcut method to establish a connection to Cloud DNS. | ||
|
||
Use this if you are going to access several zones | ||
with the same set of credentials: | ||
|
||
>>> from gcloud import dns | ||
>>> connection = dns.get_connection(project, email, key_path) | ||
>>> zone1 = connection.get_zone('zone1') | ||
>>> zone2 = connection.get_zone('zone2') | ||
|
||
:type project: string | ||
:param project: The name of the project to connect to. | ||
|
||
:type client_email: string | ||
:param client_email: The e-mail attached to the service account. | ||
|
||
:type private_key_path: string | ||
:param private_key_path: The path to a private key file (this file was | ||
given to you when you created the service | ||
account). | ||
|
||
:rtype: :class:`gcloud.dns.connection.Connection` | ||
:returns: A connection defined with the proper credentials. | ||
""" | ||
|
||
from gcloud.credentials import Credentials | ||
from gcloud.dns.connection import Connection | ||
|
||
credentials = Credentials.get_for_service_account( | ||
client_email, private_key_path, scope=SCOPE) | ||
return Connection(project=project, credentials=credentials) | ||
|
||
|
||
def get_zone(zone, project, client_email, private_key_path): | ||
"""Shortcut method to establish a connection to a particular zone. | ||
|
||
You'll generally use this as the first call to working with the API: | ||
|
||
>>> from gcloud import dns | ||
>>> zone = dns.get_zone(zone, project, email, key_path) | ||
|
||
:type zone: string | ||
:param zone: The id of the zone you want to use. | ||
This is akin to a disk name on a file system. | ||
|
||
:type project: string | ||
:param project: The name of the project to connect to. | ||
|
||
:type client_email: string | ||
:param client_email: The e-mail attached to the service account. | ||
|
||
:type private_key_path: string | ||
:param private_key_path: The path to a private key file (this file was | ||
given to you when you created the service | ||
account). | ||
|
||
:rtype: :class:`gcloud.dns.zone.Zone` | ||
:returns: A zone with a connection using the provided credentials. | ||
""" | ||
|
||
connection = get_connection(project, client_email, private_key_path) | ||
return connection.get_zone(zone) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This comment was marked as spam.
Sorry, something went wrong.