Skip to content

Commit

Permalink
feat: add CheckCompatibility method to the API (#131)
Browse files Browse the repository at this point in the history
- [ ] Regenerate this pull request now.

PiperOrigin-RevId: 394292123

Source-Link: googleapis/googleapis@3c414af

Source-Link: googleapis/googleapis-gen@1d690f2

feat: add `DimensionCompatibility`, `MetricCompatibility`, `Compatibility` types to the API
feat: add `category` field to `DimensionMetadata`, `MetricMetadata` types
  • Loading branch information
gcf-owl-bot[bot] authored Sep 1, 2021
1 parent f31bcd3 commit ad0e333
Show file tree
Hide file tree
Showing 12 changed files with 550 additions and 6 deletions.
14 changes: 14 additions & 0 deletions packages/google-analytics-data/google/analytics/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
from google.analytics.data_v1beta.types.analytics_data_api import (
BatchRunReportsResponse,
)
from google.analytics.data_v1beta.types.analytics_data_api import (
CheckCompatibilityRequest,
)
from google.analytics.data_v1beta.types.analytics_data_api import (
CheckCompatibilityResponse,
)
from google.analytics.data_v1beta.types.analytics_data_api import GetMetadataRequest
from google.analytics.data_v1beta.types.analytics_data_api import Metadata
from google.analytics.data_v1beta.types.analytics_data_api import RunPivotReportRequest
Expand All @@ -49,6 +55,7 @@
from google.analytics.data_v1beta.types.data import CohortsRange
from google.analytics.data_v1beta.types.data import DateRange
from google.analytics.data_v1beta.types.data import Dimension
from google.analytics.data_v1beta.types.data import DimensionCompatibility
from google.analytics.data_v1beta.types.data import DimensionExpression
from google.analytics.data_v1beta.types.data import DimensionHeader
from google.analytics.data_v1beta.types.data import DimensionMetadata
Expand All @@ -57,6 +64,7 @@
from google.analytics.data_v1beta.types.data import FilterExpression
from google.analytics.data_v1beta.types.data import FilterExpressionList
from google.analytics.data_v1beta.types.data import Metric
from google.analytics.data_v1beta.types.data import MetricCompatibility
from google.analytics.data_v1beta.types.data import MetricHeader
from google.analytics.data_v1beta.types.data import MetricMetadata
from google.analytics.data_v1beta.types.data import MetricValue
Expand All @@ -70,6 +78,7 @@
from google.analytics.data_v1beta.types.data import QuotaStatus
from google.analytics.data_v1beta.types.data import ResponseMetaData
from google.analytics.data_v1beta.types.data import Row
from google.analytics.data_v1beta.types.data import Compatibility
from google.analytics.data_v1beta.types.data import MetricAggregation
from google.analytics.data_v1beta.types.data import MetricType

Expand All @@ -80,6 +89,8 @@
"BatchRunPivotReportsResponse",
"BatchRunReportsRequest",
"BatchRunReportsResponse",
"CheckCompatibilityRequest",
"CheckCompatibilityResponse",
"GetMetadataRequest",
"Metadata",
"RunPivotReportRequest",
Expand All @@ -94,6 +105,7 @@
"CohortsRange",
"DateRange",
"Dimension",
"DimensionCompatibility",
"DimensionExpression",
"DimensionHeader",
"DimensionMetadata",
Expand All @@ -102,6 +114,7 @@
"FilterExpression",
"FilterExpressionList",
"Metric",
"MetricCompatibility",
"MetricHeader",
"MetricMetadata",
"MetricValue",
Expand All @@ -115,6 +128,7 @@
"QuotaStatus",
"ResponseMetaData",
"Row",
"Compatibility",
"MetricAggregation",
"MetricType",
)
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
from .types.analytics_data_api import BatchRunPivotReportsResponse
from .types.analytics_data_api import BatchRunReportsRequest
from .types.analytics_data_api import BatchRunReportsResponse
from .types.analytics_data_api import CheckCompatibilityRequest
from .types.analytics_data_api import CheckCompatibilityResponse
from .types.analytics_data_api import GetMetadataRequest
from .types.analytics_data_api import Metadata
from .types.analytics_data_api import RunPivotReportRequest
Expand All @@ -35,6 +37,7 @@
from .types.data import CohortsRange
from .types.data import DateRange
from .types.data import Dimension
from .types.data import DimensionCompatibility
from .types.data import DimensionExpression
from .types.data import DimensionHeader
from .types.data import DimensionMetadata
Expand All @@ -43,6 +46,7 @@
from .types.data import FilterExpression
from .types.data import FilterExpressionList
from .types.data import Metric
from .types.data import MetricCompatibility
from .types.data import MetricHeader
from .types.data import MetricMetadata
from .types.data import MetricValue
Expand All @@ -56,6 +60,7 @@
from .types.data import QuotaStatus
from .types.data import ResponseMetaData
from .types.data import Row
from .types.data import Compatibility
from .types.data import MetricAggregation
from .types.data import MetricType

