Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

feat: add kind field which is used to distinguish between response types #60

Merged
merged 3 commits into from Apr 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
35 changes: 35 additions & 0 deletions google/analytics/data_v1beta/types/analytics_data_api.py
Expand Up @@ -220,6 +220,11 @@ class RunReportResponse(proto.Message):
property_quota (google.analytics.data_v1beta.types.PropertyQuota):
This Analytics Property's quota state
including this request.
kind (str):
Identifies what kind of resource this message is. This
``kind`` is always the fixed string
"analyticsData#runReport". Useful to distinguish between
response types in JSON.
"""

dimension_headers = proto.RepeatedField(
Expand All @@ -244,6 +249,8 @@ class RunReportResponse(proto.Message):

property_quota = proto.Field(proto.MESSAGE, number=9, message=data.PropertyQuota,)

kind = proto.Field(proto.STRING, number=10)


class RunPivotReportRequest(proto.Message):
r"""The request to generate a pivot report.
Expand Down Expand Up @@ -405,6 +412,11 @@ class RunPivotReportResponse(proto.Message):
property_quota (google.analytics.data_v1beta.types.PropertyQuota):
This Analytics Property's quota state
including this request.
kind (str):
Identifies what kind of resource this message is. This
``kind`` is always the fixed string
"analyticsData#runPivotReport". Useful to distinguish
between response types in JSON.
"""

pivot_headers = proto.RepeatedField(
Expand All @@ -427,6 +439,8 @@ class RunPivotReportResponse(proto.Message):

property_quota = proto.Field(proto.MESSAGE, number=7, message=data.PropertyQuota,)

kind = proto.Field(proto.STRING, number=8)


class BatchRunReportsRequest(proto.Message):
r"""The batch request containing multiple report requests.
Expand Down Expand Up @@ -460,10 +474,17 @@ class BatchRunReportsResponse(proto.Message):
reports (Sequence[google.analytics.data_v1beta.types.RunReportResponse]):
Individual responses. Each response has a
separate report request.
kind (str):
Identifies what kind of resource this message is. This
``kind`` is always the fixed string
"analyticsData#batchRunReports". Useful to distinguish
between response types in JSON.
"""

reports = proto.RepeatedField(proto.MESSAGE, number=1, message="RunReportResponse",)

kind = proto.Field(proto.STRING, number=2)


class BatchRunPivotReportsRequest(proto.Message):
r"""The batch request containing multiple pivot report requests.
Expand Down Expand Up @@ -499,12 +520,19 @@ class BatchRunPivotReportsResponse(proto.Message):
pivot_reports (Sequence[google.analytics.data_v1beta.types.RunPivotReportResponse]):
Individual responses. Each response has a
separate pivot report request.
kind (str):
Identifies what kind of resource this message is. This
``kind`` is always the fixed string
"analyticsData#batchRunPivotReports". Useful to distinguish
between response types in JSON.
"""

pivot_reports = proto.RepeatedField(
proto.MESSAGE, number=1, message="RunPivotReportResponse",
)

kind = proto.Field(proto.STRING, number=2)


class GetMetadataRequest(proto.Message):
r"""Request for a property's dimension and metric metadata.
Expand Down Expand Up @@ -634,6 +662,11 @@ class RunRealtimeReportResponse(proto.Message):
property_quota (google.analytics.data_v1beta.types.PropertyQuota):
This Analytics Property's Realtime quota
state including this request.
kind (str):
Identifies what kind of resource this message is. This
``kind`` is always the fixed string
"analyticsData#runRealtimeReport". Useful to distinguish
between response types in JSON.
"""

dimension_headers = proto.RepeatedField(
Expand All @@ -656,5 +689,7 @@ class RunRealtimeReportResponse(proto.Message):

property_quota = proto.Field(proto.MESSAGE, number=8, message=data.PropertyQuota,)

kind = proto.Field(proto.STRING, number=9)


__all__ = tuple(sorted(__protobuf__.manifest))
16 changes: 13 additions & 3 deletions google/analytics/data_v1beta/types/data.py
Expand Up @@ -562,9 +562,8 @@ class Pivot(proto.Message):
is counted as row 0.
limit (int):
The number of unique combinations of dimension values to
return in this pivot. If unspecified, up to 10,000 unique
combinations of dimension values are returned. ``limit``
must be positive.
return in this pivot. The ``limit`` parameter is required. A
``limit`` of 10,000 is common for single pivot requests.

The product of the ``limit`` for each ``pivot`` in a
``RunPivotReportRequest`` must not exceed 100,000. For
Expand Down Expand Up @@ -955,6 +954,13 @@ class PropertyQuota(proto.Message):
per hour; Analytics 360 Properties and cloud
project pairs can have up to 50 server errors
per hour.
potentially_thresholded_requests_per_hour (google.analytics.data_v1beta.types.QuotaStatus):
Analytics Properties can send up to 120
requests with potentially thresholded dimensions
per hour. In a batch request, each report
request is individually counted for this quota
if the request contains potentially thresholded
dimensions.
"""

