Skip to content
This repository was archived by the owner on Nov 9, 2024. It is now read-only.

Commit 81c2eea

Browse files
feat: add CheckCompatibility method to the API (#131)
- [ ] Regenerate this pull request now. PiperOrigin-RevId: 394292123 Source-Link: googleapis/googleapis@3c414af Source-Link: https://github.com/googleapis/googleapis-gen/commit/1d690f2f38a08b6d68f546f592503a8387660d53 feat: add `DimensionCompatibility`, `MetricCompatibility`, `Compatibility` types to the API feat: add `category` field to `DimensionMetadata`, `MetricMetadata` types
1 parent a398cfa commit 81c2eea

File tree

12 files changed

+550
-6
lines changed

12 files changed

+550
-6
lines changed

google/analytics/data/__init__.py

+14
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@
3131
from google.analytics.data_v1beta.types.analytics_data_api import (
3232
BatchRunReportsResponse,
3333
)
34+
from google.analytics.data_v1beta.types.analytics_data_api import (
35+
CheckCompatibilityRequest,
36+
)
37+
from google.analytics.data_v1beta.types.analytics_data_api import (
38+
CheckCompatibilityResponse,
39+
)
3440
from google.analytics.data_v1beta.types.analytics_data_api import GetMetadataRequest
3541
from google.analytics.data_v1beta.types.analytics_data_api import Metadata
3642
from google.analytics.data_v1beta.types.analytics_data_api import RunPivotReportRequest
@@ -49,6 +55,7 @@
4955
from google.analytics.data_v1beta.types.data import CohortsRange
5056
from google.analytics.data_v1beta.types.data import DateRange
5157
from google.analytics.data_v1beta.types.data import Dimension
58+
from google.analytics.data_v1beta.types.data import DimensionCompatibility
5259
from google.analytics.data_v1beta.types.data import DimensionExpression
5360
from google.analytics.data_v1beta.types.data import DimensionHeader
5461
from google.analytics.data_v1beta.types.data import DimensionMetadata
@@ -57,6 +64,7 @@
5764
from google.analytics.data_v1beta.types.data import FilterExpression
5865
from google.analytics.data_v1beta.types.data import FilterExpressionList
5966
from google.analytics.data_v1beta.types.data import Metric
67+
from google.analytics.data_v1beta.types.data import MetricCompatibility
6068
from google.analytics.data_v1beta.types.data import MetricHeader
6169
from google.analytics.data_v1beta.types.data import MetricMetadata
6270
from google.analytics.data_v1beta.types.data import MetricValue
@@ -70,6 +78,7 @@
7078
from google.analytics.data_v1beta.types.data import QuotaStatus
7179
from google.analytics.data_v1beta.types.data import ResponseMetaData
7280
from google.analytics.data_v1beta.types.data import Row
81+
from google.analytics.data_v1beta.types.data import Compatibility
7382
from google.analytics.data_v1beta.types.data import MetricAggregation
7483
from google.analytics.data_v1beta.types.data import MetricType
7584

@@ -80,6 +89,8 @@
8089
"BatchRunPivotReportsResponse",
8190
"BatchRunReportsRequest",
8291
"BatchRunReportsResponse",
92+
"CheckCompatibilityRequest",
93+
"CheckCompatibilityResponse",
8394
"GetMetadataRequest",
8495
"Metadata",
8596
"RunPivotReportRequest",
@@ -94,6 +105,7 @@
94105
"CohortsRange",
95106
"DateRange",
96107
"Dimension",
108+
"DimensionCompatibility",
97109
"DimensionExpression",
98110
"DimensionHeader",
99111
"DimensionMetadata",
@@ -102,6 +114,7 @@
102114
"FilterExpression",
103115
"FilterExpressionList",
104116
"Metric",
117+
"MetricCompatibility",
105118
"MetricHeader",
106119
"MetricMetadata",
107120
"MetricValue",
@@ -115,6 +128,7 @@
115128
"QuotaStatus",
116129
"ResponseMetaData",
117130
"Row",
131+
"Compatibility",
118132
"MetricAggregation",
119133
"MetricType",
120134
)

