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

feat: add from_service_account_info factory and fix sphinx identifiers #42

Merged
merged 3 commits into from Apr 1, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/billing_v1/cloud_billing.rst
@@ -0,0 +1,11 @@
CloudBilling
------------------------------

.. automodule:: google.cloud.billing_v1.services.cloud_billing
:members:
:inherited-members:


.. automodule:: google.cloud.billing_v1.services.cloud_billing.pagers
:members:
:inherited-members:
11 changes: 11 additions & 0 deletions docs/billing_v1/cloud_catalog.rst
@@ -0,0 +1,11 @@
CloudCatalog
------------------------------

.. automodule:: google.cloud.billing_v1.services.cloud_catalog
:members:
:inherited-members:


.. automodule:: google.cloud.billing_v1.services.cloud_catalog.pagers
:members:
:inherited-members:
10 changes: 4 additions & 6 deletions docs/billing_v1/services.rst
@@ -1,9 +1,7 @@
Services for Google Cloud Billing v1 API
========================================
.. toctree::
:maxdepth: 2

.. automodule:: google.cloud.billing_v1.services.cloud_billing
:members:
:inherited-members:
.. automodule:: google.cloud.billing_v1.services.cloud_catalog
:members:
:inherited-members:
cloud_billing
cloud_catalog
1 change: 1 addition & 0 deletions docs/billing_v1/types.rst
Expand Up @@ -3,4 +3,5 @@ Types for Google Cloud Billing v1 API

.. automodule:: google.cloud.billing_v1.types
:members:
:undoc-members:
:show-inheritance:
4 changes: 2 additions & 2 deletions google/cloud/billing_v1/__init__.py
Expand Up @@ -44,7 +44,7 @@
"AggregationInfo",
"BillingAccount",
"Category",
"CloudBillingClient",
"CloudCatalogClient",
"CreateBillingAccountRequest",
"GetBillingAccountRequest",
"GetProjectBillingInfoRequest",
Expand All @@ -63,5 +63,5 @@
"Sku",
"UpdateBillingAccountRequest",
"UpdateProjectBillingInfoRequest",
"CloudCatalogClient",
"CloudBillingClient",
)
323 changes: 158 additions & 165 deletions google/cloud/billing_v1/services/cloud_billing/async_client.py

Large diffs are not rendered by default.

