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

Commit 7ad93f1

Browse files
fix(deps): Require google-api-core >=1.34.0, >=2.11.0 (#36)
* 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 <partheniou@google.com>
1 parent 6b22c51 commit 7ad93f1

13 files changed

+60
-60
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.0" # {x-release-please-version}

google/cloud/api_keys_v2/services/api_keys/async_client.py

Lines changed: 18 additions & 22 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.api_keys_v2 import gapic_version as package_version
3839

3940
try:
4041
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
@@ -220,7 +221,7 @@ async def create_key(
220221
key: Optional[resources.Key] = None,
221222
key_id: Optional[str] = None,
222223
retry: OptionalRetry = gapic_v1.method.DEFAULT,
223-
timeout: Optional[float] = None,
224+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
224225
metadata: Sequence[Tuple[str, str]] = (),
225226
) -> operation_async.AsyncOperation:
226227
r"""Creates a new API key.
@@ -253,7 +254,7 @@ async def sample_create_key():
253254
254255
print("Waiting for operation to complete...")
255256
256-
response = await operation.result()
257+
response = (await operation).result()
257258
258259
# Handle the response
259260
print(response)
@@ -367,7 +368,7 @@ async def list_keys(
367368
*,
368369
parent: Optional[str] = None,
369370
retry: OptionalRetry = gapic_v1.method.DEFAULT,
370-
timeout: Optional[float] = None,
371+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
371372
metadata: Sequence[Tuple[str, str]] = (),
372373
) -> pagers.ListKeysAsyncPager:
373374
r"""Lists the API keys owned by a project. The key string of the API
@@ -485,7 +486,7 @@ async def get_key(
485486
*,
486487
name: Optional[str] = None,
487488
retry: OptionalRetry = gapic_v1.method.DEFAULT,
488-
timeout: Optional[float] = None,
489+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
489490
metadata: Sequence[Tuple[str, str]] = (),
490491
) -> resources.Key:
491492
r"""Gets the metadata for an API key. The key string of the API key
@@ -590,7 +591,7 @@ async def get_key_string(
590591
*,
591592
name: Optional[str] = None,
592593
retry: OptionalRetry = gapic_v1.method.DEFAULT,
593-
timeout: Optional[float] = None,
594+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
594595
metadata: Sequence[Tuple[str, str]] = (),
595596
) -> apikeys.GetKeyStringResponse:
596597
r"""Get the key string for an API key.
@@ -694,7 +695,7 @@ async def update_key(
694695
key: Optional[resources.Key] = None,
695696
update_mask: Optional[field_mask_pb2.FieldMask] = None,
696697
retry: OptionalRetry = gapic_v1.method.DEFAULT,
697-
timeout: Optional[float] = None,
698+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
698699
metadata: Sequence[Tuple[str, str]] = (),
699700
) -> operation_async.AsyncOperation:
700701
r"""Patches the modifiable fields of an API key. The key string of
@@ -727,7 +728,7 @@ async def sample_update_key():
727728
728729
print("Waiting for operation to complete...")
729730
730-
response = await operation.result()
731+
response = (await operation).result()
731732
732733
# Handle the response
733734
print(response)
@@ -831,7 +832,7 @@ async def delete_key(
831832
*,
832833
name: Optional[str] = None,
833834
retry: OptionalRetry = gapic_v1.method.DEFAULT,
834-
timeout: Optional[float] = None,
835+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
835836
metadata: Sequence[Tuple[str, str]] = (),
836837
) -> operation_async.AsyncOperation:
837838
r"""Deletes an API key. Deleted key can be retrieved within 30 days
@@ -865,7 +866,7 @@ async def sample_delete_key():
865866
866867
print("Waiting for operation to complete...")
867868
868-
response = await operation.result()
869+
response = (await operation).result()
869870
870871
# Handle the response
871872
print(response)
@@ -951,7 +952,7 @@ async def undelete_key(
951952
request: Optional[Union[apikeys.UndeleteKeyRequest, dict]] = None,
952953
*,
953954
retry: OptionalRetry = gapic_v1.method.DEFAULT,
954-
timeout: Optional[float] = None,
955+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
955956
metadata: Sequence[Tuple[str, str]] = (),
956957
) -> operation_async.AsyncOperation:
957958
r"""Undeletes an API key which was deleted within 30 days.
@@ -984,7 +985,7 @@ async def sample_undelete_key():
984985
985986
print("Waiting for operation to complete...")
986987
987-
response = await operation.result()
988+
response = (await operation).result()
988989
989990
# Handle the response
990991
print(response)
@@ -1049,7 +1050,7 @@ async def lookup_key(
10491050
request: Optional[Union[apikeys.LookupKeyRequest, dict]] = None,
10501051
*,
10511052
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1052-
timeout: Optional[float] = None,
1053+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
10531054
metadata: Sequence[Tuple[str, str]] = (),
10541055
) -> apikeys.LookupKeyResponse:
10551056
r"""Find the parent project and resource name of the API key that
@@ -1125,7 +1126,7 @@ async def get_operation(
11251126
request: Optional[operations_pb2.GetOperationRequest] = None,
11261127
*,
11271128
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1128-
timeout: Optional[float] = None,
1129+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
11291130
metadata: Sequence[Tuple[str, str]] = (),
11301131
) -> operations_pb2.Operation:
11311132
r"""Gets the latest state of a long-running operation.
@@ -1181,14 +1182,9 @@ async def __aexit__(self, exc_type, exc, tb):
11811182
await self.transport.close()
11821183

11831184

1184-
try:
1185-
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
1186-
gapic_version=pkg_resources.get_distribution(
1187-
"google-cloud-api-keys",
1188-
).version,
1189-
)
1190-
except pkg_resources.DistributionNotFound:
1191-
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
1185+
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
1186+
gapic_version=package_version.__version__
1187+
)
11921188

11931189

11941190
__all__ = ("ApiKeysAsyncClient",)

google/cloud/api_keys_v2/services/api_keys/client.py

Lines changed: 14 additions & 18 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.api_keys_v2 import gapic_version as package_version
4243

4344
try:
4445
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
@@ -455,7 +456,7 @@ def create_key(
455456
key: Optional[resources.Key] = None,
456457
key_id: Optional[str] = None,
457458
retry: OptionalRetry = gapic_v1.method.DEFAULT,
458-
timeout: Optional[float] = None,
459+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
459460
metadata: Sequence[Tuple[str, str]] = (),
460461
) -> operation.Operation:
461462
r"""Creates a new API key.
@@ -602,7 +603,7 @@ def list_keys(
602603
*,
603604
parent: Optional[str] = None,
604605
retry: OptionalRetry = gapic_v1.method.DEFAULT,
605-
timeout: Optional[float] = None,
606+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
606607
metadata: Sequence[Tuple[str, str]] = (),
607608
) -> pagers.ListKeysPager:
608609
r"""Lists the API keys owned by a project. The key string of the API
@@ -720,7 +721,7 @@ def get_key(
720721
*,
721722
name: Optional[str] = None,
722723
retry: OptionalRetry = gapic_v1.method.DEFAULT,
723-
timeout: Optional[float] = None,
724+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
724725
metadata: Sequence[Tuple[str, str]] = (),
725726
) -> resources.Key:
726727
r"""Gets the metadata for an API key. The key string of the API key
@@ -825,7 +826,7 @@ def get_key_string(
825826
*,
826827
name: Optional[str] = None,
827828
retry: OptionalRetry = gapic_v1.method.DEFAULT,
828-
timeout: Optional[float] = None,
829+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
829830
metadata: Sequence[Tuple[str, str]] = (),
830831
) -> apikeys.GetKeyStringResponse:
831832
r"""Get the key string for an API key.
@@ -929,7 +930,7 @@ def update_key(
929930
key: Optional[resources.Key] = None,
930931
update_mask: Optional[field_mask_pb2.FieldMask] = None,
931932
retry: OptionalRetry = gapic_v1.method.DEFAULT,
932-
timeout: Optional[float] = None,
933+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
933934
metadata: Sequence[Tuple[str, str]] = (),
934935
) -> operation.Operation:
935936
r"""Patches the modifiable fields of an API key. The key string of
@@ -1066,7 +1067,7 @@ def delete_key(
10661067
*,
10671068
name: Optional[str] = None,
10681069
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1069-
timeout: Optional[float] = None,
1070+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
10701071
metadata: Sequence[Tuple[str, str]] = (),
10711072
) -> operation.Operation:
10721073
r"""Deletes an API key. Deleted key can be retrieved within 30 days
@@ -1186,7 +1187,7 @@ def undelete_key(
11861187
request: Optional[Union[apikeys.UndeleteKeyRequest, dict]] = None,
11871188
*,
11881189
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1189-
timeout: Optional[float] = None,
1190+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
11901191
metadata: Sequence[Tuple[str, str]] = (),
11911192
) -> operation.Operation:
11921193
r"""Undeletes an API key which was deleted within 30 days.
@@ -1285,7 +1286,7 @@ def lookup_key(
12851286
request: Optional[Union[apikeys.LookupKeyRequest, dict]] = None,
12861287
*,
12871288
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1288-
timeout: Optional[float] = None,
1289+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
12891290
metadata: Sequence[Tuple[str, str]] = (),
12901291
) -> apikeys.LookupKeyResponse:
12911292
r"""Find the parent project and resource name of the API key that
@@ -1375,7 +1376,7 @@ def get_operation(
13751376
request: Optional[operations_pb2.GetOperationRequest] = None,
13761377
*,
13771378
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1378-
timeout: Optional[float] = None,
1379+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
13791380
metadata: Sequence[Tuple[str, str]] = (),
13801381
) -> operations_pb2.Operation:
13811382
r"""Gets the latest state of a long-running operation.
@@ -1425,14 +1426,9 @@ def get_operation(
14251426
return response
14261427

14271428

1428-
try:
1429-
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
1430-
gapic_version=pkg_resources.get_distribution(
1431-
"google-cloud-api-keys",
1432-
).version,
1433-
)
1434-
except pkg_resources.DistributionNotFound:
1435-
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
1429+
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
1430+
gapic_version=package_version.__version__
1431+
)
14361432