google/analytics/data_v1beta/__init__.py

+10
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
from .types.analytics_data_api import BatchRunPivotReportsResponse
2222
from .types.analytics_data_api import BatchRunReportsRequest
2323
from .types.analytics_data_api import BatchRunReportsResponse
24+
from .types.analytics_data_api import CheckCompatibilityRequest
25+
from .types.analytics_data_api import CheckCompatibilityResponse
2426
from .types.analytics_data_api import GetMetadataRequest
2527
from .types.analytics_data_api import Metadata
2628
from .types.analytics_data_api import RunPivotReportRequest
@@ -35,6 +37,7 @@
3537
from .types.data import CohortsRange
3638
from .types.data import DateRange
3739
from .types.data import Dimension
40+
from .types.data import DimensionCompatibility
3841
from .types.data import DimensionExpression
3942
from .types.data import DimensionHeader
4043
from .types.data import DimensionMetadata
@@ -43,6 +46,7 @@
4346
from .types.data import FilterExpression
4447
from .types.data import FilterExpressionList
4548
from .types.data import Metric
49+
from .types.data import MetricCompatibility
4650
from .types.data import MetricHeader
4751
from .types.data import MetricMetadata
4852
from .types.data import MetricValue
@@ -56,6 +60,7 @@
5660
from .types.data import QuotaStatus
5761
from .types.data import ResponseMetaData
5862
from .types.data import Row
63+
from .types.data import Compatibility
5964
from .types.data import MetricAggregation
6065
from .types.data import MetricType
6166

@@ -66,12 +71,16 @@
6671
"BatchRunReportsRequest",
6772
"BatchRunReportsResponse",
6873
"BetaAnalyticsDataClient",
74+
"CheckCompatibilityRequest",
75+
"CheckCompatibilityResponse",
6976
"Cohort",
7077
"CohortReportSettings",
7178
"CohortSpec",
7279
"CohortsRange",
80+
"Compatibility",
7381
"DateRange",
7482
"Dimension",
83+
"DimensionCompatibility",
7584
"DimensionExpression",
7685
"DimensionHeader",
7786
"DimensionMetadata",
@@ -83,6 +92,7 @@
8392
"Metadata",
8493
"Metric",
8594
"MetricAggregation",
95+
"MetricCompatibility",
8696
"MetricHeader",
8797
"MetricMetadata",
8898
"MetricType",

google/analytics/data_v1beta/gapic_metadata.json

