Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use single routing metadata header #1005

Merged
merged 5 commits into from
Jul 30, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 68 additions & 48 deletions google/cloud/bigtable_v2/services/bigtable/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,13 @@ def read_rows(

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata(
(("table_name", request.table_name),)
),
)
metadata = tuple(metadata)
if all(m[0] != gapic_v1.routing_header.ROUTING_METADATA_KEY for m in metadata):
metadata += (
gapic_v1.routing_header.to_grpc_metadata(
(("table_name", request.table_name),)
),
)

# Validate the universe domain.
self._client._validate_universe_domain()
Expand Down Expand Up @@ -441,11 +443,13 @@ def sample_row_keys(

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata(
(("table_name", request.table_name),)
),
)
metadata = tuple(metadata)
if all(m[0] != gapic_v1.routing_header.ROUTING_METADATA_KEY for m in metadata):
metadata += (
gapic_v1.routing_header.to_grpc_metadata(
(("table_name", request.table_name),)
),
)

# Validate the universe domain.
self._client._validate_universe_domain()
Expand Down Expand Up @@ -563,11 +567,13 @@ async def mutate_row(

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata(
(("table_name", request.table_name),)
),
)
metadata = tuple(metadata)
if all(m[0] != gapic_v1.routing_header.ROUTING_METADATA_KEY for m in metadata):
metadata += (
gapic_v1.routing_header.to_grpc_metadata(
(("table_name", request.table_name),)
),
)

# Validate the universe domain.
self._client._validate_universe_domain()
Expand Down Expand Up @@ -679,11 +685,13 @@ def mutate_rows(

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata(
(("table_name", request.table_name),)
),
)
metadata = tuple(metadata)
if all(m[0] != gapic_v1.routing_header.ROUTING_METADATA_KEY for m in metadata):
metadata += (
gapic_v1.routing_header.to_grpc_metadata(
(("table_name", request.table_name),)
),
)

# Validate the universe domain.
self._client._validate_universe_domain()
Expand Down Expand Up @@ -838,11 +846,13 @@ async def check_and_mutate_row(

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata(
(("table_name", request.table_name),)
),
)
metadata = tuple(metadata)
if all(m[0] != gapic_v1.routing_header.ROUTING_METADATA_KEY for m in metadata):
metadata += (
gapic_v1.routing_header.to_grpc_metadata(
(("table_name", request.table_name),)
),
)

# Validate the universe domain.
self._client._validate_universe_domain()
Expand Down Expand Up @@ -936,9 +946,11 @@ async def ping_and_warm(

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
)
metadata = tuple(metadata)
if all(m[0] != gapic_v1.routing_header.ROUTING_METADATA_KEY for m in metadata):
metadata += (
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
)

# Validate the universe domain.
self._client._validate_universe_domain()
Expand Down Expand Up @@ -1062,11 +1074,13 @@ async def read_modify_write_row(

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata(
(("table_name", request.table_name),)
),
)
metadata = tuple(metadata)
if all(m[0] != gapic_v1.routing_header.ROUTING_METADATA_KEY for m in metadata):
metadata += (
gapic_v1.routing_header.to_grpc_metadata(
(("table_name", request.table_name),)
),
)

# Validate the universe domain.
self._client._validate_universe_domain()
Expand Down Expand Up @@ -1172,11 +1186,13 @@ def generate_initial_change_stream_partitions(

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata(
(("table_name", request.table_name),)
),
)
metadata = tuple(metadata)
if all(m[0] != gapic_v1.routing_header.ROUTING_METADATA_KEY for m in metadata):
metadata += (
gapic_v1.routing_header.to_grpc_metadata(
(("table_name", request.table_name),)
),
)

# Validate the universe domain.
self._client._validate_universe_domain()
Expand Down Expand Up @@ -1274,11 +1290,13 @@ def read_change_stream(

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata(
(("table_name", request.table_name),)
),
)
metadata = tuple(metadata)
if all(m[0] != gapic_v1.routing_header.ROUTING_METADATA_KEY for m in metadata):
metadata += (
gapic_v1.routing_header.to_grpc_metadata(
(("table_name", request.table_name),)
),
)

# Validate the universe domain.
self._client._validate_universe_domain()
Expand Down Expand Up @@ -1377,11 +1395,13 @@ def execute_query(

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata(
(("instance_name", request.instance_name),)
),
)
metadata = tuple(metadata)
if all(m[0] != gapic_v1.routing_header.ROUTING_METADATA_KEY for m in metadata):
metadata += (
gapic_v1.routing_header.to_grpc_metadata(
(("instance_name", request.instance_name),)
),
)

# Validate the universe domain.
self._client._validate_universe_domain()
Expand Down
72 changes: 38 additions & 34 deletions google/cloud/bigtable_v2/services/bigtable/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -817,9 +817,9 @@ def read_rows(
)

