Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: Add protobuf runtime version tox-goog-api-client header#812

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
parthea merged 3 commits intomainfromadd-protobuf-runtime-header
May 6, 2025
Merged
Show file tree
Hide file tree
Changes fromall 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
6 changes: 6 additions & 0 deletionsgoogle/api_core/client_info.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -59,6 +59,7 @@ class ClientInfo(object):
Recommended format: ``application-or-tool-ID/major.minor.version``.
rest_version (Optional[str]): A string with labeled versions of the
dependencies used for REST transport.
protobuf_runtime_version (Optional[str]): The protobuf runtime version.
"""

def __init__(
Expand All@@ -70,6 +71,7 @@ def __init__(
client_library_version=None,
user_agent=None,
rest_version=None,
protobuf_runtime_version=None,
):
self.python_version = python_version
self.grpc_version = grpc_version
Expand All@@ -78,6 +80,7 @@ def __init__(
self.client_library_version = client_library_version
self.user_agent = user_agent
self.rest_version = rest_version
self.protobuf_runtime_version = protobuf_runtime_version

def to_user_agent(self):
"""Returns the user-agent string for this client info."""
Expand DownExpand Up@@ -105,4 +108,7 @@ def to_user_agent(self):
if self.client_library_version is not None:
ua += "gccl/{client_library_version} "

if self.protobuf_runtime_version is not None:
ua += "pb/{protobuf_runtime_version} "

return ua.format(**self.__dict__).strip()
1 change: 1 addition & 0 deletionsgoogle/api_core/gapic_v1/client_info.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -47,6 +47,7 @@ class ClientInfo(client_info.ClientInfo):
Recommended format: ``application-or-tool-ID/major.minor.version``.
rest_version (Optional[str]): A string with labeled versions of the
dependencies used for REST transport.
protobuf_runtime_version (Optional[str]): The protobuf runtime version.
"""

defto_grpc_metadata(self):
Expand Down
1 change: 1 addition & 0 deletionstests/asyncio/gapic/test_method_async.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -81,6 +81,7 @@ async def test_wrap_method_with_custom_client_info():
api_core_version=3,
gapic_version=4,
client_library_version=5,
protobuf_runtime_version=6,
)
fake_call=grpc_helpers_async.FakeUnaryUnaryCall()
method=mock.Mock(spec=aio.UnaryUnaryMultiCallable,return_value=fake_call)
Expand Down
1 change: 1 addition & 0 deletionstests/unit/gapic/test_method.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -76,6 +76,7 @@ def test_wrap_method_with_custom_client_info():
api_core_version=3,
gapic_version=4,
client_library_version=5,
protobuf_runtime_version=6,
)
method=mock.Mock(spec=["__call__"])

Expand Down
10 changes: 8 additions & 2 deletionstests/unit/test_client_info.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -46,6 +46,7 @@ def test_constructor_options():
client_library_version="5",
user_agent="6",
rest_version="7",
protobuf_runtime_version="8",
)

assert info.python_version == "1"
Expand All@@ -55,11 +56,15 @@ def test_constructor_options():
assert info.client_library_version == "5"
assert info.user_agent == "6"
assert info.rest_version == "7"
assert info.protobuf_runtime_version == "8"


def test_to_user_agent_minimal():
info = client_info.ClientInfo(
python_version="1", api_core_version="2", grpc_version=None
python_version="1",
api_core_version="2",
grpc_version=None,
protobuf_runtime_version=None,
)

user_agent = info.to_user_agent()
Expand All@@ -75,11 +80,12 @@ def test_to_user_agent_full():
gapic_version="4",
client_library_version="5",
user_agent="app-name/1.0",
protobuf_runtime_version="6",
)

user_agent = info.to_user_agent()

assert user_agent == "app-name/1.0 gl-python/1 grpc/2 gax/3 gapic/4 gccl/5"
assert user_agent == "app-name/1.0 gl-python/1 grpc/2 gax/3 gapic/4 gccl/5 pb/6"


def test_to_user_agent_rest():
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp