Skip to content

Commit 6785908

Browse files
gcf-owl-bot[bot]Mariattaparthea
authored
feat: enable "rest" transport in Python for services supporting numeric enums (#419)
* feat: enable "rest" transport in Python for services supporting numeric enums PiperOrigin-RevId: 508143576 Source-Link: googleapis/googleapis@7a702a9 Source-Link: googleapis/googleapis-gen@6ad1279 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNmFkMTI3OWMwZTdhYTc4N2FjNmI2NmM5ZmQ0YTIxMDY5MmVkZmZjZCJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * feat: Add `OR` query support docs: Minor documentation formatting and cleanup PiperOrigin-RevId: 509848726 Source-Link: googleapis/googleapis@b9351b4 Source-Link: googleapis/googleapis-gen@99317db Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiOTkzMTdkYjY4MjcxODVlOGNhZThlZWI0NjEzN2NkODFjZDJkNmE1NCJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * fix: Add service_yaml_parameters to py_gapic_library BUILD.bazel targets PiperOrigin-RevId: 510187992 Source-Link: googleapis/googleapis@5edc235 Source-Link: googleapis/googleapis-gen@b0bedb7 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYjBiZWRiNzJlNDc2NWEzZTBiNjc0YTI4YzUwZWEwZjlhOWIyNmE4OSJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * chore: Update gapic-generator-python to v1.8.5 PiperOrigin-RevId: 511892190 Source-Link: googleapis/googleapis@a45d9c0 Source-Link: googleapis/googleapis-gen@1907294 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMTkwNzI5NGIxZDgzNjVlYTI0ZjhjNWYyZTA1OWE2NDEyNGM0ZWQzYiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Mariatta Wijaya <Mariatta@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <partheniou@google.com>
1 parent a412c62 commit 6785908

File tree

21 files changed

+8855
-632
lines changed

21 files changed

+8855
-632
lines changed

google/cloud/datastore_admin_v1/gapic_metadata.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,41 @@
7676
]
7777
}
7878
}
79+
},
80+
"rest": {
81+
"libraryClient": "DatastoreAdminClient",
82+
"rpcs": {
83+
"CreateIndex": {
84+
"methods": [
85+
"create_index"
86+
]
87+
},
88+
"DeleteIndex": {
89+
"methods": [
90+
"delete_index"
91+
]
92+
},
93+
"ExportEntities": {
94+
"methods": [
95+
"export_entities"
96+
]
97+
},
98+
"GetIndex": {
99+
"methods": [
100+
"get_index"
101+
]
102+
},
103+
"ImportEntities": {
104+
"methods": [
105+
"import_entities"
106+
]
107+
},
108+
"ListIndexes": {
109+
"methods": [
110+
"list_indexes"
111+
]
112+
}
113+
}
79114
}
80115
}
81116
}

google/cloud/datastore_admin_v1/services/datastore_admin/async_client.py

Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
from google.cloud.datastore_admin_v1.services.datastore_admin import pagers
4848
from google.cloud.datastore_admin_v1.types import datastore_admin
4949
from google.cloud.datastore_admin_v1.types import index
50+
from google.longrunning import operations_pb2
5051
from google.protobuf import empty_pb2 # type: ignore
5152
from .transports.base import DatastoreAdminTransport, DEFAULT_CLIENT_INFO
5253
from .transports.grpc_asyncio import DatastoreAdminGrpcAsyncIOTransport
@@ -1054,6 +1055,223 @@ async def sample_list_indexes():
10541055
# Done; return the response.
10551056
return response
10561057

