|
23 | 23 | import os |
24 | 24 | import warnings |
25 | 25 |
|
26 | | -from google.auth.credentials import AnonymousCredentials |
27 | 26 | from google.api_core import page_iterator |
28 | 27 | from google.cloud.exceptions import NotFound |
29 | 28 | from google.cloud.storage._helpers import _add_generation_match_parameters |
30 | 29 | from google.cloud.storage._helpers import _bucket_bound_hostname_url |
31 | 30 | from google.cloud.storage._helpers import _get_environ_project |
32 | 31 | from google.cloud.storage._helpers import _virtual_hosted_style_base_url |
33 | | -from google.cloud.storage._helpers import _DEFAULT_UNIVERSE_DOMAIN |
34 | 32 | from google.cloud.storage._helpers import _NOW |
35 | 33 | from google.cloud.storage._helpers import _UTC |
36 | 34 | from google.cloud.storage._opentelemetry_tracing import create_trace_span |
@@ -151,103 +149,6 @@ def __init__( |
151 | 149 | self._connection = connection |
152 | 150 |
|
153 | 151 |
|
154 | | - @classmethod |
155 | | - def create_anonymous_client(cls): |
156 | | - """Factory: return client with anonymous credentials. |
157 | | -
|
158 | | - .. note:: |
159 | | -
|
160 | | - Such a client has only limited access to "public" buckets: |
161 | | - listing their contents and downloading their blobs. |
162 | | -
|
163 | | - :rtype: :class:`google.cloud.storage.client.Client` |
164 | | - :returns: Instance w/ anonymous credentials and no project. |
165 | | - """ |
166 | | - client = cls(project="<none>", credentials=AnonymousCredentials()) |
167 | | - client.project = None |
168 | | - return client |
169 | | - |
170 | | - @property |
171 | | - def universe_domain(self): |
172 | | - return self._universe_domain or _DEFAULT_UNIVERSE_DOMAIN |
173 | | - |
174 | | - @property |
175 | | - def api_endpoint(self): |
176 | | - return self._connection.API_BASE_URL |
177 | | - |
178 | | - def update_user_agent(self, user_agent): |
179 | | - """Update the user-agent string for this client. |
180 | | -
|
181 | | - :type user_agent: str |
182 | | - :param user_agent: The string to add to the user-agent. |
183 | | - """ |
184 | | - existing_user_agent = self._connection._client_info.user_agent |
185 | | - if existing_user_agent is None: |
186 | | - self._connection.user_agent = user_agent |
187 | | - else: |
188 | | - self._connection.user_agent = f"{user_agent} {existing_user_agent}" |
189 | | - |
190 | | - @property |
191 | | - def _connection(self): |
192 | | - """Get connection or batch on the client. |
193 | | -
|
194 | | - :rtype: :class:`google.cloud.storage._http.Connection` |
195 | | - :returns: The connection set on the client, or the batch |
196 | | - if one is set. |
197 | | - """ |
198 | | - if self.current_batch is not None: |
199 | | - return self.current_batch |
200 | | - else: |
201 | | - return self._base_connection |
202 | | - |
203 | | - @_connection.setter |
204 | | - def _connection(self, value): |
205 | | - """Set connection on the client. |
206 | | -
|
207 | | - Intended to be used by constructor (since the base class calls) |
208 | | - self._connection = connection |
209 | | - Will raise if the connection is set more than once. |
210 | | -
|
211 | | - :type value: :class:`google.cloud.storage._http.Connection` |
212 | | - :param value: The connection set on the client. |
213 | | -
|
214 | | - :raises: :class:`ValueError` if connection has already been set. |
215 | | - """ |
216 | | - if self._base_connection is not None: |
217 | | - raise ValueError("Connection already set on client") |
218 | | - self._base_connection = value |
219 | | - |
220 | | - def _push_batch(self, batch): |
221 | | - """Push a batch onto our stack. |
222 | | -
|
223 | | - "Protected", intended for use by batch context mgrs. |
224 | | -
|
225 | | - :type batch: :class:`google.cloud.storage.batch.Batch` |
226 | | - :param batch: newly-active batch |
227 | | - """ |
228 | | - self._batch_stack.push(batch) |
229 | | - |
230 | | - def _pop_batch(self): |
231 | | - """Pop a batch from our stack. |
232 | | -
|
233 | | - "Protected", intended for use by batch context mgrs. |
234 | | -
|
235 | | - :raises: IndexError if the stack is empty. |
236 | | - :rtype: :class:`google.cloud.storage.batch.Batch` |
237 | | - :returns: the top-most batch/transaction, after removing it. |
238 | | - """ |
239 | | - return self._batch_stack.pop() |
240 | | - |
241 | | - @property |
242 | | - def current_batch(self): |
243 | | - """Currently-active batch. |
244 | | -
|
245 | | - :rtype: :class:`google.cloud.storage.batch.Batch` or ``NoneType`` (if |
246 | | - no batch is active). |
247 | | - :returns: The batch at the top of the batch stack. |
248 | | - """ |
249 | | - return self._batch_stack.top |
250 | | - |
251 | 152 | def get_service_account_email( |
252 | 153 | self, project=None, timeout=_DEFAULT_TIMEOUT, retry=DEFAULT_RETRY |
253 | 154 | ): |
|
0 commit comments