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

Commit 1b70819

Browse files
fix(deps): Require google-api-core >=1.34.0, >=2.11.0 (#78)
* fix(deps): Require google-api-core >=1.34.0, >=2.11.0 fix: Drop usage of pkg_resources fix: Fix timeout default values docs(samples): Snippetgen should call await on the operation coroutine before calling result PiperOrigin-RevId: 493260409 Source-Link: googleapis/googleapis@fea4387 Source-Link: https://github.com/googleapis/googleapis-gen/commit/387b7344c7529ee44be84e613b19a820508c612b Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMzg3YjczNDRjNzUyOWVlNDRiZTg0ZTYxM2IxOWE4MjA1MDhjNjEyYiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * add gapic_version.py Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <[email protected]>
1 parent 0bd2542 commit 1b70819

File tree

16 files changed

+130
-125
lines changed

16 files changed

+130
-125
lines changed

.coveragerc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,3 @@ exclude_lines =
1010
pragma: NO COVER
1111
# Ignore debug-only repr
1212
def __repr__
13-
# Ignore pkg_resources exceptions.
14-
# This is added at the module level as a safeguard for if someone
15-
# generates the code and tries to run it without pip installing. This
16-
# makes it virtually impossible to test properly.
17-
except pkg_resources.DistributionNotFound
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2022 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
__version__ = "0.4.1" # {x-release-please-version}

google/cloud/batch_v1/services/batch_service/async_client.py

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
from google.api_core.client_options import ClientOptions
3535
from google.auth import credentials as ga_credentials # type: ignore
3636
from google.oauth2 import service_account # type: ignore
37-
import pkg_resources
37+
38+
from google.cloud.batch_v1 import gapic_version as package_version
3839

3940
try:
4041
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
@@ -236,7 +237,7 @@ async def create_job(
236237
job: Optional[gcb_job.Job] = None,
237238
job_id: Optional[str] = None,
238239
retry: OptionalRetry = gapic_v1.method.DEFAULT,
239-
timeout: Optional[float] = None,
240+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
240241
metadata: Sequence[Tuple[str, str]] = (),
241242
) -> gcb_job.Job:
242243
r"""Create a Job.
@@ -360,7 +361,7 @@ async def get_job(
360361
*,
361362
name: Optional[str] = None,
362363
retry: OptionalRetry = gapic_v1.method.DEFAULT,
363-
timeout: Optional[float] = None,
364+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
364365
metadata: Sequence[Tuple[str, str]] = (),
365366
) -> job.Job:
366367
r"""Get a Job specified by its resource name.
@@ -466,7 +467,7 @@ async def delete_job(
466467
*,
467468
name: Optional[str] = None,
468469
retry: OptionalRetry = gapic_v1.method.DEFAULT,
469-
timeout: Optional[float] = None,
470+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
470471
metadata: Sequence[Tuple[str, str]] = (),
471472
) -> operation_async.AsyncOperation:
472473
r"""Delete a Job.
@@ -495,7 +496,7 @@ async def sample_delete_job():
495496
496497
print("Waiting for operation to complete...")
497498
498-
response = await operation.result()
499+
response = (await operation).result()
499500
500501
# Handle the response
501502
print(response)
@@ -586,7 +587,7 @@ async def list_jobs(
586587
*,
587588
parent: Optional[str] = None,
588589
retry: OptionalRetry = gapic_v1.method.DEFAULT,
589-
timeout: Optional[float] = None,
590+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
590591
metadata: Sequence[Tuple[str, str]] = (),
591592
) -> pagers.ListJobsAsyncPager:
592593
r"""List all Jobs for a project within a region.
@@ -705,7 +706,7 @@ async def get_task(
705706
*,
706707
name: Optional[str] = None,
707708
retry: OptionalRetry = gapic_v1.method.DEFAULT,
708-
timeout: Optional[float] = None,
709+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
709710
metadata: Sequence[Tuple[str, str]] = (),
710711
) -> task.Task:
711712
r"""Return a single Task.
@@ -811,7 +812,7 @@ async def list_tasks(
811812
*,
812813
parent: Optional[str] = None,
813814
retry: OptionalRetry = gapic_v1.method.DEFAULT,
814-
timeout: Optional[float] = None,
815+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
815816
metadata: Sequence[Tuple[str, str]] = (),
816817
) -> pagers.ListTasksAsyncPager:
817818
r"""List Tasks associated with a job.
@@ -933,7 +934,7 @@ async def list_operations(
933934
request: Optional[operations_pb2.ListOperationsRequest] = None,
934935
*,
935936
retry: OptionalRetry = gapic_v1.method.DEFAULT,
936-
timeout: Optional[float] = None,
937+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
937938
metadata: Sequence[Tuple[str, str]] = (),
938939
) -> operations_pb2.ListOperationsResponse:
939940
r"""Lists operations that match the specified filter in the request.
@@ -987,7 +988,7 @@ async def get_operation(
987988
request: Optional[operations_pb2.GetOperationRequest] = None,
988989
*,
989990
retry: OptionalRetry = gapic_v1.method.DEFAULT,
990-
timeout: Optional[float] = None,
991+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
991992
metadata: Sequence[Tuple[str, str]] = (),
992993
) -> operations_pb2.Operation:
993994
r"""Gets the latest state of a long-running operation.
@@ -1041,7 +1042,7 @@ async def delete_operation(
10411042
request: Optional[operations_pb2.DeleteOperationRequest] = None,
10421043
*,
10431044
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1044-
timeout: Optional[float] = None,
1045+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
10451046
metadata: Sequence[Tuple[str, str]] = (),
10461047
) -> None:
10471048
r"""Deletes a long-running operation.
@@ -1096,7 +1097,7 @@ async def cancel_operation(
10961097
request: Optional[operations_pb2.CancelOperationRequest] = None,
10971098
*,
10981099
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1099-
timeout: Optional[float] = None,
1100+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
11001101
metadata: Sequence[Tuple[str, str]] = (),
11011102
) -> None:
11021103
r"""Starts asynchronous cancellation on a long-running operation.
@@ -1150,7 +1151,7 @@ async def set_iam_policy(
11501151
request: Optional[iam_policy_pb2.SetIamPolicyRequest] = None,
11511152
*,
11521153
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1153-
timeout: Optional[float] = None,
1154+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
11541155
metadata: Sequence[Tuple[str, str]] = (),
11551156
) -> policy_pb2.Policy:
11561157
r"""Sets the IAM access control policy on the specified function.
@@ -1270,7 +1271,7 @@ async def get_iam_policy(
12701271
request: Optional[iam_policy_pb2.GetIamPolicyRequest] = None,
12711272
*,
12721273
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1273-
timeout: Optional[float] = None,
1274+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
12741275
metadata: Sequence[Tuple[str, str]] = (),
12751276
) -> policy_pb2.Policy:
12761277
r"""Gets the IAM access control policy for a function.
@@ -1391,7 +1392,7 @@ async def test_iam_permissions(
13911392
request: Optional[iam_policy_pb2.TestIamPermissionsRequest] = None,
13921393
*,
13931394
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1394-
timeout: Optional[float] = None,
1395+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
13951396
metadata: Sequence[Tuple[str, str]] = (),
13961397
) -> iam_policy_pb2.TestIamPermissionsResponse:
13971398
r"""Tests the specified IAM permissions against the IAM access control
@@ -1450,7 +1451,7 @@ async def get_location(
14501451
request: Optional[locations_pb2.GetLocationRequest] = None,
14511452
*,
14521453
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1453-
timeout: Optional[float] = None,
1454+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
14541455
metadata: Sequence[Tuple[str, str]] = (),
14551456
) -> locations_pb2.Location:
14561457
r"""Gets information about a location.
@@ -1504,7 +1505,7 @@ async def list_locations(
15041505
request: Optional[locations_pb2.ListLocationsRequest] = None,
15051506
*,
15061507
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1507-
timeout: Optional[float] = None,
1508+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
15081509
metadata: Sequence[Tuple[str, str]] = (),
15091510
) -> locations_pb2.ListLocationsResponse:
15101511
r"""Lists information about the supported locations for this service.
@@ -1560,14 +1561,9 @@ async def __aexit__(self, exc_type, exc, tb):
15601561
await self.transport.close()
15611562

15621563

1563-
try:
1564-
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
1565-
gapic_version=pkg_resources.get_distribution(
1566-
"google-cloud-batch",
1567-
).version,
1568-
)
1569-
except pkg_resources.DistributionNotFound:
1570-
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
1564+
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
1565+
gapic_version=package_version.__version__
1566+
)
15711567

15721568

15731569
__all__ = ("BatchServiceAsyncClient",)

google/cloud/batch_v1/services/batch_service/client.py

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
from google.auth.transport import mtls # type: ignore
3939
from google.auth.transport.grpc import SslCredentials # type: ignore
4040
from google.oauth2 import service_account # type: ignore
41-
import pkg_resources
41+
42+
from google.cloud.batch_v1 import gapic_version as package_version
4243

4344
try:
4445
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
@@ -513,7 +514,7 @@ def create_job(
513514
job: Optional[gcb_job.Job] = None,
514515
job_id: Optional[str] = None,
515516
retry: OptionalRetry = gapic_v1.method.DEFAULT,
516-
timeout: Optional[float] = None,
517+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
517518
metadata: Sequence[Tuple[str, str]] = (),
518519
) -> gcb_job.Job:
519520
r"""Create a Job.
@@ -637,7 +638,7 @@ def get_job(
637638
*,
638639
name: Optional[str] = None,
639640
retry: OptionalRetry = gapic_v1.method.DEFAULT,
640-
timeout: Optional[float] = None,
641+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
641642
metadata: Sequence[Tuple[str, str]] = (),
642643
) -> job.Job:
643644
r"""Get a Job specified by its resource name.
@@ -734,7 +735,7 @@ def delete_job(
734735
*,
735736
name: Optional[str] = None,
736737
retry: OptionalRetry = gapic_v1.method.DEFAULT,
737-
timeout: Optional[float] = None,
738+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
738739
metadata: Sequence[Tuple[str, str]] = (),
739740
) -> operation.Operation:
740741
r"""Delete a Job.
@@ -854,7 +855,7 @@ def list_jobs(
854855
*,
855856
parent: Optional[str] = None,
856857
retry: OptionalRetry = gapic_v1.method.DEFAULT,
857-
timeout: Optional[float] = None,
858+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
858859
metadata: Sequence[Tuple[str, str]] = (),
859860
) -> pagers.ListJobsPager:
860861
r"""List all Jobs for a project within a region.
@@ -964,7 +965,7 @@ def get_task(
964965
*,
965966
name: Optional[str] = None,
966967
retry: OptionalRetry = gapic_v1.method.DEFAULT,
967-
timeout: Optional[float] = None,
968+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
968969
metadata: Sequence[Tuple[str, str]] = (),
969970
) -> task.Task:
970971
r"""Return a single Task.
@@ -1061,7 +1062,7 @@ def list_tasks(
10611062
*,
10621063
parent: Optional[str] = None,
10631064
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1064-
timeout: Optional[float] = None,
1065+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
10651066
metadata: Sequence[Tuple[str, str]] = (),
10661067
) -> pagers.ListTasksPager:
10671068
r"""List Tasks associated with a job.
@@ -1187,7 +1188,7 @@ def list_operations(
11871188
request: Optional[operations_pb2.ListOperationsRequest] = None,
11881189
*,
11891190
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1190-
timeout: Optional[float] = None,
1191+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
11911192
metadata: Sequence[Tuple[str, str]] = (),
11921193
) -> operations_pb2.ListOperationsResponse:
11931194
r"""Lists operations that match the specified filter in the request.
@@ -1241,7 +1242,7 @@ def get_operation(
12411242
request: Optional[operations_pb2.GetOperationRequest] = None,
12421243
*,
12431244
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1244-
timeout: Optional[float] = None,
1245+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
12451246
metadata: Sequence[Tuple[str, str]] = (),
12461247
) -> operations_pb2.Operation:
12471248
r"""Gets the latest state of a long-running operation.
@@ -1295,7 +1296,7 @@ def delete_operation(
12951296
request: Optional[operations_pb2.DeleteOperationRequest] = None,
12961297
*,
12971298
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1298-
timeout: Optional[float] = None,
1299+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
12991300
metadata: Sequence[Tuple[str, str]] = (),
13001301
) -> None:
13011302
r"""Deletes a long-running operation.
@@ -1350,7 +1351,7 @@ def cancel_operation(
13501351
request: Optional[operations_pb2.CancelOperationRequest] = None,
13511352
*,
13521353
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1353-
timeout: Optional[float] = None,
1354+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
13541355
metadata: Sequence[Tuple[str, str]] = (),
13551356
) -> None:
13561357
r"""Starts asynchronous cancellation on a long-running operation.
@@ -1404,7 +1405,7 @@ def set_iam_policy(
14041405
request: Optional[iam_policy_pb2.SetIamPolicyRequest] = None,
14051406
*,
14061407
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1407-
timeout: Optional[float] = None,
1408+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
14081409
metadata: Sequence[Tuple[str, str]] = (),
14091410
) -> policy_pb2.Policy:
14101411
r"""Sets the IAM access control policy on the specified function.
@@ -1524,7 +1525,7 @@ def get_iam_policy(
15241525
request: Optional[iam_policy_pb2.GetIamPolicyRequest] = None,
15251526
*,
15261527
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1527-
timeout: Optional[float] = None,
1528+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
15281529
metadata: Sequence[Tuple[str, str]] = (),
15291530
) -> policy_pb2.Policy:
15301531
r"""Gets the IAM access control policy for a function.
@@ -1645,7 +1646,7 @@ def test_iam_permissions(
16451646
request: Optional[iam_policy_pb2.TestIamPermissionsRequest] = None,
16461647
*,
16471648
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1648-
timeout: Optional[float] = None,
1649+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
16491650
metadata: Sequence[Tuple[str, str]] = (),
16501651
) -> iam_policy_pb2.TestIamPermissionsResponse:
16511652
r"""Tests the specified IAM permissions against the IAM access control
@@ -1704,7 +1705,7 @@ def get_location(
17041705
request: Optional[locations_pb2.GetLocationRequest] = None,
17051706
*,
17061707
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1707-
timeout: Optional[float] = None,
1708+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
17081709
metadata: Sequence[Tuple[str, str]] = (),
17091710
) -> locations_pb2.Location:
17101711
r"""Gets information about a location.
@@ -1758,7 +1759,7 @@ def list_locations(
17581759
request: Optional[locations_pb2.ListLocationsRequest] = None,
17591760
*,
17601761
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1761-
timeout: Optional[float] = None,
1762+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
17621763
metadata: Sequence[Tuple[str, str]] = (),
17631764
) -> locations_pb2.ListLocationsResponse:
17641765
r"""Lists information about the supported locations for this service.
@@ -1808,14 +1809,9 @@ def list_locations(
18081809
return response
18091810

18101811

1811-
try:
1812-
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
1813-
gapic_version=pkg_resources.get_distribution(
1814-
"google-cloud-batch",
1815-
).version,
1816-
)
1817-
except pkg_resources.DistributionNotFound:
1818-
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
1812+
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
1813+
gapic_version=package_version.__version__
1814+
)
18191815

