google-cloud-logging 3.13.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. google/cloud/logging/__init__.py +53 -0
  2. google/cloud/logging/gapic_version.py +16 -0
  3. google/cloud/logging/handlers/__init__.py +31 -0
  4. google/cloud/logging/handlers/middleware/__init__.py +17 -0
  5. google/cloud/logging/handlers/transports/__init__.py +28 -0
  6. google/cloud/logging/py.typed +2 -0
  7. google/cloud/logging_v2/__init__.py +61 -0
  8. google/cloud/logging_v2/_gapic.py +647 -0
  9. google/cloud/logging_v2/_helpers.py +152 -0
  10. google/cloud/logging_v2/_http.py +549 -0
  11. google/cloud/logging_v2/_instrumentation.py +92 -0
  12. google/cloud/logging_v2/client.py +429 -0
  13. google/cloud/logging_v2/entries.py +358 -0
  14. google/cloud/logging_v2/gapic_metadata.json +481 -0
  15. google/cloud/logging_v2/gapic_version.py +16 -0
  16. google/cloud/logging_v2/handlers/__init__.py +31 -0
  17. google/cloud/logging_v2/handlers/_helpers.py +283 -0
  18. google/cloud/logging_v2/handlers/_monitored_resources.py +303 -0
  19. google/cloud/logging_v2/handlers/app_engine.py +139 -0
  20. google/cloud/logging_v2/handlers/container_engine.py +62 -0
  21. google/cloud/logging_v2/handlers/handlers.py +340 -0
  22. google/cloud/logging_v2/handlers/middleware/__init__.py +17 -0
  23. google/cloud/logging_v2/handlers/middleware/request.py +52 -0
  24. google/cloud/logging_v2/handlers/structured_log.py +150 -0
  25. google/cloud/logging_v2/handlers/transports/__init__.py +29 -0
  26. google/cloud/logging_v2/handlers/transports/background_thread.py +343 -0
  27. google/cloud/logging_v2/handlers/transports/base.py +61 -0
  28. google/cloud/logging_v2/handlers/transports/sync.py +68 -0
  29. google/cloud/logging_v2/logger.py +541 -0
  30. google/cloud/logging_v2/metric.py +180 -0
  31. google/cloud/logging_v2/py.typed +2 -0
  32. google/cloud/logging_v2/resource.py +51 -0
  33. google/cloud/logging_v2/services/__init__.py +15 -0
  34. google/cloud/logging_v2/services/config_service_v2/__init__.py +22 -0
  35. google/cloud/logging_v2/services/config_service_v2/async_client.py +4232 -0
  36. google/cloud/logging_v2/services/config_service_v2/client.py +4686 -0
  37. google/cloud/logging_v2/services/config_service_v2/pagers.py +820 -0
  38. google/cloud/logging_v2/services/config_service_v2/transports/__init__.py +33 -0
  39. google/cloud/logging_v2/services/config_service_v2/transports/base.py +748 -0
  40. google/cloud/logging_v2/services/config_service_v2/transports/grpc.py +1345 -0
  41. google/cloud/logging_v2/services/config_service_v2/transports/grpc_asyncio.py +1660 -0
  42. google/cloud/logging_v2/services/logging_service_v2/__init__.py +22 -0
  43. google/cloud/logging_v2/services/logging_service_v2/async_client.py +1272 -0
  44. google/cloud/logging_v2/services/logging_service_v2/client.py +1686 -0
  45. google/cloud/logging_v2/services/logging_service_v2/pagers.py +516 -0
  46. google/cloud/logging_v2/services/logging_service_v2/transports/__init__.py +33 -0
  47. google/cloud/logging_v2/services/logging_service_v2/transports/base.py +361 -0
  48. google/cloud/logging_v2/services/logging_service_v2/transports/grpc.py +566 -0
  49. google/cloud/logging_v2/services/logging_service_v2/transports/grpc_asyncio.py +703 -0
  50. google/cloud/logging_v2/services/metrics_service_v2/__init__.py +22 -0
  51. google/cloud/logging_v2/services/metrics_service_v2/async_client.py +1119 -0
  52. google/cloud/logging_v2/services/metrics_service_v2/client.py +1534 -0
  53. google/cloud/logging_v2/services/metrics_service_v2/pagers.py +196 -0
  54. google/cloud/logging_v2/services/metrics_service_v2/transports/__init__.py +33 -0
  55. google/cloud/logging_v2/services/metrics_service_v2/transports/base.py +320 -0
  56. google/cloud/logging_v2/services/metrics_service_v2/transports/grpc.py +520 -0
  57. google/cloud/logging_v2/services/metrics_service_v2/transports/grpc_asyncio.py +629 -0
  58. google/cloud/logging_v2/sink.py +233 -0
  59. google/cloud/logging_v2/types/__init__.py +178 -0
  60. google/cloud/logging_v2/types/log_entry.py +435 -0
  61. google/cloud/logging_v2/types/logging.py +602 -0
  62. google/cloud/logging_v2/types/logging_config.py +2418 -0
  63. google/cloud/logging_v2/types/logging_metrics.py +412 -0
  64. google_cloud_logging-3.13.0.dist-info/METADATA +143 -0
  65. google_cloud_logging-3.13.0.dist-info/RECORD +68 -0
  66. google_cloud_logging-3.13.0.dist-info/WHEEL +5 -0
  67. google_cloud_logging-3.13.0.dist-info/licenses/LICENSE +202 -0
  68. google_cloud_logging-3.13.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,361 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2025 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ import abc
