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

Commit ce8c731

Browse files
chore: Use gapic-generator-python 0.65.0 (#57)
- [ ] Regenerate this pull request now. PiperOrigin-RevId: 440970084 Source-Link: googleapis/googleapis@5e0a3d5 Source-Link: https://github.com/googleapis/googleapis-gen/commit/b0c628a3fade768f225d76992791ea1ba2a881be Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYjBjNjI4YTNmYWRlNzY4ZjIyNWQ3Njk5Mjc5MWVhMWJhMmE4ODFiZSJ9 docs: fix type in docstring for map fields
1 parent a3d2728 commit ce8c731

File tree

6 files changed

+91
-41
lines changed

6 files changed

+91
-41
lines changed

google/cloud/filestore_v1/services/cloud_filestore_manager/async_client.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from collections import OrderedDict
1717
import functools
1818
import re
19-
from typing import Dict, Optional, Sequence, Tuple, Type, Union
19+
from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union
2020
import pkg_resources
2121

2222
from google.api_core.client_options import ClientOptions
@@ -249,7 +249,6 @@ async def list_instances(
249249
r"""Lists all instances in a project for either a
250250
specified location or for all locations.
251251
252-
253252
.. code-block:: python
254253
255254
from google.cloud import filestore_v1
@@ -326,7 +325,7 @@ def sample_list_instances():
326325
maximum=32.0,
327326
multiplier=1.3,
328327
predicate=retries.if_exception_type(
329-
core_exceptions.ServiceUnavailable,
328+
core_exceptions.GoogleAPICallError,
330329
),
331330
deadline=60.0,
332331
),
@@ -437,7 +436,7 @@ def sample_get_instance():
437436
maximum=32.0,
438437
multiplier=1.3,
439438
predicate=retries.if_exception_type(
440-
core_exceptions.ServiceUnavailable,
439+
core_exceptions.GoogleAPICallError,
441440
),
442441
deadline=60.0,
443442
),
@@ -479,7 +478,6 @@ async def create_instance(
479478
capacity of the backup (and also equal to or larger than
480479
the minimum capacity of the tier).
481480
482-
483481
.. code-block:: python
484482
485483
from google.cloud import filestore_v1
@@ -739,7 +737,6 @@ async def restore_instance(
739737
larger than the capacity of the backup (and also equal
740738
to or larger than the minimum capacity of the tier).
741739
742-
743740
.. code-block:: python
744741
745742
from google.cloud import filestore_v1
@@ -952,7 +949,6 @@ async def list_backups(
952949
r"""Lists all backups in a project for either a specified
953950
location or for all locations.
954951
955-
956952
.. code-block:: python
957953
958954
from google.cloud import filestore_v1
@@ -1028,7 +1024,7 @@ def sample_list_backups():
10281024
maximum=32.0,
10291025
multiplier=1.3,
10301026
predicate=retries.if_exception_type(
1031-
core_exceptions.ServiceUnavailable,
1027+
core_exceptions.GoogleAPICallError,
10321028
),
10331029
deadline=60.0,
10341030
),
@@ -1139,7 +1135,7 @@ def sample_get_backup():
11391135
maximum=32.0,
11401136
multiplier=1.3,
11411137
predicate=retries.if_exception_type(
1142-
core_exceptions.ServiceUnavailable,
1138+
core_exceptions.GoogleAPICallError,
11431139
),
11441140
deadline=60.0,
11451141
),

google/cloud/filestore_v1/services/cloud_filestore_manager/client.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from collections import OrderedDict
1717
import os
1818
import re
19-
from typing import Dict, Optional, Sequence, Tuple, Type, Union
19+
from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union
2020
import pkg_resources
2121