18201816

18211817
__all__ = ("BatchServiceClient",)

google/cloud/batch_v1/services/batch_service/transports/base.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,16 @@
2727
from google.iam.v1 import policy_pb2 # type: ignore
2828
from google.longrunning import operations_pb2 # type: ignore
2929
from google.oauth2 import service_account # type: ignore
30-
import pkg_resources
3130

31+
from google.cloud.batch_v1 import gapic_version as package_version
3232
from google.cloud.batch_v1.types import batch
3333
from google.cloud.batch_v1.types import job
3434
from google.cloud.batch_v1.types import job as gcb_job
3535
from google.cloud.batch_v1.types import task
3636

37-
try:
38-
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
39-
gapic_version=pkg_resources.get_distribution(
40-
"google-cloud-batch",
41-
).version,
42-
)
43-
except pkg_resources.DistributionNotFound:
44-
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
37+
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
38+
gapic_version=package_version.__version__
39+
)
4540

4641

4742
class BatchServiceTransport(abc.ABC):

google/cloud/batch_v1/services/batch_service/transports/rest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,7 @@ def operations_client(self) -> operations_v1.AbstractOperationsClient:
600600
credentials=self._credentials,
601601
scopes=self._scopes,
602602
http_options=http_options,
603+
path_prefix="v1",
603604
)
604605

605606
self._operations_client = operations_v1.AbstractOperationsClient(

0 commit comments

Comments
 (0)