17
+ from typing import Awaitable, Callable, Dict, Optional, Sequence, Union
18
+
19
+ from google.cloud.logging_v2 import gapic_version as package_version
20
+
21
+ import google.auth # type: ignore
22
+ import google.api_core
23
+ from google.api_core import exceptions as core_exceptions
24
+ from google.api_core import gapic_v1
25
+ from google.api_core import retry as retries
26
+ from google.auth import credentials as ga_credentials # type: ignore
27
+ from google.oauth2 import service_account # type: ignore
28
+ import google.protobuf
29
+
30
+ from google.cloud.logging_v2.types import logging
31
+ from google.longrunning import operations_pb2 # type: ignore
32
+ from google.protobuf import empty_pb2 # type: ignore
33
+
34
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
35
+ gapic_version=package_version.__version__
36
+ )
37
+
38
+ if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER
39
+ DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
40
+
41
+
42
+ class LoggingServiceV2Transport(abc.ABC):
43
+ """Abstract transport class for LoggingServiceV2."""
44
+
45
+ AUTH_SCOPES = (
46
+ "https://www.googleapis.com/auth/cloud-platform",
47
+ "https://www.googleapis.com/auth/cloud-platform.read-only",
48
+ "https://www.googleapis.com/auth/logging.admin",
49
+ "https://www.googleapis.com/auth/logging.read",
50
+ "https://www.googleapis.com/auth/logging.write",
51
+ )
52
+
53
+ DEFAULT_HOST: str = "logging.googleapis.com"
54
+
55
+ def __init__(
56
+ self,
57
+ *,
58
+ host: str = DEFAULT_HOST,
59
+ credentials: Optional[ga_credentials.Credentials] = None,
60
+ credentials_file: Optional[str] = None,
61
+ scopes: Optional[Sequence[str]] = None,
62
+ quota_project_id: Optional[str] = None,
63
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
64
+ always_use_jwt_access: Optional[bool] = False,
65
+ api_audience: Optional[str] = None,
66
+ **kwargs,
67
+ ) -> None:
68
+ """Instantiate the transport.
69
+
70
+ Args:
71
+ host (Optional[str]):
72
+ The hostname to connect to (default: 'logging.googleapis.com').
73
+ credentials (Optional[google.auth.credentials.Credentials]): The
74
+ authorization credentials to attach to requests. These
75
+ credentials identify the application to the service; if none
76
+ are specified, the client will attempt to ascertain the
77
+ credentials from the environment.
78
+ credentials_file (Optional[str]): Deprecated. A file with credentials that can
79
+ be loaded with :func:`google.auth.load_credentials_from_file`.
80
+ This argument is mutually exclusive with credentials. This argument will be
81
+ removed in the next major version of this library.
82
+ scopes (Optional[Sequence[str]]): A list of scopes.
83
+ quota_project_id (Optional[str]): An optional project to use for billing
84
+ and quota.
85
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
86
+ The client info used to send a user-agent string along with
87
+ API requests. If ``None``, then default info will be used.
88
+ Generally, you only need to set this if you're developing
89
+ your own client library.
90
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
91
+ be used for service account credentials.
92
+ """
93
+
94
+ scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES}
95
+
96
+ # Save the scopes.
97
+ self._scopes = scopes
98
+ if not hasattr(self, "_ignore_credentials"):
99
+ self._ignore_credentials: bool = False
100
+
101
+ # If no credentials are provided, then determine the appropriate
102
+ # defaults.
103
+ if credentials and credentials_file:
104
+ raise core_exceptions.DuplicateCredentialArgs(
105
+ "'credentials_file' and 'credentials' are mutually exclusive"
106
+ )
107
+
108
+ if credentials_file is not None:
109
+ credentials, _ = google.auth.load_credentials_from_file(
110
+ credentials_file, **scopes_kwargs, quota_project_id=quota_project_id
111
+ )
112
+ elif credentials is None and not self._ignore_credentials:
113
+ credentials, _ = google.auth.default(
114
+ **scopes_kwargs, quota_project_id=quota_project_id
115
+ )
116
+ # Don't apply audience if the credentials file passed from user.
117
+ if hasattr(credentials, "with_gdch_audience"):
118
+ credentials = credentials.with_gdch_audience(
119
+ api_audience if api_audience else host
120
+ )
121
+
122
+ # If the credentials are service account credentials, then always try to use self signed JWT.
123
+ if (
124
+ always_use_jwt_access
125
+ and isinstance(credentials, service_account.Credentials)
126
+ and hasattr(service_account.Credentials, "with_always_use_jwt_access")
127
+ ):
128
+ credentials = credentials.with_always_use_jwt_access(True)
129
+
130
+ # Save the credentials.
131
+ self._credentials = credentials
132
+
133
+ # Save the hostname. Default to port 443 (HTTPS) if none is specified.
134
+ if ":" not in host:
135
+ host += ":443"
136
+ self._host = host
137
+
138
+ @property
139
+ def host(self):
140
+ return self._host
141
+
142
+ def _prep_wrapped_messages(self, client_info):
143
+ # Precompute the wrapped methods.
144
+ self._wrapped_methods = {
145
+ self.delete_log: gapic_v1.method.wrap_method(
146
+ self.delete_log,
147
+ default_retry=retries.Retry(
148
+ initial=0.1,
149
+ maximum=60.0,
150
+ multiplier=1.3,
151
+ predicate=retries.if_exception_type(
152
+ core_exceptions.DeadlineExceeded,
153
+ core_exceptions.InternalServerError,
154
+ core_exceptions.ServiceUnavailable,
155
+ ),
156
+ deadline=60.0,
157
+ ),
158
+ default_timeout=60.0,
159
+ client_info=client_info,
160
+ ),
161
+ self.write_log_entries: gapic_v1.method.wrap_method(
162
+ self.write_log_entries,
163
+ default_retry=retries.Retry(
164
+ initial=0.1,
165
+ maximum=60.0,
166
+ multiplier=1.3,
167
+ predicate=retries.if_exception_type(
168
+ core_exceptions.DeadlineExceeded,
169
+ core_exceptions.InternalServerError,
170
+ core_exceptions.ServiceUnavailable,
171
+ ),
172
+ deadline=60.0,
173
+ ),
174
+ default_timeout=60.0,
175
+ client_info=client_info,
176
+ ),
177
+ self.list_log_entries: gapic_v1.method.wrap_method(
178
+ self.list_log_entries,
179
+ default_retry=retries.Retry(
180
+ initial=0.1,
181
+ maximum=60.0,
182
+ multiplier=1.3,
183
+ predicate=retries.if_exception_type(
184
+ core_exceptions.DeadlineExceeded,
185
+ core_exceptions.InternalServerError,
186
+ core_exceptions.ServiceUnavailable,
187
+ ),
188
+ deadline=60.0,
189
+ ),
190
+ default_timeout=60.0,
191
+ client_info=client_info,
192
+ ),
193
+ self.list_monitored_resource_descriptors: gapic_v1.method.wrap_method(
194
+ self.list_monitored_resource_descriptors,
195
+ default_retry=retries.Retry(
196
+ initial=0.1,
197
+ maximum=60.0,
198
+ multiplier=1.3,
199
+ predicate=retries.if_exception_type(
200
+ core_exceptions.DeadlineExceeded,
201
+ core_exceptions.InternalServerError,
202
+ core_exceptions.ServiceUnavailable,
203
+ ),
204
+ deadline=60.0,
205
+ ),
206
+ default_timeout=60.0,
207
+ client_info=client_info,
208
+ ),
209
+ self.list_logs: gapic_v1.method.wrap_method(
210
+ self.list_logs,
211
+ default_retry=retries.Retry(
212
+ initial=0.1,
213
+ maximum=60.0,
214
+ multiplier=1.3,
215
+ predicate=retries.if_exception_type(
216
+ core_exceptions.DeadlineExceeded,
217
+ core_exceptions.InternalServerError,
218
+ core_exceptions.ServiceUnavailable,
219
+ ),
220
+ deadline=60.0,
221
+ ),
222
+ default_timeout=60.0,
223
+ client_info=client_info,
224
+ ),
225
+ self.tail_log_entries: gapic_v1.method.wrap_method(
226
+ self.tail_log_entries,
227
+ default_retry=retries.Retry(
228
+ initial=0.1,
229
+ maximum=60.0,
230
+ multiplier=1.3,
231
+ predicate=retries.if_exception_type(
232
+ core_exceptions.DeadlineExceeded,
233
+ core_exceptions.InternalServerError,
234
+ core_exceptions.ServiceUnavailable,
235
+ ),
236
+ deadline=3600.0,
237
+ ),
238
+ default_timeout=3600.0,
239
+ client_info=client_info,
240
+ ),
241
+ self.cancel_operation: gapic_v1.method.wrap_method(
242
+ self.cancel_operation,
243
+ default_timeout=None,
244
+ client_info=client_info,
245
+ ),
246
+ self.get_operation: gapic_v1.method.wrap_method(
247
+ self.get_operation,
248
+ default_timeout=None,
249
+ client_info=client_info,
250
+ ),
251
+ self.list_operations: gapic_v1.method.wrap_method(
252
+ self.list_operations,
253
+ default_timeout=None,
254
+ client_info=client_info,
255
+ ),
256
+ }
257
+
258
+ def close(self):
259
+ """Closes resources associated with the transport.
260
+
261
+ .. warning::
262
+ Only call this method if the transport is NOT shared
263
+ with other clients - this may cause errors in other clients!
264
+ """
265
+ raise NotImplementedError()
266
+
267
+ @property
268
+ def delete_log(
269
+ self,
270
+ ) -> Callable[
271
+ [logging.DeleteLogRequest], Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]]
272
+ ]:
273
+ raise NotImplementedError()
274
+
275
+ @property
276
+ def write_log_entries(
277
+ self,
278
+ ) -> Callable[
279
+ [logging.WriteLogEntriesRequest],
280
+ Union[
281
+ logging.WriteLogEntriesResponse, Awaitable[logging.WriteLogEntriesResponse]
282
+ ],
283
+ ]:
284
+ raise NotImplementedError()
285
+
286
+ @property
287
+ def list_log_entries(
288
+ self,
289
+ ) -> Callable[
290
+ [logging.ListLogEntriesRequest],
291
+ Union[
292
+ logging.ListLogEntriesResponse, Awaitable[logging.ListLogEntriesResponse]
293
+ ],
294
+ ]:
295
+ raise NotImplementedError()
296
+
297
+ @property
298
+ def list_monitored_resource_descriptors(
299
+ self,
300
+ ) -> Callable[
301
+ [logging.ListMonitoredResourceDescriptorsRequest],
302
+ Union[
303
+ logging.ListMonitoredResourceDescriptorsResponse,
304
+ Awaitable[logging.ListMonitoredResourceDescriptorsResponse],
305
+ ],
306
+ ]:
307
+ raise NotImplementedError()
308
+
309
+ @property
310
+ def list_logs(
311
+ self,
312
+ ) -> Callable[
313
+ [logging.ListLogsRequest],
314
+ Union[logging.ListLogsResponse, Awaitable[logging.ListLogsResponse]],
315
+ ]:
316
+ raise NotImplementedError()
317
+
318
+ @property
319
+ def tail_log_entries(
320
+ self,
321
+ ) -> Callable[
322
+ [logging.TailLogEntriesRequest],
323
+ Union[
324
+ logging.TailLogEntriesResponse, Awaitable[logging.TailLogEntriesResponse]
325
+ ],
326
+ ]:
327
+ raise NotImplementedError()
328
+
329
+ @property
330
+ def list_operations(
331
+ self,
332
+ ) -> Callable[
333
+ [operations_pb2.ListOperationsRequest],
334
+ Union[
335
+ operations_pb2.ListOperationsResponse,
336
+ Awaitable[operations_pb2.ListOperationsResponse],
337
+ ],
338
+ ]:
339
+ raise NotImplementedError()
340
+
341
+ @property
342
+ def get_operation(
343
+ self,
344
+ ) -> Callable[
345
+ [operations_pb2.GetOperationRequest],
346
+ Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]],
347
+ ]:
348
+ raise NotImplementedError()
349
+
350
+ @property
351
+ def cancel_operation(
352
+ self,
353
+ ) -> Callable[[operations_pb2.CancelOperationRequest], None,]:
354
+ raise NotImplementedError()
355
+
356
+ @property
357
+ def kind(self) -> str:
358
+ raise NotImplementedError()
359
+
360
+
361
+ __all__ = ("LoggingServiceV2Transport",)