google-analytics-admin 0.26.0__tar.gz → 0.28.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.
Files changed (66) hide show
  1. {google_analytics_admin-0.26.0/google_analytics_admin.egg-info → google_analytics_admin-0.28.0}/PKG-INFO +6 -8
  2. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/README.rst +2 -2
  3. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google/analytics/admin/gapic_version.py +1 -1
  4. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google/analytics/admin_v1alpha/__init__.py +105 -0
  5. {google_analytics_admin-0.26.0/google/analytics/admin_v1beta → google_analytics_admin-0.28.0/google/analytics/admin_v1alpha}/gapic_version.py +1 -1
  6. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google/analytics/admin_v1alpha/services/analytics_admin_service/async_client.py +30 -19
  7. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google/analytics/admin_v1alpha/services/analytics_admin_service/client.py +65 -45
  8. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google/analytics/admin_v1alpha/services/analytics_admin_service/pagers.py +58 -58
  9. {google_analytics_admin-0.26.0/google/analytics/admin_v1beta → google_analytics_admin-0.28.0/google/analytics/admin_v1alpha}/services/analytics_admin_service/transports/__init__.py +1 -3
  10. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/base.py +26 -15
  11. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc.py +340 -334
  12. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc_asyncio.py +339 -333
  13. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/rest.py +624 -854
  14. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/rest_base.py +11 -9
  15. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google/analytics/admin_v1alpha/types/access_report.py +3 -0
  16. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google/analytics/admin_v1alpha/types/analytics_admin.py +80 -78
  17. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google/analytics/admin_v1alpha/types/audience.py +14 -8
  18. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google/analytics/admin_v1alpha/types/channel_group.py +7 -6
  19. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google/analytics/admin_v1alpha/types/event_create_and_edit.py +1 -0
  20. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google/analytics/admin_v1alpha/types/expanded_data_set.py +8 -7
  21. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google/analytics/admin_v1alpha/types/resources.py +33 -5
  22. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google/analytics/admin_v1alpha/types/subproperty_event_filter.py +14 -12
  23. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google/analytics/admin_v1beta/__init__.py +105 -0
  24. {google_analytics_admin-0.26.0/google/analytics/admin_v1alpha → google_analytics_admin-0.28.0/google/analytics/admin_v1beta}/gapic_version.py +1 -1
  25. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google/analytics/admin_v1beta/services/analytics_admin_service/async_client.py +18 -10
  26. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google/analytics/admin_v1beta/services/analytics_admin_service/client.py +53 -36
  27. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google/analytics/admin_v1beta/services/analytics_admin_service/pagers.py +24 -24
  28. {google_analytics_admin-0.26.0/google/analytics/admin_v1alpha → google_analytics_admin-0.28.0/google/analytics/admin_v1beta}/services/analytics_admin_service/transports/__init__.py +1 -3
  29. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google/analytics/admin_v1beta/services/analytics_admin_service/transports/base.py +16 -7
  30. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google/analytics/admin_v1beta/services/analytics_admin_service/transports/grpc.py +66 -62
  31. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google/analytics/admin_v1beta/services/analytics_admin_service/transports/grpc_asyncio.py +65 -61
  32. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google/analytics/admin_v1beta/services/analytics_admin_service/transports/rest.py +144 -231
  33. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google/analytics/admin_v1beta/services/analytics_admin_service/transports/rest_base.py +1 -1
  34. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google/analytics/admin_v1beta/types/access_report.py +3 -0
  35. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google/analytics/admin_v1beta/types/analytics_admin.py +26 -26
  36. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google/analytics/admin_v1beta/types/resources.py +16 -2
  37. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0/google_analytics_admin.egg-info}/PKG-INFO +6 -8
  38. google_analytics_admin-0.28.0/google_analytics_admin.egg-info/requires.txt +11 -0
  39. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/setup.py +3 -5
  40. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/tests/unit/gapic/admin_v1alpha/test_analytics_admin_service.py +3238 -2543
  41. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/tests/unit/gapic/admin_v1beta/test_analytics_admin_service.py +1321 -941
  42. google_analytics_admin-0.26.0/google_analytics_admin.egg-info/requires.txt +0 -11
  43. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/LICENSE +0 -0
  44. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/MANIFEST.in +0 -0
  45. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google/analytics/admin/__init__.py +0 -0
  46. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google/analytics/admin/py.typed +0 -0
  47. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google/analytics/admin_v1alpha/gapic_metadata.json +0 -0
  48. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google/analytics/admin_v1alpha/py.typed +0 -0
  49. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google/analytics/admin_v1alpha/services/__init__.py +0 -0
  50. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google/analytics/admin_v1alpha/services/analytics_admin_service/__init__.py +0 -0
  51. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google/analytics/admin_v1alpha/types/__init__.py +0 -0
  52. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google/analytics/admin_v1beta/gapic_metadata.json +0 -0
  53. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google/analytics/admin_v1beta/py.typed +0 -0
  54. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google/analytics/admin_v1beta/services/__init__.py +0 -0
  55. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google/analytics/admin_v1beta/services/analytics_admin_service/__init__.py +0 -0
  56. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google/analytics/admin_v1beta/types/__init__.py +0 -0
  57. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google_analytics_admin.egg-info/SOURCES.txt +0 -0
  58. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google_analytics_admin.egg-info/dependency_links.txt +0 -0
  59. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google_analytics_admin.egg-info/not-zip-safe +0 -0
  60. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/google_analytics_admin.egg-info/top_level.txt +0 -0
  61. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/setup.cfg +0 -0
  62. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/tests/__init__.py +0 -0
  63. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/tests/unit/__init__.py +0 -0
  64. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/tests/unit/gapic/__init__.py +0 -0
  65. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/tests/unit/gapic/admin_v1alpha/__init__.py +0 -0
  66. {google_analytics_admin-0.26.0 → google_analytics_admin-0.28.0}/tests/unit/gapic/admin_v1beta/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: google-analytics-admin
