Skip to content
This repository was archived by the owner on Nov 29, 2023. It is now read-only.

Commit 662e648

Browse files
feat: Location API methods (#324)
* feat: Location API methods docs: updated comments chore: proto formatting PiperOrigin-RevId: 513582719 Source-Link: googleapis/googleapis@822476c Source-Link: https://github.com/googleapis/googleapis-gen/commit/39ca52760199d113b51ad8bdca75cea9e11a9e98 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMzljYTUyNzYwMTk5ZDExM2I1MWFkOGJkY2E3NWNlYTllMTFhOWU5OCJ9 * 🦉 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>
1 parent 19bc444 commit 662e648

File tree

11 files changed

+959
-43
lines changed

11 files changed

+959
-43
lines changed

google/cloud/scheduler_v1/services/cloud_scheduler/async_client.py

Lines changed: 116 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
except AttributeError: # pragma: NO COVER
4343
OptionalRetry = Union[retries.Retry, object] # type: ignore
4444

45+
from google.cloud.location import locations_pb2 # type: ignore
4546
from google.protobuf import duration_pb2 # type: ignore
4647
from google.protobuf import field_mask_pb2 # type: ignore
4748
from google.protobuf import timestamp_pb2 # type: ignore
@@ -285,7 +286,7 @@ async def sample_list_jobs():
285286
Returns:
286287
google.cloud.scheduler_v1.services.cloud_scheduler.pagers.ListJobsAsyncPager:
287288
Response message for listing jobs using
288-
[ListJobs][google.cloud.scheduler.v1.CloudScheduler.ListJobs].
289+
[ListJobs][google.cloud.scheduler.v1.CloudScheduler.ListJobs].
289290
290291
Iterating over this object will yield results and
291292
resolve additional pages automatically.
@@ -410,7 +411,7 @@ async def sample_get_job():
410411
google.cloud.scheduler_v1.types.Job:
411412
Configuration for a job.
412413
The maximum allowed size for a job is
413-
100KB.
414+
1MB.
414415
415416
"""
416417
# Create or coerce a protobuf request object.
@@ -537,7 +538,7 @@ async def sample_create_job():
537538
google.cloud.scheduler_v1.types.Job:
538539
Configuration for a job.
539540
The maximum allowed size for a job is
540-
100KB.
541+
1MB.
541542
542543
"""
543544
# Create or coerce a protobuf request object.
@@ -665,7 +666,7 @@ async def sample_update_job():
665666
google.cloud.scheduler_v1.types.Job:
666667
Configuration for a job.
667668
The maximum allowed size for a job is
668-
100KB.
669+
1MB.
669670
670671
"""
671672
# Create or coerce a protobuf request object.
@@ -882,7 +883,7 @@ async def sample_pause_job():
882883
google.cloud.scheduler_v1.types.Job:
883884
Configuration for a job.
884885
The maximum allowed size for a job is
885-
100KB.
886+
1MB.
886887
887888
"""
888889
# Create or coerce a protobuf request object.
@@ -995,7 +996,7 @@ async def sample_resume_job():
995996
google.cloud.scheduler_v1.types.Job:
996997
Configuration for a job.
997998
The maximum allowed size for a job is
998-
100KB.
999+
1MB.
9991000
10001001
"""
10011002
# Create or coerce a protobuf request object.
@@ -1101,7 +1102,7 @@ async def sample_run_job():
11011102
google.cloud.scheduler_v1.types.Job:
11021103
Configuration for a job.
11031104
The maximum allowed size for a job is
1104-
100KB.
1105+
1MB.
11051106
11061107
"""
11071108
# Create or coerce a protobuf request object.
@@ -1146,6 +1147,114 @@ async def sample_run_job():
11461147
# Done; return the response.
11471148
return response
11481149

1150+
async def get_location(
1151+
self,
1152+
request: Optional[locations_pb2.GetLocationRequest] = None,
1153+
*,
1154+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1155+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1156+
metadata: Sequence[Tuple[str, str]] = (),
1157+
) -> locations_pb2.Location:
1158+
r"""Gets information about a location.
1159+
1160+
Args:
1161+
request (:class:`~.location_pb2.GetLocationRequest`):
1162+
The request object. Request message for
1163+
`GetLocation` method.
1164+
retry (google.api_core.retry.Retry): Designation of what errors,
1165+
if any, should be retried.
1166+
timeout (float): The timeout for this request.
1167+
metadata (Sequence[Tuple[str, str]]): Strings which should be
1168+
sent along with the request as metadata.
1169+
Returns:
1170+
~.location_pb2.Location:
1171+
Location object.
1172+
"""
1173+
# Create or coerce a protobuf request object.
1174+
# The request isn't a proto-plus wrapped type,
1175+
# so it must be constructed via keyword expansion.
1176+
if isinstance(request, dict):
1177+
request = locations_pb2.GetLocationRequest(**request)
1178+
1179+
# Wrap the RPC method; this adds retry and timeout information,
1180+
# and friendly error handling.
1181+
rpc = gapic_v1.method.wrap_method(
1182+
self._client._transport.get_location,
1183+
default_timeout=None,
1184+
client_info=DEFAULT_CLIENT_INFO,
1185+
)
1186+
1187+
# Certain fields should be provided within the metadata header;
1188+
# add these here.
1189+
metadata = tuple(metadata) + (
1190+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1191+
)
1192+
1193+
# Send the request.
1194+
response = await rpc(
1195+
request,
1196+
retry=retry,
1197+
timeout=timeout,
1198+
metadata=metadata,
1199+
)
1200+
1201+
# Done; return the response.
1202+
return response
1203+
1204+
async def list_locations(
1205+
self,
1206+
request: Optional[locations_pb2.ListLocationsRequest] = None,
1207+
*,
1208+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1209+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1210+
metadata: Sequence[Tuple[str, str]] = (),
1211+
) -> locations_pb2.ListLocationsResponse:
1212+
r"""Lists information about the supported locations for this service.
1213+
1214+
Args:
1215+
request (:class:`~.location_pb2.ListLocationsRequest`):
1216+
The request object. Request message for
1217+
`ListLocations` method.
1218+
retry (google.api_core.retry.Retry): Designation of what errors,
1219+
if any, should be retried.
1220+
timeout (float): The timeout for this request.
1221+
metadata (Sequence[Tuple[str, str]]): Strings which should be
1222+
sent along with the request as metadata.
1223+
Returns:
1224+
~.location_pb2.ListLocationsResponse:
1225+
Response message for ``ListLocations`` method.
1226+
"""
1227+
# Create or coerce a protobuf request object.
1228+
# The request isn't a proto-plus wrapped type,
1229+
# so it must be constructed via keyword expansion.
1230+
if isinstance(request, dict):
1231+
request = locations_pb2.ListLocationsRequest(**request)
1232+
1233+
# Wrap the RPC method; this adds retry and timeout information,
1234+
# and friendly error handling.
1235+
rpc = gapic_v1.method.wrap_method(
1236+
self._client._transport.list_locations,
1237+
default_timeout=None,
1238+
client_info=DEFAULT_CLIENT_INFO,
1239+
)
1240+
1241+
# Certain fields should be provided within the metadata header;
1242+
# add these here.
1243+
metadata = tuple(metadata) + (
1244+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1245+
)
1246+
1247+
# Send the request.
1248+
response = await rpc(
1249+
request,
1250+
retry=retry,
1251+
timeout=timeout,
1252+
metadata=metadata,
1253+
)
1254+
1255+
# Done; return the response.
1256+
return response
1257+
11491258
async def __aenter__(self):
11501259
return self
11511260

google/cloud/scheduler_v1/services/cloud_scheduler/client.py

Lines changed: 116 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
except AttributeError: # pragma: NO COVER
4747
OptionalRetry = Union[retries.Retry, object] # type: ignore
4848

49+
from google.cloud.location import locations_pb2 # type: ignore
4950
from google.protobuf import duration_pb2 # type: ignore
5051
from google.protobuf import field_mask_pb2 # type: ignore
5152
from google.protobuf import timestamp_pb2 # type: ignore
@@ -529,7 +530,7 @@ def sample_list_jobs():
529530
Returns:
530531
google.cloud.scheduler_v1.services.cloud_scheduler.pagers.ListJobsPager:
531532
Response message for listing jobs using
532-
[ListJobs][google.cloud.scheduler.v1.CloudScheduler.ListJobs].
533+
[ListJobs][google.cloud.scheduler.v1.CloudScheduler.ListJobs].
533534
534535
Iterating over this object will yield results and
535536
resolve additional pages automatically.
@@ -644,7 +645,7 @@ def sample_get_job():
644645
google.cloud.scheduler_v1.types.Job:
645646
Configuration for a job.
646647
The maximum allowed size for a job is
647-
100KB.
648+
1MB.
648649
649650
"""
650651
# Create or coerce a protobuf request object.
@@ -761,7 +762,7 @@ def sample_create_job():
761762
google.cloud.scheduler_v1.types.Job:
762763
Configuration for a job.
763764
The maximum allowed size for a job is
764-
100KB.
765+
1MB.
765766
766767
"""
767768
# Create or coerce a protobuf request object.
@@ -889,7 +890,7 @@ def sample_update_job():
889890
google.cloud.scheduler_v1.types.Job:
890891
Configuration for a job.
891892
The maximum allowed size for a job is
892-
100KB.
893+
1MB.
893894
894895
"""
895896
# Create or coerce a protobuf request object.
@@ -1096,7 +1097,7 @@ def sample_pause_job():
10961097
google.cloud.scheduler_v1.types.Job:
10971098
Configuration for a job.
10981099
The maximum allowed size for a job is
1099-
100KB.
1100+
1MB.
11001101
11011102
"""
11021103
# Create or coerce a protobuf request object.
@@ -1209,7 +1210,7 @@ def sample_resume_job():
12091210
google.cloud.scheduler_v1.types.Job:
12101211
Configuration for a job.
12111212
The maximum allowed size for a job is
1212-
100KB.
1213+
1MB.
12131214
12141215
"""
12151216
# Create or coerce a protobuf request object.
@@ -1315,7 +1316,7 @@ def sample_run_job():
13151316
google.cloud.scheduler_v1.types.Job:
13161317
Configuration for a job.
13171318
The maximum allowed size for a job is
1318-
100KB.
1319+
1MB.
13191320
13201321
"""
13211322
# Create or coerce a protobuf request object.
@@ -1373,6 +1374,114 @@ def __exit__(self, type, value, traceback):
13731374
"""
13741375
self.transport.close()
13751376

1377+
def get_location(
1378+
self,
1379+
request: Optional[locations_pb2.GetLocationRequest] = None,
1380+
*,
1381+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1382+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1383+
metadata: Sequence[Tuple[str, str]] = (),
1384+
) -> locations_pb2.Location:
1385+
r"""Gets information about a location.
1386+
1387+
Args:
1388+
request (:class:`~.location_pb2.GetLocationRequest`):
1389+
The request object. Request message for
1390+
`GetLocation` method.
1391+
retry (google.api_core.retry.Retry): Designation of what errors,
1392+
if any, should be retried.
1393+
timeout (float): The timeout for this request.
1394+
metadata (Sequence[Tuple[str, str]]): Strings which should be
1395+
sent along with the request as metadata.
1396+
Returns:
1397+
~.location_pb2.Location:
1398+
Location object.
1399+
"""
1400+
# Create or coerce a protobuf request object.
1401+
# The request isn't a proto-plus wrapped type,
1402+
# so it must be constructed via keyword expansion.
1403+
if isinstance(request, dict):
1404+
request = locations_pb2.GetLocationRequest(**request)
1405+
1406+
# Wrap the RPC method; this adds retry and timeout information,
1407+
# and friendly error handling.
1408+
rpc = gapic_v1.method.wrap_method(
1409+
self._transport.get_location,
1410+
default_timeout=None,
1411+
client_info=DEFAULT_CLIENT_INFO,
1412+
)
1413+
1414+
# Certain fields should be provided within the metadata header;
1415+
# add these here.
1416+
metadata = tuple(metadata) + (
1417+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1418+
)
1419+
1420+
# Send the request.
1421+
response = rpc(
1422+
request,
1423+
retry=retry,
1424+
timeout=timeout,
1425+
metadata=metadata,
1426+
)
1427+
1428+
# Done; return the response.
1429+
return response
1430+
1431+
def list_locations(
1432+
self,
1433+
request: Optional[locations_pb2.ListLocationsRequest] = None,
1434+
*,
1435+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1436+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1437+
metadata: Sequence[Tuple[str, str]] = (),
1438+
) -> locations_pb2.ListLocationsResponse:
1439+
r"""Lists information about the supported locations for this service.
1440+
1441+
Args:
1442+
request (:class:`~.location_pb2.ListLocationsRequest`):
1443+
The request object. Request message for
1444+
`ListLocations` method.
1445+
retry (google.api_core.retry.Retry): Designation of what errors,
1446+
if any, should be retried.
1447+
timeout (float): The timeout for this request.
1448+
metadata (Sequence[Tuple[str, str]]): Strings which should be
1449+
sent along with the request as metadata.
1450+
Returns:
1451+
~.location_pb2.ListLocationsResponse:
1452+
Response message for ``ListLocations`` method.
1453+
"""
1454+
# Create or coerce a protobuf request object.
1455+
# The request isn't a proto-plus wrapped type,
1456+
# so it must be constructed via keyword expansion.
1457+
if isinstance(request, dict):
1458+
request = locations_pb2.ListLocationsRequest(**request)
1459+
1460+
# Wrap the RPC method; this adds retry and timeout information,
1461+
# and friendly error handling.
1462+
rpc = gapic_v1.method.wrap_method(
1463+
self._transport.list_locations,
1464+
default_timeout=None,
1465+
client_info=DEFAULT_CLIENT_INFO,
1466+
)
1467+
1468+
# Certain fields should be provided within the metadata header;
1469+
# add these here.
1470+
metadata = tuple(metadata) + (
1471+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1472+
)
1473+
1474+
# Send the request.
1475+
response = rpc(
1476+
request,
1477+
retry=retry,
1478+
timeout=timeout,
1479+
metadata=metadata,
1480+
)
1481+
1482+
# Done; return the response.
1483+
return response
1484+
13761485

13771486
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
13781487
gapic_version=package_version.__version__

0 commit comments

Comments
 (0)