362 changes: 185 additions & 177 deletions google/cloud/billing_v1/services/cloud_billing/client.py

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions google/cloud/billing_v1/services/cloud_billing/pagers.py
Expand Up @@ -24,7 +24,7 @@ class ListBillingAccountsPager:
"""A pager for iterating through ``list_billing_accounts`` requests.

This class thinly wraps an initial
:class:`~.cloud_billing.ListBillingAccountsResponse` object, and
:class:`google.cloud.billing_v1.types.ListBillingAccountsResponse` object, and
provides an ``__iter__`` method to iterate through its
``billing_accounts`` field.

Expand All @@ -33,7 +33,7 @@ class ListBillingAccountsPager:
through the ``billing_accounts`` field on the
corresponding responses.

All the usual :class:`~.cloud_billing.ListBillingAccountsResponse`
All the usual :class:`google.cloud.billing_v1.types.ListBillingAccountsResponse`
attributes are available on the pager. If multiple requests are made, only
the most recent response is retained, and thus used for attribute lookup.
"""
Expand All @@ -51,9 +51,9 @@ def __init__(
Args:
method (Callable): The method that was originally called, and
which instantiated this pager.
request (:class:`~.cloud_billing.ListBillingAccountsRequest`):
request (google.cloud.billing_v1.types.ListBillingAccountsRequest):
The initial request object.
response (:class:`~.cloud_billing.ListBillingAccountsResponse`):
response (google.cloud.billing_v1.types.ListBillingAccountsResponse):
The initial response object.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Expand Down Expand Up @@ -86,7 +86,7 @@ class ListBillingAccountsAsyncPager:
"""A pager for iterating through ``list_billing_accounts`` requests.

This class thinly wraps an initial
:class:`~.cloud_billing.ListBillingAccountsResponse` object, and
:class:`google.cloud.billing_v1.types.ListBillingAccountsResponse` object, and
provides an ``__aiter__`` method to iterate through its
``billing_accounts`` field.

Expand All @@ -95,7 +95,7 @@ class ListBillingAccountsAsyncPager:
through the ``billing_accounts`` field on the
corresponding responses.

All the usual :class:`~.cloud_billing.ListBillingAccountsResponse`
All the usual :class:`google.cloud.billing_v1.types.ListBillingAccountsResponse`
attributes are available on the pager. If multiple requests are made, only
the most recent response is retained, and thus used for attribute lookup.
"""
Expand All @@ -113,9 +113,9 @@ def __init__(
Args:
method (Callable): The method that was originally called, and
which instantiated this pager.
request (:class:`~.cloud_billing.ListBillingAccountsRequest`):
request (google.cloud.billing_v1.types.ListBillingAccountsRequest):
The initial request object.
response (:class:`~.cloud_billing.ListBillingAccountsResponse`):
response (google.cloud.billing_v1.types.ListBillingAccountsResponse):
The initial response object.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Expand Down Expand Up @@ -152,7 +152,7 @@ class ListProjectBillingInfoPager:
"""A pager for iterating through ``list_project_billing_info`` requests.

This class thinly wraps an initial
:class:`~.cloud_billing.ListProjectBillingInfoResponse` object, and
:class:`google.cloud.billing_v1.types.ListProjectBillingInfoResponse` object, and
provides an ``__iter__`` method to iterate through its
``project_billing_info`` field.

Expand All @@ -161,7 +161,7 @@ class ListProjectBillingInfoPager:
through the ``project_billing_info`` field on the
corresponding responses.

All the usual :class:`~.cloud_billing.ListProjectBillingInfoResponse`
All the usual :class:`google.cloud.billing_v1.types.ListProjectBillingInfoResponse`
attributes are available on the pager. If multiple requests are made, only
the most recent response is retained, and thus used for attribute lookup.
"""
Expand All @@ -179,9 +179,9 @@ def __init__(
Args:
method (Callable): The method that was originally called, and
which instantiated this pager.
request (:class:`~.cloud_billing.ListProjectBillingInfoRequest`):
request (google.cloud.billing_v1.types.ListProjectBillingInfoRequest):
The initial request object.
response (:class:`~.cloud_billing.ListProjectBillingInfoResponse`):
response (google.cloud.billing_v1.types.ListProjectBillingInfoResponse):
The initial response object.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Expand Down Expand Up @@ -214,7 +214,7 @@ class ListProjectBillingInfoAsyncPager:
"""A pager for iterating through ``list_project_billing_info`` requests.

This class thinly wraps an initial
:class:`~.cloud_billing.ListProjectBillingInfoResponse` object, and
:class:`google.cloud.billing_v1.types.ListProjectBillingInfoResponse` object, and
provides an ``__aiter__`` method to iterate through its
``project_billing_info`` field.

Expand All @@ -223,7 +223,7 @@ class ListProjectBillingInfoAsyncPager:
through the ``project_billing_info`` field on the
corresponding responses.

All the usual :class:`~.cloud_billing.ListProjectBillingInfoResponse`
All the usual :class:`google.cloud.billing_v1.types.ListProjectBillingInfoResponse`
attributes are available on the pager. If multiple requests are made, only
the most recent response is retained, and thus used for attribute lookup.
"""
Expand All @@ -241,9 +241,9 @@ def __init__(
Args:
method (Callable): The method that was originally called, and
which instantiated this pager.
request (:class:`~.cloud_billing.ListProjectBillingInfoRequest`):
request (google.cloud.billing_v1.types.ListProjectBillingInfoRequest):
The initial request object.
response (:class:`~.cloud_billing.ListProjectBillingInfoResponse`):
response (google.cloud.billing_v1.types.ListProjectBillingInfoResponse):
The initial response object.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Expand Down
16 changes: 9 additions & 7 deletions google/cloud/billing_v1/services/cloud_catalog/async_client.py
Expand Up @@ -77,6 +77,7 @@ class CloudCatalogAsyncClient:
CloudCatalogClient.parse_common_location_path
)

from_service_account_info = CloudCatalogClient.from_service_account_info
from_service_account_file = CloudCatalogClient.from_service_account_file
from_service_account_json = from_service_account_file

Expand Down Expand Up @@ -152,7 +153,7 @@ async def list_services(
r"""Lists all public cloud services.

Args:
request (:class:`~.cloud_catalog.ListServicesRequest`):
request (:class:`google.cloud.billing_v1.types.ListServicesRequest`):
The request object. Request message for `ListServices`.

retry (google.api_core.retry.Retry): Designation of what errors, if any,
Expand All @@ -162,8 +163,8 @@ async def list_services(
sent along with the request as metadata.

Returns:
~.pagers.ListServicesAsyncPager:
Response message for ``ListServices``.
google.cloud.billing_v1.services.cloud_catalog.pagers.ListServicesAsyncPager:
Response message for ListServices.

Iterating over this object will yield results and
resolve additional pages automatically.
Expand Down Expand Up @@ -206,11 +207,12 @@ async def list_skus(
service.

Args:
request (:class:`~.cloud_catalog.ListSkusRequest`):
request (:class:`google.cloud.billing_v1.types.ListSkusRequest`):
The request object. Request message for `ListSkus`.
parent (:class:`str`):
Required. The name of the service.
Example: "services/DA34-426B-A397".
Example: "services/DA34-426B-A397"

This corresponds to the ``parent`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
Expand All @@ -222,8 +224,8 @@ async def list_skus(
sent along with the request as metadata.

Returns:
~.pagers.ListSkusAsyncPager:
Response message for ``ListSkus``.
google.cloud.billing_v1.services.cloud_catalog.pagers.ListSkusAsyncPager:
Response message for ListSkus.

Iterating over this object will yield results and
resolve additional pages automatically.
Expand Down
39 changes: 28 additions & 11 deletions google/cloud/billing_v1/services/cloud_catalog/client.py
Expand Up @@ -111,6 +111,22 @@ def _get_default_mtls_endpoint(api_endpoint):
DEFAULT_ENDPOINT
)

@classmethod
def from_service_account_info(cls, info: dict, *args, **kwargs):
"""Creates an instance of this client using the provided credentials info.

Args:
info (dict): The service account private key info.
args: Additional arguments to pass to the constructor.
kwargs: Additional arguments to pass to the constructor.

Returns:
CloudCatalogClient: The constructed client.
"""
credentials = service_account.Credentials.from_service_account_info(info)
kwargs["credentials"] = credentials
return cls(*args, **kwargs)

@classmethod
def from_service_account_file(cls, filename: str, *args, **kwargs):
"""Creates an instance of this client using the provided credentials
Expand All @@ -123,7 +139,7 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):
kwargs: Additional arguments to pass to the constructor.

Returns:
{@api.name}: The constructed client.
CloudCatalogClient: The constructed client.
"""
credentials = service_account.Credentials.from_service_account_file(filename)
kwargs["credentials"] = credentials
Expand Down Expand Up @@ -237,10 +253,10 @@ def __init__(
credentials identify the application to the service; if none
are specified, the client will attempt to ascertain the
credentials from the environment.
transport (Union[str, ~.CloudCatalogTransport]): The
transport (Union[str, CloudCatalogTransport]): The
transport to use. If set to None, a transport is chosen
automatically.
client_options (client_options_lib.ClientOptions): Custom options for the
client_options (google.api_core.client_options.ClientOptions): Custom options for the
client. It won't take effect if a ``transport`` instance is provided.
(1) The ``api_endpoint`` property can be used to override the
default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT
Expand Down Expand Up @@ -349,7 +365,7 @@ def list_services(
r"""Lists all public cloud services.

Args:
request (:class:`~.cloud_catalog.ListServicesRequest`):
request (google.cloud.billing_v1.types.ListServicesRequest):
The request object. Request message for `ListServices`.

retry (google.api_core.retry.Retry): Designation of what errors, if any,
Expand All @@ -359,8 +375,8 @@ def list_services(
sent along with the request as metadata.

Returns:
~.pagers.ListServicesPager:
Response message for ``ListServices``.
google.cloud.billing_v1.services.cloud_catalog.pagers.ListServicesPager:
Response message for ListServices.

Iterating over this object will yield results and
resolve additional pages automatically.
Expand Down Expand Up @@ -404,11 +420,12 @@ def list_skus(
service.

Args:
request (:class:`~.cloud_catalog.ListSkusRequest`):
request (google.cloud.billing_v1.types.ListSkusRequest):
The request object. Request message for `ListSkus`.
parent (:class:`str`):
parent (str):
Required. The name of the service.
Example: "services/DA34-426B-A397".
Example: "services/DA34-426B-A397"

This corresponds to the ``parent`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
Expand All @@ -420,8 +437,8 @@ def list_skus(
sent along with the request as metadata.

Returns:
~.pagers.ListSkusPager:
Response message for ``ListSkus``.
google.cloud.billing_v1.services.cloud_catalog.pagers.ListSkusPager:
Response message for ListSkus.

Iterating over this object will yield results and
resolve additional pages automatically.
Expand Down