Skip to content

Commit

Permalink
chore: Use gapic-generator-python 0.65.0 (#57)
Browse files Browse the repository at this point in the history
- [ ] Regenerate this pull request now.

PiperOrigin-RevId: 440970084

Source-Link: googleapis/googleapis@5e0a3d5

Source-Link: googleapis/googleapis-gen@b0c628a
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYjBjNjI4YTNmYWRlNzY4ZjIyNWQ3Njk5Mjc5MWVhMWJhMmE4ODFiZSJ9

docs: fix type in docstring for map fields
  • Loading branch information
gcf-owl-bot[bot] authored Apr 13, 2022
1 parent ab2e926 commit 29fe6e4
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from collections import OrderedDict
import functools
import re
from typing import Dict, Optional, Sequence, Tuple, Type, Union
from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union
import pkg_resources

from google.api_core.client_options import ClientOptions
Expand Down Expand Up @@ -249,7 +249,6 @@ async def list_instances(
r"""Lists all instances in a project for either a
specified location or for all locations.
.. code-block:: python
from google.cloud import filestore_v1
Expand Down Expand Up @@ -326,7 +325,7 @@ def sample_list_instances():
maximum=32.0,
multiplier=1.3,
predicate=retries.if_exception_type(
core_exceptions.ServiceUnavailable,
core_exceptions.GoogleAPICallError,
),
deadline=60.0,
),
Expand Down Expand Up @@ -437,7 +436,7 @@ def sample_get_instance():
maximum=32.0,
multiplier=1.3,
predicate=retries.if_exception_type(
core_exceptions.ServiceUnavailable,
core_exceptions.GoogleAPICallError,
),
deadline=60.0,
),
Expand Down Expand Up @@ -479,7 +478,6 @@ async def create_instance(
capacity of the backup (and also equal to or larger than
the minimum capacity of the tier).
.. code-block:: python
from google.cloud import filestore_v1
Expand Down Expand Up @@ -739,7 +737,6 @@ async def restore_instance(
larger than the capacity of the backup (and also equal
to or larger than the minimum capacity of the tier).
.. code-block:: python
from google.cloud import filestore_v1
Expand Down Expand Up @@ -952,7 +949,6 @@ async def list_backups(
r"""Lists all backups in a project for either a specified
location or for all locations.
.. code-block:: python
from google.cloud import filestore_v1
Expand Down Expand Up @@ -1028,7 +1024,7 @@ def sample_list_backups():
maximum=32.0,
multiplier=1.3,
predicate=retries.if_exception_type(
core_exceptions.ServiceUnavailable,
core_exceptions.GoogleAPICallError,
),
deadline=60.0,
),
Expand Down Expand Up @@ -1139,7 +1135,7 @@ def sample_get_backup():
maximum=32.0,
multiplier=1.3,
predicate=retries.if_exception_type(
core_exceptions.ServiceUnavailable,
core_exceptions.GoogleAPICallError,
),
deadline=60.0,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from collections import OrderedDict
import os
import re
from typing import Dict, Optional, Sequence, Tuple, Type, Union
from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union
import pkg_resources

from google.api_core import client_options as client_options_lib
Expand Down Expand Up @@ -490,7 +490,6 @@ def list_instances(
r"""Lists all instances in a project for either a
specified location or for all locations.
.. code-block:: python
from google.cloud import filestore_v1
Expand Down Expand Up @@ -702,7 +701,6 @@ def create_instance(
capacity of the backup (and also equal to or larger than
the minimum capacity of the tier).
.. code-block:: python
from google.cloud import filestore_v1
Expand Down Expand Up @@ -962,7 +960,6 @@ def restore_instance(
larger than the capacity of the backup (and also equal
to or larger than the minimum capacity of the tier).
.. code-block:: python
from google.cloud import filestore_v1
Expand Down Expand Up @@ -1176,7 +1173,6 @@ def list_backups(
r"""Lists all backups in a project for either a specified
location or for all locations.
.. code-block:: python
from google.cloud import filestore_v1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def __init__(
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
be used for service account credentials.
"""

# Save the hostname. Default to port 443 (HTTPS) if none is specified.
if ":" not in host:
host += ":443"
Expand Down Expand Up @@ -129,7 +130,7 @@ def _prep_wrapped_messages(self, client_info):
maximum=32.0,
multiplier=1.3,
predicate=retries.if_exception_type(
core_exceptions.ServiceUnavailable,
core_exceptions.GoogleAPICallError,
),
deadline=60.0,
),
Expand All @@ -143,7 +144,7 @@ def _prep_wrapped_messages(self, client_info):
maximum=32.0,
multiplier=1.3,
predicate=retries.if_exception_type(
core_exceptions.ServiceUnavailable,
core_exceptions.GoogleAPICallError,
),
deadline=60.0,
),
Expand Down Expand Up @@ -177,7 +178,7 @@ def _prep_wrapped_messages(self, client_info):
maximum=32.0,
multiplier=1.3,
predicate=retries.if_exception_type(
core_exceptions.ServiceUnavailable,
core_exceptions.GoogleAPICallError,
),
deadline=60.0,
),
Expand All @@ -191,7 +192,7 @@ def _prep_wrapped_messages(self, client_info):
maximum=32.0,
multiplier=1.3,
predicate=retries.if_exception_type(
core_exceptions.ServiceUnavailable,
core_exceptions.GoogleAPICallError,
),
deadline=60.0,
),
Expand Down Expand Up @@ -339,5 +340,9 @@ def update_backup(
]:
raise NotImplementedError()

@property
def kind(self) -> str:
raise NotImplementedError()


__all__ = ("CloudFilestoreManagerTransport",)
Original file line number Diff line number Diff line change
Expand Up @@ -589,5 +589,9 @@ def update_backup(
def close(self):
self.grpc_channel.close()

@property
def kind(self) -> str:
return "grpc"


__all__ = ("CloudFilestoreManagerGrpcTransport",)
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ class Instance(proto.Message):
created.
tier (google.cloud.filestore_v1.types.Instance.Tier):
The service tier of the instance.
labels (Sequence[google.cloud.filestore_v1.types.Instance.LabelsEntry]):
labels (Mapping[str, str]):
Resource labels to represent user provided
metadata.
file_shares (Sequence[google.cloud.filestore_v1.types.FileShareConfig]):
Expand Down Expand Up @@ -550,7 +550,7 @@ class Backup(proto.Message):
create_time (google.protobuf.timestamp_pb2.Timestamp):
Output only. The time when the backup was
created.
labels (Sequence[google.cloud.filestore_v1.types.Backup.LabelsEntry]):
labels (Mapping[str, str]):
Resource labels to represent user provided
metadata.
capacity_gb (int):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,24 +99,26 @@ def test__get_default_mtls_endpoint():


@pytest.mark.parametrize(
"client_class",
"client_class,transport_name",
[
CloudFilestoreManagerClient,
CloudFilestoreManagerAsyncClient,
(CloudFilestoreManagerClient, "grpc"),
(CloudFilestoreManagerAsyncClient, "grpc_asyncio"),
],
)
def test_cloud_filestore_manager_client_from_service_account_info(client_class):
def test_cloud_filestore_manager_client_from_service_account_info(
client_class, transport_name
):
creds = ga_credentials.AnonymousCredentials()
with mock.patch.object(
service_account.Credentials, "from_service_account_info"
) as factory:
factory.return_value = creds
info = {"valid": True}
client = client_class.from_service_account_info(info)
client = client_class.from_service_account_info(info, transport=transport_name)
assert client.transport._credentials == creds
assert isinstance(client, client_class)

assert client.transport._host == "file.googleapis.com:443"
assert client.transport._host == ("file.googleapis.com:443")


@pytest.mark.parametrize(
Expand Down Expand Up @@ -145,27 +147,33 @@ def test_cloud_filestore_manager_client_service_account_always_use_jwt(


@pytest.mark.parametrize(
"client_class",
"client_class,transport_name",
[
CloudFilestoreManagerClient,
CloudFilestoreManagerAsyncClient,
(CloudFilestoreManagerClient, "grpc"),
(CloudFilestoreManagerAsyncClient, "grpc_asyncio"),
],
)
def test_cloud_filestore_manager_client_from_service_account_file(client_class):
def test_cloud_filestore_manager_client_from_service_account_file(
client_class, transport_name
):
creds = ga_credentials.AnonymousCredentials()
with mock.patch.object(
service_account.Credentials, "from_service_account_file"
) as factory:
factory.return_value = creds
client = client_class.from_service_account_file("dummy/file/path.json")
client = client_class.from_service_account_file(
"dummy/file/path.json", transport=transport_name
)
assert client.transport._credentials == creds
assert isinstance(client, client_class)

client = client_class.from_service_account_json("dummy/file/path.json")
client = client_class.from_service_account_json(
"dummy/file/path.json", transport=transport_name
)
assert client.transport._credentials == creds
assert isinstance(client, client_class)

assert client.transport._host == "file.googleapis.com:443"
assert client.transport._host == ("file.googleapis.com:443")


def test_cloud_filestore_manager_client_get_transport_class():
Expand Down Expand Up @@ -1044,7 +1052,7 @@ async def test_list_instances_async_pager():
)
assert async_pager.next_page_token == "abc"
responses = []
async for response in async_pager:
async for response in async_pager: # pragma: no branch
responses.append(response)

assert len(responses) == 6
Expand Down Expand Up @@ -1090,7 +1098,9 @@ async def test_list_instances_async_pages():
RuntimeError,
)
pages = []
async for page_ in (await client.list_instances(request={})).pages:
async for page_ in (
await client.list_instances(request={})
).pages: # pragma: no branch
pages.append(page_)
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
assert page_.raw_page.next_page_token == token
Expand Down Expand Up @@ -2576,7 +2586,7 @@ async def test_list_backups_async_pager():
)
assert async_pager.next_page_token == "abc"
responses = []
async for response in async_pager:
async for response in async_pager: # pragma: no branch
responses.append(response)

assert len(responses) == 6
Expand Down Expand Up @@ -2622,7 +2632,9 @@ async def test_list_backups_async_pages():
RuntimeError,
)
pages = []
async for page_ in (await client.list_backups(request={})).pages:
async for page_ in (
await client.list_backups(request={})
).pages: # pragma: no branch
pages.append(page_)
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
assert page_.raw_page.next_page_token == token
Expand Down Expand Up @@ -3699,6 +3711,19 @@ def test_transport_adc(transport_class):
adc.assert_called_once()


@pytest.mark.parametrize(
"transport_name",
[
"grpc",
],
)
def test_transport_kind(transport_name):
transport = CloudFilestoreManagerClient.get_transport_class(transport_name)(
credentials=ga_credentials.AnonymousCredentials(),
)
assert transport.kind == transport_name


def test_transport_grpc_default():
# A client should use the gRPC transport by default.
client = CloudFilestoreManagerClient(
Expand Down Expand Up @@ -3756,6 +3781,14 @@ def test_cloud_filestore_manager_base_transport():
with pytest.raises(NotImplementedError):
transport.operations_client

# Catch all for all remaining methods and properties
remainder = [
"kind",
]
for r in remainder:
with pytest.raises(NotImplementedError):
getattr(transport, r)()


def test_cloud_filestore_manager_base_transport_with_credentials_file():
# Instantiate the base transport with a credentials file
Expand Down Expand Up @@ -3905,22 +3938,38 @@ def test_cloud_filestore_manager_grpc_transport_client_cert_source_for_mtls(
)


def test_cloud_filestore_manager_host_no_port():
@pytest.mark.parametrize(
"transport_name",
[
"grpc",
"grpc_asyncio",
],
)
def test_cloud_filestore_manager_host_no_port(transport_name):
client = CloudFilestoreManagerClient(
credentials=ga_credentials.AnonymousCredentials(),
client_options=client_options.ClientOptions(api_endpoint="file.googleapis.com"),
transport=transport_name,
)
assert client.transport._host == "file.googleapis.com:443"
assert client.transport._host == ("file.googleapis.com:443")


def test_cloud_filestore_manager_host_with_port():
@pytest.mark.parametrize(
"transport_name",
[
"grpc",
"grpc_asyncio",
],
)
def test_cloud_filestore_manager_host_with_port(transport_name):
client = CloudFilestoreManagerClient(
credentials=ga_credentials.AnonymousCredentials(),
client_options=client_options.ClientOptions(
api_endpoint="file.googleapis.com:8000"
),
transport=transport_name,
)
assert client.transport._host == "file.googleapis.com:8000"
assert client.transport._host == ("file.googleapis.com:8000")


def test_cloud_filestore_manager_grpc_transport_channel():
Expand Down

0 comments on commit 29fe6e4

Please sign in to comment.