14371433

14381434
__all__ = ("ApiKeysClient",)

google/cloud/api_keys_v2/services/api_keys/transports/base.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,13 @@
2424
from google.auth import credentials as ga_credentials # type: ignore
2525
from google.longrunning import operations_pb2 # type: ignore
2626
from google.oauth2 import service_account # type: ignore
27-
import pkg_resources
2827

28+
from google.cloud.api_keys_v2 import gapic_version as package_version
2929
from google.cloud.api_keys_v2.types import apikeys, resources
3030

31-
try:
32-
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
33-
gapic_version=pkg_resources.get_distribution(
34-
"google-cloud-api-keys",
35-
).version,
36-
)
37-
except pkg_resources.DistributionNotFound:
38-
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
31+
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
32+
gapic_version=package_version.__version__
33+
)
3934

4035

4136
class ApiKeysTransport(abc.ABC):

google/cloud/api_keys_v2/services/api_keys/transports/rest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,7 @@ def operations_client(self) -> operations_v1.AbstractOperationsClient:
449449
credentials=self._credentials,
450450
scopes=self._scopes,
451451
http_options=http_options,
452+
path_prefix="v2",
452453
)
453454

454455
self._operations_client = operations_v1.AbstractOperationsClient(

release-please-config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"release-type": "python",
66
"extra-files": [
77
"google/cloud/api_keys/gapic_version.py",
8+
"google/cloud/api_keys_v2/gapic_version.py",
89
{
910
"type": "json",
1011
"path": "samples/generated_samples/snippet_metadata_google.api.apikeys.v2.json",

samples/generated_samples/apikeys_v2_generated_api_keys_create_key_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ async def sample_create_key():
4848

4949
print("Waiting for operation to complete...")
5050

51-
response = await operation.result()
51+
response = (await operation).result()
5252

5353
# Handle the response
5454
print(response)

samples/generated_samples/apikeys_v2_generated_api_keys_delete_key_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ async def sample_delete_key():
4848

4949
print("Waiting for operation to complete...")
5050

51-
response = await operation.result()
51+
response = (await operation).result()
5252

5353
# Handle the response
5454
print(response)

samples/generated_samples/apikeys_v2_generated_api_keys_undelete_key_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ async def sample_undelete_key():
4848

4949
print("Waiting for operation to complete...")
5050

51-
response = await operation.result()
51+
response = (await operation).result()
5252

5353
# Handle the response
5454
print(response)

0 commit comments

Comments
 (0)