diff --git a/.flake8 b/.flake8 index 29227d4..2e43874 100644 --- a/.flake8 +++ b/.flake8 @@ -16,7 +16,7 @@ # Generated by synthtool. DO NOT EDIT! [flake8] -ignore = E203, E266, E501, W503 +ignore = E203, E231, E266, E501, W503 exclude = # Exclude generated code. **/proto/** diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 44c78f7..757c9dc 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,4 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:4e1991042fe54b991db9ca17c8fb386e61b22fe4d1472a568bf0fcac85dcf5d3 + digest: sha256:81ed5ecdfc7cac5b699ba4537376f3563f6f04122c4ec9e735d3b3dc1d43dd32 +# created: 2022-05-05T22:08:23.383410683Z diff --git a/.github/auto-approve.yml b/.github/auto-approve.yml new file mode 100644 index 0000000..311ebbb --- /dev/null +++ b/.github/auto-approve.yml @@ -0,0 +1,3 @@ +# https://github.com/googleapis/repo-automation-bots/tree/main/packages/auto-approve +processes: + - "OwlBotTemplateChanges" diff --git a/.github/auto-label.yaml b/.github/auto-label.yaml new file mode 100644 index 0000000..41bff0b --- /dev/null +++ b/.github/auto-label.yaml @@ -0,0 +1,15 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +requestsize: + enabled: true diff --git a/.github/release-please.yml b/.github/release-please.yml index 466597e..6def37a 100644 --- a/.github/release-please.yml +++ b/.github/release-please.yml @@ -1,2 +1,8 @@ releaseType: python handleGHRelease: true +# NOTE: this section is generated by synthtool.languages.python +# See https://github.com/googleapis/synthtool/blob/master/synthtool/languages/python.py +branches: +- branch: v0 + handleGHRelease: true + releaseType: python diff --git a/.kokoro/docker/docs/Dockerfile b/.kokoro/docker/docs/Dockerfile index 4e1b1fb..238b87b 100644 --- a/.kokoro/docker/docs/Dockerfile +++ b/.kokoro/docker/docs/Dockerfile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from ubuntu:20.04 +from ubuntu:22.04 ENV DEBIAN_FRONTEND noninteractive @@ -60,8 +60,24 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* \ && rm -f /var/cache/apt/archives/*.deb +###################### Install python 3.8.11 + +# Download python 3.8.11 +RUN wget https://www.python.org/ftp/python/3.8.11/Python-3.8.11.tgz + +# Extract files +RUN tar -xvf Python-3.8.11.tgz + +# Install python 3.8.11 +RUN ./Python-3.8.11/configure --enable-optimizations +RUN make altinstall + +###################### Install pip RUN wget -O /tmp/get-pip.py 'https://bootstrap.pypa.io/get-pip.py' \ - && python3.8 /tmp/get-pip.py \ + && python3 /tmp/get-pip.py \ && rm /tmp/get-pip.py +# Test pip +RUN python3 -m pip + CMD ["python3.8"] diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 62eb5a7..46d2371 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,7 @@ repos: - id: end-of-file-fixer - id: check-yaml - repo: https://github.com/psf/black - rev: 19.10b0 + rev: 22.3.0 hooks: - id: black - repo: https://gitlab.com/pycqa/flake8 diff --git a/CHANGELOG.md b/CHANGELOG.md index ada0ff8..d249b1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog -### [1.6.1](https://github.com/googleapis/python-billingbudgets/compare/v1.6.0...v1.6.1) (2022-03-05) +## [1.6.2](https://github.com/googleapis/python-billingbudgets/compare/v1.6.1...v1.6.2) (2022-06-03) + + +### Bug Fixes + +* **deps:** require protobuf <4.0.0dev ([#208](https://github.com/googleapis/python-billingbudgets/issues/208)) ([d55daaa](https://github.com/googleapis/python-billingbudgets/commit/d55daaa337b3c8e1fea14972f4d72dc32d35ac9d)) + + +### Documentation + +* fix changelog header to consistent size ([#209](https://github.com/googleapis/python-billingbudgets/issues/209)) ([d50aaad](https://github.com/googleapis/python-billingbudgets/commit/d50aaad156ae5c3654461e5bdac213ab65d1e82c)) + +## [1.6.1](https://github.com/googleapis/python-billingbudgets/compare/v1.6.0...v1.6.1) (2022-03-05) ### Bug Fixes @@ -25,7 +37,7 @@ * add autogenerated code snippets ([5e02634](https://github.com/googleapis/python-billingbudgets/commit/5e026345b1cb9cc77359d7efd98a07ce498a7e74)) * Formatting change from HTML to markdown; Additional clarifications ([#174](https://github.com/googleapis/python-billingbudgets/issues/174)) ([eaa109d](https://github.com/googleapis/python-billingbudgets/commit/eaa109d24a6af7ad014e8c5606c88c7432f022ff)) -### [1.5.1](https://www.github.com/googleapis/python-billingbudgets/compare/v1.5.0...v1.5.1) (2021-11-01) +## [1.5.1](https://www.github.com/googleapis/python-billingbudgets/compare/v1.5.0...v1.5.1) (2021-11-01) ### Bug Fixes @@ -47,21 +59,21 @@ * add context manager support in client ([#145](https://www.github.com/googleapis/python-billingbudgets/issues/145)) ([e8f1dc0](https://www.github.com/googleapis/python-billingbudgets/commit/e8f1dc09a5b932f00bc279d8510aa5518d68b98b)) * add trove classifier for python 3.10 ([#149](https://www.github.com/googleapis/python-billingbudgets/issues/149)) ([b75cf0c](https://www.github.com/googleapis/python-billingbudgets/commit/b75cf0ca43929d6339647aa99e02ecc6e7f25c5c)) -### [1.4.4](https://www.github.com/googleapis/python-billingbudgets/compare/v1.4.3...v1.4.4) (2021-10-04) +## [1.4.4](https://www.github.com/googleapis/python-billingbudgets/compare/v1.4.3...v1.4.4) (2021-10-04) ### Bug Fixes * improper types in pagers generation ([47eb773](https://www.github.com/googleapis/python-billingbudgets/commit/47eb77346fe44ce803a20552347bb42c4a17e5a5)) -### [1.4.3](https://www.github.com/googleapis/python-billingbudgets/compare/v1.4.2...v1.4.3) (2021-09-24) +## [1.4.3](https://www.github.com/googleapis/python-billingbudgets/compare/v1.4.2...v1.4.3) (2021-09-24) ### Bug Fixes * add 'dict' annotation type to 'request' ([746a7a1](https://www.github.com/googleapis/python-billingbudgets/commit/746a7a13524217f5f0562ac35b963de17bea11bf)) -### [1.4.2](https://www.github.com/googleapis/python-billingbudgets/compare/v1.4.1...v1.4.2) (2021-07-27) +## [1.4.2](https://www.github.com/googleapis/python-billingbudgets/compare/v1.4.1...v1.4.2) (2021-07-27) ### Bug Fixes @@ -78,7 +90,7 @@ * release as 1.4.2 ([#122](https://www.github.com/googleapis/python-billingbudgets/issues/122)) ([652c0b2](https://www.github.com/googleapis/python-billingbudgets/commit/652c0b239c303369701447862d98a5aa5f109213)) -### [1.4.1](https://www.github.com/googleapis/python-billingbudgets/compare/v1.4.0...v1.4.1) (2021-07-20) +## [1.4.1](https://www.github.com/googleapis/python-billingbudgets/compare/v1.4.0...v1.4.1) (2021-07-20) ### Bug Fixes @@ -128,7 +140,7 @@ * release 1.2.0 ([#95](https://www.github.com/googleapis/python-billingbudgets/issues/95)) ([be03be9](https://www.github.com/googleapis/python-billingbudgets/commit/be03be9af446c01ded9f7306eb376a73972de39e)) -### [1.1.1](https://www.github.com/googleapis/python-billingbudgets/compare/v1.1.0...v1.1.1) (2021-02-12) +## [1.1.1](https://www.github.com/googleapis/python-billingbudgets/compare/v1.1.0...v1.1.1) (2021-02-12) ### Bug Fixes @@ -142,7 +154,7 @@ * add v1 ([#53](https://www.github.com/googleapis/python-billingbudgets/issues/53)) ([72ec268](https://www.github.com/googleapis/python-billingbudgets/commit/72ec26816d2ceb7217783f8a692b552fe5a2b28a)) -### [1.0.1](https://www.github.com/googleapis/python-billingbudgets/compare/v1.0.0...v1.0.1) (2020-08-03) +## [1.0.1](https://www.github.com/googleapis/python-billingbudgets/compare/v1.0.0...v1.0.1) (2020-08-03) ### Documentation diff --git a/docs/conf.py b/docs/conf.py index 030918e..4e25350 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -24,9 +24,9 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import sys import os import shlex +import sys # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the @@ -361,7 +361,10 @@ intersphinx_mapping = { "python": ("https://python.readthedocs.org/en/latest/", None), "google-auth": ("https://googleapis.dev/python/google-auth/latest/", None), - "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None,), + "google.api_core": ( + "https://googleapis.dev/python/google-api-core/latest/", + None, + ), "grpc": ("https://grpc.github.io/grpc/python/", None), "proto-plus": ("https://proto-plus-python.readthedocs.io/en/latest/", None), "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), diff --git a/google/cloud/billing/budgets/__init__.py b/google/cloud/billing/budgets/__init__.py index efd56c9..10ea21c 100644 --- a/google/cloud/billing/budgets/__init__.py +++ b/google/cloud/billing/budgets/__init__.py @@ -14,27 +14,30 @@ # limitations under the License. # +from google.cloud.billing.budgets_v1.services.budget_service.async_client import ( + BudgetServiceAsyncClient, +) from google.cloud.billing.budgets_v1.services.budget_service.client import ( BudgetServiceClient, ) -from google.cloud.billing.budgets_v1.services.budget_service.async_client import ( - BudgetServiceAsyncClient, +from google.cloud.billing.budgets_v1.types.budget_model import ( + Budget, + BudgetAmount, + CalendarPeriod, + CustomPeriod, + Filter, + LastPeriodAmount, + NotificationsRule, + ThresholdRule, +) +from google.cloud.billing.budgets_v1.types.budget_service import ( + CreateBudgetRequest, + DeleteBudgetRequest, + GetBudgetRequest, + ListBudgetsRequest, + ListBudgetsResponse, + UpdateBudgetRequest, ) - -from google.cloud.billing.budgets_v1.types.budget_model import Budget -from google.cloud.billing.budgets_v1.types.budget_model import BudgetAmount -from google.cloud.billing.budgets_v1.types.budget_model import CustomPeriod -from google.cloud.billing.budgets_v1.types.budget_model import Filter -from google.cloud.billing.budgets_v1.types.budget_model import LastPeriodAmount -from google.cloud.billing.budgets_v1.types.budget_model import NotificationsRule -from google.cloud.billing.budgets_v1.types.budget_model import ThresholdRule -from google.cloud.billing.budgets_v1.types.budget_model import CalendarPeriod -from google.cloud.billing.budgets_v1.types.budget_service import CreateBudgetRequest -from google.cloud.billing.budgets_v1.types.budget_service import DeleteBudgetRequest -from google.cloud.billing.budgets_v1.types.budget_service import GetBudgetRequest -from google.cloud.billing.budgets_v1.types.budget_service import ListBudgetsRequest -from google.cloud.billing.budgets_v1.types.budget_service import ListBudgetsResponse -from google.cloud.billing.budgets_v1.types.budget_service import UpdateBudgetRequest __all__ = ( "BudgetServiceClient", diff --git a/google/cloud/billing/budgets_v1/__init__.py b/google/cloud/billing/budgets_v1/__init__.py index e997b95..b8dd76a 100644 --- a/google/cloud/billing/budgets_v1/__init__.py +++ b/google/cloud/billing/budgets_v1/__init__.py @@ -14,23 +14,25 @@ # limitations under the License. # -from .services.budget_service import BudgetServiceClient -from .services.budget_service import BudgetServiceAsyncClient - -from .types.budget_model import Budget -from .types.budget_model import BudgetAmount -from .types.budget_model import CustomPeriod -from .types.budget_model import Filter -from .types.budget_model import LastPeriodAmount -from .types.budget_model import NotificationsRule -from .types.budget_model import ThresholdRule -from .types.budget_model import CalendarPeriod -from .types.budget_service import CreateBudgetRequest -from .types.budget_service import DeleteBudgetRequest -from .types.budget_service import GetBudgetRequest -from .types.budget_service import ListBudgetsRequest -from .types.budget_service import ListBudgetsResponse -from .types.budget_service import UpdateBudgetRequest +from .services.budget_service import BudgetServiceAsyncClient, BudgetServiceClient +from .types.budget_model import ( + Budget, + BudgetAmount, + CalendarPeriod, + CustomPeriod, + Filter, + LastPeriodAmount, + NotificationsRule, + ThresholdRule, +) +from .types.budget_service import ( + CreateBudgetRequest, + DeleteBudgetRequest, + GetBudgetRequest, + ListBudgetsRequest, + ListBudgetsResponse, + UpdateBudgetRequest, +) __all__ = ( "BudgetServiceAsyncClient", diff --git a/google/cloud/billing/budgets_v1/services/budget_service/__init__.py b/google/cloud/billing/budgets_v1/services/budget_service/__init__.py index 52de7ea..6ba5969 100644 --- a/google/cloud/billing/budgets_v1/services/budget_service/__init__.py +++ b/google/cloud/billing/budgets_v1/services/budget_service/__init__.py @@ -13,8 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from .client import BudgetServiceClient from .async_client import BudgetServiceAsyncClient +from .client import BudgetServiceClient __all__ = ( "BudgetServiceClient", diff --git a/google/cloud/billing/budgets_v1/services/budget_service/async_client.py b/google/cloud/billing/budgets_v1/services/budget_service/async_client.py index c40997e..1279ebd 100644 --- a/google/cloud/billing/budgets_v1/services/budget_service/async_client.py +++ b/google/cloud/billing/budgets_v1/services/budget_service/async_client.py @@ -16,28 +16,29 @@ from collections import OrderedDict import functools import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union -import pkg_resources +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union -from google.api_core.client_options import ClientOptions from google.api_core import exceptions as core_exceptions from google.api_core import gapic_v1 from google.api_core import retry as retries +from google.api_core.client_options import ClientOptions from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore +import pkg_resources try: OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object] # type: ignore -from google.cloud.billing.budgets_v1.services.budget_service import pagers -from google.cloud.billing.budgets_v1.types import budget_model -from google.cloud.billing.budgets_v1.types import budget_service from google.protobuf import field_mask_pb2 # type: ignore -from .transports.base import BudgetServiceTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import BudgetServiceGrpcAsyncIOTransport + +from google.cloud.billing.budgets_v1.services.budget_service import pagers +from google.cloud.billing.budgets_v1.types import budget_model, budget_service + from .client import BudgetServiceClient +from .transports.base import DEFAULT_CLIENT_INFO, BudgetServiceTransport +from .transports.grpc_asyncio import BudgetServiceGrpcAsyncIOTransport class BudgetServiceAsyncClient: @@ -222,14 +223,13 @@ async def create_budget( information on the limits of the number of budgets you can create. - .. code-block:: python from google.cloud.billing import budgets_v1 - def sample_create_budget(): + async def sample_create_budget(): # Create a client - client = budgets_v1.BudgetServiceClient() + client = budgets_v1.BudgetServiceAsyncClient() # Initialize request argument(s) request = budgets_v1.CreateBudgetRequest( @@ -237,7 +237,7 @@ def sample_create_budget(): ) # Make the request - response = client.create_budget(request=request) + response = await client.create_budget(request=request) # Handle the response print(response) @@ -311,7 +311,12 @@ def sample_create_budget(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -332,21 +337,20 @@ async def update_budget( fields that are not exposed in this API will not be changed by this method. - .. code-block:: python from google.cloud.billing import budgets_v1 - def sample_update_budget(): + async def sample_update_budget(): # Create a client - client = budgets_v1.BudgetServiceClient() + client = budgets_v1.BudgetServiceAsyncClient() # Initialize request argument(s) request = budgets_v1.UpdateBudgetRequest( ) # Make the request - response = client.update_budget(request=request) + response = await client.update_budget(request=request) # Handle the response print(response) @@ -438,7 +442,12 @@ def sample_update_budget(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -459,14 +468,13 @@ async def get_budget( the return value, though they may have been set in the Cloud Console. - .. code-block:: python from google.cloud.billing import budgets_v1 - def sample_get_budget(): + async def sample_get_budget(): # Create a client - client = budgets_v1.BudgetServiceClient() + client = budgets_v1.BudgetServiceAsyncClient() # Initialize request argument(s) request = budgets_v1.GetBudgetRequest( @@ -474,7 +482,7 @@ def sample_get_budget(): ) # Make the request - response = client.get_budget(request=request) + response = await client.get_budget(request=request) # Handle the response print(response) @@ -550,7 +558,12 @@ def sample_get_budget(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -571,14 +584,13 @@ async def list_budgets( the return value, though they may have been set in the Cloud Console. - .. code-block:: python from google.cloud.billing import budgets_v1 - def sample_list_budgets(): + async def sample_list_budgets(): # Create a client - client = budgets_v1.BudgetServiceClient() + client = budgets_v1.BudgetServiceAsyncClient() # Initialize request argument(s) request = budgets_v1.ListBudgetsRequest( @@ -589,7 +601,7 @@ def sample_list_budgets(): page_result = client.list_budgets(request=request) # Handle the response - for response in page_result: + async for response in page_result: print(response) Args: @@ -659,12 +671,20 @@ def sample_list_budgets(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListBudgetsAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -682,14 +702,13 @@ async def delete_budget( r"""Deletes a budget. Returns successfully if already deleted. - .. code-block:: python from google.cloud.billing import budgets_v1 - def sample_delete_budget(): + async def sample_delete_budget(): # Create a client - client = budgets_v1.BudgetServiceClient() + client = budgets_v1.BudgetServiceAsyncClient() # Initialize request argument(s) request = budgets_v1.DeleteBudgetRequest( @@ -697,7 +716,7 @@ def sample_delete_budget(): ) # Make the request - client.delete_budget(request=request) + await client.delete_budget(request=request) Args: request (Union[google.cloud.billing.budgets_v1.types.DeleteBudgetRequest, dict]): @@ -759,7 +778,10 @@ def sample_delete_budget(): # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) async def __aenter__(self): diff --git a/google/cloud/billing/budgets_v1/services/budget_service/client.py b/google/cloud/billing/budgets_v1/services/budget_service/client.py index 2459152..caab374 100644 --- a/google/cloud/billing/budgets_v1/services/budget_service/client.py +++ b/google/cloud/billing/budgets_v1/services/budget_service/client.py @@ -16,29 +16,30 @@ from collections import OrderedDict import os import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union -import pkg_resources +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union from google.api_core import client_options as client_options_lib from google.api_core import exceptions as core_exceptions from google.api_core import gapic_v1 from google.api_core import retry as retries from google.auth import credentials as ga_credentials # type: ignore +from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore -from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore +import pkg_resources try: OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object] # type: ignore -from google.cloud.billing.budgets_v1.services.budget_service import pagers -from google.cloud.billing.budgets_v1.types import budget_model -from google.cloud.billing.budgets_v1.types import budget_service from google.protobuf import field_mask_pb2 # type: ignore -from .transports.base import BudgetServiceTransport, DEFAULT_CLIENT_INFO + +from google.cloud.billing.budgets_v1.services.budget_service import pagers +from google.cloud.billing.budgets_v1.types import budget_model, budget_service + +from .transports.base import DEFAULT_CLIENT_INFO, BudgetServiceTransport from .transports.grpc import BudgetServiceGrpcTransport from .transports.grpc_asyncio import BudgetServiceGrpcAsyncIOTransport @@ -55,7 +56,10 @@ class BudgetServiceClientMeta(type): _transport_registry["grpc"] = BudgetServiceGrpcTransport _transport_registry["grpc_asyncio"] = BudgetServiceGrpcAsyncIOTransport - def get_transport_class(cls, label: str = None,) -> Type[BudgetServiceTransport]: + def get_transport_class( + cls, + label: str = None, + ) -> Type[BudgetServiceTransport]: """Returns an appropriate transport class. Args: @@ -163,10 +167,14 @@ def transport(self) -> BudgetServiceTransport: return self._transport @staticmethod - def budget_path(billing_account: str, budget: str,) -> str: + def budget_path( + billing_account: str, + budget: str, + ) -> str: """Returns a fully-qualified budget string.""" return "billingAccounts/{billing_account}/budgets/{budget}".format( - billing_account=billing_account, budget=budget, + billing_account=billing_account, + budget=budget, ) @staticmethod @@ -178,7 +186,9 @@ def parse_budget_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_billing_account_path(billing_account: str,) -> str: + def common_billing_account_path( + billing_account: str, + ) -> str: """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, @@ -191,9 +201,13 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_folder_path(folder: str,) -> str: + def common_folder_path( + folder: str, + ) -> str: """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder,) + return "folders/{folder}".format( + folder=folder, + ) @staticmethod def parse_common_folder_path(path: str) -> Dict[str, str]: @@ -202,9 +216,13 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_organization_path(organization: str,) -> str: + def common_organization_path( + organization: str, + ) -> str: """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization,) + return "organizations/{organization}".format( + organization=organization, + ) @staticmethod def parse_common_organization_path(path: str) -> Dict[str, str]: @@ -213,9 +231,13 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_project_path(project: str,) -> str: + def common_project_path( + project: str, + ) -> str: """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project,) + return "projects/{project}".format( + project=project, + ) @staticmethod def parse_common_project_path(path: str) -> Dict[str, str]: @@ -224,10 +246,14 @@ def parse_common_project_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_location_path(project: str, location: str,) -> str: + def common_location_path( + project: str, + location: str, + ) -> str: """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) @staticmethod @@ -416,7 +442,6 @@ def create_budget( information on the limits of the number of budgets you can create. - .. code-block:: python from google.cloud.billing import budgets_v1 @@ -505,7 +530,12 @@ def sample_create_budget(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -526,7 +556,6 @@ def update_budget( fields that are not exposed in this API will not be changed by this method. - .. code-block:: python from google.cloud.billing import budgets_v1 @@ -622,7 +651,12 @@ def sample_update_budget(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -643,7 +677,6 @@ def get_budget( the return value, though they may have been set in the Cloud Console. - .. code-block:: python from google.cloud.billing import budgets_v1 @@ -724,7 +757,12 @@ def sample_get_budget(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -745,7 +783,6 @@ def list_budgets( the return value, though they may have been set in the Cloud Console. - .. code-block:: python from google.cloud.billing import budgets_v1 @@ -823,12 +860,20 @@ def sample_list_budgets(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListBudgetsPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -846,7 +891,6 @@ def delete_budget( r"""Deletes a budget. Returns successfully if already deleted. - .. code-block:: python from google.cloud.billing import budgets_v1 @@ -913,7 +957,10 @@ def sample_delete_budget(): # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def __enter__(self): diff --git a/google/cloud/billing/budgets_v1/services/budget_service/pagers.py b/google/cloud/billing/budgets_v1/services/budget_service/pagers.py index 8765131..c48a801 100644 --- a/google/cloud/billing/budgets_v1/services/budget_service/pagers.py +++ b/google/cloud/billing/budgets_v1/services/budget_service/pagers.py @@ -18,14 +18,13 @@ AsyncIterator, Awaitable, Callable, + Iterator, + Optional, Sequence, Tuple, - Optional, - Iterator, ) -from google.cloud.billing.budgets_v1.types import budget_model -from google.cloud.billing.budgets_v1.types import budget_service +from google.cloud.billing.budgets_v1.types import budget_model, budget_service class ListBudgetsPager: diff --git a/google/cloud/billing/budgets_v1/services/budget_service/transports/__init__.py b/google/cloud/billing/budgets_v1/services/budget_service/transports/__init__.py index ffb6ed3..bf85936 100644 --- a/google/cloud/billing/budgets_v1/services/budget_service/transports/__init__.py +++ b/google/cloud/billing/budgets_v1/services/budget_service/transports/__init__.py @@ -20,7 +20,6 @@ from .grpc import BudgetServiceGrpcTransport from .grpc_asyncio import BudgetServiceGrpcAsyncIOTransport - # Compile a registry of transports. _transport_registry = OrderedDict() # type: Dict[str, Type[BudgetServiceTransport]] _transport_registry["grpc"] = BudgetServiceGrpcTransport diff --git a/google/cloud/billing/budgets_v1/services/budget_service/transports/base.py b/google/cloud/billing/budgets_v1/services/budget_service/transports/base.py index 8ed37ff..8b77ae3 100644 --- a/google/cloud/billing/budgets_v1/services/budget_service/transports/base.py +++ b/google/cloud/billing/budgets_v1/services/budget_service/transports/base.py @@ -15,19 +15,18 @@ # import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import pkg_resources -import google.auth # type: ignore import google.api_core from google.api_core import exceptions as core_exceptions from google.api_core import gapic_v1 from google.api_core import retry as retries +import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore - -from google.cloud.billing.budgets_v1.types import budget_model -from google.cloud.billing.budgets_v1.types import budget_service from google.protobuf import empty_pb2 # type: ignore +import pkg_resources + +from google.cloud.billing.budgets_v1.types import budget_model, budget_service try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( @@ -85,6 +84,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" @@ -126,7 +126,9 @@ def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { self.create_budget: gapic_v1.method.wrap_method( - self.create_budget, default_timeout=60.0, client_info=client_info, + self.create_budget, + default_timeout=60.0, + client_info=client_info, ), self.update_budget: gapic_v1.method.wrap_method( self.update_budget, @@ -193,9 +195,9 @@ def _prep_wrapped_messages(self, client_info): def close(self): """Closes resources associated with the transport. - .. warning:: - Only call this method if the transport is NOT shared - with other clients - this may cause errors in other clients! + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! """ raise NotImplementedError() @@ -247,5 +249,9 @@ def delete_budget( ]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("BudgetServiceTransport",) diff --git a/google/cloud/billing/budgets_v1/services/budget_service/transports/grpc.py b/google/cloud/billing/budgets_v1/services/budget_service/transports/grpc.py index 09d6b04..f57a072 100644 --- a/google/cloud/billing/budgets_v1/services/budget_service/transports/grpc.py +++ b/google/cloud/billing/budgets_v1/services/budget_service/transports/grpc.py @@ -13,21 +13,19 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import warnings from typing import Callable, Dict, Optional, Sequence, Tuple, Union +import warnings -from google.api_core import grpc_helpers -from google.api_core import gapic_v1 +from google.api_core import gapic_v1, grpc_helpers import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore - +from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore -from google.cloud.billing.budgets_v1.types import budget_model -from google.cloud.billing.budgets_v1.types import budget_service -from google.protobuf import empty_pb2 # type: ignore -from .base import BudgetServiceTransport, DEFAULT_CLIENT_INFO +from google.cloud.billing.budgets_v1.types import budget_model, budget_service + +from .base import DEFAULT_CLIENT_INFO, BudgetServiceTransport class BudgetServiceGrpcTransport(BudgetServiceTransport): @@ -228,8 +226,7 @@ def create_channel( @property def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ + """Return the channel designed to connect to this service.""" return self._grpc_channel @property @@ -385,5 +382,9 @@ def delete_budget( def close(self): self.grpc_channel.close() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("BudgetServiceGrpcTransport",) diff --git a/google/cloud/billing/budgets_v1/services/budget_service/transports/grpc_asyncio.py b/google/cloud/billing/budgets_v1/services/budget_service/transports/grpc_asyncio.py index 6d8c3ff..318078a 100644 --- a/google/cloud/billing/budgets_v1/services/budget_service/transports/grpc_asyncio.py +++ b/google/cloud/billing/budgets_v1/services/budget_service/transports/grpc_asyncio.py @@ -13,21 +13,19 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import warnings from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union +import warnings -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers_async +from google.api_core import gapic_v1, grpc_helpers_async from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore - +from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore from grpc.experimental import aio # type: ignore -from google.cloud.billing.budgets_v1.types import budget_model -from google.cloud.billing.budgets_v1.types import budget_service -from google.protobuf import empty_pb2 # type: ignore -from .base import BudgetServiceTransport, DEFAULT_CLIENT_INFO +from google.cloud.billing.budgets_v1.types import budget_model, budget_service + +from .base import DEFAULT_CLIENT_INFO, BudgetServiceTransport from .grpc import BudgetServiceGrpcTransport diff --git a/google/cloud/billing/budgets_v1/types/__init__.py b/google/cloud/billing/budgets_v1/types/__init__.py index 1ab6f8e..534bdc2 100644 --- a/google/cloud/billing/budgets_v1/types/__init__.py +++ b/google/cloud/billing/budgets_v1/types/__init__.py @@ -16,12 +16,12 @@ from .budget_model import ( Budget, BudgetAmount, + CalendarPeriod, CustomPeriod, Filter, LastPeriodAmount, NotificationsRule, ThresholdRule, - CalendarPeriod, ) from .budget_service import ( CreateBudgetRequest, diff --git a/google/cloud/billing/budgets_v1/types/budget_model.py b/google/cloud/billing/budgets_v1/types/budget_model.py index 4ab656b..5bba402 100644 --- a/google/cloud/billing/budgets_v1/types/budget_model.py +++ b/google/cloud/billing/budgets_v1/types/budget_model.py @@ -13,12 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import proto # type: ignore - from google.protobuf import struct_pb2 # type: ignore from google.type import date_pb2 # type: ignore from google.type import money_pb2 # type: ignore - +import proto # type: ignore __protobuf__ = proto.module( package="google.cloud.billing.budgets.v1", @@ -86,17 +84,38 @@ class Budget(proto.Message): other changes. """ - name = proto.Field(proto.STRING, number=1,) - display_name = proto.Field(proto.STRING, number=2,) - budget_filter = proto.Field(proto.MESSAGE, number=3, message="Filter",) - amount = proto.Field(proto.MESSAGE, number=4, message="BudgetAmount",) + name = proto.Field( + proto.STRING, + number=1, + ) + display_name = proto.Field( + proto.STRING, + number=2, + ) + budget_filter = proto.Field( + proto.MESSAGE, + number=3, + message="Filter", + ) + amount = proto.Field( + proto.MESSAGE, + number=4, + message="BudgetAmount", + ) threshold_rules = proto.RepeatedField( - proto.MESSAGE, number=5, message="ThresholdRule", + proto.MESSAGE, + number=5, + message="ThresholdRule", ) notifications_rule = proto.Field( - proto.MESSAGE, number=6, message="NotificationsRule", + proto.MESSAGE, + number=6, + message="NotificationsRule", + ) + etag = proto.Field( + proto.STRING, + number=7, ) - etag = proto.Field(proto.STRING, number=7,) class BudgetAmount(proto.Message): @@ -131,10 +150,16 @@ class BudgetAmount(proto.Message): """ specified_amount = proto.Field( - proto.MESSAGE, number=1, oneof="budget_amount", message=money_pb2.Money, + proto.MESSAGE, + number=1, + oneof="budget_amount", + message=money_pb2.Money, ) last_period_amount = proto.Field( - proto.MESSAGE, number=2, oneof="budget_amount", message="LastPeriodAmount", + proto.MESSAGE, + number=2, + oneof="budget_amount", + message="LastPeriodAmount", ) @@ -179,8 +204,15 @@ class Basis(proto.Enum): CURRENT_SPEND = 1 FORECASTED_SPEND = 2 - threshold_percent = proto.Field(proto.DOUBLE, number=1,) - spend_basis = proto.Field(proto.ENUM, number=2, enum=Basis,) + threshold_percent = proto.Field( + proto.DOUBLE, + number=1, + ) + spend_basis = proto.Field( + proto.ENUM, + number=2, + enum=Basis, + ) class NotificationsRule(proto.Message): @@ -227,10 +259,22 @@ class NotificationsRule(proto.Message): Account User IAM roles for the target account. """ - pubsub_topic = proto.Field(proto.STRING, number=1,) - schema_version = proto.Field(proto.STRING, number=2,) - monitoring_notification_channels = proto.RepeatedField(proto.STRING, number=3,) - disable_default_iam_recipients = proto.Field(proto.BOOL, number=4,) + pubsub_topic = proto.Field( + proto.STRING, + number=1, + ) + schema_version = proto.Field( + proto.STRING, + number=2, + ) + monitoring_notification_channels = proto.RepeatedField( + proto.STRING, + number=3, + ) + disable_default_iam_recipients = proto.Field( + proto.BOOL, + number=4, + ) class Filter(proto.Message): @@ -283,7 +327,7 @@ class Filter(proto.Message): account, usage from the parent account will be included. If the field is omitted, the report will include usage from the parent account and all subaccounts, if they exist. - labels (Sequence[google.cloud.billing.budgets_v1.types.Filter.LabelsEntry]): + labels (Mapping[str, google.protobuf.struct_pb2.ListValue]): Optional. A single label and value pair specifying that usage from only this set of labeled resources should be included in the @@ -323,21 +367,44 @@ class CreditTypesTreatment(proto.Enum): EXCLUDE_ALL_CREDITS = 2 INCLUDE_SPECIFIED_CREDITS = 3 - projects = proto.RepeatedField(proto.STRING, number=1,) - credit_types = proto.RepeatedField(proto.STRING, number=7,) + projects = proto.RepeatedField( + proto.STRING, + number=1, + ) + credit_types = proto.RepeatedField( + proto.STRING, + number=7, + ) credit_types_treatment = proto.Field( - proto.ENUM, number=4, enum=CreditTypesTreatment, + proto.ENUM, + number=4, + enum=CreditTypesTreatment, + ) + services = proto.RepeatedField( + proto.STRING, + number=3, + ) + subaccounts = proto.RepeatedField( + proto.STRING, + number=5, ) - services = proto.RepeatedField(proto.STRING, number=3,) - subaccounts = proto.RepeatedField(proto.STRING, number=5,) labels = proto.MapField( - proto.STRING, proto.MESSAGE, number=6, message=struct_pb2.ListValue, + proto.STRING, + proto.MESSAGE, + number=6, + message=struct_pb2.ListValue, ) calendar_period = proto.Field( - proto.ENUM, number=8, oneof="usage_period", enum="CalendarPeriod", + proto.ENUM, + number=8, + oneof="usage_period", + enum="CalendarPeriod", ) custom_period = proto.Field( - proto.MESSAGE, number=9, oneof="usage_period", message="CustomPeriod", + proto.MESSAGE, + number=9, + oneof="usage_period", + message="CustomPeriod", ) @@ -355,8 +422,16 @@ class CustomPeriod(proto.Message): track all usage incurred since the start_date. """ - start_date = proto.Field(proto.MESSAGE, number=1, message=date_pb2.Date,) - end_date = proto.Field(proto.MESSAGE, number=2, message=date_pb2.Date,) + start_date = proto.Field( + proto.MESSAGE, + number=1, + message=date_pb2.Date, + ) + end_date = proto.Field( + proto.MESSAGE, + number=2, + message=date_pb2.Date, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/billing/budgets_v1/types/budget_service.py b/google/cloud/billing/budgets_v1/types/budget_service.py index e97e8ae..4f0250a 100644 --- a/google/cloud/billing/budgets_v1/types/budget_service.py +++ b/google/cloud/billing/budgets_v1/types/budget_service.py @@ -13,11 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from google.protobuf import field_mask_pb2 # type: ignore import proto # type: ignore from google.cloud.billing.budgets_v1.types import budget_model -from google.protobuf import field_mask_pb2 # type: ignore - __protobuf__ = proto.module( package="google.cloud.billing.budgets.v1", @@ -44,8 +43,15 @@ class CreateBudgetRequest(proto.Message): Required. Budget to create. """ - parent = proto.Field(proto.STRING, number=1,) - budget = proto.Field(proto.MESSAGE, number=2, message=budget_model.Budget,) + parent = proto.Field( + proto.STRING, + number=1, + ) + budget = proto.Field( + proto.MESSAGE, + number=2, + message=budget_model.Budget, + ) class UpdateBudgetRequest(proto.Message): @@ -65,9 +71,15 @@ class UpdateBudgetRequest(proto.Message): for more details about default values. """ - budget = proto.Field(proto.MESSAGE, number=1, message=budget_model.Budget,) + budget = proto.Field( + proto.MESSAGE, + number=1, + message=budget_model.Budget, + ) update_mask = proto.Field( - proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, ) @@ -80,7 +92,10 @@ class GetBudgetRequest(proto.Message): ``billingAccounts/{billingAccountId}/budgets/{budgetId}``. """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class ListBudgetsRequest(proto.Message): @@ -102,9 +117,18 @@ class ListBudgetsRequest(proto.Message): system should return the next page of data. """ - parent = proto.Field(proto.STRING, number=1,) - page_size = proto.Field(proto.INT32, number=2,) - page_token = proto.Field(proto.STRING, number=3,) + parent = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) class ListBudgetsResponse(proto.Message): @@ -124,8 +148,15 @@ class ListBudgetsResponse(proto.Message): def raw_page(self): return self - budgets = proto.RepeatedField(proto.MESSAGE, number=1, message=budget_model.Budget,) - next_page_token = proto.Field(proto.STRING, number=2,) + budgets = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=budget_model.Budget, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) class DeleteBudgetRequest(proto.Message): @@ -138,7 +169,10 @@ class DeleteBudgetRequest(proto.Message): ``billingAccounts/{billingAccountId}/budgets/{budgetId}``. """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/billing/budgets_v1beta1/__init__.py b/google/cloud/billing/budgets_v1beta1/__init__.py index 2e1626a..0186b84 100644 --- a/google/cloud/billing/budgets_v1beta1/__init__.py +++ b/google/cloud/billing/budgets_v1beta1/__init__.py @@ -14,23 +14,25 @@ # limitations under the License. # -from .services.budget_service import BudgetServiceClient -from .services.budget_service import BudgetServiceAsyncClient - -from .types.budget_model import AllUpdatesRule -from .types.budget_model import Budget -from .types.budget_model import BudgetAmount -from .types.budget_model import CustomPeriod -from .types.budget_model import Filter -from .types.budget_model import LastPeriodAmount -from .types.budget_model import ThresholdRule -from .types.budget_model import CalendarPeriod -from .types.budget_service import CreateBudgetRequest -from .types.budget_service import DeleteBudgetRequest -from .types.budget_service import GetBudgetRequest -from .types.budget_service import ListBudgetsRequest -from .types.budget_service import ListBudgetsResponse -from .types.budget_service import UpdateBudgetRequest +from .services.budget_service import BudgetServiceAsyncClient, BudgetServiceClient +from .types.budget_model import ( + AllUpdatesRule, + Budget, + BudgetAmount, + CalendarPeriod, + CustomPeriod, + Filter, + LastPeriodAmount, + ThresholdRule, +) +from .types.budget_service import ( + CreateBudgetRequest, + DeleteBudgetRequest, + GetBudgetRequest, + ListBudgetsRequest, + ListBudgetsResponse, + UpdateBudgetRequest, +) __all__ = ( "BudgetServiceAsyncClient", diff --git a/google/cloud/billing/budgets_v1beta1/services/budget_service/__init__.py b/google/cloud/billing/budgets_v1beta1/services/budget_service/__init__.py index 52de7ea..6ba5969 100644 --- a/google/cloud/billing/budgets_v1beta1/services/budget_service/__init__.py +++ b/google/cloud/billing/budgets_v1beta1/services/budget_service/__init__.py @@ -13,8 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from .client import BudgetServiceClient from .async_client import BudgetServiceAsyncClient +from .client import BudgetServiceClient __all__ = ( "BudgetServiceClient", diff --git a/google/cloud/billing/budgets_v1beta1/services/budget_service/async_client.py b/google/cloud/billing/budgets_v1beta1/services/budget_service/async_client.py index 77ff4de..0e7b7a0 100644 --- a/google/cloud/billing/budgets_v1beta1/services/budget_service/async_client.py +++ b/google/cloud/billing/budgets_v1beta1/services/budget_service/async_client.py @@ -16,15 +16,15 @@ from collections import OrderedDict import functools import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union -import pkg_resources +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union -from google.api_core.client_options import ClientOptions from google.api_core import exceptions as core_exceptions from google.api_core import gapic_v1 from google.api_core import retry as retries +from google.api_core.client_options import ClientOptions from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore +import pkg_resources try: OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] @@ -32,11 +32,11 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.billing.budgets_v1beta1.services.budget_service import pagers -from google.cloud.billing.budgets_v1beta1.types import budget_model -from google.cloud.billing.budgets_v1beta1.types import budget_service -from .transports.base import BudgetServiceTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import BudgetServiceGrpcAsyncIOTransport +from google.cloud.billing.budgets_v1beta1.types import budget_model, budget_service + from .client import BudgetServiceClient +from .transports.base import DEFAULT_CLIENT_INFO, BudgetServiceTransport +from .transports.grpc_asyncio import BudgetServiceGrpcAsyncIOTransport class BudgetServiceAsyncClient: @@ -219,14 +219,13 @@ async def create_budget( information on the limits of the number of budgets you can create. - .. code-block:: python from google.cloud.billing import budgets_v1beta1 - def sample_create_budget(): + async def sample_create_budget(): # Create a client - client = budgets_v1beta1.BudgetServiceClient() + client = budgets_v1beta1.BudgetServiceAsyncClient() # Initialize request argument(s) request = budgets_v1beta1.CreateBudgetRequest( @@ -234,7 +233,7 @@ def sample_create_budget(): ) # Make the request - response = client.create_budget(request=request) + response = await client.create_budget(request=request) # Handle the response print(response) @@ -279,7 +278,12 @@ def sample_create_budget(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -298,21 +302,20 @@ async def update_budget( fields that are not exposed in this API will not be changed by this method. - .. code-block:: python from google.cloud.billing import budgets_v1beta1 - def sample_update_budget(): + async def sample_update_budget(): # Create a client - client = budgets_v1beta1.BudgetServiceClient() + client = budgets_v1beta1.BudgetServiceAsyncClient() # Initialize request argument(s) request = budgets_v1beta1.UpdateBudgetRequest( ) # Make the request - response = client.update_budget(request=request) + response = await client.update_budget(request=request) # Handle the response print(response) @@ -369,7 +372,12 @@ def sample_update_budget(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -389,14 +397,13 @@ async def get_budget( the return value, though they may have been set in the Cloud Console. - .. code-block:: python from google.cloud.billing import budgets_v1beta1 - def sample_get_budget(): + async def sample_get_budget(): # Create a client - client = budgets_v1beta1.BudgetServiceClient() + client = budgets_v1beta1.BudgetServiceAsyncClient() # Initialize request argument(s) request = budgets_v1beta1.GetBudgetRequest( @@ -404,7 +411,7 @@ def sample_get_budget(): ) # Make the request - response = client.get_budget(request=request) + response = await client.get_budget(request=request) # Handle the response print(response) @@ -459,7 +466,12 @@ def sample_get_budget(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -479,14 +491,13 @@ async def list_budgets( the return value, though they may have been set in the Cloud Console. - .. code-block:: python from google.cloud.billing import budgets_v1beta1 - def sample_list_budgets(): + async def sample_list_budgets(): # Create a client - client = budgets_v1beta1.BudgetServiceClient() + client = budgets_v1beta1.BudgetServiceAsyncClient() # Initialize request argument(s) request = budgets_v1beta1.ListBudgetsRequest( @@ -497,7 +508,7 @@ def sample_list_budgets(): page_result = client.list_budgets(request=request) # Handle the response - for response in page_result: + async for response in page_result: print(response) Args: @@ -545,12 +556,20 @@ def sample_list_budgets(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListBudgetsAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -567,14 +586,13 @@ async def delete_budget( r"""Deletes a budget. Returns successfully if already deleted. - .. code-block:: python from google.cloud.billing import budgets_v1beta1 - def sample_delete_budget(): + async def sample_delete_budget(): # Create a client - client = budgets_v1beta1.BudgetServiceClient() + client = budgets_v1beta1.BudgetServiceAsyncClient() # Initialize request argument(s) request = budgets_v1beta1.DeleteBudgetRequest( @@ -582,7 +600,7 @@ def sample_delete_budget(): ) # Make the request - client.delete_budget(request=request) + await client.delete_budget(request=request) Args: request (Union[google.cloud.billing.budgets_v1beta1.types.DeleteBudgetRequest, dict]): @@ -622,7 +640,10 @@ def sample_delete_budget(): # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) async def __aenter__(self): diff --git a/google/cloud/billing/budgets_v1beta1/services/budget_service/client.py b/google/cloud/billing/budgets_v1beta1/services/budget_service/client.py index 3006a6d..71d45dc 100644 --- a/google/cloud/billing/budgets_v1beta1/services/budget_service/client.py +++ b/google/cloud/billing/budgets_v1beta1/services/budget_service/client.py @@ -16,18 +16,18 @@ from collections import OrderedDict import os import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union -import pkg_resources +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union from google.api_core import client_options as client_options_lib from google.api_core import exceptions as core_exceptions from google.api_core import gapic_v1 from google.api_core import retry as retries from google.auth import credentials as ga_credentials # type: ignore +from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore -from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore +import pkg_resources try: OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] @@ -35,9 +35,9 @@ OptionalRetry = Union[retries.Retry, object] # type: ignore from google.cloud.billing.budgets_v1beta1.services.budget_service import pagers -from google.cloud.billing.budgets_v1beta1.types import budget_model -from google.cloud.billing.budgets_v1beta1.types import budget_service -from .transports.base import BudgetServiceTransport, DEFAULT_CLIENT_INFO +from google.cloud.billing.budgets_v1beta1.types import budget_model, budget_service + +from .transports.base import DEFAULT_CLIENT_INFO, BudgetServiceTransport from .transports.grpc import BudgetServiceGrpcTransport from .transports.grpc_asyncio import BudgetServiceGrpcAsyncIOTransport @@ -54,7 +54,10 @@ class BudgetServiceClientMeta(type): _transport_registry["grpc"] = BudgetServiceGrpcTransport _transport_registry["grpc_asyncio"] = BudgetServiceGrpcAsyncIOTransport - def get_transport_class(cls, label: str = None,) -> Type[BudgetServiceTransport]: + def get_transport_class( + cls, + label: str = None, + ) -> Type[BudgetServiceTransport]: """Returns an appropriate transport class. Args: @@ -162,10 +165,14 @@ def transport(self) -> BudgetServiceTransport: return self._transport @staticmethod - def budget_path(billing_account: str, budget: str,) -> str: + def budget_path( + billing_account: str, + budget: str, + ) -> str: """Returns a fully-qualified budget string.""" return "billingAccounts/{billing_account}/budgets/{budget}".format( - billing_account=billing_account, budget=budget, + billing_account=billing_account, + budget=budget, ) @staticmethod @@ -177,7 +184,9 @@ def parse_budget_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_billing_account_path(billing_account: str,) -> str: + def common_billing_account_path( + billing_account: str, + ) -> str: """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, @@ -190,9 +199,13 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_folder_path(folder: str,) -> str: + def common_folder_path( + folder: str, + ) -> str: """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder,) + return "folders/{folder}".format( + folder=folder, + ) @staticmethod def parse_common_folder_path(path: str) -> Dict[str, str]: @@ -201,9 +214,13 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_organization_path(organization: str,) -> str: + def common_organization_path( + organization: str, + ) -> str: """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization,) + return "organizations/{organization}".format( + organization=organization, + ) @staticmethod def parse_common_organization_path(path: str) -> Dict[str, str]: @@ -212,9 +229,13 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_project_path(project: str,) -> str: + def common_project_path( + project: str, + ) -> str: """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project,) + return "projects/{project}".format( + project=project, + ) @staticmethod def parse_common_project_path(path: str) -> Dict[str, str]: @@ -223,10 +244,14 @@ def parse_common_project_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_location_path(project: str, location: str,) -> str: + def common_location_path( + project: str, + location: str, + ) -> str: """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) @staticmethod @@ -413,7 +438,6 @@ def create_budget( information on the limits of the number of budgets you can create. - .. code-block:: python from google.cloud.billing import budgets_v1beta1 @@ -474,7 +498,12 @@ def sample_create_budget(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -493,7 +522,6 @@ def update_budget( fields that are not exposed in this API will not be changed by this method. - .. code-block:: python from google.cloud.billing import budgets_v1beta1 @@ -555,7 +583,12 @@ def sample_update_budget(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -575,7 +608,6 @@ def get_budget( the return value, though they may have been set in the Cloud Console. - .. code-block:: python from google.cloud.billing import budgets_v1beta1 @@ -636,7 +668,12 @@ def sample_get_budget(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -656,7 +693,6 @@ def list_budgets( the return value, though they may have been set in the Cloud Console. - .. code-block:: python from google.cloud.billing import budgets_v1beta1 @@ -713,12 +749,20 @@ def sample_list_budgets(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListBudgetsPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -735,7 +779,6 @@ def delete_budget( r"""Deletes a budget. Returns successfully if already deleted. - .. code-block:: python from google.cloud.billing import budgets_v1beta1 @@ -781,7 +824,10 @@ def sample_delete_budget(): # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def __enter__(self): diff --git a/google/cloud/billing/budgets_v1beta1/services/budget_service/pagers.py b/google/cloud/billing/budgets_v1beta1/services/budget_service/pagers.py index 971076c..897d7ff 100644 --- a/google/cloud/billing/budgets_v1beta1/services/budget_service/pagers.py +++ b/google/cloud/billing/budgets_v1beta1/services/budget_service/pagers.py @@ -18,14 +18,13 @@ AsyncIterator, Awaitable, Callable, + Iterator, + Optional, Sequence, Tuple, - Optional, - Iterator, ) -from google.cloud.billing.budgets_v1beta1.types import budget_model -from google.cloud.billing.budgets_v1beta1.types import budget_service +from google.cloud.billing.budgets_v1beta1.types import budget_model, budget_service class ListBudgetsPager: diff --git a/google/cloud/billing/budgets_v1beta1/services/budget_service/transports/__init__.py b/google/cloud/billing/budgets_v1beta1/services/budget_service/transports/__init__.py index ffb6ed3..bf85936 100644 --- a/google/cloud/billing/budgets_v1beta1/services/budget_service/transports/__init__.py +++ b/google/cloud/billing/budgets_v1beta1/services/budget_service/transports/__init__.py @@ -20,7 +20,6 @@ from .grpc import BudgetServiceGrpcTransport from .grpc_asyncio import BudgetServiceGrpcAsyncIOTransport - # Compile a registry of transports. _transport_registry = OrderedDict() # type: Dict[str, Type[BudgetServiceTransport]] _transport_registry["grpc"] = BudgetServiceGrpcTransport diff --git a/google/cloud/billing/budgets_v1beta1/services/budget_service/transports/base.py b/google/cloud/billing/budgets_v1beta1/services/budget_service/transports/base.py index ab5fe00..d8139ab 100644 --- a/google/cloud/billing/budgets_v1beta1/services/budget_service/transports/base.py +++ b/google/cloud/billing/budgets_v1beta1/services/budget_service/transports/base.py @@ -15,19 +15,18 @@ # import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import pkg_resources -import google.auth # type: ignore import google.api_core from google.api_core import exceptions as core_exceptions from google.api_core import gapic_v1 from google.api_core import retry as retries +import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore - -from google.cloud.billing.budgets_v1beta1.types import budget_model -from google.cloud.billing.budgets_v1beta1.types import budget_service from google.protobuf import empty_pb2 # type: ignore +import pkg_resources + +from google.cloud.billing.budgets_v1beta1.types import budget_model, budget_service try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( @@ -85,6 +84,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" @@ -126,7 +126,9 @@ def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { self.create_budget: gapic_v1.method.wrap_method( - self.create_budget, default_timeout=60.0, client_info=client_info, + self.create_budget, + default_timeout=60.0, + client_info=client_info, ), self.update_budget: gapic_v1.method.wrap_method( self.update_budget, @@ -193,9 +195,9 @@ def _prep_wrapped_messages(self, client_info): def close(self): """Closes resources associated with the transport. - .. warning:: - Only call this method if the transport is NOT shared - with other clients - this may cause errors in other clients! + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! """ raise NotImplementedError() @@ -247,5 +249,9 @@ def delete_budget( ]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("BudgetServiceTransport",) diff --git a/google/cloud/billing/budgets_v1beta1/services/budget_service/transports/grpc.py b/google/cloud/billing/budgets_v1beta1/services/budget_service/transports/grpc.py index d33dca5..1b8afe2 100644 --- a/google/cloud/billing/budgets_v1beta1/services/budget_service/transports/grpc.py +++ b/google/cloud/billing/budgets_v1beta1/services/budget_service/transports/grpc.py @@ -13,21 +13,19 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import warnings from typing import Callable, Dict, Optional, Sequence, Tuple, Union +import warnings -from google.api_core import grpc_helpers -from google.api_core import gapic_v1 +from google.api_core import gapic_v1, grpc_helpers import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore - +from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore -from google.cloud.billing.budgets_v1beta1.types import budget_model -from google.cloud.billing.budgets_v1beta1.types import budget_service -from google.protobuf import empty_pb2 # type: ignore -from .base import BudgetServiceTransport, DEFAULT_CLIENT_INFO +from google.cloud.billing.budgets_v1beta1.types import budget_model, budget_service + +from .base import DEFAULT_CLIENT_INFO, BudgetServiceTransport class BudgetServiceGrpcTransport(BudgetServiceTransport): @@ -228,8 +226,7 @@ def create_channel( @property def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ + """Return the channel designed to connect to this service.""" return self._grpc_channel @property @@ -385,5 +382,9 @@ def delete_budget( def close(self): self.grpc_channel.close() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("BudgetServiceGrpcTransport",) diff --git a/google/cloud/billing/budgets_v1beta1/services/budget_service/transports/grpc_asyncio.py b/google/cloud/billing/budgets_v1beta1/services/budget_service/transports/grpc_asyncio.py index 79e52ad..5b35be7 100644 --- a/google/cloud/billing/budgets_v1beta1/services/budget_service/transports/grpc_asyncio.py +++ b/google/cloud/billing/budgets_v1beta1/services/budget_service/transports/grpc_asyncio.py @@ -13,21 +13,19 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import warnings from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union +import warnings -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers_async +from google.api_core import gapic_v1, grpc_helpers_async from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore - +from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore from grpc.experimental import aio # type: ignore -from google.cloud.billing.budgets_v1beta1.types import budget_model -from google.cloud.billing.budgets_v1beta1.types import budget_service -from google.protobuf import empty_pb2 # type: ignore -from .base import BudgetServiceTransport, DEFAULT_CLIENT_INFO +from google.cloud.billing.budgets_v1beta1.types import budget_model, budget_service + +from .base import DEFAULT_CLIENT_INFO, BudgetServiceTransport from .grpc import BudgetServiceGrpcTransport diff --git a/google/cloud/billing/budgets_v1beta1/types/__init__.py b/google/cloud/billing/budgets_v1beta1/types/__init__.py index 49bc43d..e504f68 100644 --- a/google/cloud/billing/budgets_v1beta1/types/__init__.py +++ b/google/cloud/billing/budgets_v1beta1/types/__init__.py @@ -17,11 +17,11 @@ AllUpdatesRule, Budget, BudgetAmount, + CalendarPeriod, CustomPeriod, Filter, LastPeriodAmount, ThresholdRule, - CalendarPeriod, ) from .budget_service import ( CreateBudgetRequest, diff --git a/google/cloud/billing/budgets_v1beta1/types/budget_model.py b/google/cloud/billing/budgets_v1beta1/types/budget_model.py index 14a573f..1fe507a 100644 --- a/google/cloud/billing/budgets_v1beta1/types/budget_model.py +++ b/google/cloud/billing/budgets_v1beta1/types/budget_model.py @@ -13,12 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import proto # type: ignore - from google.protobuf import struct_pb2 # type: ignore from google.type import date_pb2 # type: ignore from google.type import money_pb2 # type: ignore - +import proto # type: ignore __protobuf__ = proto.module( package="google.cloud.billing.budgets.v1beta1", @@ -89,15 +87,38 @@ class Budget(proto.Message): other changes. """ - name = proto.Field(proto.STRING, number=1,) - display_name = proto.Field(proto.STRING, number=2,) - budget_filter = proto.Field(proto.MESSAGE, number=3, message="Filter",) - amount = proto.Field(proto.MESSAGE, number=4, message="BudgetAmount",) + name = proto.Field( + proto.STRING, + number=1, + ) + display_name = proto.Field( + proto.STRING, + number=2, + ) + budget_filter = proto.Field( + proto.MESSAGE, + number=3, + message="Filter", + ) + amount = proto.Field( + proto.MESSAGE, + number=4, + message="BudgetAmount", + ) threshold_rules = proto.RepeatedField( - proto.MESSAGE, number=5, message="ThresholdRule", + proto.MESSAGE, + number=5, + message="ThresholdRule", + ) + all_updates_rule = proto.Field( + proto.MESSAGE, + number=6, + message="AllUpdatesRule", + ) + etag = proto.Field( + proto.STRING, + number=7, ) - all_updates_rule = proto.Field(proto.MESSAGE, number=6, message="AllUpdatesRule",) - etag = proto.Field(proto.STRING, number=7,) class BudgetAmount(proto.Message): @@ -132,10 +153,16 @@ class BudgetAmount(proto.Message): """ specified_amount = proto.Field( - proto.MESSAGE, number=1, oneof="budget_amount", message=money_pb2.Money, + proto.MESSAGE, + number=1, + oneof="budget_amount", + message=money_pb2.Money, ) last_period_amount = proto.Field( - proto.MESSAGE, number=2, oneof="budget_amount", message="LastPeriodAmount", + proto.MESSAGE, + number=2, + oneof="budget_amount", + message="LastPeriodAmount", ) @@ -192,8 +219,15 @@ class Basis(proto.Enum): CURRENT_SPEND = 1 FORECASTED_SPEND = 2 - threshold_percent = proto.Field(proto.DOUBLE, number=1,) - spend_basis = proto.Field(proto.ENUM, number=2, enum=Basis,) + threshold_percent = proto.Field( + proto.DOUBLE, + number=1, + ) + spend_basis = proto.Field( + proto.ENUM, + number=2, + enum=Basis, + ) class AllUpdatesRule(proto.Message): @@ -240,10 +274,22 @@ class AllUpdatesRule(proto.Message): Account User IAM roles for the target account. """ - pubsub_topic = proto.Field(proto.STRING, number=1,) - schema_version = proto.Field(proto.STRING, number=2,) - monitoring_notification_channels = proto.RepeatedField(proto.STRING, number=3,) - disable_default_iam_recipients = proto.Field(proto.BOOL, number=4,) + pubsub_topic = proto.Field( + proto.STRING, + number=1, + ) + schema_version = proto.Field( + proto.STRING, + number=2, + ) + monitoring_notification_channels = proto.RepeatedField( + proto.STRING, + number=3, + ) + disable_default_iam_recipients = proto.Field( + proto.BOOL, + number=4, + ) class Filter(proto.Message): @@ -296,7 +342,7 @@ class Filter(proto.Message): account, usage from the parent account will be included. If omitted, the report will include usage from the parent account and all subaccounts, if they exist. - labels (Sequence[google.cloud.billing.budgets_v1beta1.types.Filter.LabelsEntry]): + labels (Mapping[str, google.protobuf.struct_pb2.ListValue]): Optional. A single label and value pair specifying that usage from only this set of labeled resources should be included in the budget. If omitted, the report will include @@ -339,21 +385,44 @@ class CreditTypesTreatment(proto.Enum): EXCLUDE_ALL_CREDITS = 2 INCLUDE_SPECIFIED_CREDITS = 3 - projects = proto.RepeatedField(proto.STRING, number=1,) - credit_types = proto.RepeatedField(proto.STRING, number=7,) + projects = proto.RepeatedField( + proto.STRING, + number=1, + ) + credit_types = proto.RepeatedField( + proto.STRING, + number=7, + ) credit_types_treatment = proto.Field( - proto.ENUM, number=4, enum=CreditTypesTreatment, + proto.ENUM, + number=4, + enum=CreditTypesTreatment, + ) + services = proto.RepeatedField( + proto.STRING, + number=3, + ) + subaccounts = proto.RepeatedField( + proto.STRING, + number=5, ) - services = proto.RepeatedField(proto.STRING, number=3,) - subaccounts = proto.RepeatedField(proto.STRING, number=5,) labels = proto.MapField( - proto.STRING, proto.MESSAGE, number=6, message=struct_pb2.ListValue, + proto.STRING, + proto.MESSAGE, + number=6, + message=struct_pb2.ListValue, ) calendar_period = proto.Field( - proto.ENUM, number=8, oneof="usage_period", enum="CalendarPeriod", + proto.ENUM, + number=8, + oneof="usage_period", + enum="CalendarPeriod", ) custom_period = proto.Field( - proto.MESSAGE, number=9, oneof="usage_period", message="CustomPeriod", + proto.MESSAGE, + number=9, + oneof="usage_period", + message="CustomPeriod", ) @@ -371,8 +440,16 @@ class CustomPeriod(proto.Message): track all usage incurred since the start_date. """ - start_date = proto.Field(proto.MESSAGE, number=1, message=date_pb2.Date,) - end_date = proto.Field(proto.MESSAGE, number=2, message=date_pb2.Date,) + start_date = proto.Field( + proto.MESSAGE, + number=1, + message=date_pb2.Date, + ) + end_date = proto.Field( + proto.MESSAGE, + number=2, + message=date_pb2.Date, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/billing/budgets_v1beta1/types/budget_service.py b/google/cloud/billing/budgets_v1beta1/types/budget_service.py index 4cc1a96..ff693f1 100644 --- a/google/cloud/billing/budgets_v1beta1/types/budget_service.py +++ b/google/cloud/billing/budgets_v1beta1/types/budget_service.py @@ -13,11 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from google.protobuf import field_mask_pb2 # type: ignore import proto # type: ignore from google.cloud.billing.budgets_v1beta1.types import budget_model -from google.protobuf import field_mask_pb2 # type: ignore - __protobuf__ = proto.module( package="google.cloud.billing.budgets.v1beta1", @@ -44,8 +43,15 @@ class CreateBudgetRequest(proto.Message): Required. Budget to create. """ - parent = proto.Field(proto.STRING, number=1,) - budget = proto.Field(proto.MESSAGE, number=2, message=budget_model.Budget,) + parent = proto.Field( + proto.STRING, + number=1, + ) + budget = proto.Field( + proto.MESSAGE, + number=2, + message=budget_model.Budget, + ) class UpdateBudgetRequest(proto.Message): @@ -65,9 +71,15 @@ class UpdateBudgetRequest(proto.Message): for more details about default values. """ - budget = proto.Field(proto.MESSAGE, number=1, message=budget_model.Budget,) + budget = proto.Field( + proto.MESSAGE, + number=1, + message=budget_model.Budget, + ) update_mask = proto.Field( - proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, ) @@ -80,7 +92,10 @@ class GetBudgetRequest(proto.Message): ``billingAccounts/{billingAccountId}/budgets/{budgetId}``. """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class ListBudgetsRequest(proto.Message): @@ -102,9 +117,18 @@ class ListBudgetsRequest(proto.Message): system should return the next page of data. """ - parent = proto.Field(proto.STRING, number=1,) - page_size = proto.Field(proto.INT32, number=2,) - page_token = proto.Field(proto.STRING, number=3,) + parent = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) class ListBudgetsResponse(proto.Message): @@ -124,8 +148,15 @@ class ListBudgetsResponse(proto.Message): def raw_page(self): return self - budgets = proto.RepeatedField(proto.MESSAGE, number=1, message=budget_model.Budget,) - next_page_token = proto.Field(proto.STRING, number=2,) + budgets = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=budget_model.Budget, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) class DeleteBudgetRequest(proto.Message): @@ -138,7 +169,10 @@ class DeleteBudgetRequest(proto.Message): ``billingAccounts/{billingAccountId}/budgets/{budgetId}``. """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/noxfile.py b/noxfile.py index 2a2001c..7c1742d 100644 --- a/noxfile.py +++ b/noxfile.py @@ -17,19 +17,45 @@ # Generated by synthtool. DO NOT EDIT! from __future__ import absolute_import + import os import pathlib import shutil +import warnings import nox - -BLACK_VERSION = "black==19.10b0" -BLACK_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] +BLACK_VERSION = "black==22.3.0" +ISORT_VERSION = "isort==5.10.1" +LINT_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] DEFAULT_PYTHON_VERSION = "3.8" -SYSTEM_TEST_PYTHON_VERSIONS = ["3.8"] + UNIT_TEST_PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9", "3.10"] +UNIT_TEST_STANDARD_DEPENDENCIES = [ + "mock", + "asyncmock", + "pytest", + "pytest-cov", + "pytest-asyncio", +] +UNIT_TEST_EXTERNAL_DEPENDENCIES = [] +UNIT_TEST_LOCAL_DEPENDENCIES = [] +UNIT_TEST_DEPENDENCIES = [] +UNIT_TEST_EXTRAS = [] +UNIT_TEST_EXTRAS_BY_PYTHON = {} + +SYSTEM_TEST_PYTHON_VERSIONS = ["3.8"] +SYSTEM_TEST_STANDARD_DEPENDENCIES = [ + "mock", + "pytest", + "google-cloud-testutils", +] +SYSTEM_TEST_EXTERNAL_DEPENDENCIES = [] +SYSTEM_TEST_LOCAL_DEPENDENCIES = [] +SYSTEM_TEST_DEPENDENCIES = [] +SYSTEM_TEST_EXTRAS = [] +SYSTEM_TEST_EXTRAS_BY_PYTHON = {} CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() @@ -57,7 +83,9 @@ def lint(session): """ session.install("flake8", BLACK_VERSION) session.run( - "black", "--check", *BLACK_PATHS, + "black", + "--check", + *LINT_PATHS, ) session.run("flake8", "google", "tests") @@ -67,7 +95,28 @@ def blacken(session): """Run black. Format code to uniform standard.""" session.install(BLACK_VERSION) session.run( - "black", *BLACK_PATHS, + "black", + *LINT_PATHS, + ) + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def format(session): + """ + Run isort to sort imports. Then run black + to format code to uniform standard. + """ + session.install(BLACK_VERSION, ISORT_VERSION) + # Use the --fss option to sort imports using strict alphabetical order. + # See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections + session.run( + "isort", + "--fss", + *LINT_PATHS, + ) + session.run( + "black", + *LINT_PATHS, ) @@ -78,23 +127,41 @@ def lint_setup_py(session): session.run("python", "setup.py", "check", "--restructuredtext", "--strict") +def install_unittest_dependencies(session, *constraints): + standard_deps = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_DEPENDENCIES + session.install(*standard_deps, *constraints) + + if UNIT_TEST_EXTERNAL_DEPENDENCIES: + warnings.warn( + "'unit_test_external_dependencies' is deprecated. Instead, please " + "use 'unit_test_dependencies' or 'unit_test_local_dependencies'.", + DeprecationWarning, + ) + session.install(*UNIT_TEST_EXTERNAL_DEPENDENCIES, *constraints) + + if UNIT_TEST_LOCAL_DEPENDENCIES: + session.install(*UNIT_TEST_LOCAL_DEPENDENCIES, *constraints) + + if UNIT_TEST_EXTRAS_BY_PYTHON: + extras = UNIT_TEST_EXTRAS_BY_PYTHON.get(session.python, []) + elif UNIT_TEST_EXTRAS: + extras = UNIT_TEST_EXTRAS + else: + extras = [] + + if extras: + session.install("-e", f".[{','.join(extras)}]", *constraints) + else: + session.install("-e", ".", *constraints) + + def default(session): # Install all test dependencies, then install this package in-place. constraints_path = str( CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" ) - session.install( - "mock", - "asyncmock", - "pytest", - "pytest-cov", - "pytest-asyncio", - "-c", - constraints_path, - ) - - session.install("-e", ".", "-c", constraints_path) + install_unittest_dependencies(session, "-c", constraints_path) # Run py.test against the unit tests. session.run( @@ -118,6 +185,35 @@ def unit(session): default(session) +def install_systemtest_dependencies(session, *constraints): + + # Use pre-release gRPC for system tests. + session.install("--pre", "grpcio") + + session.install(*SYSTEM_TEST_STANDARD_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_EXTERNAL_DEPENDENCIES: + session.install(*SYSTEM_TEST_EXTERNAL_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_LOCAL_DEPENDENCIES: + session.install("-e", *SYSTEM_TEST_LOCAL_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_DEPENDENCIES: + session.install("-e", *SYSTEM_TEST_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_EXTRAS_BY_PYTHON: + extras = SYSTEM_TEST_EXTRAS_BY_PYTHON.get(session.python, []) + elif SYSTEM_TEST_EXTRAS: + extras = SYSTEM_TEST_EXTRAS + else: + extras = [] + + if extras: + session.install("-e", f".[{','.join(extras)}]", *constraints) + else: + session.install("-e", ".", *constraints) + + @nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS) def system(session): """Run the system test suite.""" @@ -140,13 +236,7 @@ def system(session): if not system_test_exists and not system_test_folder_exists: session.skip("System tests were not found") - # Use pre-release gRPC for system tests. - session.install("--pre", "grpcio") - - # Install all test dependencies, then install this package into the - # virtualenv's dist-packages. - session.install("mock", "pytest", "google-cloud-testutils", "-c", constraints_path) - session.install("-e", ".", "-c", constraints_path) + install_systemtest_dependencies(session, "-c", constraints_path) # Run py.test against the system tests. if system_test_exists: diff --git a/samples/generated_samples/snippet_metadata_budgets_v1.json b/samples/generated_samples/snippet_metadata_budgets_v1.json index c619605..465fffe 100644 --- a/samples/generated_samples/snippet_metadata_budgets_v1.json +++ b/samples/generated_samples/snippet_metadata_budgets_v1.json @@ -1,16 +1,65 @@ { + "clientLibrary": { + "apis": [ + { + "id": "google.cloud.billing.budgets.v1", + "version": "v1" + } + ], + "language": "PYTHON", + "name": "google-cloud-billing-budgets" + }, "snippets": [ { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.billing.budgets_v1.BudgetServiceAsyncClient", + "shortName": "BudgetServiceAsyncClient" + }, + "fullName": "google.cloud.billing.budgets_v1.BudgetServiceAsyncClient.create_budget", "method": { + "fullName": "google.cloud.billing.budgets.v1.BudgetService.CreateBudget", "service": { + "fullName": "google.cloud.billing.budgets.v1.BudgetService", "shortName": "BudgetService" }, "shortName": "CreateBudget" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.billing.budgets_v1.types.CreateBudgetRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "budget", + "type": "google.cloud.billing.budgets_v1.types.Budget" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.billing.budgets_v1.types.Budget", + "shortName": "create_budget" }, + "description": "Sample for CreateBudget", "file": "billingbudgets_v1_generated_budget_service_create_budget_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "billingbudgets_v1_generated_BudgetService_CreateBudget_async", "segments": [ { @@ -43,18 +92,58 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "billingbudgets_v1_generated_budget_service_create_budget_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.billing.budgets_v1.BudgetServiceClient", + "shortName": "BudgetServiceClient" + }, + "fullName": "google.cloud.billing.budgets_v1.BudgetServiceClient.create_budget", "method": { + "fullName": "google.cloud.billing.budgets.v1.BudgetService.CreateBudget", "service": { + "fullName": "google.cloud.billing.budgets.v1.BudgetService", "shortName": "BudgetService" }, "shortName": "CreateBudget" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.billing.budgets_v1.types.CreateBudgetRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "budget", + "type": "google.cloud.billing.budgets_v1.types.Budget" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.billing.budgets_v1.types.Budget", + "shortName": "create_budget" }, + "description": "Sample for CreateBudget", "file": "billingbudgets_v1_generated_budget_service_create_budget_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "billingbudgets_v1_generated_BudgetService_CreateBudget_sync", "segments": [ { @@ -87,19 +176,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "billingbudgets_v1_generated_budget_service_create_budget_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.billing.budgets_v1.BudgetServiceAsyncClient", + "shortName": "BudgetServiceAsyncClient" + }, + "fullName": "google.cloud.billing.budgets_v1.BudgetServiceAsyncClient.delete_budget", "method": { + "fullName": "google.cloud.billing.budgets.v1.BudgetService.DeleteBudget", "service": { + "fullName": "google.cloud.billing.budgets.v1.BudgetService", "shortName": "BudgetService" }, "shortName": "DeleteBudget" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.billing.budgets_v1.types.DeleteBudgetRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_budget" }, + "description": "Sample for DeleteBudget", "file": "billingbudgets_v1_generated_budget_service_delete_budget_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "billingbudgets_v1_generated_BudgetService_DeleteBudget_async", "segments": [ { @@ -130,18 +254,53 @@ "end": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "billingbudgets_v1_generated_budget_service_delete_budget_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.billing.budgets_v1.BudgetServiceClient", + "shortName": "BudgetServiceClient" + }, + "fullName": "google.cloud.billing.budgets_v1.BudgetServiceClient.delete_budget", "method": { + "fullName": "google.cloud.billing.budgets.v1.BudgetService.DeleteBudget", "service": { + "fullName": "google.cloud.billing.budgets.v1.BudgetService", "shortName": "BudgetService" }, "shortName": "DeleteBudget" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.billing.budgets_v1.types.DeleteBudgetRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_budget" }, + "description": "Sample for DeleteBudget", "file": "billingbudgets_v1_generated_budget_service_delete_budget_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "billingbudgets_v1_generated_BudgetService_DeleteBudget_sync", "segments": [ { @@ -172,19 +331,55 @@ "end": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "billingbudgets_v1_generated_budget_service_delete_budget_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.billing.budgets_v1.BudgetServiceAsyncClient", + "shortName": "BudgetServiceAsyncClient" + }, + "fullName": "google.cloud.billing.budgets_v1.BudgetServiceAsyncClient.get_budget", "method": { + "fullName": "google.cloud.billing.budgets.v1.BudgetService.GetBudget", "service": { + "fullName": "google.cloud.billing.budgets.v1.BudgetService", "shortName": "BudgetService" }, "shortName": "GetBudget" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.billing.budgets_v1.types.GetBudgetRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.billing.budgets_v1.types.Budget", + "shortName": "get_budget" }, + "description": "Sample for GetBudget", "file": "billingbudgets_v1_generated_budget_service_get_budget_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "billingbudgets_v1_generated_BudgetService_GetBudget_async", "segments": [ { @@ -217,18 +412,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "billingbudgets_v1_generated_budget_service_get_budget_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.billing.budgets_v1.BudgetServiceClient", + "shortName": "BudgetServiceClient" + }, + "fullName": "google.cloud.billing.budgets_v1.BudgetServiceClient.get_budget", "method": { + "fullName": "google.cloud.billing.budgets.v1.BudgetService.GetBudget", "service": { + "fullName": "google.cloud.billing.budgets.v1.BudgetService", "shortName": "BudgetService" }, "shortName": "GetBudget" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.billing.budgets_v1.types.GetBudgetRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.billing.budgets_v1.types.Budget", + "shortName": "get_budget" }, + "description": "Sample for GetBudget", "file": "billingbudgets_v1_generated_budget_service_get_budget_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "billingbudgets_v1_generated_BudgetService_GetBudget_sync", "segments": [ { @@ -261,19 +492,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "billingbudgets_v1_generated_budget_service_get_budget_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.billing.budgets_v1.BudgetServiceAsyncClient", + "shortName": "BudgetServiceAsyncClient" + }, + "fullName": "google.cloud.billing.budgets_v1.BudgetServiceAsyncClient.list_budgets", "method": { + "fullName": "google.cloud.billing.budgets.v1.BudgetService.ListBudgets", "service": { + "fullName": "google.cloud.billing.budgets.v1.BudgetService", "shortName": "BudgetService" }, "shortName": "ListBudgets" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.billing.budgets_v1.types.ListBudgetsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.billing.budgets_v1.services.budget_service.pagers.ListBudgetsAsyncPager", + "shortName": "list_budgets" }, + "description": "Sample for ListBudgets", "file": "billingbudgets_v1_generated_budget_service_list_budgets_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "billingbudgets_v1_generated_BudgetService_ListBudgets_async", "segments": [ { @@ -306,18 +573,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "billingbudgets_v1_generated_budget_service_list_budgets_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.billing.budgets_v1.BudgetServiceClient", + "shortName": "BudgetServiceClient" + }, + "fullName": "google.cloud.billing.budgets_v1.BudgetServiceClient.list_budgets", "method": { + "fullName": "google.cloud.billing.budgets.v1.BudgetService.ListBudgets", "service": { + "fullName": "google.cloud.billing.budgets.v1.BudgetService", "shortName": "BudgetService" }, "shortName": "ListBudgets" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.billing.budgets_v1.types.ListBudgetsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.billing.budgets_v1.services.budget_service.pagers.ListBudgetsPager", + "shortName": "list_budgets" }, + "description": "Sample for ListBudgets", "file": "billingbudgets_v1_generated_budget_service_list_budgets_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "billingbudgets_v1_generated_BudgetService_ListBudgets_sync", "segments": [ { @@ -350,19 +653,59 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "billingbudgets_v1_generated_budget_service_list_budgets_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.billing.budgets_v1.BudgetServiceAsyncClient", + "shortName": "BudgetServiceAsyncClient" + }, + "fullName": "google.cloud.billing.budgets_v1.BudgetServiceAsyncClient.update_budget", "method": { + "fullName": "google.cloud.billing.budgets.v1.BudgetService.UpdateBudget", "service": { + "fullName": "google.cloud.billing.budgets.v1.BudgetService", "shortName": "BudgetService" }, "shortName": "UpdateBudget" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.billing.budgets_v1.types.UpdateBudgetRequest" + }, + { + "name": "budget", + "type": "google.cloud.billing.budgets_v1.types.Budget" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.billing.budgets_v1.types.Budget", + "shortName": "update_budget" }, + "description": "Sample for UpdateBudget", "file": "billingbudgets_v1_generated_budget_service_update_budget_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "billingbudgets_v1_generated_BudgetService_UpdateBudget_async", "segments": [ { @@ -395,18 +738,58 @@ "start": 41, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "billingbudgets_v1_generated_budget_service_update_budget_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.billing.budgets_v1.BudgetServiceClient", + "shortName": "BudgetServiceClient" + }, + "fullName": "google.cloud.billing.budgets_v1.BudgetServiceClient.update_budget", "method": { + "fullName": "google.cloud.billing.budgets.v1.BudgetService.UpdateBudget", "service": { + "fullName": "google.cloud.billing.budgets.v1.BudgetService", "shortName": "BudgetService" }, "shortName": "UpdateBudget" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.billing.budgets_v1.types.UpdateBudgetRequest" + }, + { + "name": "budget", + "type": "google.cloud.billing.budgets_v1.types.Budget" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.billing.budgets_v1.types.Budget", + "shortName": "update_budget" }, + "description": "Sample for UpdateBudget", "file": "billingbudgets_v1_generated_budget_service_update_budget_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "billingbudgets_v1_generated_BudgetService_UpdateBudget_sync", "segments": [ { @@ -439,7 +822,8 @@ "start": 41, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "billingbudgets_v1_generated_budget_service_update_budget_sync.py" } ] } diff --git a/samples/generated_samples/snippet_metadata_budgets_v1beta1.json b/samples/generated_samples/snippet_metadata_budgets_v1beta1.json index 7c18f35..24fb61e 100644 --- a/samples/generated_samples/snippet_metadata_budgets_v1beta1.json +++ b/samples/generated_samples/snippet_metadata_budgets_v1beta1.json @@ -1,16 +1,57 @@ { + "clientLibrary": { + "apis": [ + { + "id": "google.cloud.billing.budgets.v1beta1", + "version": "v1beta1" + } + ], + "language": "PYTHON", + "name": "google-cloud-billing-budgets" + }, "snippets": [ { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.billing.budgets_v1beta1.BudgetServiceAsyncClient", + "shortName": "BudgetServiceAsyncClient" + }, + "fullName": "google.cloud.billing.budgets_v1beta1.BudgetServiceAsyncClient.create_budget", "method": { + "fullName": "google.cloud.billing.budgets.v1beta1.BudgetService.CreateBudget", "service": { + "fullName": "google.cloud.billing.budgets.v1beta1.BudgetService", "shortName": "BudgetService" }, "shortName": "CreateBudget" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.billing.budgets_v1beta1.types.CreateBudgetRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.billing.budgets_v1beta1.types.Budget", + "shortName": "create_budget" }, + "description": "Sample for CreateBudget", "file": "billingbudgets_v1beta1_generated_budget_service_create_budget_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "billingbudgets_v1beta1_generated_BudgetService_CreateBudget_async", "segments": [ { @@ -43,18 +84,50 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "billingbudgets_v1beta1_generated_budget_service_create_budget_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.billing.budgets_v1beta1.BudgetServiceClient", + "shortName": "BudgetServiceClient" + }, + "fullName": "google.cloud.billing.budgets_v1beta1.BudgetServiceClient.create_budget", "method": { + "fullName": "google.cloud.billing.budgets.v1beta1.BudgetService.CreateBudget", "service": { + "fullName": "google.cloud.billing.budgets.v1beta1.BudgetService", "shortName": "BudgetService" }, "shortName": "CreateBudget" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.billing.budgets_v1beta1.types.CreateBudgetRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.billing.budgets_v1beta1.types.Budget", + "shortName": "create_budget" }, + "description": "Sample for CreateBudget", "file": "billingbudgets_v1beta1_generated_budget_service_create_budget_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "billingbudgets_v1beta1_generated_BudgetService_CreateBudget_sync", "segments": [ { @@ -87,19 +160,50 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "billingbudgets_v1beta1_generated_budget_service_create_budget_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.billing.budgets_v1beta1.BudgetServiceAsyncClient", + "shortName": "BudgetServiceAsyncClient" + }, + "fullName": "google.cloud.billing.budgets_v1beta1.BudgetServiceAsyncClient.delete_budget", "method": { + "fullName": "google.cloud.billing.budgets.v1beta1.BudgetService.DeleteBudget", "service": { + "fullName": "google.cloud.billing.budgets.v1beta1.BudgetService", "shortName": "BudgetService" }, "shortName": "DeleteBudget" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.billing.budgets_v1beta1.types.DeleteBudgetRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_budget" }, + "description": "Sample for DeleteBudget", "file": "billingbudgets_v1beta1_generated_budget_service_delete_budget_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "billingbudgets_v1beta1_generated_BudgetService_DeleteBudget_async", "segments": [ { @@ -130,18 +234,49 @@ "end": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "billingbudgets_v1beta1_generated_budget_service_delete_budget_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.billing.budgets_v1beta1.BudgetServiceClient", + "shortName": "BudgetServiceClient" + }, + "fullName": "google.cloud.billing.budgets_v1beta1.BudgetServiceClient.delete_budget", "method": { + "fullName": "google.cloud.billing.budgets.v1beta1.BudgetService.DeleteBudget", "service": { + "fullName": "google.cloud.billing.budgets.v1beta1.BudgetService", "shortName": "BudgetService" }, "shortName": "DeleteBudget" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.billing.budgets_v1beta1.types.DeleteBudgetRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_budget" }, + "description": "Sample for DeleteBudget", "file": "billingbudgets_v1beta1_generated_budget_service_delete_budget_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "billingbudgets_v1beta1_generated_BudgetService_DeleteBudget_sync", "segments": [ { @@ -172,19 +307,51 @@ "end": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "billingbudgets_v1beta1_generated_budget_service_delete_budget_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.billing.budgets_v1beta1.BudgetServiceAsyncClient", + "shortName": "BudgetServiceAsyncClient" + }, + "fullName": "google.cloud.billing.budgets_v1beta1.BudgetServiceAsyncClient.get_budget", "method": { + "fullName": "google.cloud.billing.budgets.v1beta1.BudgetService.GetBudget", "service": { + "fullName": "google.cloud.billing.budgets.v1beta1.BudgetService", "shortName": "BudgetService" }, "shortName": "GetBudget" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.billing.budgets_v1beta1.types.GetBudgetRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.billing.budgets_v1beta1.types.Budget", + "shortName": "get_budget" }, + "description": "Sample for GetBudget", "file": "billingbudgets_v1beta1_generated_budget_service_get_budget_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "billingbudgets_v1beta1_generated_BudgetService_GetBudget_async", "segments": [ { @@ -217,18 +384,50 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "billingbudgets_v1beta1_generated_budget_service_get_budget_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.billing.budgets_v1beta1.BudgetServiceClient", + "shortName": "BudgetServiceClient" + }, + "fullName": "google.cloud.billing.budgets_v1beta1.BudgetServiceClient.get_budget", "method": { + "fullName": "google.cloud.billing.budgets.v1beta1.BudgetService.GetBudget", "service": { + "fullName": "google.cloud.billing.budgets.v1beta1.BudgetService", "shortName": "BudgetService" }, "shortName": "GetBudget" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.billing.budgets_v1beta1.types.GetBudgetRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.billing.budgets_v1beta1.types.Budget", + "shortName": "get_budget" }, + "description": "Sample for GetBudget", "file": "billingbudgets_v1beta1_generated_budget_service_get_budget_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "billingbudgets_v1beta1_generated_BudgetService_GetBudget_sync", "segments": [ { @@ -261,19 +460,51 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "billingbudgets_v1beta1_generated_budget_service_get_budget_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.billing.budgets_v1beta1.BudgetServiceAsyncClient", + "shortName": "BudgetServiceAsyncClient" + }, + "fullName": "google.cloud.billing.budgets_v1beta1.BudgetServiceAsyncClient.list_budgets", "method": { + "fullName": "google.cloud.billing.budgets.v1beta1.BudgetService.ListBudgets", "service": { + "fullName": "google.cloud.billing.budgets.v1beta1.BudgetService", "shortName": "BudgetService" }, "shortName": "ListBudgets" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.billing.budgets_v1beta1.types.ListBudgetsRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.billing.budgets_v1beta1.services.budget_service.pagers.ListBudgetsAsyncPager", + "shortName": "list_budgets" }, + "description": "Sample for ListBudgets", "file": "billingbudgets_v1beta1_generated_budget_service_list_budgets_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "billingbudgets_v1beta1_generated_BudgetService_ListBudgets_async", "segments": [ { @@ -306,18 +537,50 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "billingbudgets_v1beta1_generated_budget_service_list_budgets_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.billing.budgets_v1beta1.BudgetServiceClient", + "shortName": "BudgetServiceClient" + }, + "fullName": "google.cloud.billing.budgets_v1beta1.BudgetServiceClient.list_budgets", "method": { + "fullName": "google.cloud.billing.budgets.v1beta1.BudgetService.ListBudgets", "service": { + "fullName": "google.cloud.billing.budgets.v1beta1.BudgetService", "shortName": "BudgetService" }, "shortName": "ListBudgets" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.billing.budgets_v1beta1.types.ListBudgetsRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.billing.budgets_v1beta1.services.budget_service.pagers.ListBudgetsPager", + "shortName": "list_budgets" }, + "description": "Sample for ListBudgets", "file": "billingbudgets_v1beta1_generated_budget_service_list_budgets_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "billingbudgets_v1beta1_generated_BudgetService_ListBudgets_sync", "segments": [ { @@ -350,19 +613,51 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "billingbudgets_v1beta1_generated_budget_service_list_budgets_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.billing.budgets_v1beta1.BudgetServiceAsyncClient", + "shortName": "BudgetServiceAsyncClient" + }, + "fullName": "google.cloud.billing.budgets_v1beta1.BudgetServiceAsyncClient.update_budget", "method": { + "fullName": "google.cloud.billing.budgets.v1beta1.BudgetService.UpdateBudget", "service": { + "fullName": "google.cloud.billing.budgets.v1beta1.BudgetService", "shortName": "BudgetService" }, "shortName": "UpdateBudget" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.billing.budgets_v1beta1.types.UpdateBudgetRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.billing.budgets_v1beta1.types.Budget", + "shortName": "update_budget" }, + "description": "Sample for UpdateBudget", "file": "billingbudgets_v1beta1_generated_budget_service_update_budget_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "billingbudgets_v1beta1_generated_BudgetService_UpdateBudget_async", "segments": [ { @@ -395,18 +690,50 @@ "start": 41, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "billingbudgets_v1beta1_generated_budget_service_update_budget_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.billing.budgets_v1beta1.BudgetServiceClient", + "shortName": "BudgetServiceClient" + }, + "fullName": "google.cloud.billing.budgets_v1beta1.BudgetServiceClient.update_budget", "method": { + "fullName": "google.cloud.billing.budgets.v1beta1.BudgetService.UpdateBudget", "service": { + "fullName": "google.cloud.billing.budgets.v1beta1.BudgetService", "shortName": "BudgetService" }, "shortName": "UpdateBudget" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.billing.budgets_v1beta1.types.UpdateBudgetRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.billing.budgets_v1beta1.types.Budget", + "shortName": "update_budget" }, + "description": "Sample for UpdateBudget", "file": "billingbudgets_v1beta1_generated_budget_service_update_budget_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "billingbudgets_v1beta1_generated_BudgetService_UpdateBudget_sync", "segments": [ { @@ -439,7 +766,8 @@ "start": 41, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "billingbudgets_v1beta1_generated_budget_service_update_budget_sync.py" } ] } diff --git a/scripts/readme-gen/readme_gen.py b/scripts/readme-gen/readme_gen.py index d309d6e..91b5967 100644 --- a/scripts/readme-gen/readme_gen.py +++ b/scripts/readme-gen/readme_gen.py @@ -28,7 +28,10 @@ jinja_env = jinja2.Environment( trim_blocks=True, loader=jinja2.FileSystemLoader( - os.path.abspath(os.path.join(os.path.dirname(__file__), 'templates')))) + os.path.abspath(os.path.join(os.path.dirname(__file__), "templates")) + ), + autoescape=True, +) README_TMPL = jinja_env.get_template('README.tmpl.rst') diff --git a/setup.py b/setup.py index 9d94fe7..4229bd1 100644 --- a/setup.py +++ b/setup.py @@ -19,17 +19,17 @@ import setuptools - name = "google-cloud-billing-budgets" description = "Cloud Billing Budget API API client library" -version = "1.6.1" +version = "1.6.2" release_status = "Development Status :: 5 - Production/Stable" dependencies = [ # NOTE: Maintainers, please do not require google-api-core>=2.x.x # Until this issue is closed # https://github.com/googleapis/google-cloud-python/issues/10566 "google-api-core[grpc] >= 1.31.5, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0", - "proto-plus >= 1.15.0", + "proto-plus >= 1.15.0, <2.0.0dev", + "protobuf >= 3.19.0, <4.0.0dev", ] extras = {"libcst": "libcst >= 0.2.5"} diff --git a/testing/constraints-3.6.txt b/testing/constraints-3.6.txt index 9f829f6..3b53664 100644 --- a/testing/constraints-3.6.txt +++ b/testing/constraints-3.6.txt @@ -8,3 +8,4 @@ google-api-core==1.31.5 proto-plus==1.15.0 libcst==0.2.5 +protobuf==3.19.0 diff --git a/testing/constraints-3.7.txt b/testing/constraints-3.7.txt index e69de29..3b53664 100644 --- a/testing/constraints-3.7.txt +++ b/testing/constraints-3.7.txt @@ -0,0 +1,11 @@ +# This constraints file is used to check that lower bounds +# are correct in setup.py +# List *all* library dependencies and extras in this file. +# Pin the version to the lower bound. +# +# e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev", +# Then this file should have foo==1.14.0 +google-api-core==1.31.5 +proto-plus==1.15.0 +libcst==0.2.5 +protobuf==3.19.0 diff --git a/tests/unit/gapic/budgets_v1/test_budget_service.py b/tests/unit/gapic/budgets_v1/test_budget_service.py index 537d32c..a7a24b6 100644 --- a/tests/unit/gapic/budgets_v1/test_budget_service.py +++ b/tests/unit/gapic/budgets_v1/test_budget_service.py @@ -14,37 +14,39 @@ # limitations under the License. # import os -import mock -import grpc -from grpc.experimental import aio -import math -import pytest -from proto.marshal.rules.dates import DurationRule, TimestampRule +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock +import math +from google.api_core import gapic_v1, grpc_helpers, grpc_helpers_async, path_template from google.api_core import client_options from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers -from google.api_core import grpc_helpers_async -from google.api_core import path_template +import google.auth from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError -from google.cloud.billing.budgets_v1.services.budget_service import ( - BudgetServiceAsyncClient, -) -from google.cloud.billing.budgets_v1.services.budget_service import BudgetServiceClient -from google.cloud.billing.budgets_v1.services.budget_service import pagers -from google.cloud.billing.budgets_v1.services.budget_service import transports -from google.cloud.billing.budgets_v1.types import budget_model -from google.cloud.billing.budgets_v1.types import budget_service from google.oauth2 import service_account from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import struct_pb2 # type: ignore from google.type import date_pb2 # type: ignore from google.type import money_pb2 # type: ignore -import google.auth +import grpc +from grpc.experimental import aio +from proto.marshal.rules.dates import DurationRule, TimestampRule +import pytest + +from google.cloud.billing.budgets_v1.services.budget_service import ( + BudgetServiceAsyncClient, + BudgetServiceClient, + pagers, + transports, +) +from google.cloud.billing.budgets_v1.types import budget_model, budget_service def client_cert_source_callback(): @@ -92,20 +94,24 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", [BudgetServiceClient, BudgetServiceAsyncClient,] + "client_class,transport_name", + [ + (BudgetServiceClient, "grpc"), + (BudgetServiceAsyncClient, "grpc_asyncio"), + ], ) -def test_budget_service_client_from_service_account_info(client_class): +def test_budget_service_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 == "billingbudgets.googleapis.com:443" + assert client.transport._host == ("billingbudgets.googleapis.com:443") @pytest.mark.parametrize( @@ -134,23 +140,31 @@ def test_budget_service_client_service_account_always_use_jwt( @pytest.mark.parametrize( - "client_class", [BudgetServiceClient, BudgetServiceAsyncClient,] + "client_class,transport_name", + [ + (BudgetServiceClient, "grpc"), + (BudgetServiceAsyncClient, "grpc_asyncio"), + ], ) -def test_budget_service_client_from_service_account_file(client_class): +def test_budget_service_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 == "billingbudgets.googleapis.com:443" + assert client.transport._host == ("billingbudgets.googleapis.com:443") def test_budget_service_client_get_transport_class(): @@ -498,7 +512,9 @@ def test_budget_service_client_client_options_scopes( client_class, transport_class, transport_name ): # Check the case scopes are provided. - options = client_options.ClientOptions(scopes=["1", "2"],) + options = client_options.ClientOptions( + scopes=["1", "2"], + ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -641,10 +657,17 @@ def test_budget_service_client_create_channel_credentials_file( ) -@pytest.mark.parametrize("request_type", [budget_service.CreateBudgetRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + budget_service.CreateBudgetRequest, + dict, + ], +) def test_create_budget(request_type, transport: str = "grpc"): client = BudgetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -655,7 +678,9 @@ def test_create_budget(request_type, transport: str = "grpc"): with mock.patch.object(type(client.transport.create_budget), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = budget_model.Budget( - name="name_value", display_name="display_name_value", etag="etag_value", + name="name_value", + display_name="display_name_value", + etag="etag_value", ) response = client.create_budget(request) @@ -675,7 +700,8 @@ def test_create_budget_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = BudgetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -691,7 +717,8 @@ async def test_create_budget_async( transport: str = "grpc_asyncio", request_type=budget_service.CreateBudgetRequest ): client = BudgetServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -703,7 +730,9 @@ async def test_create_budget_async( # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( budget_model.Budget( - name="name_value", display_name="display_name_value", etag="etag_value", + name="name_value", + display_name="display_name_value", + etag="etag_value", ) ) response = await client.create_budget(request) @@ -726,13 +755,15 @@ async def test_create_budget_async_from_dict(): def test_create_budget_field_headers(): - client = BudgetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = BudgetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = budget_service.CreateBudgetRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_budget), "__call__") as call: @@ -746,7 +777,10 @@ def test_create_budget_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -759,7 +793,7 @@ async def test_create_budget_field_headers_async(): # a field header. Set these to a non-empty value. request = budget_service.CreateBudgetRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_budget), "__call__") as call: @@ -773,11 +807,16 @@ async def test_create_budget_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] def test_create_budget_flattened(): - client = BudgetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = BudgetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_budget), "__call__") as call: @@ -786,7 +825,8 @@ def test_create_budget_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_budget( - parent="parent_value", budget=budget_model.Budget(name="name_value"), + parent="parent_value", + budget=budget_model.Budget(name="name_value"), ) # Establish that the underlying call was made with the expected @@ -802,7 +842,9 @@ def test_create_budget_flattened(): def test_create_budget_flattened_error(): - client = BudgetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = BudgetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -829,7 +871,8 @@ async def test_create_budget_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.create_budget( - parent="parent_value", budget=budget_model.Budget(name="name_value"), + parent="parent_value", + budget=budget_model.Budget(name="name_value"), ) # Establish that the underlying call was made with the expected @@ -860,10 +903,17 @@ async def test_create_budget_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [budget_service.UpdateBudgetRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + budget_service.UpdateBudgetRequest, + dict, + ], +) def test_update_budget(request_type, transport: str = "grpc"): client = BudgetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -874,7 +924,9 @@ def test_update_budget(request_type, transport: str = "grpc"): with mock.patch.object(type(client.transport.update_budget), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = budget_model.Budget( - name="name_value", display_name="display_name_value", etag="etag_value", + name="name_value", + display_name="display_name_value", + etag="etag_value", ) response = client.update_budget(request) @@ -894,7 +946,8 @@ def test_update_budget_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = BudgetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -910,7 +963,8 @@ async def test_update_budget_async( transport: str = "grpc_asyncio", request_type=budget_service.UpdateBudgetRequest ): client = BudgetServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -922,7 +976,9 @@ async def test_update_budget_async( # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( budget_model.Budget( - name="name_value", display_name="display_name_value", etag="etag_value", + name="name_value", + display_name="display_name_value", + etag="etag_value", ) ) response = await client.update_budget(request) @@ -945,13 +1001,15 @@ async def test_update_budget_async_from_dict(): def test_update_budget_field_headers(): - client = BudgetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = BudgetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = budget_service.UpdateBudgetRequest() - request.budget.name = "budget.name/value" + request.budget.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_budget), "__call__") as call: @@ -965,7 +1023,10 @@ def test_update_budget_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "budget.name=budget.name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "budget.name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -978,7 +1039,7 @@ async def test_update_budget_field_headers_async(): # a field header. Set these to a non-empty value. request = budget_service.UpdateBudgetRequest() - request.budget.name = "budget.name/value" + request.budget.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_budget), "__call__") as call: @@ -992,11 +1053,16 @@ async def test_update_budget_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "budget.name=budget.name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "budget.name=name_value", + ) in kw["metadata"] def test_update_budget_flattened(): - client = BudgetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = BudgetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_budget), "__call__") as call: @@ -1022,7 +1088,9 @@ def test_update_budget_flattened(): def test_update_budget_flattened_error(): - client = BudgetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = BudgetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1081,10 +1149,17 @@ async def test_update_budget_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [budget_service.GetBudgetRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + budget_service.GetBudgetRequest, + dict, + ], +) def test_get_budget(request_type, transport: str = "grpc"): client = BudgetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1095,7 +1170,9 @@ def test_get_budget(request_type, transport: str = "grpc"): with mock.patch.object(type(client.transport.get_budget), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = budget_model.Budget( - name="name_value", display_name="display_name_value", etag="etag_value", + name="name_value", + display_name="display_name_value", + etag="etag_value", ) response = client.get_budget(request) @@ -1115,7 +1192,8 @@ def test_get_budget_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = BudgetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1131,7 +1209,8 @@ async def test_get_budget_async( transport: str = "grpc_asyncio", request_type=budget_service.GetBudgetRequest ): client = BudgetServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1143,7 +1222,9 @@ async def test_get_budget_async( # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( budget_model.Budget( - name="name_value", display_name="display_name_value", etag="etag_value", + name="name_value", + display_name="display_name_value", + etag="etag_value", ) ) response = await client.get_budget(request) @@ -1166,13 +1247,15 @@ async def test_get_budget_async_from_dict(): def test_get_budget_field_headers(): - client = BudgetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = BudgetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = budget_service.GetBudgetRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_budget), "__call__") as call: @@ -1186,7 +1269,10 @@ def test_get_budget_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1199,7 +1285,7 @@ async def test_get_budget_field_headers_async(): # a field header. Set these to a non-empty value. request = budget_service.GetBudgetRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_budget), "__call__") as call: @@ -1213,11 +1299,16 @@ async def test_get_budget_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] def test_get_budget_flattened(): - client = BudgetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = BudgetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_budget), "__call__") as call: @@ -1225,7 +1316,9 @@ def test_get_budget_flattened(): call.return_value = budget_model.Budget() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_budget(name="name_value",) + client.get_budget( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1237,13 +1330,16 @@ def test_get_budget_flattened(): def test_get_budget_flattened_error(): - client = BudgetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = BudgetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.get_budget( - budget_service.GetBudgetRequest(), name="name_value", + budget_service.GetBudgetRequest(), + name="name_value", ) @@ -1261,7 +1357,9 @@ async def test_get_budget_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(budget_model.Budget()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_budget(name="name_value",) + response = await client.get_budget( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1282,14 +1380,22 @@ async def test_get_budget_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.get_budget( - budget_service.GetBudgetRequest(), name="name_value", + budget_service.GetBudgetRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [budget_service.ListBudgetsRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + budget_service.ListBudgetsRequest, + dict, + ], +) def test_list_budgets(request_type, transport: str = "grpc"): client = BudgetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1318,7 +1424,8 @@ def test_list_budgets_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = BudgetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1334,7 +1441,8 @@ async def test_list_budgets_async( transport: str = "grpc_asyncio", request_type=budget_service.ListBudgetsRequest ): client = BudgetServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1345,7 +1453,9 @@ async def test_list_budgets_async( with mock.patch.object(type(client.transport.list_budgets), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - budget_service.ListBudgetsResponse(next_page_token="next_page_token_value",) + budget_service.ListBudgetsResponse( + next_page_token="next_page_token_value", + ) ) response = await client.list_budgets(request) @@ -1365,13 +1475,15 @@ async def test_list_budgets_async_from_dict(): def test_list_budgets_field_headers(): - client = BudgetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = BudgetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = budget_service.ListBudgetsRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_budgets), "__call__") as call: @@ -1385,7 +1497,10 @@ def test_list_budgets_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1398,7 +1513,7 @@ async def test_list_budgets_field_headers_async(): # a field header. Set these to a non-empty value. request = budget_service.ListBudgetsRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_budgets), "__call__") as call: @@ -1414,11 +1529,16 @@ async def test_list_budgets_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] def test_list_budgets_flattened(): - client = BudgetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = BudgetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_budgets), "__call__") as call: @@ -1426,7 +1546,9 @@ def test_list_budgets_flattened(): call.return_value = budget_service.ListBudgetsResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_budgets(parent="parent_value",) + client.list_budgets( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1438,13 +1560,16 @@ def test_list_budgets_flattened(): def test_list_budgets_flattened_error(): - client = BudgetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = BudgetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.list_budgets( - budget_service.ListBudgetsRequest(), parent="parent_value", + budget_service.ListBudgetsRequest(), + parent="parent_value", ) @@ -1464,7 +1589,9 @@ async def test_list_budgets_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_budgets(parent="parent_value",) + response = await client.list_budgets( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1485,13 +1612,15 @@ async def test_list_budgets_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.list_budgets( - budget_service.ListBudgetsRequest(), parent="parent_value", + budget_service.ListBudgetsRequest(), + parent="parent_value", ) def test_list_budgets_pager(transport_name: str = "grpc"): client = BudgetServiceClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1506,12 +1635,21 @@ def test_list_budgets_pager(transport_name: str = "grpc"): ], next_page_token="abc", ), - budget_service.ListBudgetsResponse(budgets=[], next_page_token="def",), budget_service.ListBudgetsResponse( - budgets=[budget_model.Budget(),], next_page_token="ghi", + budgets=[], + next_page_token="def", + ), + budget_service.ListBudgetsResponse( + budgets=[ + budget_model.Budget(), + ], + next_page_token="ghi", ), budget_service.ListBudgetsResponse( - budgets=[budget_model.Budget(), budget_model.Budget(),], + budgets=[ + budget_model.Budget(), + budget_model.Budget(), + ], ), RuntimeError, ) @@ -1524,14 +1662,15 @@ def test_list_budgets_pager(transport_name: str = "grpc"): assert pager._metadata == metadata - results = [i for i in pager] + results = list(pager) assert len(results) == 6 assert all(isinstance(i, budget_model.Budget) for i in results) def test_list_budgets_pages(transport_name: str = "grpc"): client = BudgetServiceClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1546,12 +1685,21 @@ def test_list_budgets_pages(transport_name: str = "grpc"): ], next_page_token="abc", ), - budget_service.ListBudgetsResponse(budgets=[], next_page_token="def",), budget_service.ListBudgetsResponse( - budgets=[budget_model.Budget(),], next_page_token="ghi", + budgets=[], + next_page_token="def", ), budget_service.ListBudgetsResponse( - budgets=[budget_model.Budget(), budget_model.Budget(),], + budgets=[ + budget_model.Budget(), + ], + next_page_token="ghi", + ), + budget_service.ListBudgetsResponse( + budgets=[ + budget_model.Budget(), + budget_model.Budget(), + ], ), RuntimeError, ) @@ -1562,7 +1710,9 @@ def test_list_budgets_pages(transport_name: str = "grpc"): @pytest.mark.asyncio async def test_list_budgets_async_pager(): - client = BudgetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = BudgetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1578,19 +1728,30 @@ async def test_list_budgets_async_pager(): ], next_page_token="abc", ), - budget_service.ListBudgetsResponse(budgets=[], next_page_token="def",), budget_service.ListBudgetsResponse( - budgets=[budget_model.Budget(),], next_page_token="ghi", + budgets=[], + next_page_token="def", ), budget_service.ListBudgetsResponse( - budgets=[budget_model.Budget(), budget_model.Budget(),], + budgets=[ + budget_model.Budget(), + ], + next_page_token="ghi", + ), + budget_service.ListBudgetsResponse( + budgets=[ + budget_model.Budget(), + budget_model.Budget(), + ], ), RuntimeError, ) - async_pager = await client.list_budgets(request={},) + async_pager = await client.list_budgets( + request={}, + ) 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 @@ -1599,7 +1760,9 @@ async def test_list_budgets_async_pager(): @pytest.mark.asyncio async def test_list_budgets_async_pages(): - client = BudgetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = BudgetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1615,26 +1778,44 @@ async def test_list_budgets_async_pages(): ], next_page_token="abc", ), - budget_service.ListBudgetsResponse(budgets=[], next_page_token="def",), budget_service.ListBudgetsResponse( - budgets=[budget_model.Budget(),], next_page_token="ghi", + budgets=[], + next_page_token="def", ), budget_service.ListBudgetsResponse( - budgets=[budget_model.Budget(), budget_model.Budget(),], + budgets=[ + budget_model.Budget(), + ], + next_page_token="ghi", + ), + budget_service.ListBudgetsResponse( + budgets=[ + budget_model.Budget(), + budget_model.Budget(), + ], ), RuntimeError, ) pages = [] - async for page_ in (await client.list_budgets(request={})).pages: + async for page_ in ( + await client.list_budgets(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 -@pytest.mark.parametrize("request_type", [budget_service.DeleteBudgetRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + budget_service.DeleteBudgetRequest, + dict, + ], +) def test_delete_budget(request_type, transport: str = "grpc"): client = BudgetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1660,7 +1841,8 @@ def test_delete_budget_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = BudgetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1676,7 +1858,8 @@ async def test_delete_budget_async( transport: str = "grpc_asyncio", request_type=budget_service.DeleteBudgetRequest ): client = BudgetServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1704,13 +1887,15 @@ async def test_delete_budget_async_from_dict(): def test_delete_budget_field_headers(): - client = BudgetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = BudgetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = budget_service.DeleteBudgetRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_budget), "__call__") as call: @@ -1724,7 +1909,10 @@ def test_delete_budget_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1737,7 +1925,7 @@ async def test_delete_budget_field_headers_async(): # a field header. Set these to a non-empty value. request = budget_service.DeleteBudgetRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_budget), "__call__") as call: @@ -1751,11 +1939,16 @@ async def test_delete_budget_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] def test_delete_budget_flattened(): - client = BudgetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = BudgetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_budget), "__call__") as call: @@ -1763,7 +1956,9 @@ def test_delete_budget_flattened(): call.return_value = None # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.delete_budget(name="name_value",) + client.delete_budget( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1775,13 +1970,16 @@ def test_delete_budget_flattened(): def test_delete_budget_flattened_error(): - client = BudgetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = BudgetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.delete_budget( - budget_service.DeleteBudgetRequest(), name="name_value", + budget_service.DeleteBudgetRequest(), + name="name_value", ) @@ -1799,7 +1997,9 @@ async def test_delete_budget_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.delete_budget(name="name_value",) + response = await client.delete_budget( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1820,7 +2020,8 @@ async def test_delete_budget_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.delete_budget( - budget_service.DeleteBudgetRequest(), name="name_value", + budget_service.DeleteBudgetRequest(), + name="name_value", ) @@ -1831,7 +2032,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = BudgetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # It is an error to provide a credentials file and a transport instance. @@ -1851,7 +2053,10 @@ def test_credentials_transport_error(): options = client_options.ClientOptions() options.api_key = "api_key" with pytest.raises(ValueError): - client = BudgetServiceClient(client_options=options, transport=transport,) + client = BudgetServiceClient( + client_options=options, + transport=transport, + ) # It is an error to provide an api_key and a credential. options = mock.Mock() @@ -1867,7 +2072,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = BudgetServiceClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -1910,10 +2116,28 @@ def test_transport_adc(transport_class): adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = BudgetServiceClient.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 = BudgetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) - assert isinstance(client.transport, transports.BudgetServiceGrpcTransport,) + client = BudgetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.BudgetServiceGrpcTransport, + ) def test_budget_service_base_transport_error(): @@ -1951,6 +2175,14 @@ def test_budget_service_base_transport(): with pytest.raises(NotImplementedError): transport.close() + # Catch all for all remaining methods and properties + remainder = [ + "kind", + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + def test_budget_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file @@ -1962,7 +2194,8 @@ def test_budget_service_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.BudgetServiceTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -2107,24 +2340,40 @@ def test_budget_service_grpc_transport_client_cert_source_for_mtls(transport_cla ) -def test_budget_service_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_budget_service_host_no_port(transport_name): client = BudgetServiceClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="billingbudgets.googleapis.com" ), + transport=transport_name, ) - assert client.transport._host == "billingbudgets.googleapis.com:443" + assert client.transport._host == ("billingbudgets.googleapis.com:443") -def test_budget_service_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_budget_service_host_with_port(transport_name): client = BudgetServiceClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="billingbudgets.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "billingbudgets.googleapis.com:8000" + assert client.transport._host == ("billingbudgets.googleapis.com:8000") def test_budget_service_grpc_transport_channel(): @@ -2132,7 +2381,8 @@ def test_budget_service_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.BudgetServiceGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -2144,7 +2394,8 @@ def test_budget_service_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.BudgetServiceGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -2253,7 +2504,8 @@ def test_budget_path(): billing_account = "squid" budget = "clam" expected = "billingAccounts/{billing_account}/budgets/{budget}".format( - billing_account=billing_account, budget=budget, + billing_account=billing_account, + budget=budget, ) actual = BudgetServiceClient.budget_path(billing_account, budget) assert expected == actual @@ -2293,7 +2545,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "cuttlefish" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = BudgetServiceClient.common_folder_path(folder) assert expected == actual @@ -2311,7 +2565,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "winkle" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = BudgetServiceClient.common_organization_path(organization) assert expected == actual @@ -2329,7 +2585,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "scallop" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = BudgetServiceClient.common_project_path(project) assert expected == actual @@ -2349,7 +2607,8 @@ def test_common_location_path(): project = "squid" location = "clam" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = BudgetServiceClient.common_location_path(project, location) assert expected == actual @@ -2374,7 +2633,8 @@ def test_client_with_default_client_info(): transports.BudgetServiceTransport, "_prep_wrapped_messages" ) as prep: client = BudgetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -2383,7 +2643,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = BudgetServiceClient.get_transport_class() transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -2391,7 +2652,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = BudgetServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) with mock.patch.object( type(getattr(client.transport, "grpc_channel")), "close" diff --git a/tests/unit/gapic/budgets_v1beta1/test_budget_service.py b/tests/unit/gapic/budgets_v1beta1/test_budget_service.py index 01a0044..3440d44 100644 --- a/tests/unit/gapic/budgets_v1beta1/test_budget_service.py +++ b/tests/unit/gapic/budgets_v1beta1/test_budget_service.py @@ -14,39 +14,39 @@ # limitations under the License. # import os -import mock -import grpc -from grpc.experimental import aio -import math -import pytest -from proto.marshal.rules.dates import DurationRule, TimestampRule +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock +import math +from google.api_core import gapic_v1, grpc_helpers, grpc_helpers_async, path_template from google.api_core import client_options from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers -from google.api_core import grpc_helpers_async -from google.api_core import path_template +import google.auth from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError -from google.cloud.billing.budgets_v1beta1.services.budget_service import ( - BudgetServiceAsyncClient, -) -from google.cloud.billing.budgets_v1beta1.services.budget_service import ( - BudgetServiceClient, -) -from google.cloud.billing.budgets_v1beta1.services.budget_service import pagers -from google.cloud.billing.budgets_v1beta1.services.budget_service import transports -from google.cloud.billing.budgets_v1beta1.types import budget_model -from google.cloud.billing.budgets_v1beta1.types import budget_service from google.oauth2 import service_account from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import struct_pb2 # type: ignore from google.type import date_pb2 # type: ignore from google.type import money_pb2 # type: ignore -import google.auth +import grpc +from grpc.experimental import aio +from proto.marshal.rules.dates import DurationRule, TimestampRule +import pytest + +from google.cloud.billing.budgets_v1beta1.services.budget_service import ( + BudgetServiceAsyncClient, + BudgetServiceClient, + pagers, + transports, +) +from google.cloud.billing.budgets_v1beta1.types import budget_model, budget_service def client_cert_source_callback(): @@ -94,20 +94,24 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", [BudgetServiceClient, BudgetServiceAsyncClient,] + "client_class,transport_name", + [ + (BudgetServiceClient, "grpc"), + (BudgetServiceAsyncClient, "grpc_asyncio"), + ], ) -def test_budget_service_client_from_service_account_info(client_class): +def test_budget_service_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 == "billingbudgets.googleapis.com:443" + assert client.transport._host == ("billingbudgets.googleapis.com:443") @pytest.mark.parametrize( @@ -136,23 +140,31 @@ def test_budget_service_client_service_account_always_use_jwt( @pytest.mark.parametrize( - "client_class", [BudgetServiceClient, BudgetServiceAsyncClient,] + "client_class,transport_name", + [ + (BudgetServiceClient, "grpc"), + (BudgetServiceAsyncClient, "grpc_asyncio"), + ], ) -def test_budget_service_client_from_service_account_file(client_class): +def test_budget_service_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 == "billingbudgets.googleapis.com:443" + assert client.transport._host == ("billingbudgets.googleapis.com:443") def test_budget_service_client_get_transport_class(): @@ -500,7 +512,9 @@ def test_budget_service_client_client_options_scopes( client_class, transport_class, transport_name ): # Check the case scopes are provided. - options = client_options.ClientOptions(scopes=["1", "2"],) + options = client_options.ClientOptions( + scopes=["1", "2"], + ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -643,10 +657,17 @@ def test_budget_service_client_create_channel_credentials_file( ) -@pytest.mark.parametrize("request_type", [budget_service.CreateBudgetRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + budget_service.CreateBudgetRequest, + dict, + ], +) def test_create_budget(request_type, transport: str = "grpc"): client = BudgetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -657,7 +678,9 @@ def test_create_budget(request_type, transport: str = "grpc"): with mock.patch.object(type(client.transport.create_budget), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = budget_model.Budget( - name="name_value", display_name="display_name_value", etag="etag_value", + name="name_value", + display_name="display_name_value", + etag="etag_value", ) response = client.create_budget(request) @@ -677,7 +700,8 @@ def test_create_budget_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = BudgetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -693,7 +717,8 @@ async def test_create_budget_async( transport: str = "grpc_asyncio", request_type=budget_service.CreateBudgetRequest ): client = BudgetServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -705,7 +730,9 @@ async def test_create_budget_async( # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( budget_model.Budget( - name="name_value", display_name="display_name_value", etag="etag_value", + name="name_value", + display_name="display_name_value", + etag="etag_value", ) ) response = await client.create_budget(request) @@ -728,13 +755,15 @@ async def test_create_budget_async_from_dict(): def test_create_budget_field_headers(): - client = BudgetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = BudgetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = budget_service.CreateBudgetRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_budget), "__call__") as call: @@ -748,7 +777,10 @@ def test_create_budget_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -761,7 +793,7 @@ async def test_create_budget_field_headers_async(): # a field header. Set these to a non-empty value. request = budget_service.CreateBudgetRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_budget), "__call__") as call: @@ -775,13 +807,23 @@ async def test_create_budget_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] -@pytest.mark.parametrize("request_type", [budget_service.UpdateBudgetRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + budget_service.UpdateBudgetRequest, + dict, + ], +) def test_update_budget(request_type, transport: str = "grpc"): client = BudgetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -792,7 +834,9 @@ def test_update_budget(request_type, transport: str = "grpc"): with mock.patch.object(type(client.transport.update_budget), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = budget_model.Budget( - name="name_value", display_name="display_name_value", etag="etag_value", + name="name_value", + display_name="display_name_value", + etag="etag_value", ) response = client.update_budget(request) @@ -812,7 +856,8 @@ def test_update_budget_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = BudgetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -828,7 +873,8 @@ async def test_update_budget_async( transport: str = "grpc_asyncio", request_type=budget_service.UpdateBudgetRequest ): client = BudgetServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -840,7 +886,9 @@ async def test_update_budget_async( # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( budget_model.Budget( - name="name_value", display_name="display_name_value", etag="etag_value", + name="name_value", + display_name="display_name_value", + etag="etag_value", ) ) response = await client.update_budget(request) @@ -863,13 +911,15 @@ async def test_update_budget_async_from_dict(): def test_update_budget_field_headers(): - client = BudgetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = BudgetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = budget_service.UpdateBudgetRequest() - request.budget.name = "budget.name/value" + request.budget.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_budget), "__call__") as call: @@ -883,7 +933,10 @@ def test_update_budget_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "budget.name=budget.name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "budget.name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -896,7 +949,7 @@ async def test_update_budget_field_headers_async(): # a field header. Set these to a non-empty value. request = budget_service.UpdateBudgetRequest() - request.budget.name = "budget.name/value" + request.budget.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_budget), "__call__") as call: @@ -910,13 +963,23 @@ async def test_update_budget_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "budget.name=budget.name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "budget.name=name_value", + ) in kw["metadata"] -@pytest.mark.parametrize("request_type", [budget_service.GetBudgetRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + budget_service.GetBudgetRequest, + dict, + ], +) def test_get_budget(request_type, transport: str = "grpc"): client = BudgetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -927,7 +990,9 @@ def test_get_budget(request_type, transport: str = "grpc"): with mock.patch.object(type(client.transport.get_budget), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = budget_model.Budget( - name="name_value", display_name="display_name_value", etag="etag_value", + name="name_value", + display_name="display_name_value", + etag="etag_value", ) response = client.get_budget(request) @@ -947,7 +1012,8 @@ def test_get_budget_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = BudgetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -963,7 +1029,8 @@ async def test_get_budget_async( transport: str = "grpc_asyncio", request_type=budget_service.GetBudgetRequest ): client = BudgetServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -975,7 +1042,9 @@ async def test_get_budget_async( # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( budget_model.Budget( - name="name_value", display_name="display_name_value", etag="etag_value", + name="name_value", + display_name="display_name_value", + etag="etag_value", ) ) response = await client.get_budget(request) @@ -998,13 +1067,15 @@ async def test_get_budget_async_from_dict(): def test_get_budget_field_headers(): - client = BudgetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = BudgetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = budget_service.GetBudgetRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_budget), "__call__") as call: @@ -1018,7 +1089,10 @@ def test_get_budget_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1031,7 +1105,7 @@ async def test_get_budget_field_headers_async(): # a field header. Set these to a non-empty value. request = budget_service.GetBudgetRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_budget), "__call__") as call: @@ -1045,13 +1119,23 @@ async def test_get_budget_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] -@pytest.mark.parametrize("request_type", [budget_service.ListBudgetsRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + budget_service.ListBudgetsRequest, + dict, + ], +) def test_list_budgets(request_type, transport: str = "grpc"): client = BudgetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1080,7 +1164,8 @@ def test_list_budgets_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = BudgetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1096,7 +1181,8 @@ async def test_list_budgets_async( transport: str = "grpc_asyncio", request_type=budget_service.ListBudgetsRequest ): client = BudgetServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1107,7 +1193,9 @@ async def test_list_budgets_async( with mock.patch.object(type(client.transport.list_budgets), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - budget_service.ListBudgetsResponse(next_page_token="next_page_token_value",) + budget_service.ListBudgetsResponse( + next_page_token="next_page_token_value", + ) ) response = await client.list_budgets(request) @@ -1127,13 +1215,15 @@ async def test_list_budgets_async_from_dict(): def test_list_budgets_field_headers(): - client = BudgetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = BudgetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = budget_service.ListBudgetsRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_budgets), "__call__") as call: @@ -1147,7 +1237,10 @@ def test_list_budgets_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1160,7 +1253,7 @@ async def test_list_budgets_field_headers_async(): # a field header. Set these to a non-empty value. request = budget_service.ListBudgetsRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_budgets), "__call__") as call: @@ -1176,12 +1269,16 @@ async def test_list_budgets_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] def test_list_budgets_pager(transport_name: str = "grpc"): client = BudgetServiceClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1196,12 +1293,21 @@ def test_list_budgets_pager(transport_name: str = "grpc"): ], next_page_token="abc", ), - budget_service.ListBudgetsResponse(budgets=[], next_page_token="def",), budget_service.ListBudgetsResponse( - budgets=[budget_model.Budget(),], next_page_token="ghi", + budgets=[], + next_page_token="def", ), budget_service.ListBudgetsResponse( - budgets=[budget_model.Budget(), budget_model.Budget(),], + budgets=[ + budget_model.Budget(), + ], + next_page_token="ghi", + ), + budget_service.ListBudgetsResponse( + budgets=[ + budget_model.Budget(), + budget_model.Budget(), + ], ), RuntimeError, ) @@ -1214,14 +1320,15 @@ def test_list_budgets_pager(transport_name: str = "grpc"): assert pager._metadata == metadata - results = [i for i in pager] + results = list(pager) assert len(results) == 6 assert all(isinstance(i, budget_model.Budget) for i in results) def test_list_budgets_pages(transport_name: str = "grpc"): client = BudgetServiceClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1236,12 +1343,21 @@ def test_list_budgets_pages(transport_name: str = "grpc"): ], next_page_token="abc", ), - budget_service.ListBudgetsResponse(budgets=[], next_page_token="def",), budget_service.ListBudgetsResponse( - budgets=[budget_model.Budget(),], next_page_token="ghi", + budgets=[], + next_page_token="def", ), budget_service.ListBudgetsResponse( - budgets=[budget_model.Budget(), budget_model.Budget(),], + budgets=[ + budget_model.Budget(), + ], + next_page_token="ghi", + ), + budget_service.ListBudgetsResponse( + budgets=[ + budget_model.Budget(), + budget_model.Budget(), + ], ), RuntimeError, ) @@ -1252,7 +1368,9 @@ def test_list_budgets_pages(transport_name: str = "grpc"): @pytest.mark.asyncio async def test_list_budgets_async_pager(): - client = BudgetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = BudgetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1268,19 +1386,30 @@ async def test_list_budgets_async_pager(): ], next_page_token="abc", ), - budget_service.ListBudgetsResponse(budgets=[], next_page_token="def",), budget_service.ListBudgetsResponse( - budgets=[budget_model.Budget(),], next_page_token="ghi", + budgets=[], + next_page_token="def", ), budget_service.ListBudgetsResponse( - budgets=[budget_model.Budget(), budget_model.Budget(),], + budgets=[ + budget_model.Budget(), + ], + next_page_token="ghi", + ), + budget_service.ListBudgetsResponse( + budgets=[ + budget_model.Budget(), + budget_model.Budget(), + ], ), RuntimeError, ) - async_pager = await client.list_budgets(request={},) + async_pager = await client.list_budgets( + request={}, + ) 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 @@ -1289,7 +1418,9 @@ async def test_list_budgets_async_pager(): @pytest.mark.asyncio async def test_list_budgets_async_pages(): - client = BudgetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = BudgetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1305,26 +1436,44 @@ async def test_list_budgets_async_pages(): ], next_page_token="abc", ), - budget_service.ListBudgetsResponse(budgets=[], next_page_token="def",), budget_service.ListBudgetsResponse( - budgets=[budget_model.Budget(),], next_page_token="ghi", + budgets=[], + next_page_token="def", ), budget_service.ListBudgetsResponse( - budgets=[budget_model.Budget(), budget_model.Budget(),], + budgets=[ + budget_model.Budget(), + ], + next_page_token="ghi", + ), + budget_service.ListBudgetsResponse( + budgets=[ + budget_model.Budget(), + budget_model.Budget(), + ], ), RuntimeError, ) pages = [] - async for page_ in (await client.list_budgets(request={})).pages: + async for page_ in ( + await client.list_budgets(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 -@pytest.mark.parametrize("request_type", [budget_service.DeleteBudgetRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + budget_service.DeleteBudgetRequest, + dict, + ], +) def test_delete_budget(request_type, transport: str = "grpc"): client = BudgetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1350,7 +1499,8 @@ def test_delete_budget_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = BudgetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1366,7 +1516,8 @@ async def test_delete_budget_async( transport: str = "grpc_asyncio", request_type=budget_service.DeleteBudgetRequest ): client = BudgetServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1394,13 +1545,15 @@ async def test_delete_budget_async_from_dict(): def test_delete_budget_field_headers(): - client = BudgetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = BudgetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = budget_service.DeleteBudgetRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_budget), "__call__") as call: @@ -1414,7 +1567,10 @@ def test_delete_budget_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1427,7 +1583,7 @@ async def test_delete_budget_field_headers_async(): # a field header. Set these to a non-empty value. request = budget_service.DeleteBudgetRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_budget), "__call__") as call: @@ -1441,7 +1597,10 @@ async def test_delete_budget_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] def test_credentials_transport_error(): @@ -1451,7 +1610,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = BudgetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # It is an error to provide a credentials file and a transport instance. @@ -1471,7 +1631,10 @@ def test_credentials_transport_error(): options = client_options.ClientOptions() options.api_key = "api_key" with pytest.raises(ValueError): - client = BudgetServiceClient(client_options=options, transport=transport,) + client = BudgetServiceClient( + client_options=options, + transport=transport, + ) # It is an error to provide an api_key and a credential. options = mock.Mock() @@ -1487,7 +1650,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = BudgetServiceClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -1530,10 +1694,28 @@ def test_transport_adc(transport_class): adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = BudgetServiceClient.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 = BudgetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) - assert isinstance(client.transport, transports.BudgetServiceGrpcTransport,) + client = BudgetServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.BudgetServiceGrpcTransport, + ) def test_budget_service_base_transport_error(): @@ -1571,6 +1753,14 @@ def test_budget_service_base_transport(): with pytest.raises(NotImplementedError): transport.close() + # Catch all for all remaining methods and properties + remainder = [ + "kind", + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + def test_budget_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file @@ -1582,7 +1772,8 @@ def test_budget_service_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.BudgetServiceTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -1727,24 +1918,40 @@ def test_budget_service_grpc_transport_client_cert_source_for_mtls(transport_cla ) -def test_budget_service_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_budget_service_host_no_port(transport_name): client = BudgetServiceClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="billingbudgets.googleapis.com" ), + transport=transport_name, ) - assert client.transport._host == "billingbudgets.googleapis.com:443" + assert client.transport._host == ("billingbudgets.googleapis.com:443") -def test_budget_service_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_budget_service_host_with_port(transport_name): client = BudgetServiceClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="billingbudgets.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "billingbudgets.googleapis.com:8000" + assert client.transport._host == ("billingbudgets.googleapis.com:8000") def test_budget_service_grpc_transport_channel(): @@ -1752,7 +1959,8 @@ def test_budget_service_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.BudgetServiceGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -1764,7 +1972,8 @@ def test_budget_service_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.BudgetServiceGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -1873,7 +2082,8 @@ def test_budget_path(): billing_account = "squid" budget = "clam" expected = "billingAccounts/{billing_account}/budgets/{budget}".format( - billing_account=billing_account, budget=budget, + billing_account=billing_account, + budget=budget, ) actual = BudgetServiceClient.budget_path(billing_account, budget) assert expected == actual @@ -1913,7 +2123,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "cuttlefish" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = BudgetServiceClient.common_folder_path(folder) assert expected == actual @@ -1931,7 +2143,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "winkle" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = BudgetServiceClient.common_organization_path(organization) assert expected == actual @@ -1949,7 +2163,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "scallop" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = BudgetServiceClient.common_project_path(project) assert expected == actual @@ -1969,7 +2185,8 @@ def test_common_location_path(): project = "squid" location = "clam" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = BudgetServiceClient.common_location_path(project, location) assert expected == actual @@ -1994,7 +2211,8 @@ def test_client_with_default_client_info(): transports.BudgetServiceTransport, "_prep_wrapped_messages" ) as prep: client = BudgetServiceClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -2003,7 +2221,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = BudgetServiceClient.get_transport_class() transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -2011,7 +2230,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = BudgetServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) with mock.patch.object( type(getattr(client.transport, "grpc_channel")), "close"