2222
from google.api_core import client_options as client_options_lib
@@ -490,7 +490,6 @@ def list_instances(
490490
r"""Lists all instances in a project for either a
491491
specified location or for all locations.
492492
493-
494493
.. code-block:: python
495494
496495
from google.cloud import filestore_v1
@@ -702,7 +701,6 @@ def create_instance(
702701
capacity of the backup (and also equal to or larger than
703702
the minimum capacity of the tier).
704703
705-
706704
.. code-block:: python
707705
708706
from google.cloud import filestore_v1
@@ -962,7 +960,6 @@ def restore_instance(
962960
larger than the capacity of the backup (and also equal
963961
to or larger than the minimum capacity of the tier).
964962
965-
966963
.. code-block:: python
967964
968965
from google.cloud import filestore_v1
@@ -1176,7 +1173,6 @@ def list_backups(
11761173
r"""Lists all backups in a project for either a specified
11771174
location or for all locations.
11781175
1179-
11801176
.. code-block:: python
11811177
11821178
from google.cloud import filestore_v1

google/cloud/filestore_v1/services/cloud_filestore_manager/transports/base.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ def __init__(
8282
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
8383
be used for service account credentials.
8484
"""
85+
8586
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
8687
if ":" not in host:
8788
host += ":443"
@@ -129,7 +130,7 @@ def _prep_wrapped_messages(self, client_info):
129130
maximum=32.0,
130131
multiplier=1.3,
131132
predicate=retries.if_exception_type(
132-
core_exceptions.ServiceUnavailable,
133+
core_exceptions.GoogleAPICallError,
133134
),
134135
deadline=60.0,
135136
),
@@ -143,7 +144,7 @@ def _prep_wrapped_messages(self, client_info):
143144
maximum=32.0,
144145
multiplier=1.3,
145146
predicate=retries.if_exception_type(
146-
core_exceptions.ServiceUnavailable,
147+
core_exceptions.GoogleAPICallError,
147148
),
148149
deadline=60.0,
149150
),
@@ -177,7 +178,7 @@ def _prep_wrapped_messages(self, client_info):
177178
maximum=32.0,
178179
multiplier=1.3,
179180
predicate=retries.if_exception_type(
180-
core_exceptions.ServiceUnavailable,
181+
core_exceptions.GoogleAPICallError,
181182
),
182183
deadline=60.0,
183184
),
@@ -191,7 +192,7 @@ def _prep_wrapped_messages(self, client_info):
191192
maximum=32.0,
192193
multiplier=1.3,
193194
predicate=retries.if_exception_type(
194-
core_exceptions.ServiceUnavailable,
195+
core_exceptions.GoogleAPICallError,
195196
),
196197
deadline=60.0,
197198
),
@@ -339,5 +340,9 @@ def update_backup(
339340
]:
340341
raise NotImplementedError()
341342

343+
@property
344+
def kind(self) -> str:
345+
raise NotImplementedError()
346+
342347

343348
__all__ = ("CloudFilestoreManagerTransport",)

google/cloud/filestore_v1/services/cloud_filestore_manager/transports/grpc.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,5 +589,9 @@ def update_backup(
589589
def close(self):
590590
self.grpc_channel.close()
591591

592+
@property
593+
def kind(self) -> str:
594+
return "grpc"
595+
592596

593597
__all__ = ("CloudFilestoreManagerGrpcTransport",)

google/cloud/filestore_v1/types/cloud_filestore_service.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ class Instance(proto.Message):
230230
created.
231231
tier (google.cloud.filestore_v1.types.Instance.Tier):
232232
The service tier of the instance.
233-
labels (Sequence[google.cloud.filestore_v1.types.Instance.LabelsEntry]):
233+
labels (Mapping[str, str]):
234234
Resource labels to represent user provided
235235
metadata.
236236
file_shares (Sequence[google.cloud.filestore_v1.types.FileShareConfig]):
@@ -550,7 +550,7 @@ class Backup(proto.Message):
550550
create_time (google.protobuf.timestamp_pb2.Timestamp):
551551
Output only. The time when the backup was
552552
created.
553-
labels (Sequence[google.cloud.filestore_v1.types.Backup.LabelsEntry]):
553+
labels (Mapping[str, str]):
554554
Resource labels to represent user provided
555555
metadata.
556556
capacity_gb (int):

tests/unit/gapic/filestore_v1/test_cloud_filestore_manager.py

Lines changed: 70 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -99,24 +99,26 @@ def test__get_default_mtls_endpoint():
9999

100100

101101
@pytest.mark.parametrize(
102-
"client_class",
102+
"client_class,transport_name",
103103
[
104-
CloudFilestoreManagerClient,
105-
CloudFilestoreManagerAsyncClient,
104+
(CloudFilestoreManagerClient, "grpc"),
105+
(CloudFilestoreManagerAsyncClient, "grpc_asyncio"),
106106
],
107107
)
108-
def test_cloud_filestore_manager_client_from_service_account_info(client_class):
108+
def test_cloud_filestore_manager_client_from_service_account_info(
109+
client_class, transport_name
110+
):
109111
creds = ga_credentials.AnonymousCredentials()
110112
with mock.patch.object(
111113
service_account.Credentials, "from_service_account_info"
112114
) as factory:
113115
factory.return_value = creds
114116
info = {"valid": True}
115-
client = client_class.from_service_account_info(info)
117+
client = client_class.from_service_account_info(info, transport=transport_name)
116118
assert client.transport._credentials == creds
117119
assert isinstance(client, client_class)
118120

119-
assert client.transport._host == "file.googleapis.com:443"
121+
assert client.transport._host == ("file.googleapis.com:443")
120122

121123

122124
@pytest.mark.parametrize(
@@ -145,27 +147,33 @@ def test_cloud_filestore_manager_client_service_account_always_use_jwt(
145147

146148

147149
@pytest.mark.parametrize(
148-
"client_class",
150+
"client_class,transport_name",
149151
[
150-
CloudFilestoreManagerClient,
151-
CloudFilestoreManagerAsyncClient,
152+
(CloudFilestoreManagerClient, "grpc"),
153+
(CloudFilestoreManagerAsyncClient, "grpc_asyncio"),
152154
],
153155
)
154-
def test_cloud_filestore_manager_client_from_service_account_file(client_class):
156+
def test_cloud_filestore_manager_client_from_service_account_file(
157+
client_class, transport_name
158+
):
155159
creds = ga_credentials.AnonymousCredentials()
156160
with mock.patch.object(
157161
service_account.Credentials, "from_service_account_file"
158162
) as factory:
159163
factory.return_value = creds
160-
client = client_class.from_service_account_file("dummy/file/path.json")
164+
client = client_class.from_service_account_file(
165+
"dummy/file/path.json", transport=transport_name
166+
)
161167
assert client.transport._credentials == creds
162168
assert isinstance(client, client_class)
163169

164-
client = client_class.from_service_account_json("dummy/file/path.json")
170+
client = client_class.from_service_account_json(
171+
"dummy/file/path.json", transport=transport_name
172+
)
165173
assert client.transport._credentials == creds
166174
assert isinstance(client, client_class)
167175

168-
assert client.transport._host == "file.googleapis.com:443"
176+
assert client.transport._host == ("file.googleapis.com:443")
169177

170178

171179
def test_cloud_filestore_manager_client_get_transport_class():
@@ -1044,7 +1052,7 @@ async def test_list_instances_async_pager():
10441052
)
10451053
assert async_pager.next_page_token == "abc"
10461054
responses = []
1047-
async for response in async_pager:
1055+
async for response in async_pager: # pragma: no branch
10481056
responses.append(response)
10491057

10501058
assert len(responses) == 6
@@ -1090,7 +1098,9 @@ async def test_list_instances_async_pages():
10901098
RuntimeError,
10911099
)
10921100
pages = []
1093-
async for page_ in (await client.list_instances(request={})).pages:
1101+
async for page_ in (
1102+
await client.list_instances(request={})
1103+
).pages: # pragma: no branch
10941104
pages.append(page_)
10951105
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
10961106
assert page_.raw_page.next_page_token == token
@@ -2576,7 +2586,7 @@ async def test_list_backups_async_pager():
25762586
)
25772587
assert async_pager.next_page_token == "abc"
25782588
responses = []
2579-
async for response in async_pager:
2589+
async for response in async_pager: # pragma: no branch
25802590
responses.append(response)
25812591

25822592
assert len(responses) == 6
@@ -2622,7 +2632,9 @@ async def test_list_backups_async_pages():
26222632
RuntimeError,
26232633
)
26242634
pages = []
2625-
async for page_ in (await client.list_backups(request={})).pages:
2635+
async for page_ in (
2636+
await client.list_backups(request={})
2637+
).pages: # pragma: no branch
26262638
pages.append(page_)
26272639
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
26282640
assert page_.raw_page.next_page_token == token
@@ -3699,6 +3711,19 @@ def test_transport_adc(transport_class):
36993711
adc.assert_called_once()
37003712

37013713

3714+
@pytest.mark.parametrize(
3715+
"transport_name",
3716+
[
3717+
"grpc",
3718+
],
3719+
)
3720+
def test_transport_kind(transport_name):
3721+
transport = CloudFilestoreManagerClient.get_transport_class(transport_name)(
3722+
credentials=ga_credentials.AnonymousCredentials(),
3723+
)
3724+
assert transport.kind == transport_name
3725+
3726+
37023727
def test_transport_grpc_default():
37033728
# A client should use the gRPC transport by default.
37043729
client = CloudFilestoreManagerClient(
@@ -3756,6 +3781,14 @@ def test_cloud_filestore_manager_base_transport():
37563781
with pytest.raises(NotImplementedError):
37573782
transport.operations_client
37583783

3784+
# Catch all for all remaining methods and properties
3785+
remainder = [
3786+
"kind",
3787+
]
3788+
for r in remainder:
3789+
with pytest.raises(NotImplementedError):
3790+
getattr(transport, r)()
3791+
37593792

37603793
def test_cloud_filestore_manager_base_transport_with_credentials_file():
37613794
# Instantiate the base transport with a credentials file
@@ -3905,22 +3938,38 @@ def test_cloud_filestore_manager_grpc_transport_client_cert_source_for_mtls(
39053938
)
39063939

39073940

3908-
def test_cloud_filestore_manager_host_no_port():
3941+
@pytest.mark.parametrize(
3942+
"transport_name",
3943+
[
3944+
"grpc",
3945+
"grpc_asyncio",
3946+
],
3947+
)
3948+
def test_cloud_filestore_manager_host_no_port(transport_name):
39093949
client = CloudFilestoreManagerClient(
39103950
credentials=ga_credentials.AnonymousCredentials(),
39113951
client_options=client_options.ClientOptions(api_endpoint="file.googleapis.com"),
3952+
transport=transport_name,
39123953
)
3913-
assert client.transport._host == "file.googleapis.com:443"
3954+
assert client.transport._host == ("file.googleapis.com:443")
39143955

39153956

3916-
def test_cloud_filestore_manager_host_with_port():
3957+
@pytest.mark.parametrize(
3958+
"transport_name",
3959+
[
3960+
"grpc",
3961+
"grpc_asyncio",
3962+
],
3963+
)
3964+
def test_cloud_filestore_manager_host_with_port(transport_name):
39173965
client = CloudFilestoreManagerClient(
39183966
credentials=ga_credentials.AnonymousCredentials(),
39193967
client_options=client_options.ClientOptions(
39203968
api_endpoint="file.googleapis.com:8000"
39213969
),
3970+
transport=transport_name,
39223971
)
3923-
assert client.transport._host == "file.googleapis.com:8000"
3972+
assert client.transport._host == ("file.googleapis.com:8000")
39243973

39253974

39263975
def test_cloud_filestore_manager_grpc_transport_channel():

0 commit comments

Comments
 (0)