tokens_per_day = proto.Field(proto.MESSAGE, number=1, message="QuotaStatus",)
Expand All @@ -967,6 +973,10 @@ class PropertyQuota(proto.Message):
proto.MESSAGE, number=4, message="QuotaStatus",
)

potentially_thresholded_requests_per_hour = proto.Field(
proto.MESSAGE, number=5, message="QuotaStatus",
)


class QuotaStatus(proto.Message):
r"""Current state for a particular quota group.
Expand Down
6 changes: 3 additions & 3 deletions synth.metadata
Expand Up @@ -4,15 +4,15 @@
"git": {
"name": ".",
"remote": "https://github.com/googleapis/python-analytics-data.git",
"sha": "ad51cf28f6c3e306780ca48eb26299b4158068ad"
"sha": "1c1d58f1ee88e50ce92c40b0ec58c19cec631297"
}
},
{
"git": {
"name": "googleapis",
"remote": "https://github.com/googleapis/googleapis.git",
"sha": "149a3a84c29c9b8189576c7442ccb6dcf6a8f95b",
"internalRef": "364411656"
"sha": "95dd24960cf9f794ef583e59ad9f1fabe1c4a924",
"internalRef": "365882072"
}
},
{
Expand Down
52 changes: 42 additions & 10 deletions tests/unit/gapic/data_v1beta/test_beta_analytics_data.py
Expand Up @@ -471,7 +471,9 @@ def test_run_report(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(type(client.transport.run_report), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = analytics_data_api.RunReportResponse(row_count=992,)
call.return_value = analytics_data_api.RunReportResponse(
row_count=992, kind="kind_value",
)

response = client.run_report(request)

Expand All @@ -487,6 +489,8 @@ def test_run_report(

assert response.row_count == 992

assert response.kind == "kind_value"


def test_run_report_from_dict():
test_run_report(request_type=dict)
Expand Down Expand Up @@ -524,7 +528,7 @@ async def test_run_report_async(
with mock.patch.object(type(client.transport.run_report), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
analytics_data_api.RunReportResponse(row_count=992,)
analytics_data_api.RunReportResponse(row_count=992, kind="kind_value",)
)

response = await client.run_report(request)
Expand All @@ -540,6 +544,8 @@ async def test_run_report_async(

assert response.row_count == 992

assert response.kind == "kind_value"


@pytest.mark.asyncio
async def test_run_report_async_from_dict():
Expand Down Expand Up @@ -613,7 +619,9 @@ def test_run_pivot_report(
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(type(client.transport.run_pivot_report), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = analytics_data_api.RunPivotReportResponse()
call.return_value = analytics_data_api.RunPivotReportResponse(
kind="kind_value",
)

response = client.run_pivot_report(request)

Expand All @@ -627,6 +635,8 @@ def test_run_pivot_report(

assert isinstance(response, analytics_data_api.RunPivotReportResponse)

assert response.kind == "kind_value"


def test_run_pivot_report_from_dict():
test_run_pivot_report(request_type=dict)
Expand Down Expand Up @@ -665,7 +675,7 @@ async def test_run_pivot_report_async(
with mock.patch.object(type(client.transport.run_pivot_report), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
analytics_data_api.RunPivotReportResponse()
analytics_data_api.RunPivotReportResponse(kind="kind_value",)
)

response = await client.run_pivot_report(request)
Expand All @@ -679,6 +689,8 @@ async def test_run_pivot_report_async(
# Establish that the response is the type that we expect.
assert isinstance(response, analytics_data_api.RunPivotReportResponse)

assert response.kind == "kind_value"


@pytest.mark.asyncio
async def test_run_pivot_report_async_from_dict():
Expand Down Expand Up @@ -754,7 +766,9 @@ def test_batch_run_reports(
type(client.transport.batch_run_reports), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = analytics_data_api.BatchRunReportsResponse()
call.return_value = analytics_data_api.BatchRunReportsResponse(
kind="kind_value",
)

response = client.batch_run_reports(request)

Expand All @@ -768,6 +782,8 @@ def test_batch_run_reports(

assert isinstance(response, analytics_data_api.BatchRunReportsResponse)

assert response.kind == "kind_value"


def test_batch_run_reports_from_dict():
test_batch_run_reports(request_type=dict)
Expand Down Expand Up @@ -810,7 +826,7 @@ async def test_batch_run_reports_async(
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
analytics_data_api.BatchRunReportsResponse()
analytics_data_api.BatchRunReportsResponse(kind="kind_value",)
)

response = await client.batch_run_reports(request)
Expand All @@ -824,6 +840,8 @@ async def test_batch_run_reports_async(
# Establish that the response is the type that we expect.
assert isinstance(response, analytics_data_api.BatchRunReportsResponse)

assert response.kind == "kind_value"


@pytest.mark.asyncio
async def test_batch_run_reports_async_from_dict():
Expand Down Expand Up @@ -903,7 +921,9 @@ def test_batch_run_pivot_reports(
type(client.transport.batch_run_pivot_reports), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = analytics_data_api.BatchRunPivotReportsResponse()
call.return_value = analytics_data_api.BatchRunPivotReportsResponse(
kind="kind_value",
)

response = client.batch_run_pivot_reports(request)

Expand All @@ -917,6 +937,8 @@ def test_batch_run_pivot_reports(

assert isinstance(response, analytics_data_api.BatchRunPivotReportsResponse)

assert response.kind == "kind_value"


def test_batch_run_pivot_reports_from_dict():
test_batch_run_pivot_reports(request_type=dict)
Expand Down Expand Up @@ -959,7 +981,7 @@ async def test_batch_run_pivot_reports_async(
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
analytics_data_api.BatchRunPivotReportsResponse()
analytics_data_api.BatchRunPivotReportsResponse(kind="kind_value",)
)

response = await client.batch_run_pivot_reports(request)
Expand All @@ -973,6 +995,8 @@ async def test_batch_run_pivot_reports_async(
# Establish that the response is the type that we expect.
assert isinstance(response, analytics_data_api.BatchRunPivotReportsResponse)

assert response.kind == "kind_value"


@pytest.mark.asyncio
async def test_batch_run_pivot_reports_async_from_dict():
Expand Down Expand Up @@ -1265,7 +1289,9 @@ def test_run_realtime_report(
type(client.transport.run_realtime_report), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = analytics_data_api.RunRealtimeReportResponse(row_count=992,)
call.return_value = analytics_data_api.RunRealtimeReportResponse(
row_count=992, kind="kind_value",
)

response = client.run_realtime_report(request)

Expand All @@ -1281,6 +1307,8 @@ def test_run_realtime_report(

assert response.row_count == 992

assert response.kind == "kind_value"


def test_run_realtime_report_from_dict():
test_run_realtime_report(request_type=dict)
Expand Down Expand Up @@ -1323,7 +1351,9 @@ async def test_run_realtime_report_async(
) as call:
# Designate an appropriate return value for the call.
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
analytics_data_api.RunRealtimeReportResponse(row_count=992,)
analytics_data_api.RunRealtimeReportResponse(
row_count=992, kind="kind_value",
)
)

response = await client.run_realtime_report(request)
Expand All @@ -1339,6 +1369,8 @@ async def test_run_realtime_report_async(

assert response.row_count == 992

assert response.kind == "kind_value"


@pytest.mark.asyncio
async def test_run_realtime_report_async_from_dict():
Expand Down