3
- Version: 0.26.0
3
+ Version: 0.28.0
4
4
  Summary: Google Analytics Admin API client library
5
5
  Home-page: https://github.com/googleapis/google-cloud-python/tree/main/packages/google-analytics-admin
6
6
  Author: Google LLC
@@ -12,8 +12,6 @@ Classifier: Intended Audience :: Developers
12
12
  Classifier: License :: OSI Approved :: Apache Software License
13
13
  Classifier: Programming Language :: Python
14
14
  Classifier: Programming Language :: Python :: 3
15
- Classifier: Programming Language :: Python :: 3.7
16
- Classifier: Programming Language :: Python :: 3.8
17
15
  Classifier: Programming Language :: Python :: 3.9
18
16
  Classifier: Programming Language :: Python :: 3.10
19
17
  Classifier: Programming Language :: Python :: 3.11
@@ -22,15 +20,15 @@ Classifier: Programming Language :: Python :: 3.13
22
20
  Classifier: Programming Language :: Python :: 3.14
23
21
  Classifier: Operating System :: OS Independent
24
22
  Classifier: Topic :: Internet
25
- Requires-Python: >=3.7
23
+ Requires-Python: >=3.9
26
24
  License-File: LICENSE
27
- Requires-Dist: google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.10.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,<3.0.0,>=1.34.1
25
+ Requires-Dist: google-api-core[grpc]<3.0.0,>=2.11.0
28
26
  Requires-Dist: google-auth!=2.24.0,!=2.25.0,<3.0.0,>=2.14.1
29
27
  Requires-Dist: grpcio<2.0.0,>=1.33.2
30
28
  Requires-Dist: grpcio<2.0.0,>=1.75.1; python_version >= "3.14"
31
29
  Requires-Dist: proto-plus<2.0.0,>=1.22.3
32
30
  Requires-Dist: proto-plus<2.0.0,>=1.25.0; python_version >= "3.13"
33
- Requires-Dist: protobuf!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<7.0.0,>=3.20.2
31
+ Requires-Dist: protobuf<8.0.0,>=4.25.8
34
32
  Dynamic: author
35
33
  Dynamic: author-email
36
34
  Dynamic: classifier
@@ -106,14 +104,14 @@ Supported Python Versions
106
104
  Our client libraries are compatible with all current `active`_ and `maintenance`_ versions of
107
105
  Python.
108
106
 
109
- Python >= 3.7, including 3.14
107
+ Python >= 3.9, including 3.14
110
108
 
111
109
  .. _active: https://devguide.python.org/devcycle/#in-development-main-branch