+10
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
"batch_run_reports"
2121
]
2222
},
23+
"CheckCompatibility": {
24+
"methods": [
25+
"check_compatibility"
26+
]
27+
},
2328
"GetMetadata": {
2429
"methods": [
2530
"get_metadata"
@@ -55,6 +60,11 @@
5560
"batch_run_reports"
5661
]
5762
},
63+
"CheckCompatibility": {
64+
"methods": [
65+
"check_compatibility"
66+
]
67+
},
5868
"GetMetadata": {
5969
"methods": [
6070
"get_metadata"

google/analytics/data_v1beta/services/beta_analytics_data/async_client.py

+64
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,70 @@ async def run_realtime_report(
514514
# Done; return the response.
515515
return response
516516

517+
async def check_compatibility(
518+
self,
519+
request: analytics_data_api.CheckCompatibilityRequest = None,
520+
*,
521+
retry: retries.Retry = gapic_v1.method.DEFAULT,
522+
timeout: float = None,
523+
metadata: Sequence[Tuple[str, str]] = (),
524+
) -> analytics_data_api.CheckCompatibilityResponse:
525+
r"""This compatibility method lists dimensions and
526+
metrics that can be added to a report request and
527+
maintain compatibility. This method fails if the
528+
request's dimensions and metrics are incompatible.
529+
In Google Analytics, reports fail if they request
530+
incompatible dimensions and/or metrics; in that case,
531+
you will need to remove dimensions and/or metrics from
532+
the incompatible report until the report is compatible.
533+
The Realtime and Core reports have different
534+
compatibility rules. This method checks compatibility
535+
for Core reports.
536+
537+
Args:
538+
request (:class:`google.analytics.data_v1beta.types.CheckCompatibilityRequest`):
539+
The request object. The request for compatibility
540+
information for a report's dimensions and metrics. Check
541+
compatibility provides a preview of the compatibility of
542+
a report; fields shared with the `runReport` request
543+
should be the same values as in your `runReport`
544+
request.
545+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
546+
should be retried.
547+
timeout (float): The timeout for this request.
548+
metadata (Sequence[Tuple[str, str]]): Strings which should be
549+
sent along with the request as metadata.
550+
551+
Returns:
552+
google.analytics.data_v1beta.types.CheckCompatibilityResponse:
553+
The compatibility response with the
554+
compatibility of each dimension &
555+
metric.
556+
557+
"""
558+
# Create or coerce a protobuf request object.
559+
request = analytics_data_api.CheckCompatibilityRequest(request)
560+
561+
# Wrap the RPC method; this adds retry and timeout information,
562+
# and friendly error handling.
563+
rpc = gapic_v1.method_async.wrap_method(
564+
self._client._transport.check_compatibility,
565+
default_timeout=None,
566+
client_info=DEFAULT_CLIENT_INFO,
567+
)
568+
569+
# Certain fields should be provided within the metadata header;
570+
# add these here.
571+
metadata = tuple(metadata) + (
572+
gapic_v1.routing_header.to_grpc_metadata((("property", request.property),)),
573+
)
574+
575+
# Send the request.
576+
response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
577+
578+
# Done; return the response.
579+
return response
580+
517581

518582
try:
519583
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(

google/analytics/data_v1beta/services/beta_analytics_data/client.py

+65
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,71 @@ def run_realtime_report(
705705
# Done; return the response.
706706
return response
707707

708+
def check_compatibility(
709+
self,
710+
request: analytics_data_api.CheckCompatibilityRequest = None,
711+
*,
712+
retry: retries.Retry = gapic_v1.method.DEFAULT,
713+
timeout: float = None,
714+
metadata: Sequence[Tuple[str, str]] = (),
715+
) -> analytics_data_api.CheckCompatibilityResponse:
716+
r"""This compatibility method lists dimensions and
717+
metrics that can be added to a report request and
718+
maintain compatibility. This method fails if the
719+
request's dimensions and metrics are incompatible.
720+
In Google Analytics, reports fail if they request
721+
incompatible dimensions and/or metrics; in that case,
722+
you will need to remove dimensions and/or metrics from
723+
the incompatible report until the report is compatible.
724+
The Realtime and Core reports have different
725+
compatibility rules. This method checks compatibility
726+
for Core reports.
727+
728+
Args:
729+
request (google.analytics.data_v1beta.types.CheckCompatibilityRequest):
730+
The request object. The request for compatibility
731+
information for a report's dimensions and metrics. Check
732+
compatibility provides a preview of the compatibility of
733+
a report; fields shared with the `runReport` request
734+
should be the same values as in your `runReport`
735+
request.
736+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
737+
should be retried.
738+
timeout (float): The timeout for this request.
739+
metadata (Sequence[Tuple[str, str]]): Strings which should be
740+
sent along with the request as metadata.
741+
742+
Returns:
743+
google.analytics.data_v1beta.types.CheckCompatibilityResponse:
744+
The compatibility response with the
745+
compatibility of each dimension &
746+
metric.
747+
748+
"""
749+
# Create or coerce a protobuf request object.
750+
# Minor optimization to avoid making a copy if the user passes
751+
# in a analytics_data_api.CheckCompatibilityRequest.
752+
# There's no risk of modifying the input as we've already verified
753+
# there are no flattened fields.
754+
if not isinstance(request, analytics_data_api.CheckCompatibilityRequest):
755+
request = analytics_data_api.CheckCompatibilityRequest(request)
756+
757+
# Wrap the RPC method; this adds retry and timeout information,
758+
# and friendly error handling.
759+
rpc = self._transport._wrapped_methods[self._transport.check_compatibility]
760+
761+
# Certain fields should be provided within the metadata header;
762+
# add these here.
763+
metadata = tuple(metadata) + (
764+
gapic_v1.routing_header.to_grpc_metadata((("property", request.property),)),
765+
)
766+
767+
# Send the request.
768+
response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
769+
770+
# Done; return the response.
771+
return response
772+
708773

709774
try:
710775
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(

google/analytics/data_v1beta/services/beta_analytics_data/transports/base.py

+15
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ def _prep_wrapped_messages(self, client_info):
175175
self.run_realtime_report: gapic_v1.method.wrap_method(
176176
self.run_realtime_report, default_timeout=60.0, client_info=client_info,
177177
),
178+
self.check_compatibility: gapic_v1.method.wrap_method(
179+
self.check_compatibility, default_timeout=None, client_info=client_info,
180+
),
178181
}
179182

180183
@property
@@ -246,5 +249,17 @@ def run_realtime_report(
246249
]:
247250
raise NotImplementedError()
248251

252+
@property
253+
def check_compatibility(
254+
self,
255+
) -> Callable[
256+
[analytics_data_api.CheckCompatibilityRequest],
257+
Union[
258+
analytics_data_api.CheckCompatibilityResponse,
259+
Awaitable[analytics_data_api.CheckCompatibilityResponse],
260+
],
261+
]:
262+
raise NotImplementedError()
263+
249264

250265
__all__ = ("BetaAnalyticsDataTransport",)

google/analytics/data_v1beta/services/beta_analytics_data/transports/grpc.py

+39
Original file line numberDiff line numberDiff line change
@@ -423,5 +423,44 @@ def run_realtime_report(
423423
)
424424
return self._stubs["run_realtime_report"]
425425

426+
@property
427+
def check_compatibility(
428+
self,
429+
) -> Callable[
430+
[analytics_data_api.CheckCompatibilityRequest],
431+
analytics_data_api.CheckCompatibilityResponse,
432+
]:
433+
r"""Return a callable for the check compatibility method over gRPC.
434+
435+
This compatibility method lists dimensions and
436+
metrics that can be added to a report request and
437+
maintain compatibility. This method fails if the
438+
request's dimensions and metrics are incompatible.
439+
In Google Analytics, reports fail if they request
440+
incompatible dimensions and/or metrics; in that case,
441+
you will need to remove dimensions and/or metrics from
442+
the incompatible report until the report is compatible.
443+
The Realtime and Core reports have different
444+
compatibility rules. This method checks compatibility
445+
for Core reports.
446+
447+
Returns:
448+
Callable[[~.CheckCompatibilityRequest],
449+
~.CheckCompatibilityResponse]:
450+
A function that, when called, will call the underlying RPC
451+
on the server.
452+
"""
453+
# Generate a "stub function" on-the-fly which will actually make
454+
# the request.
455+
# gRPC handles serialization and deserialization, so we just need
456+
# to pass in the functions for each.
457+
if "check_compatibility" not in self._stubs:
458+
self._stubs["check_compatibility"] = self.grpc_channel.unary_unary(
459+
"/google.analytics.data.v1beta.BetaAnalyticsData/CheckCompatibility",
460+
request_serializer=analytics_data_api.CheckCompatibilityRequest.serialize,
461+
response_deserializer=analytics_data_api.CheckCompatibilityResponse.deserialize,
462+
)
463+
return self._stubs["check_compatibility"]
464+
426465

427466
__all__ = ("BetaAnalyticsDataGrpcTransport",)

0 commit comments

Comments
 (0)