|
21 | 21 |
|
22 | 22 | import httplib2 |
23 | 23 |
|
24 | | -from gcloud.credentials import get_credentials |
25 | | -from gcloud.credentials import get_for_service_account_json |
26 | | -from gcloud.credentials import get_for_service_account_p12 |
27 | 24 | from gcloud.exceptions import make_exception |
28 | 25 |
|
29 | 26 |
|
@@ -122,92 +119,6 @@ def _create_scoped_credentials(credentials, scope): |
122 | 119 | credentials = credentials.create_scoped(scope) |
123 | 120 | return credentials |
124 | 121 |
|
125 | | - @classmethod |
126 | | - def from_service_account_json(cls, json_credentials_path, *args, **kwargs): |
127 | | - """Factory to retrieve JSON credentials while creating connection. |
128 | | -
|
129 | | - :type json_credentials_path: string |
130 | | - :param json_credentials_path: The path to a private key file (this file |
131 | | - was given to you when you created the |
132 | | - service account). This file must contain |
133 | | - a JSON object with a private key and |
134 | | - other credentials information (downloaded |
135 | | - from the Google APIs console). |
136 | | -
|
137 | | - :type args: tuple |
138 | | - :param args: Remaining positional arguments to pass to constructor. |
139 | | -
|
140 | | - :type kwargs: dictionary |
141 | | - :param kwargs: Remaining keyword arguments to pass to constructor. |
142 | | -
|
143 | | - :rtype: :class:`gcloud.connection.Connection` |
144 | | - :returns: The connection created with the retrieved JSON credentials. |
145 | | - :raises: class:`TypeError` if there is a conflict with the kwargs |
146 | | - and the credentials created by the factory. |
147 | | - """ |
148 | | - if 'credentials' in kwargs: |
149 | | - raise TypeError('credentials must not be in keyword arguments') |
150 | | - credentials = get_for_service_account_json(json_credentials_path) |
151 | | - kwargs['credentials'] = credentials |
152 | | - return cls(*args, **kwargs) |
153 | | - |
154 | | - @classmethod |
155 | | - def from_service_account_p12(cls, client_email, private_key_path, |
156 | | - *args, **kwargs): |
157 | | - """Factory to retrieve P12 credentials while creating connection. |
158 | | -
|
159 | | - .. note:: |
160 | | - Unless you have an explicit reason to use a PKCS12 key for your |
161 | | - service account, we recommend using a JSON key. |
162 | | -
|
163 | | - :type client_email: string |
164 | | - :param client_email: The e-mail attached to the service account. |
165 | | -
|
166 | | - :type private_key_path: string |
167 | | - :param private_key_path: The path to a private key file (this file was |
168 | | - given to you when you created the service |
169 | | - account). This file must be in P12 format. |
170 | | -
|
171 | | - :type args: tuple |
172 | | - :param args: Remaining positional arguments to pass to constructor. |
173 | | -
|
174 | | - :type kwargs: dictionary |
175 | | - :param kwargs: Remaining keyword arguments to pass to constructor. |
176 | | -
|
177 | | - :rtype: :class:`gcloud.connection.Connection` |
178 | | - :returns: The connection created with the retrieved P12 credentials. |
179 | | - :raises: class:`TypeError` if there is a conflict with the kwargs |
180 | | - and the credentials created by the factory. |
181 | | - """ |
182 | | - if 'credentials' in kwargs: |
183 | | - raise TypeError('credentials must not be in keyword arguments') |
184 | | - credentials = get_for_service_account_p12(client_email, |
185 | | - private_key_path) |
186 | | - kwargs['credentials'] = credentials |
187 | | - return cls(*args, **kwargs) |
188 | | - |
189 | | - @classmethod |
190 | | - def from_environment(cls, *args, **kwargs): |
191 | | - """Factory to retrieve implicit credentials while creating connection. |
192 | | -
|
193 | | - :type args: tuple |
194 | | - :param args: Remaining positional arguments to pass to constructor. |
195 | | -
|
196 | | - :type kwargs: dictionary |
197 | | - :param kwargs: Remaining keyword arguments to pass to constructor. |
198 | | -
|
199 | | - :rtype: :class:`gcloud.connection.Connection` |
200 | | - :returns: The connection created with the retrieved implicit |
201 | | - credentials. |
202 | | - :raises: class:`TypeError` if there is a conflict with the kwargs |
203 | | - and the credentials created by the factory. |
204 | | - """ |
205 | | - if 'credentials' in kwargs: |
206 | | - raise TypeError('credentials must not be in keyword arguments') |
207 | | - credentials = get_credentials() |
208 | | - kwargs['credentials'] = credentials |
209 | | - return cls(*args, **kwargs) |
210 | | - |
211 | 122 |
|
212 | 123 | class JSONConnection(Connection): |
213 | 124 | """A connection to a Google JSON-based API. |
|
0 commit comments