Expand All @@ -66,12 +71,16 @@
"BatchRunReportsRequest",
"BatchRunReportsResponse",
"BetaAnalyticsDataClient",
"CheckCompatibilityRequest",
"CheckCompatibilityResponse",
"Cohort",
"CohortReportSettings",
"CohortSpec",
"CohortsRange",
"Compatibility",
"DateRange",
"Dimension",
"DimensionCompatibility",
"DimensionExpression",
"DimensionHeader",
"DimensionMetadata",
Expand All @@ -83,6 +92,7 @@
"Metadata",
"Metric",
"MetricAggregation",
"MetricCompatibility",
"MetricHeader",
"MetricMetadata",
"MetricType",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
"batch_run_reports"
]
},
"CheckCompatibility": {
"methods": [
"check_compatibility"
]
},
"GetMetadata": {
"methods": [
"get_metadata"
Expand Down Expand Up @@ -55,6 +60,11 @@
"batch_run_reports"
]
},
"CheckCompatibility": {
"methods": [
"check_compatibility"
]
},
"GetMetadata": {
"methods": [
"get_metadata"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,70 @@ async def run_realtime_report(
# Done; return the response.
return response

async def check_compatibility(
self,
request: analytics_data_api.CheckCompatibilityRequest = None,
*,
retry: retries.Retry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> analytics_data_api.CheckCompatibilityResponse:
r"""This compatibility method lists dimensions and
metrics that can be added to a report request and
maintain compatibility. This method fails if the
request's dimensions and metrics are incompatible.
In Google Analytics, reports fail if they request
incompatible dimensions and/or metrics; in that case,
you will need to remove dimensions and/or metrics from
the incompatible report until the report is compatible.
The Realtime and Core reports have different
compatibility rules. This method checks compatibility
for Core reports.
Args:
request (:class:`google.analytics.data_v1beta.types.CheckCompatibilityRequest`):
The request object. The request for compatibility
information for a report's dimensions and metrics. Check
compatibility provides a preview of the compatibility of
a report; fields shared with the `runReport` request
should be the same values as in your `runReport`
request.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
google.analytics.data_v1beta.types.CheckCompatibilityResponse:
The compatibility response with the
compatibility of each dimension &
metric.
"""
# Create or coerce a protobuf request object.
request = analytics_data_api.CheckCompatibilityRequest(request)

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.check_compatibility,
default_timeout=None,
client_info=DEFAULT_CLIENT_INFO,
)

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("property", request.property),)),
)

# Send the request.
response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)

# Done; return the response.
return response