112
110
  .. _maintenance: https://devguide.python.org/devcycle/#maintenance-branches
113
111
 
114
112
  Unsupported Python Versions
115
113
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
116
- Python <= 3.6
114
+ Python <= 3.8
117
115
 
118
116
  If you are using an `end-of-life`_
119
117
  version of Python, we recommend that you update as soon as possible to an actively supported version.
@@ -61,14 +61,14 @@ Supported Python Versions
61
61
  Our client libraries are compatible with all current `active`_ and `maintenance`_ versions of
62
62
  Python.
63
63
 
64
- Python >= 3.7, including 3.14
64
+ Python >= 3.9, including 3.14
65
65
 
66
66
  .. _active: https://devguide.python.org/devcycle/#in-development-main-branch
67
67
  .. _maintenance: https://devguide.python.org/devcycle/#maintenance-branches
68
68
 
69
69
  Unsupported Python Versions
70
70
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
71
- Python <= 3.6
71
+ Python <= 3.8
72
72
 
73
73
  If you are using an `end-of-life`_
74
74
  version of Python, we recommend that you update as soon as possible to an actively supported version.
@@ -13,4 +13,4 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
  #
16
- __version__ = "0.26.0" # {x-release-please-version}
16
+ __version__ = "0.28.0" # {x-release-please-version}
@@ -13,10 +13,21 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
  #
16
+ import sys
17
+
18
+ import google.api_core as api_core
19
+
16
20
  from google.analytics.admin_v1alpha import gapic_version as package_version
17
21
 
18
22
  __version__ = package_version.__version__
19
23
 
24
+ if sys.version_info >= (3, 8): # pragma: NO COVER
25
+ from importlib import metadata
26
+ else: # pragma: NO COVER
27
+ # TODO(https://github.com/googleapis/python-api-core/issues/835): Remove
28
+ # this code path once we drop support for Python 3.7
29
+ import importlib_metadata as metadata
30
+
20
31
 
