From 7c343209613ae0e303d5beb2b9aae526dc9069c8 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 1 Sep 2022 13:50:39 +0000 Subject: [PATCH] feat: update BigQuery Analytics Hub API v1beta1 client (#32) - [ ] Regenerate this pull request now. refresh current dataexchange/v1beta1/* directory to include recent change in protos. fix: refactor references to Category message docs: improve proto documentation. PiperOrigin-RevId: 471349319 Source-Link: https://github.com/googleapis/googleapis/commit/84950242f2bb5d57bcc35511725508302d2403ab Source-Link: https://github.com/googleapis/googleapis-gen/commit/2d8c38b90a5a198d71eb1a8eb43e0ce56127ac0d Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMmQ4YzM4YjkwYTVhMTk4ZDcxZWIxYThlYjQzZTBjZTU2MTI3YWMwZCJ9 --- .coveragerc | 2 +- .../analytics_hub_service/async_client.py | 278 +++++++++---- .../services/analytics_hub_service/client.py | 278 +++++++++---- .../analytics_hub_service/transports/base.py | 22 + .../analytics_hub_service/transports/grpc.py | 95 +++-- .../transports/grpc_asyncio.py | 95 +++-- .../types/dataexchange.py | 241 ++++++----- .../test_analytics_hub_service.py | 390 ++++++++++++++++-- 8 files changed, 1039 insertions(+), 362 deletions(-) diff --git a/.coveragerc b/.coveragerc index fbfb52c..db5d1de 100644 --- a/.coveragerc +++ b/.coveragerc @@ -4,7 +4,7 @@ branch = True [report] show_missing = True omit = - google/cloud/bigquery_data_exchange/common/__init__.py + google/cloud/bigquery_data_exchange/__init__.py exclude_lines = # Re-enable the standard pragma pragma: NO COVER diff --git a/google/cloud/bigquery_data_exchange_v1beta1/services/analytics_hub_service/async_client.py b/google/cloud/bigquery_data_exchange_v1beta1/services/analytics_hub_service/async_client.py index 44999e7..3d43099 100644 --- a/google/cloud/bigquery_data_exchange_v1beta1/services/analytics_hub_service/async_client.py +++ b/google/cloud/bigquery_data_exchange_v1beta1/services/analytics_hub_service/async_client.py @@ -31,11 +31,11 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object] # type: ignore -from google.cloud.bigquery_data_exchange_v1beta1 import common # type: ignore from google.cloud.bigquery_data_exchange_v1beta1.services.analytics_hub_service import ( pagers, ) from google.cloud.bigquery_data_exchange_v1beta1.types import dataexchange +from google.cloud.location import locations_pb2 # type: ignore from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -45,12 +45,13 @@ class AnalyticsHubServiceAsyncClient: - """The AnalyticsHubService API facilitates data sharing within - and across organizations. It allows data providers to publish - Listings --- a discoverable and searchable SKU representing a - dataset. Data consumers can subscribe to Listings. Upon - subscription, AnalyticsHub provisions a "Linked Datasets" - surfacing the data in the consumer's project. + """The ``AnalyticsHubService`` API facilitates data sharing within and + across organizations. It allows data providers to publish listings + that reference shared datasets. With Analytics Hub, users can + discover and search for listings that they have access to. + Subscribers can view and subscribe to listings. When you subscribe + to a listing, Analytics Hub creates a linked dataset in your + project. """ _client: AnalyticsHubServiceClient @@ -230,7 +231,8 @@ async def list_data_exchanges( timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListDataExchangesAsyncPager: - r"""Lists DataExchanges in a given project and location. + r"""Lists all data exchanges in a given project and + location. .. code-block:: python @@ -254,11 +256,11 @@ async def sample_list_data_exchanges(): Args: request (Union[google.cloud.bigquery_data_exchange_v1beta1.types.ListDataExchangesRequest, dict]): - The request object. Message for requesting list of - DataExchanges. + The request object. Message for requesting the list of + data exchanges. parent (:class:`str`): - Required. The parent resource path of the DataExchanges. - e.g. ``projects/myproject/locations/US``. + Required. The parent resource path of the data + exchanges. e.g. ``projects/myproject/locations/US``. This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this @@ -271,8 +273,8 @@ async def sample_list_data_exchanges(): Returns: google.cloud.bigquery_data_exchange_v1beta1.services.analytics_hub_service.pagers.ListDataExchangesAsyncPager: - Message for response to listing - DataExchanges. + Message for response to the list of + data exchanges. Iterating over this object will yield results and resolve additional pages automatically. @@ -338,7 +340,7 @@ async def list_org_data_exchanges( timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListOrgDataExchangesAsyncPager: - r"""Lists DataExchanges from projects in a given + r"""Lists all data exchanges from projects in a given organization and location. .. code-block:: python @@ -363,8 +365,8 @@ async def sample_list_org_data_exchanges(): Args: request (Union[google.cloud.bigquery_data_exchange_v1beta1.types.ListOrgDataExchangesRequest, dict]): - The request object. Message for requesting list of - DataExchanges from projects in an organization and + The request object. Message for requesting the list of + data exchanges from projects in an organization and location. organization (:class:`str`): Required. The organization resource path of the projects @@ -382,8 +384,8 @@ async def sample_list_org_data_exchanges(): Returns: google.cloud.bigquery_data_exchange_v1beta1.services.analytics_hub_service.pagers.ListOrgDataExchangesAsyncPager: - Message for response to listing - DataExchanges in an organization and + Message for response to listing data + exchanges in an organization and location. Iterating over this object will yield results and resolve additional pages @@ -452,7 +454,7 @@ async def get_data_exchange( timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> dataexchange.DataExchange: - r"""Gets details of a single DataExchange. + r"""Gets the details of a data exchange. .. code-block:: python @@ -475,9 +477,9 @@ async def sample_get_data_exchange(): Args: request (Union[google.cloud.bigquery_data_exchange_v1beta1.types.GetDataExchangeRequest, dict]): - The request object. Message for getting a DataExchange. + The request object. Message for getting a data exchange. name (:class:`str`): - Required. The resource name of the DataExchange. e.g. + Required. The resource name of the data exchange. e.g. ``projects/myproject/locations/US/dataExchanges/123``. This corresponds to the ``name`` field @@ -492,10 +494,10 @@ async def sample_get_data_exchange(): Returns: google.cloud.bigquery_data_exchange_v1beta1.types.DataExchange: A data exchange is a container that - enables data sharing. It contains a set - of listings of the data sources along - with descriptive information of the data - exchange. + lets you share data. Along with the + descriptive information about the data + exchange, it contains listings that + reference shared datasets. """ # Create or coerce a protobuf request object. @@ -550,8 +552,7 @@ async def create_data_exchange( timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> dataexchange.DataExchange: - r"""Creates a new DataExchange in a given project and - location. + r"""Creates a new data exchange. .. code-block:: python @@ -579,16 +580,19 @@ async def sample_create_data_exchange(): Args: request (Union[google.cloud.bigquery_data_exchange_v1beta1.types.CreateDataExchangeRequest, dict]): - The request object. Message for creating a DataExchange. + The request object. Message for creating a data + exchange. parent (:class:`str`): - Required. The parent resource path of the DataExchange. + Required. The parent resource path of the data exchange. e.g. ``projects/myproject/locations/US``. This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. data_exchange (:class:`google.cloud.bigquery_data_exchange_v1beta1.types.DataExchange`): - Required. The DataExchange to create. + Required. The data exchange to + create. + This corresponds to the ``data_exchange`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -601,10 +605,10 @@ async def sample_create_data_exchange(): Returns: google.cloud.bigquery_data_exchange_v1beta1.types.DataExchange: A data exchange is a container that - enables data sharing. It contains a set - of listings of the data sources along - with descriptive information of the data - exchange. + lets you share data. Along with the + descriptive information about the data + exchange, it contains listings that + reference shared datasets. """ # Create or coerce a protobuf request object. @@ -661,7 +665,7 @@ async def update_data_exchange( timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> dataexchange.DataExchange: - r"""Updates the parameters of a single DataExchange. + r"""Updates an existing data exchange. .. code-block:: python @@ -687,17 +691,20 @@ async def sample_update_data_exchange(): Args: request (Union[google.cloud.bigquery_data_exchange_v1beta1.types.UpdateDataExchangeRequest, dict]): - The request object. Message for updating a DataExchange. + The request object. Message for updating a data + exchange. data_exchange (:class:`google.cloud.bigquery_data_exchange_v1beta1.types.DataExchange`): - Required. The DataExchange to update. + Required. The data exchange to + update. + This corresponds to the ``data_exchange`` field on the ``request`` instance; if ``request`` is provided, this should not be set. update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Required. Field mask is used to specify the fields to be - overwritten in the DataExchange resource by the update. - The fields specified in the update_mask are relative to - the resource, not the full request. + Required. Field mask specifies the fields to update in + the data exchange resource. The fields specified in the + ``updateMask`` are relative to the resource and are not + a full request. This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this @@ -711,10 +718,10 @@ async def sample_update_data_exchange(): Returns: google.cloud.bigquery_data_exchange_v1beta1.types.DataExchange: A data exchange is a container that - enables data sharing. It contains a set - of listings of the data sources along - with descriptive information of the data - exchange. + lets you share data. Along with the + descriptive information about the data + exchange, it contains listings that + reference shared datasets. """ # Create or coerce a protobuf request object. @@ -772,7 +779,7 @@ async def delete_data_exchange( timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: - r"""Deletes a single DataExchange. + r"""Deletes an existing data exchange. .. code-block:: python @@ -792,10 +799,11 @@ async def sample_delete_data_exchange(): Args: request (Union[google.cloud.bigquery_data_exchange_v1beta1.types.DeleteDataExchangeRequest, dict]): - The request object. Message for deleting a DataExchange. + The request object. Message for deleting a data + exchange. name (:class:`str`): - Required. Resource name of the DataExchange to delete. - e.g. + Required. The full name of the data exchange resource + that you want to delete. For example, ``projects/myproject/locations/US/dataExchanges/123``. This corresponds to the ``name`` field @@ -855,7 +863,7 @@ async def list_listings( timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListListingsAsyncPager: - r"""Lists Listings in a given project and location. + r"""Lists all listings in a given project and location. .. code-block:: python @@ -879,8 +887,8 @@ async def sample_list_listings(): Args: request (Union[google.cloud.bigquery_data_exchange_v1beta1.types.ListListingsRequest, dict]): - The request object. Message for requesting list of - Listings. + The request object. Message for requesting the list of + listings. parent (:class:`str`): Required. The parent resource path of the listing. e.g. ``projects/myproject/locations/US/dataExchanges/123``. @@ -896,7 +904,7 @@ async def sample_list_listings(): Returns: google.cloud.bigquery_data_exchange_v1beta1.services.analytics_hub_service.pagers.ListListingsAsyncPager: - Message for response to listing + Message for response to the list of Listings. Iterating over this object will yield results and resolve additional pages @@ -963,7 +971,7 @@ async def get_listing( timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> dataexchange.Listing: - r"""Gets details of a single Listing. + r"""Gets the details of a listing. .. code-block:: python @@ -986,7 +994,7 @@ async def sample_get_listing(): Args: request (Union[google.cloud.bigquery_data_exchange_v1beta1.types.GetListingRequest, dict]): - The request object. Message for getting a Listing. + The request object. Message for getting a listing. name (:class:`str`): Required. The resource name of the listing. e.g. ``projects/myproject/locations/US/dataExchanges/123/listings/456``. @@ -1062,8 +1070,7 @@ async def create_listing( timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> dataexchange.Listing: - r"""Creates a new Listing in a given project and - location. + r"""Creates a new listing. .. code-block:: python @@ -1091,7 +1098,7 @@ async def sample_create_listing(): Args: request (Union[google.cloud.bigquery_data_exchange_v1beta1.types.CreateListingRequest, dict]): - The request object. Message for creating a Listing. + The request object. Message for creating a listing. parent (:class:`str`): Required. The parent resource path of the listing. e.g. ``projects/myproject/locations/US/dataExchanges/123``. @@ -1174,7 +1181,7 @@ async def update_listing( timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> dataexchange.Listing: - r"""Updates the parameters of a single Listing. + r"""Updates an existing listing. .. code-block:: python @@ -1207,10 +1214,10 @@ async def sample_update_listing(): on the ``request`` instance; if ``request`` is provided, this should not be set. update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Required. Field mask is used to specify the fields to be - overwritten in the Listing resource by the update. The - fields specified in the update_mask are relative to the - resource, not the full request. + Required. Field mask specifies the fields to update in + the listing resource. The fields specified in the + ``updateMask`` are relative to the resource and are not + a full request. This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this @@ -1286,9 +1293,7 @@ async def delete_listing( timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: - r"""Deletes a single Listing, as long as there are no - subscriptions associated with the source of this - Listing. + r"""Deletes a listing. .. code-block:: python @@ -1308,7 +1313,7 @@ async def sample_delete_listing(): Args: request (Union[google.cloud.bigquery_data_exchange_v1beta1.types.DeleteListingRequest, dict]): - The request object. Message for deleting a Listing. + The request object. Message for deleting a listing. name (:class:`str`): Required. Resource name of the listing to delete. e.g. ``projects/myproject/locations/US/dataExchanges/123/listings/456``. @@ -1370,11 +1375,12 @@ async def subscribe_listing( timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> dataexchange.SubscribeListingResponse: - r"""Subscribes to a single Listing. - Data Exchange currently supports one type of Listing: a - BigQuery dataset. Upon subscription to a Listing for a - BigQuery dataset, Data Exchange creates a linked dataset - in the subscriber's project. + r"""Subscribes to a listing. + Currently, with Analytics Hub, you can create listings + that reference only BigQuery datasets. + Upon subscription to a listing for a BigQuery dataset, + Analytics Hub creates a linked dataset in the + subscriber's project. .. code-block:: python @@ -1403,10 +1409,11 @@ async def sample_subscribe_listing(): Args: request (Union[google.cloud.bigquery_data_exchange_v1beta1.types.SubscribeListingRequest, dict]): - The request object. Message for subscribing a Listing. + The request object. Message for subscribing to a + listing. name (:class:`str`): - Required. Resource name of the listing to subscribe to. - e.g. + Required. Resource name of the listing that you want to + subscribe to. e.g. ``projects/myproject/locations/US/dataExchanges/123/listings/456``. This corresponds to the ``name`` field @@ -1420,8 +1427,8 @@ async def sample_subscribe_listing(): Returns: google.cloud.bigquery_data_exchange_v1beta1.types.SubscribeListingResponse: - Message for response to subscribing a - Listing. Empty for now. + Message for response when you + subscribe to a listing. """ # Create or coerce a protobuf request object. @@ -1474,7 +1481,7 @@ async def get_iam_policy( timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> policy_pb2.Policy: - r"""Gets the IAM policy for a dataExchange or a listing. + r"""Gets the IAM policy. .. code-block:: python @@ -1610,7 +1617,7 @@ async def set_iam_policy( timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> policy_pb2.Policy: - r"""Sets the IAM policy for a dataExchange or a listing. + r"""Sets the IAM policy. .. code-block:: python @@ -1746,8 +1753,7 @@ async def test_iam_permissions( timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: - r"""Returns the permissions that a caller has on a - specified dataExchange or listing. + r"""Returns the permissions that a caller has. .. code-block:: python @@ -1815,6 +1821,114 @@ async def sample_test_iam_permissions(): # Done; return the response. return response + async def get_location( + self, + request: locations_pb2.GetLocationRequest = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> locations_pb2.Location: + r"""Gets information about a location. + + Args: + request (:class:`~.location_pb2.GetLocationRequest`): + The request object. Request message for + `GetLocation` method. + retry (google.api_core.retry.Retry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + Returns: + ~.location_pb2.Location: + Location object. + """ + # Create or coerce a protobuf request object. + # The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = locations_pb2.GetLocationRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._client._transport.get_location, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_locations( + self, + request: locations_pb2.ListLocationsRequest = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> locations_pb2.ListLocationsResponse: + r"""Lists information about the supported locations for this service. + + Args: + request (:class:`~.location_pb2.ListLocationsRequest`): + The request object. Request message for + `ListLocations` method. + retry (google.api_core.retry.Retry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + Returns: + ~.location_pb2.ListLocationsResponse: + Response message for ``ListLocations`` method. + """ + # Create or coerce a protobuf request object. + # The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = locations_pb2.ListLocationsRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._client._transport.list_locations, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + async def __aenter__(self): return self diff --git a/google/cloud/bigquery_data_exchange_v1beta1/services/analytics_hub_service/client.py b/google/cloud/bigquery_data_exchange_v1beta1/services/analytics_hub_service/client.py index 0acff2c..f441afe 100644 --- a/google/cloud/bigquery_data_exchange_v1beta1/services/analytics_hub_service/client.py +++ b/google/cloud/bigquery_data_exchange_v1beta1/services/analytics_hub_service/client.py @@ -34,11 +34,11 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object] # type: ignore -from google.cloud.bigquery_data_exchange_v1beta1 import common # type: ignore from google.cloud.bigquery_data_exchange_v1beta1.services.analytics_hub_service import ( pagers, ) from google.cloud.bigquery_data_exchange_v1beta1.types import dataexchange +from google.cloud.location import locations_pb2 # type: ignore from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -84,12 +84,13 @@ def get_transport_class( class AnalyticsHubServiceClient(metaclass=AnalyticsHubServiceClientMeta): - """The AnalyticsHubService API facilitates data sharing within - and across organizations. It allows data providers to publish - Listings --- a discoverable and searchable SKU representing a - dataset. Data consumers can subscribe to Listings. Upon - subscription, AnalyticsHub provisions a "Linked Datasets" - surfacing the data in the consumer's project. + """The ``AnalyticsHubService`` API facilitates data sharing within and + across organizations. It allows data providers to publish listings + that reference shared datasets. With Analytics Hub, users can + discover and search for listings that they have access to. + Subscribers can view and subscribe to listings. When you subscribe + to a listing, Analytics Hub creates a linked dataset in your + project. """ @staticmethod @@ -489,7 +490,8 @@ def list_data_exchanges( timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListDataExchangesPager: - r"""Lists DataExchanges in a given project and location. + r"""Lists all data exchanges in a given project and + location. .. code-block:: python @@ -513,11 +515,11 @@ def sample_list_data_exchanges(): Args: request (Union[google.cloud.bigquery_data_exchange_v1beta1.types.ListDataExchangesRequest, dict]): - The request object. Message for requesting list of - DataExchanges. + The request object. Message for requesting the list of + data exchanges. parent (str): - Required. The parent resource path of the DataExchanges. - e.g. ``projects/myproject/locations/US``. + Required. The parent resource path of the data + exchanges. e.g. ``projects/myproject/locations/US``. This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this @@ -530,8 +532,8 @@ def sample_list_data_exchanges(): Returns: google.cloud.bigquery_data_exchange_v1beta1.services.analytics_hub_service.pagers.ListDataExchangesPager: - Message for response to listing - DataExchanges. + Message for response to the list of + data exchanges. Iterating over this object will yield results and resolve additional pages automatically. @@ -597,7 +599,7 @@ def list_org_data_exchanges( timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListOrgDataExchangesPager: - r"""Lists DataExchanges from projects in a given + r"""Lists all data exchanges from projects in a given organization and location. .. code-block:: python @@ -622,8 +624,8 @@ def sample_list_org_data_exchanges(): Args: request (Union[google.cloud.bigquery_data_exchange_v1beta1.types.ListOrgDataExchangesRequest, dict]): - The request object. Message for requesting list of - DataExchanges from projects in an organization and + The request object. Message for requesting the list of + data exchanges from projects in an organization and location. organization (str): Required. The organization resource path of the projects @@ -641,8 +643,8 @@ def sample_list_org_data_exchanges(): Returns: google.cloud.bigquery_data_exchange_v1beta1.services.analytics_hub_service.pagers.ListOrgDataExchangesPager: - Message for response to listing - DataExchanges in an organization and + Message for response to listing data + exchanges in an organization and location. Iterating over this object will yield results and resolve additional pages @@ -711,7 +713,7 @@ def get_data_exchange( timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> dataexchange.DataExchange: - r"""Gets details of a single DataExchange. + r"""Gets the details of a data exchange. .. code-block:: python @@ -734,9 +736,9 @@ def sample_get_data_exchange(): Args: request (Union[google.cloud.bigquery_data_exchange_v1beta1.types.GetDataExchangeRequest, dict]): - The request object. Message for getting a DataExchange. + The request object. Message for getting a data exchange. name (str): - Required. The resource name of the DataExchange. e.g. + Required. The resource name of the data exchange. e.g. ``projects/myproject/locations/US/dataExchanges/123``. This corresponds to the ``name`` field @@ -751,10 +753,10 @@ def sample_get_data_exchange(): Returns: google.cloud.bigquery_data_exchange_v1beta1.types.DataExchange: A data exchange is a container that - enables data sharing. It contains a set - of listings of the data sources along - with descriptive information of the data - exchange. + lets you share data. Along with the + descriptive information about the data + exchange, it contains listings that + reference shared datasets. """ # Create or coerce a protobuf request object. @@ -809,8 +811,7 @@ def create_data_exchange( timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> dataexchange.DataExchange: - r"""Creates a new DataExchange in a given project and - location. + r"""Creates a new data exchange. .. code-block:: python @@ -838,16 +839,19 @@ def sample_create_data_exchange(): Args: request (Union[google.cloud.bigquery_data_exchange_v1beta1.types.CreateDataExchangeRequest, dict]): - The request object. Message for creating a DataExchange. + The request object. Message for creating a data + exchange. parent (str): - Required. The parent resource path of the DataExchange. + Required. The parent resource path of the data exchange. e.g. ``projects/myproject/locations/US``. This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. data_exchange (google.cloud.bigquery_data_exchange_v1beta1.types.DataExchange): - Required. The DataExchange to create. + Required. The data exchange to + create. + This corresponds to the ``data_exchange`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -860,10 +864,10 @@ def sample_create_data_exchange(): Returns: google.cloud.bigquery_data_exchange_v1beta1.types.DataExchange: A data exchange is a container that - enables data sharing. It contains a set - of listings of the data sources along - with descriptive information of the data - exchange. + lets you share data. Along with the + descriptive information about the data + exchange, it contains listings that + reference shared datasets. """ # Create or coerce a protobuf request object. @@ -920,7 +924,7 @@ def update_data_exchange( timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> dataexchange.DataExchange: - r"""Updates the parameters of a single DataExchange. + r"""Updates an existing data exchange. .. code-block:: python @@ -946,17 +950,20 @@ def sample_update_data_exchange(): Args: request (Union[google.cloud.bigquery_data_exchange_v1beta1.types.UpdateDataExchangeRequest, dict]): - The request object. Message for updating a DataExchange. + The request object. Message for updating a data + exchange. data_exchange (google.cloud.bigquery_data_exchange_v1beta1.types.DataExchange): - Required. The DataExchange to update. + Required. The data exchange to + update. + This corresponds to the ``data_exchange`` field on the ``request`` instance; if ``request`` is provided, this should not be set. update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. Field mask is used to specify the fields to be - overwritten in the DataExchange resource by the update. - The fields specified in the update_mask are relative to - the resource, not the full request. + Required. Field mask specifies the fields to update in + the data exchange resource. The fields specified in the + ``updateMask`` are relative to the resource and are not + a full request. This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this @@ -970,10 +977,10 @@ def sample_update_data_exchange(): Returns: google.cloud.bigquery_data_exchange_v1beta1.types.DataExchange: A data exchange is a container that - enables data sharing. It contains a set - of listings of the data sources along - with descriptive information of the data - exchange. + lets you share data. Along with the + descriptive information about the data + exchange, it contains listings that + reference shared datasets. """ # Create or coerce a protobuf request object. @@ -1031,7 +1038,7 @@ def delete_data_exchange( timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: - r"""Deletes a single DataExchange. + r"""Deletes an existing data exchange. .. code-block:: python @@ -1051,10 +1058,11 @@ def sample_delete_data_exchange(): Args: request (Union[google.cloud.bigquery_data_exchange_v1beta1.types.DeleteDataExchangeRequest, dict]): - The request object. Message for deleting a DataExchange. + The request object. Message for deleting a data + exchange. name (str): - Required. Resource name of the DataExchange to delete. - e.g. + Required. The full name of the data exchange resource + that you want to delete. For example, ``projects/myproject/locations/US/dataExchanges/123``. This corresponds to the ``name`` field @@ -1114,7 +1122,7 @@ def list_listings( timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListListingsPager: - r"""Lists Listings in a given project and location. + r"""Lists all listings in a given project and location. .. code-block:: python @@ -1138,8 +1146,8 @@ def sample_list_listings(): Args: request (Union[google.cloud.bigquery_data_exchange_v1beta1.types.ListListingsRequest, dict]): - The request object. Message for requesting list of - Listings. + The request object. Message for requesting the list of + listings. parent (str): Required. The parent resource path of the listing. e.g. ``projects/myproject/locations/US/dataExchanges/123``. @@ -1155,7 +1163,7 @@ def sample_list_listings(): Returns: google.cloud.bigquery_data_exchange_v1beta1.services.analytics_hub_service.pagers.ListListingsPager: - Message for response to listing + Message for response to the list of Listings. Iterating over this object will yield results and resolve additional pages @@ -1222,7 +1230,7 @@ def get_listing( timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> dataexchange.Listing: - r"""Gets details of a single Listing. + r"""Gets the details of a listing. .. code-block:: python @@ -1245,7 +1253,7 @@ def sample_get_listing(): Args: request (Union[google.cloud.bigquery_data_exchange_v1beta1.types.GetListingRequest, dict]): - The request object. Message for getting a Listing. + The request object. Message for getting a listing. name (str): Required. The resource name of the listing. e.g. ``projects/myproject/locations/US/dataExchanges/123/listings/456``. @@ -1321,8 +1329,7 @@ def create_listing( timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> dataexchange.Listing: - r"""Creates a new Listing in a given project and - location. + r"""Creates a new listing. .. code-block:: python @@ -1350,7 +1357,7 @@ def sample_create_listing(): Args: request (Union[google.cloud.bigquery_data_exchange_v1beta1.types.CreateListingRequest, dict]): - The request object. Message for creating a Listing. + The request object. Message for creating a listing. parent (str): Required. The parent resource path of the listing. e.g. ``projects/myproject/locations/US/dataExchanges/123``. @@ -1433,7 +1440,7 @@ def update_listing( timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> dataexchange.Listing: - r"""Updates the parameters of a single Listing. + r"""Updates an existing listing. .. code-block:: python @@ -1466,10 +1473,10 @@ def sample_update_listing(): on the ``request`` instance; if ``request`` is provided, this should not be set. update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. Field mask is used to specify the fields to be - overwritten in the Listing resource by the update. The - fields specified in the update_mask are relative to the - resource, not the full request. + Required. Field mask specifies the fields to update in + the listing resource. The fields specified in the + ``updateMask`` are relative to the resource and are not + a full request. This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this @@ -1545,9 +1552,7 @@ def delete_listing( timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: - r"""Deletes a single Listing, as long as there are no - subscriptions associated with the source of this - Listing. + r"""Deletes a listing. .. code-block:: python @@ -1567,7 +1572,7 @@ def sample_delete_listing(): Args: request (Union[google.cloud.bigquery_data_exchange_v1beta1.types.DeleteListingRequest, dict]): - The request object. Message for deleting a Listing. + The request object. Message for deleting a listing. name (str): Required. Resource name of the listing to delete. e.g. ``projects/myproject/locations/US/dataExchanges/123/listings/456``. @@ -1629,11 +1634,12 @@ def subscribe_listing( timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> dataexchange.SubscribeListingResponse: - r"""Subscribes to a single Listing. - Data Exchange currently supports one type of Listing: a - BigQuery dataset. Upon subscription to a Listing for a - BigQuery dataset, Data Exchange creates a linked dataset - in the subscriber's project. + r"""Subscribes to a listing. + Currently, with Analytics Hub, you can create listings + that reference only BigQuery datasets. + Upon subscription to a listing for a BigQuery dataset, + Analytics Hub creates a linked dataset in the + subscriber's project. .. code-block:: python @@ -1662,10 +1668,11 @@ def sample_subscribe_listing(): Args: request (Union[google.cloud.bigquery_data_exchange_v1beta1.types.SubscribeListingRequest, dict]): - The request object. Message for subscribing a Listing. + The request object. Message for subscribing to a + listing. name (str): - Required. Resource name of the listing to subscribe to. - e.g. + Required. Resource name of the listing that you want to + subscribe to. e.g. ``projects/myproject/locations/US/dataExchanges/123/listings/456``. This corresponds to the ``name`` field @@ -1679,8 +1686,8 @@ def sample_subscribe_listing(): Returns: google.cloud.bigquery_data_exchange_v1beta1.types.SubscribeListingResponse: - Message for response to subscribing a - Listing. Empty for now. + Message for response when you + subscribe to a listing. """ # Create or coerce a protobuf request object. @@ -1733,7 +1740,7 @@ def get_iam_policy( timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> policy_pb2.Policy: - r"""Gets the IAM policy for a dataExchange or a listing. + r"""Gets the IAM policy. .. code-block:: python @@ -1868,7 +1875,7 @@ def set_iam_policy( timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> policy_pb2.Policy: - r"""Sets the IAM policy for a dataExchange or a listing. + r"""Sets the IAM policy. .. code-block:: python @@ -2003,8 +2010,7 @@ def test_iam_permissions( timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: - r"""Returns the permissions that a caller has on a - specified dataExchange or listing. + r"""Returns the permissions that a caller has. .. code-block:: python @@ -2084,6 +2090,114 @@ def __exit__(self, type, value, traceback): """ self.transport.close() + def get_location( + self, + request: locations_pb2.GetLocationRequest = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> locations_pb2.Location: + r"""Gets information about a location. + + Args: + request (:class:`~.location_pb2.GetLocationRequest`): + The request object. Request message for + `GetLocation` method. + retry (google.api_core.retry.Retry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + Returns: + ~.location_pb2.Location: + Location object. + """ + # Create or coerce a protobuf request object. + # The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = locations_pb2.GetLocationRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.get_location, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_locations( + self, + request: locations_pb2.ListLocationsRequest = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> locations_pb2.ListLocationsResponse: + r"""Lists information about the supported locations for this service. + + Args: + request (:class:`~.location_pb2.ListLocationsRequest`): + The request object. Request message for + `ListLocations` method. + retry (google.api_core.retry.Retry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + Returns: + ~.location_pb2.ListLocationsResponse: + Response message for ``ListLocations`` method. + """ + # Create or coerce a protobuf request object. + # The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = locations_pb2.ListLocationsRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.list_locations, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/bigquery_data_exchange_v1beta1/services/analytics_hub_service/transports/base.py b/google/cloud/bigquery_data_exchange_v1beta1/services/analytics_hub_service/transports/base.py index 4086c04..356aa6f 100644 --- a/google/cloud/bigquery_data_exchange_v1beta1/services/analytics_hub_service/transports/base.py +++ b/google/cloud/bigquery_data_exchange_v1beta1/services/analytics_hub_service/transports/base.py @@ -26,6 +26,7 @@ from google.oauth2 import service_account # type: ignore from google.cloud.bigquery_data_exchange_v1beta1.types import dataexchange +from google.cloud.location import locations_pb2 # type: ignore from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore @@ -369,6 +370,27 @@ def test_iam_permissions( ]: raise NotImplementedError() + @property + def get_location( + self, + ) -> Callable[ + [locations_pb2.GetLocationRequest], + Union[locations_pb2.Location, Awaitable[locations_pb2.Location]], + ]: + raise NotImplementedError() + + @property + def list_locations( + self, + ) -> Callable[ + [locations_pb2.ListLocationsRequest], + Union[ + locations_pb2.ListLocationsResponse, + Awaitable[locations_pb2.ListLocationsResponse], + ], + ]: + raise NotImplementedError() + @property def kind(self) -> str: raise NotImplementedError() diff --git a/google/cloud/bigquery_data_exchange_v1beta1/services/analytics_hub_service/transports/grpc.py b/google/cloud/bigquery_data_exchange_v1beta1/services/analytics_hub_service/transports/grpc.py index b8f88fd..18852d1 100644 --- a/google/cloud/bigquery_data_exchange_v1beta1/services/analytics_hub_service/transports/grpc.py +++ b/google/cloud/bigquery_data_exchange_v1beta1/services/analytics_hub_service/transports/grpc.py @@ -25,6 +25,7 @@ import grpc # type: ignore from google.cloud.bigquery_data_exchange_v1beta1.types import dataexchange +from google.cloud.location import locations_pb2 # type: ignore from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore @@ -34,12 +35,13 @@ class AnalyticsHubServiceGrpcTransport(AnalyticsHubServiceTransport): """gRPC backend transport for AnalyticsHubService. - The AnalyticsHubService API facilitates data sharing within - and across organizations. It allows data providers to publish - Listings --- a discoverable and searchable SKU representing a - dataset. Data consumers can subscribe to Listings. Upon - subscription, AnalyticsHub provisions a "Linked Datasets" - surfacing the data in the consumer's project. + The ``AnalyticsHubService`` API facilitates data sharing within and + across organizations. It allows data providers to publish listings + that reference shared datasets. With Analytics Hub, users can + discover and search for listings that they have access to. + Subscribers can view and subscribe to listings. When you subscribe + to a listing, Analytics Hub creates a linked dataset in your + project. This class defines the same methods as the primary client, so the primary client can load the underlying transport implementation @@ -245,7 +247,8 @@ def list_data_exchanges( ]: r"""Return a callable for the list data exchanges method over gRPC. - Lists DataExchanges in a given project and location. + Lists all data exchanges in a given project and + location. Returns: Callable[[~.ListDataExchangesRequest], @@ -274,7 +277,7 @@ def list_org_data_exchanges( ]: r"""Return a callable for the list org data exchanges method over gRPC. - Lists DataExchanges from projects in a given + Lists all data exchanges from projects in a given organization and location. Returns: @@ -301,7 +304,7 @@ def get_data_exchange( ) -> Callable[[dataexchange.GetDataExchangeRequest], dataexchange.DataExchange]: r"""Return a callable for the get data exchange method over gRPC. - Gets details of a single DataExchange. + Gets the details of a data exchange. Returns: Callable[[~.GetDataExchangeRequest], @@ -327,8 +330,7 @@ def create_data_exchange( ) -> Callable[[dataexchange.CreateDataExchangeRequest], dataexchange.DataExchange]: r"""Return a callable for the create data exchange method over gRPC. - Creates a new DataExchange in a given project and - location. + Creates a new data exchange. Returns: Callable[[~.CreateDataExchangeRequest], @@ -354,7 +356,7 @@ def update_data_exchange( ) -> Callable[[dataexchange.UpdateDataExchangeRequest], dataexchange.DataExchange]: r"""Return a callable for the update data exchange method over gRPC. - Updates the parameters of a single DataExchange. + Updates an existing data exchange. Returns: Callable[[~.UpdateDataExchangeRequest], @@ -380,7 +382,7 @@ def delete_data_exchange( ) -> Callable[[dataexchange.DeleteDataExchangeRequest], empty_pb2.Empty]: r"""Return a callable for the delete data exchange method over gRPC. - Deletes a single DataExchange. + Deletes an existing data exchange. Returns: Callable[[~.DeleteDataExchangeRequest], @@ -408,7 +410,7 @@ def list_listings( ]: r"""Return a callable for the list listings method over gRPC. - Lists Listings in a given project and location. + Lists all listings in a given project and location. Returns: Callable[[~.ListListingsRequest], @@ -434,7 +436,7 @@ def get_listing( ) -> Callable[[dataexchange.GetListingRequest], dataexchange.Listing]: r"""Return a callable for the get listing method over gRPC. - Gets details of a single Listing. + Gets the details of a listing. Returns: Callable[[~.GetListingRequest], @@ -460,8 +462,7 @@ def create_listing( ) -> Callable[[dataexchange.CreateListingRequest], dataexchange.Listing]: r"""Return a callable for the create listing method over gRPC. - Creates a new Listing in a given project and - location. + Creates a new listing. Returns: Callable[[~.CreateListingRequest], @@ -487,7 +488,7 @@ def update_listing( ) -> Callable[[dataexchange.UpdateListingRequest], dataexchange.Listing]: r"""Return a callable for the update listing method over gRPC. - Updates the parameters of a single Listing. + Updates an existing listing. Returns: Callable[[~.UpdateListingRequest], @@ -513,9 +514,7 @@ def delete_listing( ) -> Callable[[dataexchange.DeleteListingRequest], empty_pb2.Empty]: r"""Return a callable for the delete listing method over gRPC. - Deletes a single Listing, as long as there are no - subscriptions associated with the source of this - Listing. + Deletes a listing. Returns: Callable[[~.DeleteListingRequest], @@ -543,11 +542,12 @@ def subscribe_listing( ]: r"""Return a callable for the subscribe listing method over gRPC. - Subscribes to a single Listing. - Data Exchange currently supports one type of Listing: a - BigQuery dataset. Upon subscription to a Listing for a - BigQuery dataset, Data Exchange creates a linked dataset - in the subscriber's project. + Subscribes to a listing. + Currently, with Analytics Hub, you can create listings + that reference only BigQuery datasets. + Upon subscription to a listing for a BigQuery dataset, + Analytics Hub creates a linked dataset in the + subscriber's project. Returns: Callable[[~.SubscribeListingRequest], @@ -573,7 +573,7 @@ def get_iam_policy( ) -> Callable[[iam_policy_pb2.GetIamPolicyRequest], policy_pb2.Policy]: r"""Return a callable for the get iam policy method over gRPC. - Gets the IAM policy for a dataExchange or a listing. + Gets the IAM policy. Returns: Callable[[~.GetIamPolicyRequest], @@ -599,7 +599,7 @@ def set_iam_policy( ) -> Callable[[iam_policy_pb2.SetIamPolicyRequest], policy_pb2.Policy]: r"""Return a callable for the set iam policy method over gRPC. - Sets the IAM policy for a dataExchange or a listing. + Sets the IAM policy. Returns: Callable[[~.SetIamPolicyRequest], @@ -628,8 +628,7 @@ def test_iam_permissions( ]: r"""Return a callable for the test iam permissions method over gRPC. - Returns the permissions that a caller has on a - specified dataExchange or listing. + Returns the permissions that a caller has. Returns: Callable[[~.TestIamPermissionsRequest], @@ -652,6 +651,42 @@ def test_iam_permissions( def close(self): self.grpc_channel.close() + @property + def list_locations( + self, + ) -> Callable[ + [locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse + ]: + r"""Return a callable for the list locations method over gRPC.""" + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_locations" not in self._stubs: + self._stubs["list_locations"] = self.grpc_channel.unary_unary( + "/google.cloud.location.Locations/ListLocations", + request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, + response_deserializer=locations_pb2.ListLocationsResponse.FromString, + ) + return self._stubs["list_locations"] + + @property + def get_location( + self, + ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: + r"""Return a callable for the list locations method over gRPC.""" + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_location" not in self._stubs: + self._stubs["get_location"] = self.grpc_channel.unary_unary( + "/google.cloud.location.Locations/GetLocation", + request_serializer=locations_pb2.GetLocationRequest.SerializeToString, + response_deserializer=locations_pb2.Location.FromString, + ) + return self._stubs["get_location"] + @property def kind(self) -> str: return "grpc" diff --git a/google/cloud/bigquery_data_exchange_v1beta1/services/analytics_hub_service/transports/grpc_asyncio.py b/google/cloud/bigquery_data_exchange_v1beta1/services/analytics_hub_service/transports/grpc_asyncio.py index 09084df..8262f11 100644 --- a/google/cloud/bigquery_data_exchange_v1beta1/services/analytics_hub_service/transports/grpc_asyncio.py +++ b/google/cloud/bigquery_data_exchange_v1beta1/services/analytics_hub_service/transports/grpc_asyncio.py @@ -25,6 +25,7 @@ from grpc.experimental import aio # type: ignore from google.cloud.bigquery_data_exchange_v1beta1.types import dataexchange +from google.cloud.location import locations_pb2 # type: ignore from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore @@ -35,12 +36,13 @@ class AnalyticsHubServiceGrpcAsyncIOTransport(AnalyticsHubServiceTransport): """gRPC AsyncIO backend transport for AnalyticsHubService. - The AnalyticsHubService API facilitates data sharing within - and across organizations. It allows data providers to publish - Listings --- a discoverable and searchable SKU representing a - dataset. Data consumers can subscribe to Listings. Upon - subscription, AnalyticsHub provisions a "Linked Datasets" - surfacing the data in the consumer's project. + The ``AnalyticsHubService`` API facilitates data sharing within and + across organizations. It allows data providers to publish listings + that reference shared datasets. With Analytics Hub, users can + discover and search for listings that they have access to. + Subscribers can view and subscribe to listings. When you subscribe + to a listing, Analytics Hub creates a linked dataset in your + project. This class defines the same methods as the primary client, so the primary client can load the underlying transport implementation @@ -249,7 +251,8 @@ def list_data_exchanges( ]: r"""Return a callable for the list data exchanges method over gRPC. - Lists DataExchanges in a given project and location. + Lists all data exchanges in a given project and + location. Returns: Callable[[~.ListDataExchangesRequest], @@ -278,7 +281,7 @@ def list_org_data_exchanges( ]: r"""Return a callable for the list org data exchanges method over gRPC. - Lists DataExchanges from projects in a given + Lists all data exchanges from projects in a given organization and location. Returns: @@ -307,7 +310,7 @@ def get_data_exchange( ]: r"""Return a callable for the get data exchange method over gRPC. - Gets details of a single DataExchange. + Gets the details of a data exchange. Returns: Callable[[~.GetDataExchangeRequest], @@ -335,8 +338,7 @@ def create_data_exchange( ]: r"""Return a callable for the create data exchange method over gRPC. - Creates a new DataExchange in a given project and - location. + Creates a new data exchange. Returns: Callable[[~.CreateDataExchangeRequest], @@ -364,7 +366,7 @@ def update_data_exchange( ]: r"""Return a callable for the update data exchange method over gRPC. - Updates the parameters of a single DataExchange. + Updates an existing data exchange. Returns: Callable[[~.UpdateDataExchangeRequest], @@ -390,7 +392,7 @@ def delete_data_exchange( ) -> Callable[[dataexchange.DeleteDataExchangeRequest], Awaitable[empty_pb2.Empty]]: r"""Return a callable for the delete data exchange method over gRPC. - Deletes a single DataExchange. + Deletes an existing data exchange. Returns: Callable[[~.DeleteDataExchangeRequest], @@ -418,7 +420,7 @@ def list_listings( ]: r"""Return a callable for the list listings method over gRPC. - Lists Listings in a given project and location. + Lists all listings in a given project and location. Returns: Callable[[~.ListListingsRequest], @@ -444,7 +446,7 @@ def get_listing( ) -> Callable[[dataexchange.GetListingRequest], Awaitable[dataexchange.Listing]]: r"""Return a callable for the get listing method over gRPC. - Gets details of a single Listing. + Gets the details of a listing. Returns: Callable[[~.GetListingRequest], @@ -470,8 +472,7 @@ def create_listing( ) -> Callable[[dataexchange.CreateListingRequest], Awaitable[dataexchange.Listing]]: r"""Return a callable for the create listing method over gRPC. - Creates a new Listing in a given project and - location. + Creates a new listing. Returns: Callable[[~.CreateListingRequest], @@ -497,7 +498,7 @@ def update_listing( ) -> Callable[[dataexchange.UpdateListingRequest], Awaitable[dataexchange.Listing]]: r"""Return a callable for the update listing method over gRPC. - Updates the parameters of a single Listing. + Updates an existing listing. Returns: Callable[[~.UpdateListingRequest], @@ -523,9 +524,7 @@ def delete_listing( ) -> Callable[[dataexchange.DeleteListingRequest], Awaitable[empty_pb2.Empty]]: r"""Return a callable for the delete listing method over gRPC. - Deletes a single Listing, as long as there are no - subscriptions associated with the source of this - Listing. + Deletes a listing. Returns: Callable[[~.DeleteListingRequest], @@ -554,11 +553,12 @@ def subscribe_listing( ]: r"""Return a callable for the subscribe listing method over gRPC. - Subscribes to a single Listing. - Data Exchange currently supports one type of Listing: a - BigQuery dataset. Upon subscription to a Listing for a - BigQuery dataset, Data Exchange creates a linked dataset - in the subscriber's project. + Subscribes to a listing. + Currently, with Analytics Hub, you can create listings + that reference only BigQuery datasets. + Upon subscription to a listing for a BigQuery dataset, + Analytics Hub creates a linked dataset in the + subscriber's project. Returns: Callable[[~.SubscribeListingRequest], @@ -584,7 +584,7 @@ def get_iam_policy( ) -> Callable[[iam_policy_pb2.GetIamPolicyRequest], Awaitable[policy_pb2.Policy]]: r"""Return a callable for the get iam policy method over gRPC. - Gets the IAM policy for a dataExchange or a listing. + Gets the IAM policy. Returns: Callable[[~.GetIamPolicyRequest], @@ -610,7 +610,7 @@ def set_iam_policy( ) -> Callable[[iam_policy_pb2.SetIamPolicyRequest], Awaitable[policy_pb2.Policy]]: r"""Return a callable for the set iam policy method over gRPC. - Sets the IAM policy for a dataExchange or a listing. + Sets the IAM policy. Returns: Callable[[~.SetIamPolicyRequest], @@ -639,8 +639,7 @@ def test_iam_permissions( ]: r"""Return a callable for the test iam permissions method over gRPC. - Returns the permissions that a caller has on a - specified dataExchange or listing. + Returns the permissions that a caller has. Returns: Callable[[~.TestIamPermissionsRequest], @@ -663,5 +662,41 @@ def test_iam_permissions( def close(self): return self.grpc_channel.close() + @property + def list_locations( + self, + ) -> Callable[ + [locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse + ]: + r"""Return a callable for the list locations method over gRPC.""" + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_locations" not in self._stubs: + self._stubs["list_locations"] = self.grpc_channel.unary_unary( + "/google.cloud.location.Locations/ListLocations", + request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, + response_deserializer=locations_pb2.ListLocationsResponse.FromString, + ) + return self._stubs["list_locations"] + + @property + def get_location( + self, + ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: + r"""Return a callable for the list locations method over gRPC.""" + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_location" not in self._stubs: + self._stubs["get_location"] = self.grpc_channel.unary_unary( + "/google.cloud.location.Locations/GetLocation", + request_serializer=locations_pb2.GetLocationRequest.SerializeToString, + response_deserializer=locations_pb2.Location.FromString, + ) + return self._stubs["get_location"] + __all__ = ("AnalyticsHubServiceGrpcAsyncIOTransport",) diff --git a/google/cloud/bigquery_data_exchange_v1beta1/types/dataexchange.py b/google/cloud/bigquery_data_exchange_v1beta1/types/dataexchange.py index 3047c65..5e9fe28 100644 --- a/google/cloud/bigquery_data_exchange_v1beta1/types/dataexchange.py +++ b/google/cloud/bigquery_data_exchange_v1beta1/types/dataexchange.py @@ -15,7 +15,6 @@ # import proto # type: ignore -from google.cloud.bigquery_data_exchange_v1beta1 import common # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import wrappers_pb2 # type: ignore @@ -50,9 +49,9 @@ class DataExchange(proto.Message): - r"""A data exchange is a container that enables data sharing. - It contains a set of listings of the data sources along with - descriptive information of the data exchange. + r"""A data exchange is a container that lets you share data. + Along with the descriptive information about the data exchange, + it contains listings that reference shared datasets. Attributes: name (str): @@ -61,22 +60,21 @@ class DataExchange(proto.Message): display_name (str): Required. Human-readable display name of the data exchange. The display name must contain only Unicode letters, numbers - (0-9), underscores (_), dashes (-), spaces ( ), and can't - start or end with spaces. Default value is an empty string. - Max length: 63 bytes. + (0-9), underscores (_), dashes (-), spaces ( ), ampersands + (&) and must not start or end with spaces. Default value is + an empty string. Max length: 63 bytes. description (str): - Optional. Short description of the data - exchange that can consist of sentences or - paragraphs. The description must not contain - Unicode non-characters as well as C0 and C1 - control codes except tabs (HT), new lines (LF), - carriage returns (CR), and page breaks (FF). - Default value is an empty string. + Optional. Description of the data exchange. + The description must not contain Unicode + non-characters as well as C0 and C1 control + codes except tabs (HT), new lines (LF), carriage + returns (CR), and page breaks (FF). Default + value is an empty string. Max length: 2000 bytes. primary_contact (str): - Optional. Email, URL or other reference of - the primary point of contact of the data - exchange Max Length: 1000 bytes. + Optional. Email or URL of the primary point + of contact of the data exchange. Max Length: + 1000 bytes. documentation (str): Optional. Documentation describing the data exchange. @@ -88,8 +86,8 @@ class DataExchange(proto.Message): the data exchange. Max Size: 3.0MiB Expected image dimensions are 512x512 pixels, however the API only performs validation on size of the - encoded data. Note: For byte fields, the - contents of the field are base64-encoded (which + encoded data. Note: For byte fields, the content + of the fields are base64-encoded (which increases the size of the data by 33-36%) when using JSON on the wire. """ @@ -125,13 +123,13 @@ class DataExchange(proto.Message): class DataProvider(proto.Message): - r"""Contains details of the Data Provider. + r"""Contains details of the data provider. Attributes: name (str): - Optional. Name of the Data Provider. + Optional. Name of the data provider. primary_contact (str): - Optional. Email or URL of the Data Provider. + Optional. Email or URL of the data provider. Max Length: 1000 bytes. """ @@ -146,14 +144,14 @@ class DataProvider(proto.Message): class Publisher(proto.Message): - r"""Contains details of the Publisher. + r"""Contains details of the listing publisher. Attributes: name (str): - Optional. Name of the listing Publisher. + Optional. Name of the listing publisher. primary_contact (str): Optional. Email or URL of the listing - Publisher. Max Length: 1000 bytes. + publisher. Max Length: 1000 bytes. """ name = proto.Field( @@ -167,7 +165,8 @@ class Publisher(proto.Message): class DestinationDatasetReference(proto.Message): - r"""Defines the Destination BigQuery Dataset Reference. + r"""Contains the reference that identifies a destination bigquery + dataset. Attributes: dataset_id (str): @@ -191,7 +190,7 @@ class DestinationDatasetReference(proto.Message): class DestinationDataset(proto.Message): - r"""Defines the Destination BigQuery Dataset. + r"""Defines the destination bigquery dataset. Attributes: dataset_reference (google.cloud.bigquery_data_exchange_v1beta1.types.DestinationDatasetReference): @@ -252,23 +251,27 @@ class Listing(proto.Message): .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields Attributes: + bigquery_dataset (google.cloud.bigquery_data_exchange_v1beta1.types.Listing.BigQueryDatasetSource): + Required. Shared dataset i.e. BigQuery + dataset source. + + This field is a member of `oneof`_ ``source``. name (str): Output only. The resource name of the listing. e.g. ``projects/myproject/locations/US/dataExchanges/123/listings/456`` display_name (str): Required. Human-readable display name of the listing. The display name must contain only Unicode letters, numbers - (0-9), underscores (_), dashes (-), spaces ( ), and can't - start or end with spaces. Default value is an empty string. - Max length: 63 bytes. + (0-9), underscores (_), dashes (-), spaces ( ), ampersands + (&) and can't start or end with spaces. Default value is an + empty string. Max length: 63 bytes. description (str): - Optional. Short description of the listing - that can consist of sentences or paragraphs. The - description must not contain Unicode - non-characters as well as C0 and C1 control - codes except tabs (HT), new lines (LF), carriage - returns (CR), and page breaks (FF). - Default value is an empty string. + Optional. Short description of the listing. + The description must not contain Unicode + non-characters and C0 and C1 control codes + except tabs (HT), new lines (LF), carriage + returns (CR), and page breaks (FF). Default + value is an empty string. Max length: 2000 bytes. primary_contact (str): Optional. Email or URL of the primary point @@ -277,13 +280,8 @@ class Listing(proto.Message): documentation (str): Optional. Documentation describing the listing. - bigquery_dataset (google.cloud.bigquery_data_exchange_v1beta1.types.Listing.BigQueryDatasetSource): - Required. Shared dataset i.e. BigQuery - dataset source. - - This field is a member of `oneof`_ ``source``. state (google.cloud.bigquery_data_exchange_v1beta1.types.Listing.State): - Output only. Current state of the Listing. + Output only. Current state of the listing. icon (bytes): Optional. Base64 encoded image representing the listing. Max Size: 3.0MiB Expected image @@ -294,15 +292,14 @@ class Listing(proto.Message): size of the data by 33-36%) when using JSON on the wire. data_provider (google.cloud.bigquery_data_exchange_v1beta1.types.DataProvider): - Optional. The details of the Data Provider - who owns the source data. - categories (Sequence[google.cloud.bigquery_data_exchange_v1beta1.common.Category]): - Optional. Categories of the Listing. Up to + Optional. Details of the data provider who + owns the source data. + categories (Sequence[google.cloud.bigquery_data_exchange_v1beta1.types.Listing.Category]): + Optional. Categories of the listing. Up to two categories are allowed. publisher (google.cloud.bigquery_data_exchange_v1beta1.types.Publisher): - Optional. The details of the Publisher who - owns the listing and has rights to share the - source data. + Optional. Details of the publisher who owns + the listing and who can share the source data. request_access (str): Optional. Email or URL of the request access of the listing. Subscribers can use this @@ -311,18 +308,40 @@ class Listing(proto.Message): """ class State(proto.Enum): - r"""State of the Listing""" + r"""State of the listing.""" STATE_UNSPECIFIED = 0 ACTIVE = 1 + class Category(proto.Enum): + r"""Listing categories.""" + CATEGORY_UNSPECIFIED = 0 + CATEGORY_OTHERS = 1 + CATEGORY_ADVERTISING_AND_MARKETING = 2 + CATEGORY_COMMERCE = 3 + CATEGORY_CLIMATE_AND_ENVIRONMENT = 4 + CATEGORY_DEMOGRAPHICS = 5 + CATEGORY_ECONOMICS = 6 + CATEGORY_EDUCATION = 7 + CATEGORY_ENERGY = 8 + CATEGORY_FINANCIAL = 9 + CATEGORY_GAMING = 10 + CATEGORY_GEOSPATIAL = 11 + CATEGORY_HEALTHCARE_AND_LIFE_SCIENCE = 12 + CATEGORY_MEDIA = 13 + CATEGORY_PUBLIC_SECTOR = 14 + CATEGORY_RETAIL = 15 + CATEGORY_SPORTS = 16 + CATEGORY_SCIENCE_AND_RESEARCH = 17 + CATEGORY_TRANSPORTATION_AND_LOGISTICS = 18 + CATEGORY_TRAVEL_AND_TOURISM = 19 + class BigQueryDatasetSource(proto.Message): - r"""A reference to a Shared dataset. It's an existing BigQuery - dataset with a collection of objects, such as tables and views, - that you want to share with subscribers. - Upon subscription to a Listing, Data Exchange creates a Linked - dataset in the subscriber's project. A Linked dataset is an - opaque, read-only BigQuery dataset that serves as a "symbolic - link" to a shared dataset. + r"""A reference to a shared dataset. It is an existing BigQuery dataset + with a collection of objects such as tables and views that you want + to share with subscribers. When subscriber's subscribe to a listing, + Analytics Hub creates a linked dataset in the subscriber's project. + A Linked dataset is an opaque, read-only BigQuery dataset that + serves as a *symbolic link* to a shared dataset. Attributes: dataset (str): @@ -335,6 +354,12 @@ class BigQueryDatasetSource(proto.Message): number=1, ) + bigquery_dataset = proto.Field( + proto.MESSAGE, + number=6, + oneof="source", + message=BigQueryDatasetSource, + ) name = proto.Field( proto.STRING, number=1, @@ -355,12 +380,6 @@ class BigQueryDatasetSource(proto.Message): proto.STRING, number=5, ) - bigquery_dataset = proto.Field( - proto.MESSAGE, - number=6, - oneof="source", - message=BigQueryDatasetSource, - ) state = proto.Field( proto.ENUM, number=7, @@ -378,7 +397,7 @@ class BigQueryDatasetSource(proto.Message): categories = proto.RepeatedField( proto.ENUM, number=10, - enum=common.Category, + enum=Category, ) publisher = proto.Field( proto.MESSAGE, @@ -392,11 +411,11 @@ class BigQueryDatasetSource(proto.Message): class ListDataExchangesRequest(proto.Message): - r"""Message for requesting list of DataExchanges. + r"""Message for requesting the list of data exchanges. Attributes: parent (str): - Required. The parent resource path of the DataExchanges. + Required. The parent resource path of the data exchanges. e.g. ``projects/myproject/locations/US``. page_size (int): The maximum number of results to return in a @@ -422,11 +441,11 @@ class ListDataExchangesRequest(proto.Message): class ListDataExchangesResponse(proto.Message): - r"""Message for response to listing DataExchanges. + r"""Message for response to the list of data exchanges. Attributes: data_exchanges (Sequence[google.cloud.bigquery_data_exchange_v1beta1.types.DataExchange]): - The list of DataExchange. + The list of data exchanges. next_page_token (str): A token to request the next page of results. """ @@ -447,8 +466,8 @@ def raw_page(self): class ListOrgDataExchangesRequest(proto.Message): - r"""Message for requesting list of DataExchanges from projects in - an organization and location. + r"""Message for requesting the list of data exchanges from + projects in an organization and location. Attributes: organization (str): @@ -479,12 +498,12 @@ class ListOrgDataExchangesRequest(proto.Message): class ListOrgDataExchangesResponse(proto.Message): - r"""Message for response to listing DataExchanges in an + r"""Message for response to listing data exchanges in an organization and location. Attributes: data_exchanges (Sequence[google.cloud.bigquery_data_exchange_v1beta1.types.DataExchange]): - The list of DataExchange. + The list of data exchanges. next_page_token (str): A token to request the next page of results. """ @@ -505,11 +524,11 @@ def raw_page(self): class GetDataExchangeRequest(proto.Message): - r"""Message for getting a DataExchange. + r"""Message for getting a data exchange. Attributes: name (str): - Required. The resource name of the DataExchange. e.g. + Required. The resource name of the data exchange. e.g. ``projects/myproject/locations/US/dataExchanges/123``. """ @@ -520,19 +539,19 @@ class GetDataExchangeRequest(proto.Message): class CreateDataExchangeRequest(proto.Message): - r"""Message for creating a DataExchange. + r"""Message for creating a data exchange. Attributes: parent (str): - Required. The parent resource path of the DataExchange. e.g. - ``projects/myproject/locations/US``. + Required. The parent resource path of the data exchange. + e.g. ``projects/myproject/locations/US``. data_exchange_id (str): - Required. The ID of the DataExchange to create. Must contain - only Unicode letters, numbers (0-9), underscores (_). Should - not use characters that require URL-escaping, or characters + Required. The ID of the data exchange. Must contain only + Unicode letters, numbers (0-9), underscores (_). Should not + use characters that require URL-escaping, or characters outside of ASCII, spaces. Max length: 100 bytes. data_exchange (google.cloud.bigquery_data_exchange_v1beta1.types.DataExchange): - Required. The DataExchange to create. + Required. The data exchange to create. """ parent = proto.Field( @@ -551,16 +570,16 @@ class CreateDataExchangeRequest(proto.Message): class UpdateDataExchangeRequest(proto.Message): - r"""Message for updating a DataExchange. + r"""Message for updating a data exchange. Attributes: update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. Field mask is used to specify the fields to be - overwritten in the DataExchange resource by the update. The - fields specified in the update_mask are relative to the - resource, not the full request. + Required. Field mask specifies the fields to update in the + data exchange resource. The fields specified in the + ``updateMask`` are relative to the resource and are not a + full request. data_exchange (google.cloud.bigquery_data_exchange_v1beta1.types.DataExchange): - Required. The DataExchange to update. + Required. The data exchange to update. """ update_mask = proto.Field( @@ -576,11 +595,12 @@ class UpdateDataExchangeRequest(proto.Message): class DeleteDataExchangeRequest(proto.Message): - r"""Message for deleting a DataExchange. + r"""Message for deleting a data exchange. Attributes: name (str): - Required. Resource name of the DataExchange to delete. e.g. + Required. The full name of the data exchange resource that + you want to delete. For example, ``projects/myproject/locations/US/dataExchanges/123``. """ @@ -591,7 +611,7 @@ class DeleteDataExchangeRequest(proto.Message): class ListListingsRequest(proto.Message): - r"""Message for requesting list of Listings. + r"""Message for requesting the list of listings. Attributes: parent (str): @@ -621,7 +641,7 @@ class ListListingsRequest(proto.Message): class ListListingsResponse(proto.Message): - r"""Message for response to listing Listings. + r"""Message for response to the list of Listings. Attributes: listings (Sequence[google.cloud.bigquery_data_exchange_v1beta1.types.Listing]): @@ -646,7 +666,7 @@ def raw_page(self): class GetListingRequest(proto.Message): - r"""Message for getting a Listing. + r"""Message for getting a listing. Attributes: name (str): @@ -661,14 +681,14 @@ class GetListingRequest(proto.Message): class CreateListingRequest(proto.Message): - r"""Message for creating a Listing. + r"""Message for creating a listing. Attributes: parent (str): Required. The parent resource path of the listing. e.g. ``projects/myproject/locations/US/dataExchanges/123``. listing_id (str): - Required. The ID of the Listing to create. Must contain only + Required. The ID of the listing to create. Must contain only Unicode letters, numbers (0-9), underscores (_). Should not use characters that require URL-escaping, or characters outside of ASCII, spaces. Max length: 100 bytes. @@ -696,10 +716,9 @@ class UpdateListingRequest(proto.Message): Attributes: update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. Field mask is used to specify the fields to be - overwritten in the Listing resource by the update. The - fields specified in the update_mask are relative to the - resource, not the full request. + Required. Field mask specifies the fields to update in the + listing resource. The fields specified in the ``updateMask`` + are relative to the resource and are not a full request. listing (google.cloud.bigquery_data_exchange_v1beta1.types.Listing): Required. The listing to update. """ @@ -717,7 +736,7 @@ class UpdateListingRequest(proto.Message): class DeleteListingRequest(proto.Message): - r"""Message for deleting a Listing. + r"""Message for deleting a listing. Attributes: name (str): @@ -732,38 +751,36 @@ class DeleteListingRequest(proto.Message): class SubscribeListingRequest(proto.Message): - r"""Message for subscribing a Listing. + r"""Message for subscribing to a listing. .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields Attributes: - name (str): - Required. Resource name of the listing to subscribe to. e.g. - ``projects/myproject/locations/US/dataExchanges/123/listings/456``. destination_dataset (google.cloud.bigquery_data_exchange_v1beta1.types.DestinationDataset): BigQuery destination dataset to create for the subscriber. This field is a member of `oneof`_ ``destination``. + name (str): + Required. Resource name of the listing that you want to + subscribe to. e.g. + ``projects/myproject/locations/US/dataExchanges/123/listings/456``. """ - name = proto.Field( - proto.STRING, - number=1, - ) destination_dataset = proto.Field( proto.MESSAGE, number=3, oneof="destination", message="DestinationDataset", ) + name = proto.Field( + proto.STRING, + number=1, + ) class SubscribeListingResponse(proto.Message): - r"""Message for response to subscribing a Listing. - Empty for now. - - """ + r"""Message for response when you subscribe to a listing.""" __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/tests/unit/gapic/bigquery_data_exchange_v1beta1/test_analytics_hub_service.py b/tests/unit/gapic/bigquery_data_exchange_v1beta1/test_analytics_hub_service.py index 3dca4f2..c776109 100644 --- a/tests/unit/gapic/bigquery_data_exchange_v1beta1/test_analytics_hub_service.py +++ b/tests/unit/gapic/bigquery_data_exchange_v1beta1/test_analytics_hub_service.py @@ -37,7 +37,6 @@ from google.api_core import path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError -from google.cloud.bigquery_data_exchange_v1beta1 import common # type: ignore from google.cloud.bigquery_data_exchange_v1beta1.services.analytics_hub_service import ( AnalyticsHubServiceAsyncClient, ) @@ -51,6 +50,7 @@ transports, ) from google.cloud.bigquery_data_exchange_v1beta1.types import dataexchange +from google.cloud.location import locations_pb2 from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import options_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore @@ -3118,7 +3118,7 @@ def test_get_listing(request_type, transport: str = "grpc"): documentation="documentation_value", state=dataexchange.Listing.State.ACTIVE, icon=b"icon_blob", - categories=[common.Category.CATEGORY_OTHERS], + categories=[dataexchange.Listing.Category.CATEGORY_OTHERS], request_access="request_access_value", bigquery_dataset=dataexchange.Listing.BigQueryDatasetSource( dataset="dataset_value" @@ -3140,7 +3140,7 @@ def test_get_listing(request_type, transport: str = "grpc"): assert response.documentation == "documentation_value" assert response.state == dataexchange.Listing.State.ACTIVE assert response.icon == b"icon_blob" - assert response.categories == [common.Category.CATEGORY_OTHERS] + assert response.categories == [dataexchange.Listing.Category.CATEGORY_OTHERS] assert response.request_access == "request_access_value" @@ -3185,7 +3185,7 @@ async def test_get_listing_async( documentation="documentation_value", state=dataexchange.Listing.State.ACTIVE, icon=b"icon_blob", - categories=[common.Category.CATEGORY_OTHERS], + categories=[dataexchange.Listing.Category.CATEGORY_OTHERS], request_access="request_access_value", ) ) @@ -3205,7 +3205,7 @@ async def test_get_listing_async( assert response.documentation == "documentation_value" assert response.state == dataexchange.Listing.State.ACTIVE assert response.icon == b"icon_blob" - assert response.categories == [common.Category.CATEGORY_OTHERS] + assert response.categories == [dataexchange.Listing.Category.CATEGORY_OTHERS] assert response.request_access == "request_access_value" @@ -3385,7 +3385,7 @@ def test_create_listing(request_type, transport: str = "grpc"): documentation="documentation_value", state=dataexchange.Listing.State.ACTIVE, icon=b"icon_blob", - categories=[common.Category.CATEGORY_OTHERS], + categories=[dataexchange.Listing.Category.CATEGORY_OTHERS], request_access="request_access_value", bigquery_dataset=dataexchange.Listing.BigQueryDatasetSource( dataset="dataset_value" @@ -3407,7 +3407,7 @@ def test_create_listing(request_type, transport: str = "grpc"): assert response.documentation == "documentation_value" assert response.state == dataexchange.Listing.State.ACTIVE assert response.icon == b"icon_blob" - assert response.categories == [common.Category.CATEGORY_OTHERS] + assert response.categories == [dataexchange.Listing.Category.CATEGORY_OTHERS] assert response.request_access == "request_access_value" @@ -3452,7 +3452,7 @@ async def test_create_listing_async( documentation="documentation_value", state=dataexchange.Listing.State.ACTIVE, icon=b"icon_blob", - categories=[common.Category.CATEGORY_OTHERS], + categories=[dataexchange.Listing.Category.CATEGORY_OTHERS], request_access="request_access_value", ) ) @@ -3472,7 +3472,7 @@ async def test_create_listing_async( assert response.documentation == "documentation_value" assert response.state == dataexchange.Listing.State.ACTIVE assert response.icon == b"icon_blob" - assert response.categories == [common.Category.CATEGORY_OTHERS] + assert response.categories == [dataexchange.Listing.Category.CATEGORY_OTHERS] assert response.request_access == "request_access_value" @@ -3555,7 +3555,11 @@ def test_create_listing_flattened(): # using the keyword arguments to the method. client.create_listing( parent="parent_value", - listing=dataexchange.Listing(name="name_value"), + listing=dataexchange.Listing( + bigquery_dataset=dataexchange.Listing.BigQueryDatasetSource( + dataset="dataset_value" + ) + ), ) # Establish that the underlying call was made with the expected @@ -3566,7 +3570,11 @@ def test_create_listing_flattened(): mock_val = "parent_value" assert arg == mock_val arg = args[0].listing - mock_val = dataexchange.Listing(name="name_value") + mock_val = dataexchange.Listing( + bigquery_dataset=dataexchange.Listing.BigQueryDatasetSource( + dataset="dataset_value" + ) + ) assert arg == mock_val @@ -3581,7 +3589,11 @@ def test_create_listing_flattened_error(): client.create_listing( dataexchange.CreateListingRequest(), parent="parent_value", - listing=dataexchange.Listing(name="name_value"), + listing=dataexchange.Listing( + bigquery_dataset=dataexchange.Listing.BigQueryDatasetSource( + dataset="dataset_value" + ) + ), ) @@ -3603,7 +3615,11 @@ async def test_create_listing_flattened_async(): # using the keyword arguments to the method. response = await client.create_listing( parent="parent_value", - listing=dataexchange.Listing(name="name_value"), + listing=dataexchange.Listing( + bigquery_dataset=dataexchange.Listing.BigQueryDatasetSource( + dataset="dataset_value" + ) + ), ) # Establish that the underlying call was made with the expected @@ -3614,7 +3630,11 @@ async def test_create_listing_flattened_async(): mock_val = "parent_value" assert arg == mock_val arg = args[0].listing - mock_val = dataexchange.Listing(name="name_value") + mock_val = dataexchange.Listing( + bigquery_dataset=dataexchange.Listing.BigQueryDatasetSource( + dataset="dataset_value" + ) + ) assert arg == mock_val @@ -3630,7 +3650,11 @@ async def test_create_listing_flattened_error_async(): await client.create_listing( dataexchange.CreateListingRequest(), parent="parent_value", - listing=dataexchange.Listing(name="name_value"), + listing=dataexchange.Listing( + bigquery_dataset=dataexchange.Listing.BigQueryDatasetSource( + dataset="dataset_value" + ) + ), ) @@ -3662,7 +3686,7 @@ def test_update_listing(request_type, transport: str = "grpc"): documentation="documentation_value", state=dataexchange.Listing.State.ACTIVE, icon=b"icon_blob", - categories=[common.Category.CATEGORY_OTHERS], + categories=[dataexchange.Listing.Category.CATEGORY_OTHERS], request_access="request_access_value", bigquery_dataset=dataexchange.Listing.BigQueryDatasetSource( dataset="dataset_value" @@ -3684,7 +3708,7 @@ def test_update_listing(request_type, transport: str = "grpc"): assert response.documentation == "documentation_value" assert response.state == dataexchange.Listing.State.ACTIVE assert response.icon == b"icon_blob" - assert response.categories == [common.Category.CATEGORY_OTHERS] + assert response.categories == [dataexchange.Listing.Category.CATEGORY_OTHERS] assert response.request_access == "request_access_value" @@ -3729,7 +3753,7 @@ async def test_update_listing_async( documentation="documentation_value", state=dataexchange.Listing.State.ACTIVE, icon=b"icon_blob", - categories=[common.Category.CATEGORY_OTHERS], + categories=[dataexchange.Listing.Category.CATEGORY_OTHERS], request_access="request_access_value", ) ) @@ -3749,7 +3773,7 @@ async def test_update_listing_async( assert response.documentation == "documentation_value" assert response.state == dataexchange.Listing.State.ACTIVE assert response.icon == b"icon_blob" - assert response.categories == [common.Category.CATEGORY_OTHERS] + assert response.categories == [dataexchange.Listing.Category.CATEGORY_OTHERS] assert response.request_access == "request_access_value" @@ -3831,7 +3855,11 @@ def test_update_listing_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_listing( - listing=dataexchange.Listing(name="name_value"), + listing=dataexchange.Listing( + bigquery_dataset=dataexchange.Listing.BigQueryDatasetSource( + dataset="dataset_value" + ) + ), update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -3840,7 +3868,11 @@ def test_update_listing_flattened(): assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] arg = args[0].listing - mock_val = dataexchange.Listing(name="name_value") + mock_val = dataexchange.Listing( + bigquery_dataset=dataexchange.Listing.BigQueryDatasetSource( + dataset="dataset_value" + ) + ) assert arg == mock_val arg = args[0].update_mask mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) @@ -3857,7 +3889,11 @@ def test_update_listing_flattened_error(): with pytest.raises(ValueError): client.update_listing( dataexchange.UpdateListingRequest(), - listing=dataexchange.Listing(name="name_value"), + listing=dataexchange.Listing( + bigquery_dataset=dataexchange.Listing.BigQueryDatasetSource( + dataset="dataset_value" + ) + ), update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -3879,7 +3915,11 @@ async def test_update_listing_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.update_listing( - listing=dataexchange.Listing(name="name_value"), + listing=dataexchange.Listing( + bigquery_dataset=dataexchange.Listing.BigQueryDatasetSource( + dataset="dataset_value" + ) + ), update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -3888,7 +3928,11 @@ async def test_update_listing_flattened_async(): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] arg = args[0].listing - mock_val = dataexchange.Listing(name="name_value") + mock_val = dataexchange.Listing( + bigquery_dataset=dataexchange.Listing.BigQueryDatasetSource( + dataset="dataset_value" + ) + ) assert arg == mock_val arg = args[0].update_mask mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) @@ -3906,7 +3950,11 @@ async def test_update_listing_flattened_error_async(): with pytest.raises(ValueError): await client.update_listing( dataexchange.UpdateListingRequest(), - listing=dataexchange.Listing(name="name_value"), + listing=dataexchange.Listing( + bigquery_dataset=dataexchange.Listing.BigQueryDatasetSource( + dataset="dataset_value" + ) + ), update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -5042,6 +5090,8 @@ def test_analytics_hub_service_base_transport(): "get_iam_policy", "set_iam_policy", "test_iam_permissions", + "get_location", + "list_locations", ) for method in methods: with pytest.raises(NotImplementedError): @@ -5625,6 +5675,296 @@ async def test_transport_close_async(): close.assert_called_once() +def test_list_locations(transport: str = "grpc"): + client = AnalyticsHubServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = locations_pb2.ListLocationsRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_locations), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = locations_pb2.ListLocationsResponse() + response = client.list_locations(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, locations_pb2.ListLocationsResponse) + + +@pytest.mark.asyncio +async def test_list_locations_async(transport: str = "grpc"): + client = AnalyticsHubServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = locations_pb2.ListLocationsRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_locations), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + locations_pb2.ListLocationsResponse() + ) + response = await client.list_locations(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, locations_pb2.ListLocationsResponse) + + +def test_list_locations_field_headers(): + client = AnalyticsHubServiceClient( + 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 = locations_pb2.ListLocationsRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_locations), "__call__") as call: + call.return_value = locations_pb2.ListLocationsResponse() + + client.list_locations(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=locations", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_list_locations_field_headers_async(): + client = AnalyticsHubServiceAsyncClient( + 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 = locations_pb2.ListLocationsRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_locations), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + locations_pb2.ListLocationsResponse() + ) + await client.list_locations(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=locations", + ) in kw["metadata"] + + +def test_list_locations_from_dict(): + client = AnalyticsHubServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_locations), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = locations_pb2.ListLocationsResponse() + + response = client.list_locations( + request={ + "name": "locations", + } + ) + call.assert_called() + + +@pytest.mark.asyncio +async def test_list_locations_from_dict_async(): + client = AnalyticsHubServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_locations), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + locations_pb2.ListLocationsResponse() + ) + response = await client.list_locations( + request={ + "name": "locations", + } + ) + call.assert_called() + + +def test_get_location(transport: str = "grpc"): + client = AnalyticsHubServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = locations_pb2.GetLocationRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_location), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = locations_pb2.Location() + response = client.get_location(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, locations_pb2.Location) + + +@pytest.mark.asyncio +async def test_get_location_async(transport: str = "grpc_asyncio"): + client = AnalyticsHubServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = locations_pb2.GetLocationRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_location), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + locations_pb2.Location() + ) + response = await client.get_location(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, locations_pb2.Location) + + +def test_get_location_field_headers(): + client = AnalyticsHubServiceClient( + 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 = locations_pb2.GetLocationRequest() + request.name = "locations/abc" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_location), "__call__") as call: + call.return_value = locations_pb2.Location() + + client.get_location(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=locations/abc", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_get_location_field_headers_async(): + client = AnalyticsHubServiceAsyncClient( + 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 = locations_pb2.GetLocationRequest() + request.name = "locations/abc" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_location), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + locations_pb2.Location() + ) + await client.get_location(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=locations/abc", + ) in kw["metadata"] + + +def test_get_location_from_dict(): + client = AnalyticsHubServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_locations), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = locations_pb2.Location() + + response = client.get_location( + request={ + "name": "locations/abc", + } + ) + call.assert_called() + + +@pytest.mark.asyncio +async def test_get_location_from_dict_async(): + client = AnalyticsHubServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_locations), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + locations_pb2.Location() + ) + response = await client.get_location( + request={ + "name": "locations", + } + ) + call.assert_called() + + def test_transport_close(): transports = { "grpc": "_grpc_channel",