try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,71 @@ def run_realtime_report(
# Done; return the response.
return response

def check_compatibility(
self,
request: analytics_data_api.CheckCompatibilityRequest = None,
*,
retry: retries.Retry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> analytics_data_api.CheckCompatibilityResponse:
r"""This compatibility method lists dimensions and
metrics that can be added to a report request and
maintain compatibility. This method fails if the
request's dimensions and metrics are incompatible.
In Google Analytics, reports fail if they request
incompatible dimensions and/or metrics; in that case,
you will need to remove dimensions and/or metrics from
the incompatible report until the report is compatible.
The Realtime and Core reports have different
compatibility rules. This method checks compatibility
for Core reports.
Args:
request (google.analytics.data_v1beta.types.CheckCompatibilityRequest):
The request object. The request for compatibility
information for a report's dimensions and metrics. Check
compatibility provides a preview of the compatibility of
a report; fields shared with the `runReport` request
should be the same values as in your `runReport`
request.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
google.analytics.data_v1beta.types.CheckCompatibilityResponse:
The compatibility response with the
compatibility of each dimension &
metric.
"""
# Create or coerce a protobuf request object.
# Minor optimization to avoid making a copy if the user passes
# in a analytics_data_api.CheckCompatibilityRequest.
# There's no risk of modifying the input as we've already verified
# there are no flattened fields.
if not isinstance(request, analytics_data_api.CheckCompatibilityRequest):
request = analytics_data_api.CheckCompatibilityRequest(request)

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._transport._wrapped_methods[self._transport.check_compatibility]

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("property", request.property),)),
)

# Send the request.
response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)

# Done; return the response.
return response


try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ def _prep_wrapped_messages(self, client_info):
self.run_realtime_report: gapic_v1.method.wrap_method(
self.run_realtime_report, default_timeout=60.0, client_info=client_info,
),
self.check_compatibility: gapic_v1.method.wrap_method(
self.check_compatibility, default_timeout=None, client_info=client_info,
),
}

@property
Expand Down Expand Up @@ -246,5 +249,17 @@ def run_realtime_report(
]:
raise NotImplementedError()

@property
def check_compatibility(
self,
) -> Callable[
[analytics_data_api.CheckCompatibilityRequest],
Union[
analytics_data_api.CheckCompatibilityResponse,
Awaitable[analytics_data_api.CheckCompatibilityResponse],
],
]:
raise NotImplementedError()


__all__ = ("BetaAnalyticsDataTransport",)
Original file line number Diff line number Diff line change
Expand Up @@ -423,5 +423,44 @@ def run_realtime_report(
)
return self._stubs["run_realtime_report"]

@property
def check_compatibility(
self,
) -> Callable[
[analytics_data_api.CheckCompatibilityRequest],
analytics_data_api.CheckCompatibilityResponse,
]:
r"""Return a callable for the check compatibility method over gRPC.
This compatibility method lists dimensions and
metrics that can be added to a report request and
maintain compatibility. This method fails if the
request's dimensions and metrics are incompatible.
In Google Analytics, reports fail if they request
incompatible dimensions and/or metrics; in that case,
you will need to remove dimensions and/or metrics from
the incompatible report until the report is compatible.
The Realtime and Core reports have different
compatibility rules. This method checks compatibility
for Core reports.
Returns:
Callable[[~.CheckCompatibilityRequest],
~.CheckCompatibilityResponse]:
A function that, when called, will call the underlying RPC
on the server.
"""
# Generate a "stub function" on-the-fly which will actually make
# the request.
# gRPC handles serialization and deserialization, so we just need
# to pass in the functions for each.
if "check_compatibility" not in self._stubs:
self._stubs["check_compatibility"] = self.grpc_channel.unary_unary(
"/google.analytics.data.v1beta.BetaAnalyticsData/CheckCompatibility",
request_serializer=analytics_data_api.CheckCompatibilityRequest.serialize,
response_deserializer=analytics_data_api.CheckCompatibilityResponse.deserialize,
)
return self._stubs["check_compatibility"]


__all__ = ("BetaAnalyticsDataGrpcTransport",)
Loading

0 comments on commit ad0e333

Please sign in to comment.