21
32
  from .services.analytics_admin_service import (
22
33
  AnalyticsAdminServiceAsyncClient,
@@ -327,6 +338,100 @@ from .types.subproperty_event_filter import (
327
338
  SubpropertyEventFilterExpressionList,
328
339
  )
329
340
 
341
+ if hasattr(api_core, "check_python_version") and hasattr(
342
+ api_core, "check_dependency_versions"
343
+ ): # pragma: NO COVER
344
+ api_core.check_python_version("google.analytics.admin_v1alpha") # type: ignore
345
+ api_core.check_dependency_versions("google.analytics.admin_v1alpha") # type: ignore
346
+ else: # pragma: NO COVER
347
+ # An older version of api_core is installed which does not define the
348
+ # functions above. We do equivalent checks manually.
349
+ try:
350
+ import sys
351
+ import warnings
352
+
353
+ _py_version_str = sys.version.split()[0]
354
+ _package_label = "google.analytics.admin_v1alpha"
355
+ if sys.version_info < (3, 9):
356
+ warnings.warn(
357
+ "You are using a non-supported Python version "
358
+ + f"({_py_version_str}). Google will not post any further "
359
+ + f"updates to {_package_label} supporting this Python version. "
360
+ + "Please upgrade to the latest Python version, or at "
361
+ + f"least to Python 3.9, and then update {_package_label}.",
362
+ FutureWarning,
363
+ )
364
+ if sys.version_info[:2] == (3, 9):
365
+ warnings.warn(
366
+ f"You are using a Python version ({_py_version_str}) "
367
+ + f"which Google will stop supporting in {_package_label} in "
368
+ + "January 2026. Please "
369
+ + "upgrade to the latest Python version, or at "
370
+ + "least to Python 3.10, before then, and "
371
+ + f"then update {_package_label}.",
372
+ FutureWarning,
373
+ )
374
+
375
+ def parse_version_to_tuple(version_string: str):
376
+ """Safely converts a semantic version string to a comparable tuple of integers.
377
+ Example: "4.25.8" -> (4, 25, 8)
378
+ Ignores non-numeric parts and handles common version formats.
379
+ Args:
380
+ version_string: Version string in the format "x.y.z" or "x.y.z<suffix>"
381
+ Returns:
382
+ Tuple of integers for the parsed version string.
383
+ """
384
+ parts = []
385
+ for part in version_string.split("."):
386
+ try:
387
+ parts.append(int(part))
388
+ except ValueError:
389
+ # If it's a non-numeric part (e.g., '1.0.0b1' -> 'b1'), stop here.
390
+ # This is a simplification compared to 'packaging.parse_version', but sufficient
391
+ # for comparing strictly numeric semantic versions.
392
+ break
393
+ return tuple(parts)
394
+
395
+ def _get_version(dependency_name):
396
+ try:
397
+ version_string: str = metadata.version(dependency_name)
398
+ parsed_version = parse_version_to_tuple(version_string)
399
+ return (parsed_version, version_string)
400
+ except Exception:
401
+ # Catch exceptions from metadata.version() (e.g., PackageNotFoundError)
402
+ # or errors during parse_version_to_tuple
403
+ return (None, "--")
404
+
405
+ _dependency_package = "google.protobuf"
406
+ _next_supported_version = "4.25.8"
407
+ _next_supported_version_tuple = (4, 25, 8)
408
+ _recommendation = " (we recommend 6.x)"
409
+ (_version_used, _version_used_string) = _get_version(_dependency_package)
410
+ if _version_used and _version_used < _next_supported_version_tuple:
411
+ warnings.warn(
412
+ f"Package {_package_label} depends on "
413
+ + f"{_dependency_package}, currently installed at version "
414
+ + f"{_version_used_string}. Future updates to "
415
+ + f"{_package_label} will require {_dependency_package} at "
416
+ + f"version {_next_supported_version} or higher{_recommendation}."
417
+ + " Please ensure "
418
+ + "that either (a) your Python environment doesn't pin the "
419
+ + f"version of {_dependency_package}, so that updates to "
420
+ + f"{_package_label} can require the higher version, or "
421
+ + "(b) you manually update your Python environment to use at "
422
+ + f"least version {_next_supported_version} of "
423
+ + f"{_dependency_package}.",
424
+ FutureWarning,
425
+ )
426
+ except Exception:
427
+ warnings.warn(
428
+ "Could not determine the version of Python "
429
+ + "currently being used. To continue receiving "
430
+ + "updates for {_package_label}, ensure you are "
431
+ + "using a supported version of Python; see "
432
+ + "https://devguide.python.org/versions/"
433
+ )
434
+
330
435
  __all__ = (
331
436
  "AnalyticsAdminServiceAsyncClient",
332
437
  "AccessBetweenFilter",
@@ -13,4 +13,4 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
  #
16
- __version__ = "0.26.0" # {x-release-please-version}
16
+ __version__ = "0.28.0" # {x-release-please-version}
@@ -13,9 +13,10 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
  #
16
- from collections import OrderedDict
17
16
  import logging as std_logging
18
17
  import re
18
+ import warnings
19
+ from collections import OrderedDict
19
20
  from typing import (
20
21
  Callable,
21
22
  Dict,
@@ -28,15 +29,14 @@ from typing import (
28
29
  Type,
29
30
  Union,
30
31
  )
31
- import warnings
32
32
 
33
+ import google.protobuf
33
34
  from google.api_core import exceptions as core_exceptions
34
35
  from google.api_core import gapic_v1
35
36
  from google.api_core import retry_async as retries
36
37
  from google.api_core.client_options import ClientOptions
37
38
  from google.auth import credentials as ga_credentials # type: ignore
38
39
  from google.oauth2 import service_account # type: ignore
39
- import google.protobuf
40
40
 
41
41
  from google.analytics.admin_v1alpha import gapic_version as package_version
42
42
 
@@ -45,12 +45,23 @@ try:
45
45
  except AttributeError: # pragma: NO COVER
46
46
  OptionalRetry = Union[retries.AsyncRetry, object, None] # type: ignore
47
47
 
48
- from google.protobuf import field_mask_pb2 # type: ignore
49
- from google.protobuf import timestamp_pb2 # type: ignore
50
- from google.protobuf import wrappers_pb2 # type: ignore
51
- from google.type import date_pb2 # type: ignore
48
+ import google.protobuf.field_mask_pb2 as field_mask_pb2 # type: ignore
49
+ import google.protobuf.timestamp_pb2 as timestamp_pb2 # type: ignore
50
+ import google.protobuf.wrappers_pb2 as wrappers_pb2 # type: ignore
51
+ import google.type.date_pb2 as date_pb2 # type: ignore
52
52
 
53
53
  from google.analytics.admin_v1alpha.services.analytics_admin_service import pagers
54
+ from google.analytics.admin_v1alpha.types import (
55
+ access_report,
56
+ analytics_admin,
57
+ audience,
58
+ channel_group,
59
+ event_create_and_edit,
60
+ expanded_data_set,
61
+ resources,
62
+ subproperty_event_filter,
63
+ )
64
+ from google.analytics.admin_v1alpha.types import audience as gaa_audience
54
65
  from google.analytics.admin_v1alpha.types import channel_group as gaa_channel_group
55
66
  from google.analytics.admin_v1alpha.types import (
56
67
  expanded_data_set as gaa_expanded_data_set,
@@ -58,14 +69,6 @@ from google.analytics.admin_v1alpha.types import (
58
69
  from google.analytics.admin_v1alpha.types import (
59
70
  subproperty_event_filter as gaa_subproperty_event_filter,
60
71
  )
61
- from google.analytics.admin_v1alpha.types import access_report, analytics_admin
62
- from google.analytics.admin_v1alpha.types import audience
63
- from google.analytics.admin_v1alpha.types import audience as gaa_audience
64
- from google.analytics.admin_v1alpha.types import channel_group
65
- from google.analytics.admin_v1alpha.types import event_create_and_edit
66
- from google.analytics.admin_v1alpha.types import expanded_data_set
67
- from google.analytics.admin_v1alpha.types import resources
68
- from google.analytics.admin_v1alpha.types import subproperty_event_filter
69
72
 
70
73
  from .client import AnalyticsAdminServiceClient
71
74
  from .transports.base import DEFAULT_CLIENT_INFO, AnalyticsAdminServiceTransport
@@ -325,7 +328,10 @@ class AnalyticsAdminServiceAsyncClient:
325
328
  Returns:
326
329
  AnalyticsAdminServiceAsyncClient: The constructed client.
327
330
  """
328
- return AnalyticsAdminServiceClient.from_service_account_info.__func__(AnalyticsAdminServiceAsyncClient, info, *args, **kwargs) # type: ignore
331
+ sa_info_func = (
332
+ AnalyticsAdminServiceClient.from_service_account_info.__func__ # type: ignore
333
+ )
334
+ return sa_info_func(AnalyticsAdminServiceAsyncClient, info, *args, **kwargs)
329
335
 
330
336
  @classmethod
331
337
  def from_service_account_file(cls, filename: str, *args, **kwargs):
@@ -341,7 +347,10 @@ class AnalyticsAdminServiceAsyncClient:
341
347
  Returns:
342
348
  AnalyticsAdminServiceAsyncClient: The constructed client.
343
349
  """
344
- return AnalyticsAdminServiceClient.from_service_account_file.__func__(AnalyticsAdminServiceAsyncClient, filename, *args, **kwargs) # type: ignore
350
+ sa_file_func = (
351
+ AnalyticsAdminServiceClient.from_service_account_file.__func__ # type: ignore
352
+ )
353
+ return sa_file_func(AnalyticsAdminServiceAsyncClient, filename, *args, **kwargs)
345
354
 
346
355
  from_service_account_json = from_service_account_file
347
356
 
@@ -379,7 +388,9 @@ class AnalyticsAdminServiceAsyncClient:
379
388
  Raises:
380
389
  google.auth.exceptions.MutualTLSChannelError: If any errors happen.
381
390
  """
382
- return AnalyticsAdminServiceClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore
391
+ return AnalyticsAdminServiceClient.get_mtls_endpoint_and_cert_source(
392
+ client_options
393
+ ) # type: ignore
383
394
 
384
395
  @property
385
396
  def transport(self) -> AnalyticsAdminServiceTransport:
@@ -391,7 +402,7 @@ class AnalyticsAdminServiceAsyncClient:
391
402
  return self._client.transport
392
403
 
393
404
  @property
394
- def api_endpoint(self):
405
+ def api_endpoint(self) -> str:
395
406
  """Return the API endpoint used by the client instance.
396
407
 
397
408
  Returns:
@@ -13,12 +13,13 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
  #
16
- from collections import OrderedDict
17
- from http import HTTPStatus
18
16
  import json
19
17
  import logging as std_logging
20
18
  import os
21
19
  import re
20
+ import warnings
21
+ from collections import OrderedDict
22
+ from http import HTTPStatus
22
23
  from typing import (
23
24
  Callable,
24
25
  Dict,
@@ -32,8 +33,8 @@ from typing import (
32
33
  Union,
33
34
  cast,
34
35
  )
35
- import warnings
36
36
 
37
+ import google.protobuf
37
38
  from google.api_core import client_options as client_options_lib
38
39
  from google.api_core import exceptions as core_exceptions
39
40
  from google.api_core import gapic_v1
@@ -43,7 +44,6 @@ from google.auth.exceptions import MutualTLSChannelError # type: ignore
43
44
  from google.auth.transport import mtls # type: ignore
44
45
  from google.auth.transport.grpc import SslCredentials # type: ignore
45
46
  from google.oauth2 import service_account # type: ignore
46
- import google.protobuf
47
47
 
48
48
  from google.analytics.admin_v1alpha import gapic_version as package_version
49
49
 
@@ -61,12 +61,23 @@ except ImportError: # pragma: NO COVER
61
61
 
62
62
  _LOGGER = std_logging.getLogger(__name__)
63
63
 
64
- from google.protobuf import field_mask_pb2 # type: ignore
65
- from google.protobuf import timestamp_pb2 # type: ignore
66
- from google.protobuf import wrappers_pb2 # type: ignore
67
- from google.type import date_pb2 # type: ignore
64
+ import google.protobuf.field_mask_pb2 as field_mask_pb2 # type: ignore
65
+ import google.protobuf.timestamp_pb2 as timestamp_pb2 # type: ignore
66
+ import google.protobuf.wrappers_pb2 as wrappers_pb2 # type: ignore
67
+ import google.type.date_pb2 as date_pb2 # type: ignore
68
68
 
69
69
  from google.analytics.admin_v1alpha.services.analytics_admin_service import pagers
70
+ from google.analytics.admin_v1alpha.types import (
71
+ access_report,
72
+ analytics_admin,
73
+ audience,
74
+ channel_group,
75
+ event_create_and_edit,
76
+ expanded_data_set,
77
+ resources,
78
+ subproperty_event_filter,
79
+ )
80
+ from google.analytics.admin_v1alpha.types import audience as gaa_audience
70
81
  from google.analytics.admin_v1alpha.types import channel_group as gaa_channel_group
71
82
  from google.analytics.admin_v1alpha.types import (
72
83
  expanded_data_set as gaa_expanded_data_set,
@@ -74,14 +85,6 @@ from google.analytics.admin_v1alpha.types import (
74
85
  from google.analytics.admin_v1alpha.types import (
75
86
  subproperty_event_filter as gaa_subproperty_event_filter,
76
87
  )
77
- from google.analytics.admin_v1alpha.types import access_report, analytics_admin
78
- from google.analytics.admin_v1alpha.types import audience
79
- from google.analytics.admin_v1alpha.types import audience as gaa_audience
80
- from google.analytics.admin_v1alpha.types import channel_group
81
- from google.analytics.admin_v1alpha.types import event_create_and_edit
82
- from google.analytics.admin_v1alpha.types import expanded_data_set
83
- from google.analytics.admin_v1alpha.types import resources
84
- from google.analytics.admin_v1alpha.types import subproperty_event_filter
85
88
 
86
89
  from .transports.base import DEFAULT_CLIENT_INFO, AnalyticsAdminServiceTransport
87
90
  from .transports.grpc import AnalyticsAdminServiceGrpcTransport
@@ -97,9 +100,7 @@ class AnalyticsAdminServiceClientMeta(type):
97
100
  objects.
98
101
  """
99
102
 
100
- _transport_registry = (
101
- OrderedDict()
102
- ) # type: Dict[str, Type[AnalyticsAdminServiceTransport]]
103
+ _transport_registry = OrderedDict() # type: Dict[str, Type[AnalyticsAdminServiceTransport]]
103
104
  _transport_registry["grpc"] = AnalyticsAdminServiceGrpcTransport
104
105
  _transport_registry["grpc_asyncio"] = AnalyticsAdminServiceGrpcAsyncIOTransport
105
106
  _transport_registry["rest"] = AnalyticsAdminServiceRestTransport
@@ -130,7 +131,7 @@ class AnalyticsAdminServiceClient(metaclass=AnalyticsAdminServiceClientMeta):
130
131
  """Service Interface for the Google Analytics Admin API."""
131
132
 
132
133
  @staticmethod
133
- def _get_default_mtls_endpoint(api_endpoint):
134
+ def _get_default_mtls_endpoint(api_endpoint) -> Optional[str]:
134
135
  """Converts api endpoint to mTLS endpoint.
135
136
 
136
137
  Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to
@@ -138,7 +139,7 @@ class AnalyticsAdminServiceClient(metaclass=AnalyticsAdminServiceClientMeta):
138
139
  Args:
139
140
  api_endpoint (Optional[str]): the api endpoint to convert.
140
141
  Returns:
141
- str: converted mTLS api endpoint.
142
+ Optional[str]: converted mTLS api endpoint.
142
143
  """
143
144
  if not api_endpoint:
144
145
  return api_endpoint
@@ -148,6 +149,10 @@ class AnalyticsAdminServiceClient(metaclass=AnalyticsAdminServiceClientMeta):
148
149
  )
149
150
 
150
151
  m = mtls_endpoint_re.match(api_endpoint)
152
+ if m is None:
153
+ # Could not parse api_endpoint; return as-is.
154
+ return api_endpoint
155
+
151
156
  name, mtls, sandbox, googledomain = m.groups()
152
157
  if mtls or not googledomain:
153
158
  return api_endpoint
@@ -168,6 +173,34 @@ class AnalyticsAdminServiceClient(metaclass=AnalyticsAdminServiceClientMeta):
168
173
  _DEFAULT_ENDPOINT_TEMPLATE = "analyticsadmin.{UNIVERSE_DOMAIN}"
169
174
  _DEFAULT_UNIVERSE = "googleapis.com"
170
175
 
176
+ @staticmethod
177
+ def _use_client_cert_effective():
178
+ """Returns whether client certificate should be used for mTLS if the
179
+ google-auth version supports should_use_client_cert automatic mTLS enablement.
180
+
181
+ Alternatively, read from the GOOGLE_API_USE_CLIENT_CERTIFICATE env var.
182
+
183
+ Returns:
184
+ bool: whether client certificate should be used for mTLS
185
+ Raises:
186
+ ValueError: (If using a version of google-auth without should_use_client_cert and
187
+ GOOGLE_API_USE_CLIENT_CERTIFICATE is set to an unexpected value.)
188
+ """
189
+ # check if google-auth version supports should_use_client_cert for automatic mTLS enablement
190
+ if hasattr(mtls, "should_use_client_cert"): # pragma: NO COVER
191
+ return mtls.should_use_client_cert()
192
+ else: # pragma: NO COVER
193
+ # if unsupported, fallback to reading from env var
194
+ use_client_cert_str = os.getenv(
195
+ "GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"
196
+ ).lower()
197
+ if use_client_cert_str not in ("true", "false"):
198
+ raise ValueError(
199
+ "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be"
200
+ " either `true` or `false`"
201
+ )
202
+ return use_client_cert_str == "true"
203
+
171
204
  @classmethod
172
205
  def from_service_account_info(cls, info: dict, *args, **kwargs):
173
206
  """Creates an instance of this client using the provided credentials
@@ -1029,12 +1062,8 @@ class AnalyticsAdminServiceClient(metaclass=AnalyticsAdminServiceClientMeta):
1029
1062
  )
1030
1063
  if client_options is None:
1031
1064
  client_options = client_options_lib.ClientOptions()
1032
- use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")
1065
+ use_client_cert = AnalyticsAdminServiceClient._use_client_cert_effective()
1033
1066
  use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto")
1034
- if use_client_cert not in ("true", "false"):
1035
- raise ValueError(
1036
- "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`"
1037
- )
1038
1067
  if use_mtls_endpoint not in ("auto", "never", "always"):
1039
1068
  raise MutualTLSChannelError(
1040
1069
  "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
@@ -1042,7 +1071,7 @@ class AnalyticsAdminServiceClient(metaclass=AnalyticsAdminServiceClientMeta):
1042
1071
 
1043
1072
  # Figure out the client cert source to use.
1044
1073
  client_cert_source = None
1045
- if use_client_cert == "true":
1074
+ if use_client_cert:
1046
1075
  if client_options.client_cert_source:
1047
1076
  client_cert_source = client_options.client_cert_source
1048
1077
  elif mtls.has_default_client_cert_source():
@@ -1074,20 +1103,14 @@ class AnalyticsAdminServiceClient(metaclass=AnalyticsAdminServiceClientMeta):
1074
1103
  google.auth.exceptions.MutualTLSChannelError: If GOOGLE_API_USE_MTLS_ENDPOINT
1075
1104
  is not any of ["auto", "never", "always"].
1076
1105
  """
1077
- use_client_cert = os.getenv(
1078
- "GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"
1079
- ).lower()
1106
+ use_client_cert = AnalyticsAdminServiceClient._use_client_cert_effective()
1080
1107
  use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto").lower()
1081
1108
  universe_domain_env = os.getenv("GOOGLE_CLOUD_UNIVERSE_DOMAIN")
1082
- if use_client_cert not in ("true", "false"):
1083
- raise ValueError(
1084
- "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`"
1085
- )
1086
1109
  if use_mtls_endpoint not in ("auto", "never", "always"):
1087
1110
  raise MutualTLSChannelError(
1088
1111
  "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
1089
1112
  )
1090
- return use_client_cert == "true", use_mtls_endpoint, universe_domain_env
1113
+ return use_client_cert, use_mtls_endpoint, universe_domain_env
1091
1114
 
1092
1115
  @staticmethod
1093
1116
  def _get_client_cert_source(provided_cert_source, use_cert_flag):
@@ -1111,7 +1134,7 @@ class AnalyticsAdminServiceClient(metaclass=AnalyticsAdminServiceClientMeta):
1111
1134
  @staticmethod
1112
1135
  def _get_api_endpoint(
1113
1136
  api_override, client_cert_source, universe_domain, use_mtls_endpoint
1114
- ):
1137
+ ) -> str:
1115
1138
  """Return the API endpoint used by the client.
1116
1139
 
1117
1140
  Args:
@@ -1210,7 +1233,7 @@ class AnalyticsAdminServiceClient(metaclass=AnalyticsAdminServiceClientMeta):
1210
1233
  error._details.append(json.dumps(cred_info))
1211
1234
 
1212
1235
  @property
1213
- def api_endpoint(self):
1236
+ def api_endpoint(self) -> str:
1214
1237
  """Return the API endpoint used by the client instance.
1215
1238
 
1216
1239
  Returns:
@@ -1301,18 +1324,16 @@ class AnalyticsAdminServiceClient(metaclass=AnalyticsAdminServiceClientMeta):
1301
1324
 
1302
1325
  universe_domain_opt = getattr(self._client_options, "universe_domain", None)
1303
1326
 
1304
- (
1305
- self._use_client_cert,
1306
- self._use_mtls_endpoint,
1307
- self._universe_domain_env,
1308
- ) = AnalyticsAdminServiceClient._read_environment_variables()
1327
+ self._use_client_cert, self._use_mtls_endpoint, self._universe_domain_env = (
1328
+ AnalyticsAdminServiceClient._read_environment_variables()
1329
+ )
1309
1330
  self._client_cert_source = AnalyticsAdminServiceClient._get_client_cert_source(
1310
1331
  self._client_options.client_cert_source, self._use_client_cert
1311
1332
  )
1312
1333
  self._universe_domain = AnalyticsAdminServiceClient._get_universe_domain(
1313
1334
  universe_domain_opt, self._universe_domain_env
1314
1335
  )
1315
- self._api_endpoint = None # updated below, depending on `transport`
1336
+ self._api_endpoint: str = "" # updated below, depending on `transport`
1316
1337
 
1317
1338
  # Initialize the universe domain validation.
1318
1339
  self._is_universe_domain_valid = False
@@ -1340,8 +1361,7 @@ class AnalyticsAdminServiceClient(metaclass=AnalyticsAdminServiceClientMeta):
1340
1361
  )
1341
1362
  if self._client_options.scopes:
1342
1363
  raise ValueError(
1343
- "When providing a transport instance, provide its scopes "
1344
- "directly."
1364
+ "When providing a transport instance, provide its scopes directly."
1345
1365
  )
1346
1366
  self._transport = cast(AnalyticsAdminServiceTransport, transport)
1347
1367
  self._api_endpoint = self._transport.host