if header_params:
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata(header_params),
)
metadata = tuple(metadata)
if all(m[0] != gapic_v1.routing_header.ROUTING_METADATA_KEY for m in metadata):
metadata += (gapic_v1.routing_header.to_grpc_metadata(header_params),)

# Validate the universe domain.
self._validate_universe_domain()
Expand Down Expand Up @@ -933,9 +933,9 @@ def sample_row_keys(
)

if header_params:
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata(header_params),
)
metadata = tuple(metadata)
if all(m[0] != gapic_v1.routing_header.ROUTING_METADATA_KEY for m in metadata):
metadata += (gapic_v1.routing_header.to_grpc_metadata(header_params),)

# Validate the universe domain.
self._validate_universe_domain()
Expand Down Expand Up @@ -1070,9 +1070,9 @@ def mutate_row(
)

if header_params:
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata(header_params),
)
metadata = tuple(metadata)
if all(m[0] != gapic_v1.routing_header.ROUTING_METADATA_KEY for m in metadata):
metadata += (gapic_v1.routing_header.to_grpc_metadata(header_params),)

# Validate the universe domain.
self._validate_universe_domain()
Expand Down Expand Up @@ -1201,9 +1201,9 @@ def mutate_rows(
)

if header_params:
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata(header_params),
)
metadata = tuple(metadata)
if all(m[0] != gapic_v1.routing_header.ROUTING_METADATA_KEY for m in metadata):
metadata += (gapic_v1.routing_header.to_grpc_metadata(header_params),)

# Validate the universe domain.
self._validate_universe_domain()
Expand Down Expand Up @@ -1375,9 +1375,9 @@ def check_and_mutate_row(
)

if header_params:
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata(header_params),
)
metadata = tuple(metadata)
if all(m[0] != gapic_v1.routing_header.ROUTING_METADATA_KEY for m in metadata):
metadata += (gapic_v1.routing_header.to_grpc_metadata(header_params),)

# Validate the universe domain.
self._validate_universe_domain()
Expand Down Expand Up @@ -1477,9 +1477,9 @@ def ping_and_warm(
header_params["app_profile_id"] = request.app_profile_id

if header_params:
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata(header_params),
)
metadata = tuple(metadata)
if all(m[0] != gapic_v1.routing_header.ROUTING_METADATA_KEY for m in metadata):
metadata += (gapic_v1.routing_header.to_grpc_metadata(header_params),)

# Validate the universe domain.
self._validate_universe_domain()
Expand Down Expand Up @@ -1620,9 +1620,9 @@ def read_modify_write_row(
)

if header_params:
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata(header_params),
)
metadata = tuple(metadata)
if all(m[0] != gapic_v1.routing_header.ROUTING_METADATA_KEY for m in metadata):
metadata += (gapic_v1.routing_header.to_grpc_metadata(header_params),)

# Validate the universe domain.
self._validate_universe_domain()
Expand Down Expand Up @@ -1725,11 +1725,13 @@ def generate_initial_change_stream_partitions(

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata(
(("table_name", request.table_name),)
),
)
metadata = tuple(metadata)
if all(m[0] != gapic_v1.routing_header.ROUTING_METADATA_KEY for m in metadata):
metadata += (
gapic_v1.routing_header.to_grpc_metadata(
(("table_name", request.table_name),)
),
)

# Validate the universe domain.
self._validate_universe_domain()
Expand Down Expand Up @@ -1824,11 +1826,13 @@ def read_change_stream(

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata(
(("table_name", request.table_name),)
),
)
metadata = tuple(metadata)
if all(m[0] != gapic_v1.routing_header.ROUTING_METADATA_KEY for m in metadata):
metadata += (
gapic_v1.routing_header.to_grpc_metadata(
(("table_name", request.table_name),)
),
)

# Validate the universe domain.
self._validate_universe_domain()
Expand Down Expand Up @@ -1933,9 +1937,9 @@ def execute_query(
header_params["app_profile_id"] = request.app_profile_id

if header_params:
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata(header_params),
)
metadata = tuple(metadata)
if all(m[0] != gapic_v1.routing_header.ROUTING_METADATA_KEY for m in metadata):
metadata += (gapic_v1.routing_header.to_grpc_metadata(header_params),)

# Validate the universe domain.
self._validate_universe_domain()
Expand Down
11 changes: 11 additions & 0 deletions owlbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,17 @@ def insert(file, before_line, insert_line, after_line, escape=None):
escape='"'
)

# ----------------------------------------------------------------------------
# Patch duplicate routing header: https://github.com/googleapis/gapic-generator-python/issues/2078
# ----------------------------------------------------------------------------
for file in ["client.py", "async_client.py"]:
s.replace(
f"google/cloud/bigtable_v2/services/bigtable/{file}",
"metadata \= tuple\(metadata\) \+ \(",
"""metadata = tuple(metadata)
if all(m[0] != gapic_v1.routing_header.ROUTING_METADATA_KEY for m in metadata):
metadata += ("""
)

# ----------------------------------------------------------------------------
# Samples templates
Expand Down
Loading
Loading