8000 Add routing header to method metadata (via synth). (#7623) · googleapis/google-cloud-python@b457593 · GitHub
[go: up one dir, main page]

Skip to content

Commit b457593

Browse files
yoshi-automationbusunkim96
authored andcommitted
Add routing header to method metadata (via synth). (#7623)
1 parent 1b940bb commit b457593

File tree

3 files changed

+358
-5
lines changed

3 files changed

+358
-5
lines changed

packages/google-cloud-pubsub/google/cloud/pubsub_v1/gapic/publisher_client.py

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import google.api_core.gapic_v1.config
2525
import google.api_core.gapic_v1.method
2626
import google.api_core.path_template
27+
import google.api_core.gapic_v1.routing_header
2728
import google.api_core.grpc_helpers
2829
import google.api_core.page_iterator
2930
import google.api_core.path_template
@@ -267,6 +268,19 @@ def create_topic(
267268
request = pubsub_pb2.Topic(
268269
name=name, labels=labels, message_storage_policy=message_storage_policy
269270
)
271+
if metadata is None:
272+
metadata = []
273+
metadata = list(metadata)
274+
try:
275+
routing_header = [("name", name)]
276+
except AttributeError:
277+
pass
278+
else:
279+
routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata(
280+
routing_header
281+
)
282+
metadata.append(routing_metadata)
283+
270284
return self._inner_api_calls["create_topic"](
271285
request, retry=retry, timeout=timeout, metadata=metadata
272286
)
@@ -341,6 +355,19 @@ def update_topic(
341355
)
342356

343357
request = pubsub_pb2.UpdateTopicRequest(topic=topic, update_mask=update_mask)
358+
if metadata is None:
359+
metadata = []
360+
metadata = list(metadata)
361+
try:
362+
routing_header = [("topic.name", topic.name)]
363+
except AttributeError:
364+
pass
365+
else:
366+
routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata(
367+
routing_header
368+
)
369+
metadata.append(routing_metadata)
370+
344371
return self._inner_api_calls["update_topic"](
345372
request, retry=retry, timeout=timeout, metadata=metadata
346373
)
@@ -407,6 +434,19 @@ def publish(
407434
)
408435

409436
request = pubsub_pb2.PublishRequest(topic=topic, messages=messages)
437+
if metadata is None:
438+
metadata = []
439+
metadata = list(metadata)
440+
try:
441+
routing_header = [("topic", topic)]
442+
except AttributeError:
443+
pass
444+
else:
445+
routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata(
446+
routing_header
447+
)
448+
metadata.append(routing_metadata)
449+
410450
return self._inner_api_calls["publish"](
411451
request, retry=retry, timeout=timeout, metadata=metadata
412452
)
@@ -464,6 +504,19 @@ def get_topic(
464504
)
465505

466506
request = pubsub_pb2.GetTopicRequest(topic=topic)
507+
if metadata is None:
508+
metadata = []
509+
metadata = list(metadata)
510+
try:
511+
routing_header = [("topic", topic)]
512+
except AttributeError:
513+
pass
514+
else:
515+
routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata(
516+
routing_header
517+
)
518+
metadata.append(routing_metadata)
519+
467520
return self._inner_api_calls["get_topic"](
468521
request, retry=retry, timeout=timeout, metadata=metadata
469522
)
@@ -542,6 +595,19 @@ def list_topics(
542595
)
543596

544597
request = pubsub_pb2.ListTopicsRequest(project=project, page_size=page_size)
598+
if metadata is None:
599+
metadata = []
600+
metadata = list(metadata)
601+
try:
602+
routing_header = [("project", project)]
603+
except AttributeError:
604+
pass
605+
else:
606+
routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata(
607+
routing_header
608+
)
609+
metadata.append(routing_metadata)
610+
545611
iterator = google.api_core.page_iterator.GRPCIterator(
546612
client=None,
547613
method=functools.partial(
@@ -633,6 +699,19 @@ def list_topic_subscriptions(
633699
request = pubsub_pb2.ListTopicSubscriptionsRequest(
634700
topic=topic, page_size=page_size
635701
)
702+
if metadata is None:
703+
metadata = []
704+
metadata = list(metadata)
705+
try:
706+
routing_header = [("topic", topic)]
707+
except AttributeError:
708+
pass
709+
else:
710+
routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata(
711+
routing_header
712+
)
713+
metadata.append(routing_metadata)
714+
636715
iterator = google.api_core.page_iterator.GRPCIterator(
637716
client=None,
638717
method=functools.partial(
@@ -703,6 +782,19 @@ def delete_topic(
703782
)
704783

705784
request = pubsub_pb2.DeleteTopicRequest(topic=topic)
785+
if metadata is None:
786+
metadata = []
787+
metadata = list(metadata)
788+
try:
789+
routing_header = [("topic", topic)]
790+
except AttributeError:
791+
pass
792+
else:
793+
routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata(
794+
routing_header
795+
)
796+
metadata.append(routing_metadata)
797+
706798
self._inner_api_calls["delete_topic"](
707799
request, retry=retry, timeout=timeout, metadata=metadata
708800
)
@@ -773,6 +865,19 @@ def set_iam_policy(
773865
)
774866

775867
request = iam_policy_pb2.SetIamPolicyRequest(resource=resource, policy=policy)
868+
if metadata is None:
869+
metadata = []
870+
metadata = list(metadata)
871+
try:
872+
routing_header = [("resource", resource)]
873+
except AttributeError:
874+
pass
875+
else:
876+
routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata(
877+
routing_header
878+
)
879+
metadata.append(routing_metadata)
880+
776881
return self._inner_api_calls["set_iam_policy"](
777882
request, retry=retry, timeout=timeout, metadata=metadata
778883
)
@@ -833,6 +938,19 @@ def get_iam_policy(
833938
)
834939

835940
request = iam_policy_pb2.GetIamPolicyRequest(resource=resource)
941+
if metadata is None:
942+
metadata = []
943+
metadata = list(metadata)
944+
try:
945+
routing_header = [("resource", resource)]
946+
except AttributeError:
947+
pass
948+
else:
949+
routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata(
950+
routing_header
951+
)
952+
metadata.append(routing_metadata)
953+
836954
return self._inner_api_calls["get_iam_policy"](
837955
request, retry=retry, timeout=timeout, metadata=metadata
838956
)
@@ -903,6 +1021,19 @@ def test_iam_permissions(
9031021
request = iam_policy_pb2.TestIamPermissionsRequest(
9041022
resource=resource, permissions=permissions
9051023
)
1024+
if metadata is None:
1025+
metadata = []
1026+
metadata = list(metadata)
1027+
try:
1028+
routing_header = [("resource", resource)]
1029+
except AttributeError:
1030+
pass
1031+
else:
1032+
routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata(
1033+
routing_header
1034+
)
1035+
metadata.append(routing_metadata)
1036+
9061037
return self._inner_api_calls["test_iam_permissions"](
9071038
request, retry=retry, timeout=timeout, metadata=metadata
9081039
)

0 commit comments

Comments
 (0)
0