Skip to content

Commit dbe8293

Browse files
gcf-owl-bot[bot]parthea
authored andcommitted
feat: enable "rest" transport in Python for services supporting numeric enums (GoogleCloudPlatform#294)
* feat: enable "rest" transport in Python for services supporting numeric enums PiperOrigin-RevId: 508143576 Source-Link: googleapis/googleapis@7a702a9 Source-Link: https://github.com/googleapis/googleapis-gen/commit/6ad1279c0e7aa787ac6b66c9fd4a210692edffcd Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNmFkMTI3OWMwZTdhYTc4N2FjNmI2NmM5ZmQ0YTIxMDY5MmVkZmZjZCJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * use REST transport in samples/tests * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * revert changes to fixtures * revert * revert --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <[email protected]>
1 parent 0253756 commit dbe8293

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

bigquery-connection/snippets/create_mysql_connection.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def main() -> None:
2828
username = "my-username" # set database username
2929
password = "my-password" # set database password
3030
cloud_sql_conn_name = "" # set the name of your connection
31+
transport = "grpc" # Set the transport to either "grpc" or "rest"
3132

3233
cloud_sql_credential = bq_connection.CloudSqlCredential(
3334
{
@@ -43,16 +44,17 @@ def main() -> None:
4344
"credential": cloud_sql_credential,
4445
}
4546
)
46-
create_mysql_connection(project_id, location, cloud_sql_properties)
47+
create_mysql_connection(project_id, location, cloud_sql_properties, transport)
4748

4849

4950
def create_mysql_connection(
5051
project_id: str,
5152
location: str,
5253
cloud_sql_properties: bq_connection.CloudSqlProperties,
54+
transport: str,
5355
) -> None:
5456
connection = bq_connection.types.Connection({"cloud_sql": cloud_sql_properties})
55-
client = bq_connection.ConnectionServiceClient()
57+
client = bq_connection.ConnectionServiceClient(transport=transport)
5658
parent = client.common_location_path(project_id, location)
5759
request = bq_connection.CreateConnectionRequest(
5860
{"parent": parent, "connection": connection}

bigquery-connection/snippets/create_mysql_connection_test.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def connection_id(
5858
pass
5959

6060

61+
@pytest.mark.parametrize("transport", ["grpc", "rest"])
6162
def test_create_mysql_connection(
6263
capsys: pytest.CaptureFixture,
6364
mysql_username: str,
@@ -66,6 +67,7 @@ def test_create_mysql_connection(
6667
cloud_sql_conn_name: str,
6768
project_id: str,
6869
location: str,
70+
transport: str,
6971
) -> None:
7072
cloud_sql_credential = bq_connection.CloudSqlCredential(
7173
{
@@ -85,6 +87,7 @@ def test_create_mysql_connection(
8587
project_id=project_id,
8688
location=location,
8789
cloud_sql_properties=cloud_sql_properties,
90+
transport=transport,
8891
)
8992
out, _ = capsys.readouterr()
9093
assert "Created connection successfully:" in out

bigquery-connection/snippets/quickstart.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717
from google.cloud import bigquery_connection_v1 as bq_connection
1818

1919

20-
def main(project_id: str = "your-project-id", location: str = "US") -> None:
20+
def main(
21+
project_id: str = "your-project-id", location: str = "US", transport: str = "grpc"
22+
) -> None:
2123
"""Prints details and summary information about connections for a given admin project and location"""
22-
client = bq_connection.ConnectionServiceClient()
24+
client = bq_connection.ConnectionServiceClient(transport=transport)
2325
print(f"List of connections in project {project_id} in location {location}")
2426
req = bq_connection.ListConnectionsRequest(
2527
parent=client.common_location_path(project_id, location)

bigquery-connection/snippets/quickstart_test.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717
from . import quickstart
1818

1919

20+
@pytest.mark.parametrize("transport", ["grpc", "rest"])
2021
def test_quickstart(
21-
capsys: pytest.CaptureFixture, project_id: str, location: str
22+
capsys: pytest.CaptureFixture, project_id: str, location: str, transport: str
2223
) -> None:
23-
quickstart.main(project_id, location)
24+
quickstart.main(project_id, location, transport)
2425
out, _ = capsys.readouterr()
2526
assert "List of connections in project" in out

0 commit comments

Comments
 (0)