google-cloud-logging 3.16.2__tar.gz → 3.17.0__tar.gz
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.
- {google_cloud_logging-3.16.2/google_cloud_logging.egg-info → google_cloud_logging-3.17.0}/PKG-INFO +3 -2
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging/gapic_version.py +1 -1
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/__init__.py +5 -0
- google_cloud_logging-3.17.0/google/cloud/logging_v2/_compat.py +262 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/gapic_version.py +1 -1
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/services/config_service_v2/client.py +23 -160
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/services/logging_service_v2/client.py +23 -160
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/services/metrics_service_v2/client.py +23 -160
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0/google_cloud_logging.egg-info}/PKG-INFO +3 -2
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google_cloud_logging.egg-info/SOURCES.txt +2 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google_cloud_logging.egg-info/requires.txt +1 -1
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/setup.py +2 -1
- google_cloud_logging-3.17.0/tests/unit/gapic/logging_v2/test_compat.py +429 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/tests/unit/gapic/logging_v2/test_config_service_v2.py +14 -295
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/tests/unit/gapic/logging_v2/test_logging_service_v2.py +14 -296
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/tests/unit/gapic/logging_v2/test_metrics_service_v2.py +14 -296
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/LICENSE +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/MANIFEST.in +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/README.rst +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging/__init__.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging/handlers/__init__.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging/handlers/middleware/__init__.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging/handlers/transports/__init__.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging/py.typed +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/_gapic.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/_helpers.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/_http.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/_instrumentation.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/client.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/entries.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/gapic_metadata.json +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/handlers/__init__.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/handlers/_helpers.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/handlers/_monitored_resources.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/handlers/app_engine.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/handlers/container_engine.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/handlers/handlers.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/handlers/middleware/__init__.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/handlers/middleware/request.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/handlers/structured_log.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/handlers/transports/__init__.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/handlers/transports/background_thread.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/handlers/transports/base.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/handlers/transports/sync.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/logger.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/metric.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/py.typed +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/resource.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/services/__init__.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/services/config_service_v2/__init__.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/services/config_service_v2/async_client.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/services/config_service_v2/pagers.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/services/config_service_v2/transports/__init__.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/services/config_service_v2/transports/base.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/services/config_service_v2/transports/grpc.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/services/config_service_v2/transports/grpc_asyncio.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/services/logging_service_v2/__init__.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/services/logging_service_v2/async_client.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/services/logging_service_v2/pagers.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/services/logging_service_v2/transports/__init__.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/services/logging_service_v2/transports/base.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/services/logging_service_v2/transports/grpc.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/services/logging_service_v2/transports/grpc_asyncio.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/services/metrics_service_v2/__init__.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/services/metrics_service_v2/async_client.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/services/metrics_service_v2/pagers.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/services/metrics_service_v2/transports/__init__.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/services/metrics_service_v2/transports/base.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/services/metrics_service_v2/transports/grpc.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/services/metrics_service_v2/transports/grpc_asyncio.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/sink.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/types/__init__.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/types/log_entry.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/types/logging.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/types/logging_config.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/types/logging_metrics.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google_cloud_logging.egg-info/dependency_links.txt +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google_cloud_logging.egg-info/not-zip-safe +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google_cloud_logging.egg-info/top_level.txt +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/setup.cfg +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/tests/__init__.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/tests/system/gapic/v2/test_system_logging_service_v2_v2.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/tests/system/test_system.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/tests/unit/__init__.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/tests/unit/gapic/__init__.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/tests/unit/gapic/logging_v2/__init__.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/tests/unit/handlers/__init__.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/tests/unit/handlers/middleware/test_request.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/tests/unit/handlers/test__helpers.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/tests/unit/handlers/test__monitored_resources.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/tests/unit/handlers/test_app_engine.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/tests/unit/handlers/test_container_engine.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/tests/unit/handlers/test_handlers.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/tests/unit/handlers/test_structured_log.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/tests/unit/handlers/transports/__init__.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/tests/unit/handlers/transports/test_background_thread.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/tests/unit/handlers/transports/test_base.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/tests/unit/handlers/transports/test_sync.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/tests/unit/test__gapic.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/tests/unit/test__helpers.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/tests/unit/test__http.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/tests/unit/test__instrumentation.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/tests/unit/test_client.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/tests/unit/test_entries.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/tests/unit/test_logger.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/tests/unit/test_logging_shim.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/tests/unit/test_metric.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/tests/unit/test_packaging.py +0 -0
- {google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/tests/unit/test_sink.py +0 -0
{google_cloud_logging-3.16.2/google_cloud_logging.egg-info → google_cloud_logging-3.17.0}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: google-cloud-logging
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.17.0
|
|
4
4
|
Summary: Google Cloud Logging API client library
|
|
5
5
|
Home-page: https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-logging
|
|
6
6
|
Author: Google LLC
|
|
@@ -17,11 +17,12 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.12
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.13
|
|
19
19
|
Classifier: Programming Language :: Python :: 3.14
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
20
21
|
Classifier: Operating System :: OS Independent
|
|
21
22
|
Classifier: Topic :: Internet
|
|
22
23
|
Requires-Python: >=3.10
|
|
23
24
|
License-File: LICENSE
|
|
24
|
-
Requires-Dist: google-api-core[grpc]<3.0.0,>=2.
|
|
25
|
+
Requires-Dist: google-api-core[grpc]<3.0.0,>=2.28.0
|
|
25
26
|
Requires-Dist: google-auth!=2.24.0,!=2.25.0,<3.0.0,>=2.14.1
|
|
26
27
|
Requires-Dist: google-cloud-appengine-logging<2.0.0,>=1.6.1
|
|
27
28
|
Requires-Dist: google-cloud-audit-log<1.0.0,>=0.3.2
|
{google_cloud_logging-3.16.2 → google_cloud_logging-3.17.0}/google/cloud/logging_v2/__init__.py
RENAMED
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
#
|
|
16
16
|
from __future__ import absolute_import
|
|
17
17
|
|
|
18
|
+
import google.api_core as api_core
|
|
19
|
+
|
|
18
20
|
from google.cloud.logging_v2 import gapic_version as package_version
|
|
19
21
|
|
|
20
22
|
__version__ = package_version.__version__
|
|
@@ -59,3 +61,6 @@ __all__ = (
|
|
|
59
61
|
"TextEntry",
|
|
60
62
|
"types",
|
|
61
63
|
)
|
|
64
|
+
|
|
65
|
+
api_core.check_python_version("google.cloud.logging_v2")
|
|
66
|
+
api_core.check_dependency_versions("google.cloud.logging_v2")
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Copyright 2026 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
|
+
"""A compatibility module for older versions of google-api-core."""
|
|
17
|
+
|
|
18
|
+
import json
|
|
19
|
+
import os
|
|
20
|
+
from typing import Any, Dict, List, Optional, Tuple
|
|
21
|
+
from urllib.parse import urlparse, urlunparse
|
|
22
|
+
|
|
23
|
+
from google.api_core import path_template
|
|
24
|
+
from google.api_core.universe import EmptyUniverseError
|
|
25
|
+
from google.auth.exceptions import MutualTLSChannelError
|
|
26
|
+
from google.protobuf import json_format
|
|
27
|
+
|
|
28
|
+
try:
|
|
29
|
+
# note: `#type: ignore` is added because the return type for `should_use_client_cert`
|
|
30
|
+
# is different than that of the fallback implementation below. This will be removed once
|
|
31
|
+
# we bump the minimum supported version of google-auth.
|
|
32
|
+
from google.auth.transport.mtls import should_use_client_cert # type: ignore
|
|
33
|
+
except ImportError: # pragma: NO COVER
|
|
34
|
+
|
|
35
|
+
def should_use_client_cert():
|
|
36
|
+
"""Returns whether client certificate should be used for mTLS."""
|
|
37
|
+
use_client_cert = os.getenv(
|
|
38
|
+
"GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"
|
|
39
|
+
).lower()
|
|
40
|
+
if use_client_cert not in ("true", "false"):
|
|
41
|
+
raise ValueError(
|
|
42
|
+
"Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be"
|
|
43
|
+
" either `true` or `false`"
|
|
44
|
+
)
|
|
45
|
+
return use_client_cert == "true"
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def read_environment_variables():
|
|
49
|
+
"""Returns the environment variables used by the client.
|
|
50
|
+
|
|
51
|
+
Returns:
|
|
52
|
+
Tuple[bool, str, str]: returns the GOOGLE_API_USE_CLIENT_CERTIFICATE,
|
|
53
|
+
GOOGLE_API_USE_MTLS_ENDPOINT, and GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variables.
|
|
54
|
+
|
|
55
|
+
Raises:
|
|
56
|
+
ValueError: If GOOGLE_API_USE_CLIENT_CERTIFICATE is not
|
|
57
|
+
any of ["true", "false"].
|
|
58
|
+
google.auth.exceptions.MutualTLSChannelError: If GOOGLE_API_USE_MTLS_ENDPOINT
|
|
59
|
+
is not any of ["auto", "never", "always"].
|
|
60
|
+
"""
|
|
61
|
+
use_client_cert = should_use_client_cert()
|
|
62
|
+
use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto").lower()
|
|
63
|
+
universe_domain_env = os.getenv("GOOGLE_CLOUD_UNIVERSE_DOMAIN")
|
|
64
|
+
if use_mtls_endpoint not in ("auto", "never", "always"):
|
|
65
|
+
raise MutualTLSChannelError(
|
|
66
|
+
"Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`,"
|
|
67
|
+
" `auto` or `always`"
|
|
68
|
+
)
|
|
69
|
+
return use_client_cert, use_mtls_endpoint, universe_domain_env
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
DEFAULT_UNIVERSE = "googleapis.com"
|
|
73
|
+
|
|
74
|
+
try:
|
|
75
|
+
from google.api_core.universe import get_default_mtls_endpoint
|
|
76
|
+
except ImportError: # pragma: NO COVER
|
|
77
|
+
|
|
78
|
+
def get_default_mtls_endpoint(api_endpoint: Optional[str]) -> Optional[str]:
|
|
79
|
+
"""Converts api endpoint to mTLS endpoint.
|
|
80
|
+
|
|
81
|
+
Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to
|
|
82
|
+
"*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively.
|
|
83
|
+
Other URLs (including those that do not match these domain suffixes or
|
|
84
|
+
already contain '.mtls.') are passed through as-is.
|
|
85
|
+
|
|
86
|
+
Args:
|
|
87
|
+
api_endpoint (Optional[str]): the api endpoint to convert.
|
|
88
|
+
|
|
89
|
+
Returns:
|
|
90
|
+
Optional[str]: converted mTLS api endpoint.
|
|
91
|
+
"""
|
|
92
|
+
if not api_endpoint or ".mtls." in api_endpoint.lower():
|
|
93
|
+
return api_endpoint
|
|
94
|
+
|
|
95
|
+
has_scheme = "://" in api_endpoint
|
|
96
|
+
if not has_scheme:
|
|
97
|
+
parsed = urlparse("//" + api_endpoint)
|
|
98
|
+
else:
|
|
99
|
+
parsed = urlparse(api_endpoint)
|
|
100
|
+
|
|
101
|
+
host = parsed.hostname
|
|
102
|
+
if not host:
|
|
103
|
+
return api_endpoint
|
|
104
|
+
|
|
105
|
+
port = f":{parsed.port}" if parsed.port else ""
|
|
106
|
+
|
|
107
|
+
lowered_host = host.lower()
|
|
108
|
+
suffix_sandbox = ".sandbox.googleapis.com"
|
|
109
|
+
suffix_google = ".googleapis.com"
|
|
110
|
+
if lowered_host.endswith(suffix_sandbox):
|
|
111
|
+
new_host = host[: -len(suffix_sandbox)] + ".mtls.sandbox.googleapis.com"
|
|
112
|
+
elif lowered_host.endswith(suffix_google):
|
|
113
|
+
new_host = host[: -len(suffix_google)] + ".mtls.googleapis.com"
|
|
114
|
+
else:
|
|
115
|
+
return api_endpoint
|
|
116
|
+
|
|
117
|
+
netloc = new_host + port
|
|
118
|
+
new_parsed = parsed._replace(netloc=netloc)
|
|
119
|
+
|
|
120
|
+
if not has_scheme:
|
|
121
|
+
return urlunparse(new_parsed)[2:]
|
|
122
|
+
else:
|
|
123
|
+
return urlunparse(new_parsed)
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
try:
|
|
127
|
+
from google.api_core.universe import get_api_endpoint
|
|
128
|
+
except ImportError: # pragma: NO COVER
|
|
129
|
+
|
|
130
|
+
def get_api_endpoint(
|
|
131
|
+
api_override: Optional[str],
|
|
132
|
+
universe_domain: str,
|
|
133
|
+
default_universe: str,
|
|
134
|
+
default_mtls_endpoint: Optional[str],
|
|
135
|
+
default_endpoint_template: str,
|
|
136
|
+
use_mtls: bool,
|
|
137
|
+
) -> str:
|
|
138
|
+
"""Return the API endpoint used by the client.
|
|
139
|
+
|
|
140
|
+
Args:
|
|
141
|
+
api_override (Optional[str]): The API endpoint override. If specified,
|
|
142
|
+
this is always returned.
|
|
143
|
+
universe_domain (str): The universe domain used by the client.
|
|
144
|
+
default_universe (str): The default universe domain.
|
|
145
|
+
default_mtls_endpoint (Optional[str]): The default mTLS endpoint.
|
|
146
|
+
default_endpoint_template (str): The default endpoint template containing
|
|
147
|
+
a placeholder `{UNIVERSE_DOMAIN}`.
|
|
148
|
+
use_mtls (bool): Whether to use the mTLS endpoint.
|
|
149
|
+
|
|
150
|
+
Returns:
|
|
151
|
+
str: The API endpoint to be used by the client.
|
|
152
|
+
|
|
153
|
+
Raises:
|
|
154
|
+
google.auth.exceptions.MutualTLSChannelError: If mTLS is requested but
|
|
155
|
+
not supported in the configured universe domain.
|
|
156
|
+
ValueError: If mTLS is requested but no mTLS endpoint is available.
|
|
157
|
+
"""
|
|
158
|
+
if api_override is not None:
|
|
159
|
+
return api_override
|
|
160
|
+
|
|
161
|
+
if use_mtls:
|
|
162
|
+
if universe_domain.lower() != default_universe.lower():
|
|
163
|
+
raise MutualTLSChannelError(
|
|
164
|
+
f"mTLS is not supported in any universe other than {default_universe}."
|
|
165
|
+
)
|
|
166
|
+
if not default_mtls_endpoint:
|
|
167
|
+
raise ValueError("mTLS endpoint is not available.")
|
|
168
|
+
return default_mtls_endpoint
|
|
169
|
+
else:
|
|
170
|
+
return default_endpoint_template.format(UNIVERSE_DOMAIN=universe_domain)
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
try:
|
|
174
|
+
from google.api_core.universe import get_universe_domain
|
|
175
|
+
except ImportError: # pragma: NO COVER
|
|
176
|
+
|
|
177
|
+
def get_universe_domain(
|
|
178
|
+
*potential_universes: Optional[str],
|
|
179
|
+
default_universe: str,
|
|
180
|
+
) -> str:
|
|
181
|
+
"""Return the universe domain used by the client.
|
|
182
|
+
|
|
183
|
+
Args:
|
|
184
|
+
*potential_universes (Optional[str]): Potential universe domains in order of preference.
|
|
185
|
+
default_universe (str): The default universe domain.
|
|
186
|
+
|
|
187
|
+
Returns:
|
|
188
|
+
str: The universe domain to be used by the client.
|
|
189
|
+
|
|
190
|
+
Raises:
|
|
191
|
+
EmptyUniverseError: If the resolved universe domain is an empty string.
|
|
192
|
+
"""
|
|
193
|
+
resolved = next(
|
|
194
|
+
(x.strip() for x in potential_universes if x is not None),
|
|
195
|
+
default_universe,
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
if not resolved:
|
|
199
|
+
raise EmptyUniverseError()
|
|
200
|
+
return resolved
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
try:
|
|
204
|
+
from google.api_core.rest_helpers import transcode_request # type: ignore
|
|
205
|
+
except ImportError: # pragma: NO COVER
|
|
206
|
+
|
|
207
|
+
def transcode_request(
|
|
208
|
+
http_options: List[Dict[str, str]],
|
|
209
|
+
request: Any,
|
|
210
|
+
required_fields_default_values: Optional[Dict[str, Any]] = None,
|
|
211
|
+
rest_numeric_enums: bool = False,
|
|
212
|
+
) -> Tuple[Dict[str, Any], Optional[str], Dict[str, Any]]:
|
|
213
|
+
"""Transcodes a request into HTTP method, URI, body, and query parameters.
|
|
214
|
+
|
|
215
|
+
Args:
|
|
216
|
+
http_options (List[Dict[str, str]]): List of HTTP transcoding rules.
|
|
217
|
+
request (Any): The protobuf or proto-plus request message.
|
|
218
|
+
required_fields_default_values (Optional[Dict[str, Any]]): Dictionary
|
|
219
|
+
of required fields default values to merge into query parameters if missing.
|
|
220
|
+
rest_numeric_enums (bool): Whether to encode enums as integers.
|
|
221
|
+
|
|
222
|
+
Returns:
|
|
223
|
+
Tuple[Dict[str, Any], Optional[str], Dict[str, Any]]: A tuple containing:
|
|
224
|
+
- The raw transcoded request dictionary (containing keys like 'uri', 'method').
|
|
225
|
+
- The serialized request body JSON string, or None if no body.
|
|
226
|
+
- The query parameters dictionary.
|
|
227
|
+
"""
|
|
228
|
+
if request is None:
|
|
229
|
+
raise TypeError("request cannot be None")
|
|
230
|
+
|
|
231
|
+
# Convert proto-plus message to its underlying protobuf message if needed
|
|
232
|
+
pb_request = getattr(request, "_pb", request)
|
|
233
|
+
|
|
234
|
+
transcoded_request = path_template.transcode(http_options, pb_request)
|
|
235
|
+
|
|
236
|
+
body_json = None
|
|
237
|
+
if transcoded_request.get("body") is not None:
|
|
238
|
+
body_json = json_format.MessageToJson(
|
|
239
|
+
transcoded_request["body"],
|
|
240
|
+
use_integers_for_enums=rest_numeric_enums,
|
|
241
|
+
)
|
|
242
|
+
|
|
243
|
+
query_params_json = {}
|
|
244
|
+
if transcoded_request.get("query_params") is not None:
|
|
245
|
+
query_params_json = json.loads(
|
|
246
|
+
json_format.MessageToJson(
|
|
247
|
+
transcoded_request["query_params"],
|
|
248
|
+
use_integers_for_enums=rest_numeric_enums,
|
|
249
|
+
)
|
|
250
|
+
)
|
|
251
|
+
|
|
252
|
+
# If required_fields_default_values is provided, we merge default values for missing
|
|
253
|
+
# required fields into the query parameters.
|
|
254
|
+
if required_fields_default_values:
|
|
255
|
+
for k, v in required_fields_default_values.items():
|
|
256
|
+
if k not in query_params_json:
|
|
257
|
+
query_params_json[k] = v
|
|
258
|
+
|
|
259
|
+
if rest_numeric_enums:
|
|
260
|
+
query_params_json["$alt"] = "json;enum-encoding=int"
|
|
261
|
+
|
|
262
|
+
return transcoded_request, body_json, query_params_json
|
|
@@ -46,6 +46,13 @@ from google.auth.transport.grpc import SslCredentials # type: ignore
|
|
|
46
46
|
from google.oauth2 import service_account # type: ignore
|
|
47
47
|
|
|
48
48
|
from google.cloud.logging_v2 import gapic_version as package_version
|
|
49
|
+
from google.cloud.logging_v2._compat import (
|
|
50
|
+
get_api_endpoint,
|
|
51
|
+
get_default_mtls_endpoint,
|
|
52
|
+
get_universe_domain,
|
|
53
|
+
read_environment_variables,
|
|
54
|
+
should_use_client_cert,
|
|
55
|
+
)
|
|
49
56
|
|
|
50
57
|
try:
|
|
51
58
|
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None]
|
|
@@ -113,77 +120,13 @@ class ConfigServiceV2ClientMeta(type):
|
|
|
113
120
|
class ConfigServiceV2Client(metaclass=ConfigServiceV2ClientMeta):
|
|
114
121
|
"""Service for configuring sinks used to route log entries."""
|
|
115
122
|
|
|
116
|
-
@staticmethod
|
|
117
|
-
def _get_default_mtls_endpoint(api_endpoint) -> Optional[str]:
|
|
118
|
-
"""Converts api endpoint to mTLS endpoint.
|
|
119
|
-
|
|
120
|
-
Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to
|
|
121
|
-
"*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively.
|
|
122
|
-
Args:
|
|
123
|
-
api_endpoint (Optional[str]): the api endpoint to convert.
|
|
124
|
-
Returns:
|
|
125
|
-
Optional[str]: converted mTLS api endpoint.
|
|
126
|
-
"""
|
|
127
|
-
if not api_endpoint:
|
|
128
|
-
return api_endpoint
|
|
129
|
-
|
|
130
|
-
mtls_endpoint_re = re.compile(
|
|
131
|
-
r"(?P<name>[^.]+)(?P<mtls>\.mtls)?(?P<sandbox>\.sandbox)?(?P<googledomain>\.googleapis\.com)?"
|
|
132
|
-
)
|
|
133
|
-
|
|
134
|
-
m = mtls_endpoint_re.match(api_endpoint)
|
|
135
|
-
if m is None:
|
|
136
|
-
# Could not parse api_endpoint; return as-is.
|
|
137
|
-
return api_endpoint
|
|
138
|
-
|
|
139
|
-
name, mtls, sandbox, googledomain = m.groups()
|
|
140
|
-
if mtls or not googledomain:
|
|
141
|
-
return api_endpoint
|
|
142
|
-
|
|
143
|
-
if sandbox:
|
|
144
|
-
return api_endpoint.replace(
|
|
145
|
-
"sandbox.googleapis.com", "mtls.sandbox.googleapis.com"
|
|
146
|
-
)
|
|
147
|
-
|
|
148
|
-
return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com")
|
|
149
|
-
|
|
150
123
|
# Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
|
|
151
124
|
DEFAULT_ENDPOINT = "logging.googleapis.com"
|
|
152
|
-
DEFAULT_MTLS_ENDPOINT =
|
|
153
|
-
DEFAULT_ENDPOINT
|
|
154
|
-
)
|
|
125
|
+
DEFAULT_MTLS_ENDPOINT = get_default_mtls_endpoint(DEFAULT_ENDPOINT)
|
|
155
126
|
|
|
156
127
|
_DEFAULT_ENDPOINT_TEMPLATE = "logging.{UNIVERSE_DOMAIN}"
|
|
157
128
|
_DEFAULT_UNIVERSE = "googleapis.com"
|
|
158
129
|
|
|
159
|
-
@staticmethod
|
|
160
|
-
def _use_client_cert_effective():
|
|
161
|
-
"""Returns whether client certificate should be used for mTLS if the
|
|
162
|
-
google-auth version supports should_use_client_cert automatic mTLS enablement.
|
|
163
|
-
|
|
164
|
-
Alternatively, read from the GOOGLE_API_USE_CLIENT_CERTIFICATE env var.
|
|
165
|
-
|
|
166
|
-
Returns:
|
|
167
|
-
bool: whether client certificate should be used for mTLS
|
|
168
|
-
Raises:
|
|
169
|
-
ValueError: (If using a version of google-auth without should_use_client_cert and
|
|
170
|
-
GOOGLE_API_USE_CLIENT_CERTIFICATE is set to an unexpected value.)
|
|
171
|
-
"""
|
|
172
|
-
# check if google-auth version supports should_use_client_cert for automatic mTLS enablement
|
|
173
|
-
if hasattr(mtls, "should_use_client_cert"): # pragma: NO COVER
|
|
174
|
-
return mtls.should_use_client_cert()
|
|
175
|
-
else: # pragma: NO COVER
|
|
176
|
-
# if unsupported, fallback to reading from env var
|
|
177
|
-
use_client_cert_str = os.getenv(
|
|
178
|
-
"GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"
|
|
179
|
-
).lower()
|
|
180
|
-
if use_client_cert_str not in ("true", "false"):
|
|
181
|
-
raise ValueError(
|
|
182
|
-
"Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be"
|
|
183
|
-
" either `true` or `false`"
|
|
184
|
-
)
|
|
185
|
-
return use_client_cert_str == "true"
|
|
186
|
-
|
|
187
130
|
@classmethod
|
|
188
131
|
def from_service_account_info(cls, info: dict, *args, **kwargs):
|
|
189
132
|
"""Creates an instance of this client using the provided credentials
|
|
@@ -483,7 +426,7 @@ class ConfigServiceV2Client(metaclass=ConfigServiceV2ClientMeta):
|
|
|
483
426
|
)
|
|
484
427
|
if client_options is None:
|
|
485
428
|
client_options = client_options_lib.ClientOptions()
|
|
486
|
-
use_client_cert =
|
|
429
|
+
use_client_cert = should_use_client_cert()
|
|
487
430
|
use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto")
|
|
488
431
|
if use_mtls_endpoint not in ("auto", "never", "always"):
|
|
489
432
|
raise MutualTLSChannelError(
|
|
@@ -504,35 +447,12 @@ class ConfigServiceV2Client(metaclass=ConfigServiceV2ClientMeta):
|
|
|
504
447
|
elif use_mtls_endpoint == "always" or (
|
|
505
448
|
use_mtls_endpoint == "auto" and client_cert_source
|
|
506
449
|
):
|
|
507
|
-
api_endpoint = cls.DEFAULT_MTLS_ENDPOINT
|
|
450
|
+
api_endpoint = cls.DEFAULT_MTLS_ENDPOINT # type: ignore
|
|
508
451
|
else:
|
|
509
452
|
api_endpoint = cls.DEFAULT_ENDPOINT
|
|
510
453
|
|
|
511
454
|
return api_endpoint, client_cert_source
|
|
512
455
|
|
|
513
|
-
@staticmethod
|
|
514
|
-
def _read_environment_variables():
|
|
515
|
-
"""Returns the environment variables used by the client.
|
|
516
|
-
|
|
517
|
-
Returns:
|
|
518
|
-
Tuple[bool, str, str]: returns the GOOGLE_API_USE_CLIENT_CERTIFICATE,
|
|
519
|
-
GOOGLE_API_USE_MTLS_ENDPOINT, and GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variables.
|
|
520
|
-
|
|
521
|
-
Raises:
|
|
522
|
-
ValueError: If GOOGLE_API_USE_CLIENT_CERTIFICATE is not
|
|
523
|
-
any of ["true", "false"].
|
|
524
|
-
google.auth.exceptions.MutualTLSChannelError: If GOOGLE_API_USE_MTLS_ENDPOINT
|
|
525
|
-
is not any of ["auto", "never", "always"].
|
|
526
|
-
"""
|
|
527
|
-
use_client_cert = ConfigServiceV2Client._use_client_cert_effective()
|
|
528
|
-
use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto").lower()
|
|
529
|
-
universe_domain_env = os.getenv("GOOGLE_CLOUD_UNIVERSE_DOMAIN")
|
|
530
|
-
if use_mtls_endpoint not in ("auto", "never", "always"):
|
|
531
|
-
raise MutualTLSChannelError(
|
|
532
|
-
"Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
|
|
533
|
-
)
|
|
534
|
-
return use_client_cert, use_mtls_endpoint, universe_domain_env
|
|
535
|
-
|
|
536
456
|
@staticmethod
|
|
537
457
|
def _get_client_cert_source(provided_cert_source, use_cert_flag):
|
|
538
458
|
"""Return the client cert source to be used by the client.
|
|
@@ -552,65 +472,6 @@ class ConfigServiceV2Client(metaclass=ConfigServiceV2ClientMeta):
|
|
|
552
472
|
client_cert_source = mtls.default_client_cert_source()
|
|
553
473
|
return client_cert_source
|
|
554
474
|
|
|
555
|
-
@staticmethod
|
|
556
|
-
def _get_api_endpoint(
|
|
557
|
-
api_override, client_cert_source, universe_domain, use_mtls_endpoint
|
|
558
|
-
) -> str:
|
|
559
|
-
"""Return the API endpoint used by the client.
|
|
560
|
-
|
|
561
|
-
Args:
|
|
562
|
-
api_override (str): The API endpoint override. If specified, this is always
|
|
563
|
-
the return value of this function and the other arguments are not used.
|
|
564
|
-
client_cert_source (bytes): The client certificate source used by the client.
|
|
565
|
-
universe_domain (str): The universe domain used by the client.
|
|
566
|
-
use_mtls_endpoint (str): How to use the mTLS endpoint, which depends also on the other parameters.
|
|
567
|
-
Possible values are "always", "auto", or "never".
|
|
568
|
-
|
|
569
|
-
Returns:
|
|
570
|
-
str: The API endpoint to be used by the client.
|
|
571
|
-
"""
|
|
572
|
-
if api_override is not None:
|
|
573
|
-
api_endpoint = api_override
|
|
574
|
-
elif use_mtls_endpoint == "always" or (
|
|
575
|
-
use_mtls_endpoint == "auto" and client_cert_source
|
|
576
|
-
):
|
|
577
|
-
_default_universe = ConfigServiceV2Client._DEFAULT_UNIVERSE
|
|
578
|
-
if universe_domain != _default_universe:
|
|
579
|
-
raise MutualTLSChannelError(
|
|
580
|
-
f"mTLS is not supported in any universe other than {_default_universe}."
|
|
581
|
-
)
|
|
582
|
-
api_endpoint = ConfigServiceV2Client.DEFAULT_MTLS_ENDPOINT
|
|
583
|
-
else:
|
|
584
|
-
api_endpoint = ConfigServiceV2Client._DEFAULT_ENDPOINT_TEMPLATE.format(
|
|
585
|
-
UNIVERSE_DOMAIN=universe_domain
|
|
586
|
-
)
|
|
587
|
-
return api_endpoint
|
|
588
|
-
|
|
589
|
-
@staticmethod
|
|
590
|
-
def _get_universe_domain(
|
|
591
|
-
client_universe_domain: Optional[str], universe_domain_env: Optional[str]
|
|
592
|
-
) -> str:
|
|
593
|
-
"""Return the universe domain used by the client.
|
|
594
|
-
|
|
595
|
-
Args:
|
|
596
|
-
client_universe_domain (Optional[str]): The universe domain configured via the client options.
|
|
597
|
-
universe_domain_env (Optional[str]): The universe domain configured via the "GOOGLE_CLOUD_UNIVERSE_DOMAIN" environment variable.
|
|
598
|
-
|
|
599
|
-
Returns:
|
|
600
|
-
str: The universe domain to be used by the client.
|
|
601
|
-
|
|
602
|
-
Raises:
|
|
603
|
-
ValueError: If the universe domain is an empty string.
|
|
604
|
-
"""
|
|
605
|
-
universe_domain = ConfigServiceV2Client._DEFAULT_UNIVERSE
|
|
606
|
-
if client_universe_domain is not None:
|
|
607
|
-
universe_domain = client_universe_domain
|
|
608
|
-
elif universe_domain_env is not None:
|
|
609
|
-
universe_domain = universe_domain_env
|
|
610
|
-
if len(universe_domain.strip()) == 0:
|
|
611
|
-
raise ValueError("Universe Domain cannot be an empty string.")
|
|
612
|
-
return universe_domain
|
|
613
|
-
|
|
614
475
|
def _validate_universe_domain(self):
|
|
615
476
|
"""Validates client's and credentials' universe domains are consistent.
|
|
616
477
|
|
|
@@ -742,13 +603,15 @@ class ConfigServiceV2Client(metaclass=ConfigServiceV2ClientMeta):
|
|
|
742
603
|
universe_domain_opt = getattr(self._client_options, "universe_domain", None)
|
|
743
604
|
|
|
744
605
|
self._use_client_cert, self._use_mtls_endpoint, self._universe_domain_env = (
|
|
745
|
-
|
|
606
|
+
read_environment_variables()
|
|
746
607
|
)
|
|
747
608
|
self._client_cert_source = ConfigServiceV2Client._get_client_cert_source(
|
|
748
609
|
self._client_options.client_cert_source, self._use_client_cert
|
|
749
610
|
)
|
|
750
|
-
self._universe_domain =
|
|
751
|
-
universe_domain_opt,
|
|
611
|
+
self._universe_domain = get_universe_domain(
|
|
612
|
+
universe_domain_opt,
|
|
613
|
+
self._universe_domain_env,
|
|
614
|
+
default_universe=ConfigServiceV2Client._DEFAULT_UNIVERSE,
|
|
752
615
|
)
|
|
753
616
|
self._api_endpoint: str = "" # updated below, depending on `transport`
|
|
754
617
|
|
|
@@ -783,14 +646,14 @@ class ConfigServiceV2Client(metaclass=ConfigServiceV2ClientMeta):
|
|
|
783
646
|
self._transport = cast(ConfigServiceV2Transport, transport)
|
|
784
647
|
self._api_endpoint = self._transport.host
|
|
785
648
|
|
|
786
|
-
self._api_endpoint = (
|
|
787
|
-
self.
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
)
|
|
649
|
+
self._api_endpoint = self._api_endpoint or get_api_endpoint(
|
|
650
|
+
api_override=self._client_options.api_endpoint,
|
|
651
|
+
universe_domain=self._universe_domain,
|
|
652
|
+
default_universe=ConfigServiceV2Client._DEFAULT_UNIVERSE,
|
|
653
|
+
default_mtls_endpoint=ConfigServiceV2Client.DEFAULT_MTLS_ENDPOINT,
|
|
654
|
+
default_endpoint_template=ConfigServiceV2Client._DEFAULT_ENDPOINT_TEMPLATE,
|
|
655
|
+
use_mtls=self._use_mtls_endpoint == "always"
|
|
656
|
+
or (self._use_mtls_endpoint == "auto" and self._client_cert_source),
|
|
794
657
|
)
|
|
795
658
|
|
|
796
659
|
if not transport_provided:
|