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,233 @@
1
+ # Copyright 2016 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """Define Cloud Logging API Sinks."""
16
+
17
+ from google.cloud.exceptions import NotFound
18
+
19
+
20
+ class Sink(object):
21
+ """Sinks represent filtered exports for log entries.
22
+
23
+ See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks
24
+ """
25
+
26
+ def __init__(
27
+ self, name, *, filter_=None, parent=None, destination=None, client=None
28
+ ):
29
+ """
30
+ Args:
31
+ name (str): The name of the sink.
32
+ parent(Optional[str]): The resource in which to create the sink:
33
+
34
+ ::
35
+
36
+ "projects/[PROJECT_ID]"
37
+ "organizations/[ORGANIZATION_ID]"
38
+ "billingAccounts/[BILLING_ACCOUNT_ID]"
39
+ "folders/[FOLDER_ID]".
40
+
41
+ Defaults to the project stored on the client.
42
+ filter_ (Optional[str]): The advanced logs filter expression defining
43
+ the entries exported by the sink.
44
+ destination (Optional[str]): Destination URI for the entries exported by the sink.
45
+ If not passed, the instance should already exist, to
46
+ be refreshed via :meth:`reload`.
47
+ client (Optional[~logging_v2.client.Client]): A client which holds
48
+ credentials and project configuration for the sink (which requires a project).
49
+ """
50
+ self.name = name
51
+ self.filter_ = filter_
52
+ self.destination = destination
53
+ self._client = client
54
+ self._parent = parent
55
+ self._writer_identity = None
56
+
57
+ @property
58
+ def client(self):
59
+ """Client bound to the sink."""
60
+ return self._client
61
+
62
+ @property
63
+ def parent(self):
64
+ """Parent resource of the sink (project, organization, billingAccount, or folder)."""
65
+ if self._parent is None:
66
+ self._parent = f"projects/{self.client.project}"
67
+ return self._parent
68
+
69
+ @property
70
+ def full_name(self):
71
+ """Fully-qualified name used in sink APIs"""
72
+ return f"{self.parent}/sinks/{self.name}"
73
+
74
+ @property
75
+ def path(self):
76
+ """URL path for the sink's APIs"""
77
+ return f"/{self.full_name}"
78
+
79
+ @property
80
+ def writer_identity(self):
81
+ """Identity used for exports via the sink"""
82
+ return self._writer_identity
83
+
84
+ def _update_from_api_repr(self, resource):
85
+ """Helper for API methods returning sink resources."""
86
+ self.destination = resource["destination"]
87
+ self.filter_ = resource.get("filter")
88
+ self._writer_identity = resource.get("writerIdentity")
89
+
90
+ @classmethod
91
+ def from_api_repr(cls, resource, client, *, parent=None):
92
+ """Construct a sink given its API representation
93
+
94
+ Args:
95
+ resource (dict): sink resource representation returned from the API
96
+ client (~logging_v2.client.Client): Client which holds
97
+ credentials and project configuration for the sink.
98
+ parent(Optional[str]): The resource in which to create the sink:
99
+
100
+ ::
101
+
102
+ "projects/[PROJECT_ID]"
103
+ "organizations/[ORGANIZATION_ID]"
104
+ "billingAccounts/[BILLING_ACCOUNT_ID]"
105
+ "folders/[FOLDER_ID]".
106
+
107
+ Defaults to the project stored on the client.
108
+
109
+ Returns:
110
+ ~logging_v2.sink.Sink: Sink parsed from ``resource``.
111
+
112
+ Raises:
113
+ ValueError: if ``client`` is not ``None`` and the
114
+ project from the resource does not agree with the project
115
+ from the client.
116
+ """
117
+ sink_name = resource["name"]
118
+ instance = cls(sink_name, client=client, parent=parent)
119
+ instance._update_from_api_repr(resource)
120
+ return instance
121
+
122
+ def _require_client(self, client):
123
+ """Check client or verify over-ride. Also sets ``parent``.
124
+
125
+ Args:
126
+ client (Union[None, ~logging_v2.client.Client]):
127
+ The client to use. If not passed, falls back to the
128
+ ``client`` stored on the current sink.
129
+
130
+ Returns:
131
+ ~logging_v2.client.Client: The client passed in
132
+ or the currently bound client.
133
+ """
134
+ if client is None:
135
+ client = self._client
136
+ return client
137
+
138
+ def create(self, *, client=None, unique_writer_identity=False):
139
+ """Create the sink via a PUT request
140
+
141
+ See
142
+ https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/create
143
+
144
+ Args:
145
+ client (Optional[~logging_v2.client.Client]):
146
+ The client to use. If not passed, falls back to the
147
+ ``client`` stored on the current sink.
148
+ unique_writer_identity (Optional[bool]): Determines the kind of
149
+ IAM identity returned as writer_identity in the new sink.
150
+ """
151
+ client = self._require_client(client)
152
+ resource = client.sinks_api.sink_create(
153
+ self.parent,
154
+ self.name,
155
+ self.filter_,
156
+ self.destination,
157
+ unique_writer_identity=unique_writer_identity,
158
+ )
159
+ self._update_from_api_repr(resource)
160
+
161
+ def exists(self, *, client=None):
162
+ """Test for the existence of the sink via a GET request
163
+
164
+ See
165
+ https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/get
166
+
167
+ Args:
168
+ client (Optional[~logging_v2.client.Client]):
169
+ The client to use. If not passed, falls back to the
170
+ ``client`` stored on the current sink.
171
+
172
+ Returns:
173
+ bool: Boolean indicating existence of the sink.
174
+ """
175
+ client = self._require_client(client)
176
+
177
+ try:
178
+ client.sinks_api.sink_get(self.full_name)
179
+ except NotFound:
180
+ return False
181
+ else:
182
+ return True
183
+
184
+ def reload(self, *, client=None):
185
+ """Sync local sink configuration via a GET request
186
+
187
+ See
188
+ https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/get
189
+
190
+ Args:
191
+ client (Optional[~logging_v2.client.Client]):
192
+ The client to use. If not passed, falls back to the
193
+ ``client`` stored on the current sink.
194
+ """
195
+ client = self._require_client(client)
196
+ resource = client.sinks_api.sink_get(self.full_name)
197
+ self._update_from_api_repr(resource)
198
+
199
+ def update(self, *, client=None, unique_writer_identity=False):
200
+ """Update sink configuration via a PUT request
201
+
202
+ See
203
+ https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/update
204
+
205
+ Args:
206
+ client (Optional[~logging_v2.client.Client]):
207
+ The client to use. If not passed, falls back to the
208
+ ``client`` stored on the current sink.
209
+ unique_writer_identity (Optional[bool]): Determines the kind of
210
+ IAM identity returned as writer_identity in the new sink.
211
+ """
212
+ client = self._require_client(client)
213
+ resource = client.sinks_api.sink_update(
214
+ self.full_name,
215
+ self.filter_,
216
+ self.destination,
217
+ unique_writer_identity=unique_writer_identity,
218
+ )
219
+ self._update_from_api_repr(resource)
220
+
221
+ def delete(self, *, client=None):
222
+ """Delete a sink via a DELETE request
223
+
224
+ See
225
+ https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/delete
226
+
227
+ Args:
228
+ client (Optional[~logging_v2.client.Client]):
229
+ The client to use. If not passed, falls back to the
230
+ ``client`` stored on the current sink.
231
+ """
232
+ client = self._require_client(client)
233
+ client.sinks_api.sink_delete(self.full_name)
@@ -0,0 +1,178 @@
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
+ from .log_entry import (
17
+ LogEntry,
18
+ LogEntryOperation,
19
+ LogEntrySourceLocation,
20
+ LogSplit,
21
+ )
22
+ from .logging import (
23
+ DeleteLogRequest,
24
+ ListLogEntriesRequest,
25
+ ListLogEntriesResponse,
26
+ ListLogsRequest,
27
+ ListLogsResponse,
28
+ ListMonitoredResourceDescriptorsRequest,
29
+ ListMonitoredResourceDescriptorsResponse,
30
+ TailLogEntriesRequest,
31
+ TailLogEntriesResponse,
32
+ WriteLogEntriesPartialErrors,
33
+ WriteLogEntriesRequest,
34
+ WriteLogEntriesResponse,
35
+ )
36
+ from .logging_config import (
37
+ BigQueryDataset,
38
+ BigQueryOptions,
39
+ BucketMetadata,
40
+ CmekSettings,
41
+ CopyLogEntriesMetadata,
42
+ CopyLogEntriesRequest,
43
+ CopyLogEntriesResponse,
44
+ CreateBucketRequest,
45
+ CreateExclusionRequest,
46
+ CreateLinkRequest,
47
+ CreateSinkRequest,
48
+ CreateViewRequest,
49
+ DeleteBucketRequest,
50
+ DeleteExclusionRequest,
51
+ DeleteLinkRequest,
52
+ DeleteSinkRequest,
53
+ DeleteViewRequest,
54
+ GetBucketRequest,
55
+ GetCmekSettingsRequest,
56
+ GetExclusionRequest,
57
+ GetLinkRequest,
58
+ GetSettingsRequest,
59
+ GetSinkRequest,
60
+ GetViewRequest,
61
+ IndexConfig,
62
+ Link,
63
+ LinkMetadata,
64
+ ListBucketsRequest,
65
+ ListBucketsResponse,
66
+ ListExclusionsRequest,
67
+ ListExclusionsResponse,
68
+ ListLinksRequest,
69
+ ListLinksResponse,
70
+ ListSinksRequest,
71
+ ListSinksResponse,
72
+ ListViewsRequest,
73
+ ListViewsResponse,
74
+ LocationMetadata,
75
+ LogBucket,
76
+ LogExclusion,
77
+ LogSink,
78
+ LogView,
79
+ Settings,
80
+ UndeleteBucketRequest,
81
+ UpdateBucketRequest,
82
+ UpdateCmekSettingsRequest,
83
+ UpdateExclusionRequest,
84
+ UpdateSettingsRequest,
85
+ UpdateSinkRequest,
86
+ UpdateViewRequest,
87
+ IndexType,
88
+ LifecycleState,
89
+ OperationState,
90
+ )
91
+ from .logging_metrics import (
92
+ CreateLogMetricRequest,
93
+ DeleteLogMetricRequest,
94
+ GetLogMetricRequest,
95
+ ListLogMetricsRequest,
96
+ ListLogMetricsResponse,
97
+ LogMetric,
98
+ UpdateLogMetricRequest,
99
+ )
100
+
101
+ __all__ = (
102
+ "LogEntry",
103
+ "LogEntryOperation",
104
+ "LogEntrySourceLocation",
105
+ "LogSplit",
106
+ "DeleteLogRequest",
107
+ "ListLogEntriesRequest",
108
+ "ListLogEntriesResponse",
109
+ "ListLogsRequest",
110
+ "ListLogsResponse",
111
+ "ListMonitoredResourceDescriptorsRequest",
112
+ "ListMonitoredResourceDescriptorsResponse",
113
+ "TailLogEntriesRequest",
114
+ "TailLogEntriesResponse",
115
+ "WriteLogEntriesPartialErrors",
116
+ "WriteLogEntriesRequest",
117
+ "WriteLogEntriesResponse",
118
+ "BigQueryDataset",
119
+ "BigQueryOptions",
120
+ "BucketMetadata",
121
+ "CmekSettings",
122
+ "CopyLogEntriesMetadata",
123
+ "CopyLogEntriesRequest",
124
+ "CopyLogEntriesResponse",
125
+ "CreateBucketRequest",
126
+ "CreateExclusionRequest",
127
+ "CreateLinkRequest",
128
+ "CreateSinkRequest",
129
+ "CreateViewRequest",
130
+ "DeleteBucketRequest",
131
+ "DeleteExclusionRequest",
132
+ "DeleteLinkRequest",
133
+ "DeleteSinkRequest",
134
+ "DeleteViewRequest",
135
+ "GetBucketRequest",
136
+ "GetCmekSettingsRequest",
137
+ "GetExclusionRequest",
138
+ "GetLinkRequest",
139
+ "GetSettingsRequest",
140
+ "GetSinkRequest",
141
+ "GetViewRequest",
142
+ "IndexConfig",
143
+ "Link",
144
+ "LinkMetadata",
145
+ "ListBucketsRequest",
146
+ "ListBucketsResponse",
147
+ "ListExclusionsRequest",
148
+ "ListExclusionsResponse",
149
+ "ListLinksRequest",
150
+ "ListLinksResponse",
151
+ "ListSinksRequest",
152
+ "ListSinksResponse",
153
+ "ListViewsRequest",
154
+ "ListViewsResponse",
155
+ "LocationMetadata",
156
+ "LogBucket",
157
+ "LogExclusion",
158
+ "LogSink",
159
+ "LogView",
160
+ "Settings",
161
+ "UndeleteBucketRequest",
162
+ "UpdateBucketRequest",
163
+ "UpdateCmekSettingsRequest",
164
+ "UpdateExclusionRequest",
165
+ "UpdateSettingsRequest",
166
+ "UpdateSinkRequest",
167
+ "UpdateViewRequest",
168
+ "IndexType",
169
+ "LifecycleState",
170
+ "OperationState",
171
+ "CreateLogMetricRequest",
172
+ "DeleteLogMetricRequest",
173
+ "GetLogMetricRequest",
174
+ "ListLogMetricsRequest",
175
+ "ListLogMetricsResponse",
176
+ "LogMetric",
177
+ "UpdateLogMetricRequest",
178
+ )