|
32 | 32 | which represents a lookup or search over the rows in the datastore. |
33 | 33 | """ |
34 | 34 |
|
35 | | - |
36 | 35 | __version__ = '0.1.2' |
37 | 36 |
|
38 | 37 | SCOPE = ('https://www.googleapis.com/auth/datastore ', |
|
41 | 40 |
|
42 | 41 |
|
43 | 42 | def get_connection(client_email, private_key_path): |
44 | | - """Shortcut method to establish a connection to the Cloud Datastore. |
| 43 | + """Shortcut method to establish a connection to the Cloud Datastore. |
45 | 44 |
|
46 | | - Use this if you are going to access several datasets |
47 | | - with the same set of credentials (unlikely): |
| 45 | + Use this if you are going to access several datasets |
| 46 | + with the same set of credentials (unlikely): |
48 | 47 |
|
49 | | - >>> from gcloud import datastore |
50 | | - >>> connection = datastore.get_connection(email, key_path) |
51 | | - >>> dataset1 = connection.dataset('dataset1') |
52 | | - >>> dataset2 = connection.dataset('dataset2') |
| 48 | + >>> from gcloud import datastore |
| 49 | + >>> connection = datastore.get_connection(email, key_path) |
| 50 | + >>> dataset1 = connection.dataset('dataset1') |
| 51 | + >>> dataset2 = connection.dataset('dataset2') |
53 | 52 |
|
54 | | - :type client_email: string |
55 | | - :param client_email: The e-mail attached to the service account. |
| 53 | + :type client_email: string |
| 54 | + :param client_email: The e-mail attached to the service account. |
56 | 55 |
|
57 | | - :type private_key_path: string |
58 | | - :param private_key_path: The path to a private key file (this file was |
59 | | - given to you when you created the service |
60 | | - account). |
| 56 | + :type private_key_path: string |
| 57 | + :param private_key_path: The path to a private key file (this file was |
| 58 | + given to you when you created the service |
| 59 | + account). |
61 | 60 |
|
62 | | - :rtype: :class:`gcloud.datastore.connection.Connection` |
63 | | - :returns: A connection defined with the proper credentials. |
64 | | - """ |
65 | | - from gcloud.credentials import Credentials |
66 | | - from gcloud.datastore.connection import Connection |
| 61 | + :rtype: :class:`gcloud.datastore.connection.Connection` |
| 62 | + :returns: A connection defined with the proper credentials. |
| 63 | + """ |
| 64 | + from gcloud.credentials import Credentials |
| 65 | + from gcloud.datastore.connection import Connection |
67 | 66 |
|
68 | | - credentials = Credentials.get_for_service_account( |
69 | | - client_email, private_key_path, scope=SCOPE) |
70 | | - return Connection(credentials=credentials) |
| 67 | + credentials = Credentials.get_for_service_account( |
| 68 | + client_email, private_key_path, scope=SCOPE) |
| 69 | + return Connection(credentials=credentials) |
71 | 70 |
|
72 | 71 |
|
73 | 72 | def get_dataset(dataset_id, client_email, private_key_path): |
74 | | - """Establish a connection to a particular dataset in the Cloud Datastore. |
75 | | -
|
76 | | - This is a shortcut method for creating a connection and using it |
77 | | - to connect to a dataset. |
78 | | -
|
79 | | - You'll generally use this as the first call to working with the API: |
80 | | -
|
81 | | - >>> from gcloud import datastore |
82 | | - >>> dataset = datastore.get_dataset('dataset-id', email, key_path) |
83 | | - >>> # Now you can do things with the dataset. |
84 | | - >>> dataset.query().kind('TestKind').fetch() |
85 | | - [...] |
86 | | -
|
87 | | - :type dataset_id: string |
88 | | - :param dataset_id: The id of the dataset you want to use. |
89 | | - This is akin to a database name |
90 | | - and is usually the same as your Cloud Datastore project |
91 | | - name. |
92 | | -
|
93 | | - :type client_email: string |
94 | | - :param client_email: The e-mail attached to the service account. |
95 | | -
|
96 | | - :type private_key_path: string |
97 | | - :param private_key_path: The path to a private key file (this file was |
98 | | - given to you when you created the service |
99 | | - account). |
100 | | -
|
101 | | - :rtype: :class:`gcloud.datastore.dataset.Dataset` |
102 | | - :returns: A dataset with a connection using the provided credentials. |
103 | | - """ |
104 | | - connection = get_connection(client_email, private_key_path) |
105 | | - return connection.dataset(dataset_id) |
| 73 | + """Establish a connection to a particular dataset in the Cloud Datastore. |
| 74 | +
|
| 75 | + This is a shortcut method for creating a connection and using it |
| 76 | + to connect to a dataset. |
| 77 | +
|
| 78 | + You'll generally use this as the first call to working with the API: |
| 79 | +
|
| 80 | + >>> from gcloud import datastore |
| 81 | + >>> dataset = datastore.get_dataset('dataset-id', email, key_path) |
| 82 | + >>> # Now you can do things with the dataset. |
| 83 | + >>> dataset.query().kind('TestKind').fetch() |
| 84 | + [...] |
| 85 | +
|
| 86 | + :type dataset_id: string |
| 87 | + :param dataset_id: The id of the dataset you want to use. |
| 88 | + This is akin to a database name |
| 89 | + and is usually the same as your Cloud Datastore project |
| 90 | + name. |
| 91 | +
|
| 92 | + :type client_email: string |
| 93 | + :param client_email: The e-mail attached to the service account. |
| 94 | +
|
| 95 | + :type private_key_path: string |
| 96 | + :param private_key_path: The path to a private key file (this file was |
| 97 | + given to you when you created the service |
| 98 | + account). |
| 99 | +
|
| 100 | + :rtype: :class:`gcloud.datastore.dataset.Dataset` |
| 101 | + :returns: A dataset with a connection using the provided credentials. |
| 102 | + """ |
| 103 | + connection = get_connection(client_email, private_key_path) |
| 104 | + return connection.dataset(dataset_id) |
0 commit comments