1058+
async def list_operations(
1059+
self,
1060+
request: Optional[operations_pb2.ListOperationsRequest] = None,
1061+
*,
1062+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1063+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1064+
metadata: Sequence[Tuple[str, str]] = (),
1065+
) -> operations_pb2.ListOperationsResponse:
1066+
r"""Lists operations that match the specified filter in the request.
1067+
1068+
Args:
1069+
request (:class:`~.operations_pb2.ListOperationsRequest`):
1070+
The request object. Request message for
1071+
`ListOperations` method.
1072+
retry (google.api_core.retry.Retry): Designation of what errors,
1073+
if any, should be retried.
1074+
timeout (float): The timeout for this request.
1075+
metadata (Sequence[Tuple[str, str]]): Strings which should be
1076+
sent along with the request as metadata.
1077+
Returns:
1078+
~.operations_pb2.ListOperationsResponse:
1079+
Response message for ``ListOperations`` method.
1080+
"""
1081+
# Create or coerce a protobuf request object.
1082+
# The request isn't a proto-plus wrapped type,
1083+
# so it must be constructed via keyword expansion.
1084+
if isinstance(request, dict):
1085+
request = operations_pb2.ListOperationsRequest(**request)
1086+
1087+
# Wrap the RPC method; this adds retry and timeout information,
1088+
# and friendly error handling.
1089+
rpc = gapic_v1.method.wrap_method(
1090+
self._client._transport.list_operations,
1091+
default_timeout=None,
1092+
client_info=DEFAULT_CLIENT_INFO,
1093+
)
1094+
1095+
# Certain fields should be provided within the metadata header;
1096+
# add these here.
1097+
metadata = tuple(metadata) + (
1098+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1099+
)
1100+
1101+
# Send the request.
1102+
response = await rpc(
1103+
request,
1104+
retry=retry,
1105+
timeout=timeout,
1106+
metadata=metadata,
1107+
)
1108+
1109+
# Done; return the response.
1110+
return response
1111+
1112+
async def get_operation(
1113+
self,
1114+
request: Optional[operations_pb2.GetOperationRequest] = None,
1115+
*,
1116+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1117+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1118+
metadata: Sequence[Tuple[str, str]] = (),
1119+
) -> operations_pb2.Operation:
1120+
r"""Gets the latest state of a long-running operation.
1121+
1122+
Args:
1123+
request (:class:`~.operations_pb2.GetOperationRequest`):
1124+
The request object. Request message for
1125+
`GetOperation` method.
1126+
retry (google.api_core.retry.Retry): Designation of what errors,
1127+
if any, should be retried.
1128+
timeout (float): The timeout for this request.
1129+
metadata (Sequence[Tuple[str, str]]): Strings which should be
1130+
sent along with the request as metadata.
1131+
Returns:
1132+
~.operations_pb2.Operation:
1133+
An ``Operation`` object.
1134+
"""
1135+
# Create or coerce a protobuf request object.
1136+
# The request isn't a proto-plus wrapped type,
1137+
# so it must be constructed via keyword expansion.
1138+
if isinstance(request, dict):
1139+
request = operations_pb2.GetOperationRequest(**request)
1140+
1141+
# Wrap the RPC method; this adds retry and timeout information,
1142+
# and friendly error handling.
1143+
rpc = gapic_v1.method.wrap_method(
1144+
self._client._transport.get_operation,
1145+
default_timeout=None,
1146+
client_info=DEFAULT_CLIENT_INFO,
1147+
)
1148+
1149+
# Certain fields should be provided within the metadata header;
1150+
# add these here.
1151+
metadata = tuple(metadata) + (
1152+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1153+
)
1154+
1155+
# Send the request.
1156+
response = await rpc(
1157+
request,
1158+
retry=retry,
1159+
timeout=timeout,
1160+
metadata=metadata,
1161+
)
1162+
1163+
# Done; return the response.
1164+
return response
1165+
1166+
async def delete_operation(
1167+
self,
1168+
request: Optional[operations_pb2.DeleteOperationRequest] = None,
1169+
*,
1170+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1171+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1172+
metadata: Sequence[Tuple[str, str]] = (),
1173+
) -> None:
1174+
r"""Deletes a long-running operation.
1175+
1176+
This method indicates that the client is no longer interested
1177+
in the operation result. It does not cancel the operation.
1178+
If the server doesn't support this method, it returns
1179+
`google.rpc.Code.UNIMPLEMENTED`.
1180+
1181+
Args:
1182+
request (:class:`~.operations_pb2.DeleteOperationRequest`):
1183+
The request object. Request message for
1184+
`DeleteOperation` method.
1185+
retry (google.api_core.retry.Retry): Designation of what errors,
1186+
if any, should be retried.
1187+
timeout (float): The timeout for this request.
1188+
metadata (Sequence[Tuple[str, str]]): Strings which should be
1189+
sent along with the request as metadata.
1190+
Returns:
1191+
None
1192+
"""
1193+
# Create or coerce a protobuf request object.
1194+
# The request isn't a proto-plus wrapped type,
1195+
# so it must be constructed via keyword expansion.
1196+
if isinstance(request, dict):
1197+
request = operations_pb2.DeleteOperationRequest(**request)
1198+
1199+
# Wrap the RPC method; this adds retry and timeout information,
1200+
# and friendly error handling.
1201+
rpc = gapic_v1.method.wrap_method(
1202+
self._client._transport.delete_operation,
1203+
default_timeout=None,
1204+
client_info=DEFAULT_CLIENT_INFO,
1205+
)
1206+
1207+
# Certain fields should be provided within the metadata header;
1208+
# add these here.
1209+
metadata = tuple(metadata) + (
1210+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1211+
)
1212+
1213+
# Send the request.
1214+
await rpc(
1215+
request,
1216+
retry=retry,
1217+
timeout=timeout,
1218+
metadata=metadata,
1219+
)
1220+
1221+
async def cancel_operation(
1222+
self,
1223+
request: Optional[operations_pb2.CancelOperationRequest] = None,
1224+
*,
1225+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1226+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1227+
metadata: Sequence[Tuple[str, str]] = (),
1228+
) -> None:
1229+
r"""Starts asynchronous cancellation on a long-running operation.
1230+
1231+
The server makes a best effort to cancel the operation, but success
1232+
is not guaranteed. If the server doesn't support this method, it returns
1233+
`google.rpc.Code.UNIMPLEMENTED`.
1234+
1235+
Args:
1236+
request (:class:`~.operations_pb2.CancelOperationRequest`):
1237+
The request object. Request message for
1238+
`CancelOperation` method.
1239+
retry (google.api_core.retry.Retry): Designation of what errors,
1240+
if any, should be retried.
1241+
timeout (float): The timeout for this request.
1242+
metadata (Sequence[Tuple[str, str]]): Strings which should be
1243+
sent along with the request as metadata.
1244+
Returns:
1245+
None
1246+
"""
1247+
# Create or coerce a protobuf request object.
1248+
# The request isn't a proto-plus wrapped type,
1249+
# so it must be constructed via keyword expansion.
1250+
if isinstance(request, dict):
1251+
request = operations_pb2.CancelOperationRequest(**request)
1252+
1253+
# Wrap the RPC method; this adds retry and timeout information,
1254+
# and friendly error handling.
1255+
rpc = gapic_v1.method.wrap_method(
1256+
self._client._transport.cancel_operation,
1257+
default_timeout=None,
1258+
client_info=DEFAULT_CLIENT_INFO,
1259+
)
1260+
1261+
# Certain fields should be provided within the metadata header;
1262+
# add these here.
1263+
metadata = tuple(metadata) + (
1264+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1265+
)
1266+
1267+
# Send the request.
1268+
await rpc(
1269+
request,
1270+
retry=retry,
1271+
timeout=timeout,
1272+
metadata=metadata,
1273+
)
1274+
10571275
async def __aenter__(self):
10581276
return self
10591277

0 commit comments

Comments
 (0)