Skip to content

Commit

Permalink
Copybara import of the project:
Browse files Browse the repository at this point in the history
--
e167a6f by Yu-Han Liu <[email protected]>:

feat: regenerate with gapic-generator-python 1.4.4
COPYBARA_INTEGRATE_REVIEW=#1840 from googleapis:regenerate-1.20.0-1 f6fdd20
PiperOrigin-RevId: 494168144
  • Loading branch information
dizcology authored and copybara-github committed Dec 9, 2022
1 parent df0d782 commit 43468bd
Show file tree
Hide file tree
Showing 32 changed files with 2,604 additions and 30 deletions.
6 changes: 6 additions & 0 deletions google/cloud/aiplatform_v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
from .types.dataset import ImportDataConfig
from .types.dataset_service import CreateDatasetOperationMetadata
from .types.dataset_service import CreateDatasetRequest
from .types.dataset_service import DataItemView
from .types.dataset_service import DeleteDatasetRequest
from .types.dataset_service import ExportDataOperationMetadata
from .types.dataset_service import ExportDataRequest
Expand All @@ -89,6 +90,8 @@
from .types.dataset_service import ListDatasetsResponse
from .types.dataset_service import ListSavedQueriesRequest
from .types.dataset_service import ListSavedQueriesResponse
from .types.dataset_service import SearchDataItemsRequest
from .types.dataset_service import SearchDataItemsResponse
from .types.dataset_service import UpdateDatasetRequest
from .types.deployed_index_ref import DeployedIndexRef
from .types.deployed_model_ref import DeployedModelRef
Expand Down Expand Up @@ -622,6 +625,7 @@
"CustomJob",
"CustomJobSpec",
"DataItem",
"DataItemView",
"DataLabelingJob",
"Dataset",
"DatasetServiceClient",
Expand Down Expand Up @@ -917,6 +921,8 @@
"SavedQuery",
"Scalar",
"Scheduling",
"SearchDataItemsRequest",
"SearchDataItemsResponse",
"SearchFeaturesRequest",
"SearchFeaturesResponse",
"SearchMigratableResourcesRequest",
Expand Down
10 changes: 10 additions & 0 deletions google/cloud/aiplatform_v1/gapic_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@
"list_saved_queries"
]
},
"SearchDataItems": {
"methods": [
"search_data_items"
]
},
"UpdateDataset": {
"methods": [
"update_dataset"
Expand Down Expand Up @@ -120,6 +125,11 @@
"list_saved_queries"
]
},
"SearchDataItems": {
"methods": [
"search_data_items"
]
},
"UpdateDataset": {
"methods": [
"update_dataset"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1213,6 +1213,100 @@ async def sample_list_data_items():
# Done; return the response.
return response

async def search_data_items(
self,
request: Union[dataset_service.SearchDataItemsRequest, dict] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.SearchDataItemsAsyncPager:
r"""Searches DataItems in a Dataset.
.. code-block:: python
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import aiplatform_v1
async def sample_search_data_items():
# Create a client
client = aiplatform_v1.DatasetServiceAsyncClient()
# Initialize request argument(s)
request = aiplatform_v1.SearchDataItemsRequest(
order_by_data_item="order_by_data_item_value",
dataset="dataset_value",
)
# Make the request
page_result = client.search_data_items(request=request)
# Handle the response
async for response in page_result:
print(response)
Args:
request (Union[google.cloud.aiplatform_v1.types.SearchDataItemsRequest, dict]):
The request object. Request message for
[DatasetService.SearchDataItems][google.cloud.aiplatform.v1.DatasetService.SearchDataItems].
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:
google.cloud.aiplatform_v1.services.dataset_service.pagers.SearchDataItemsAsyncPager:
Response message for
[DatasetService.SearchDataItems][google.cloud.aiplatform.v1.DatasetService.SearchDataItems].
Iterating over this object will yield results and
resolve additional pages automatically.
"""
# Create or coerce a protobuf request object.
request = dataset_service.SearchDataItemsRequest(request)

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.search_data_items,
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((("dataset", request.dataset),)),
)

# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)

# This method is paged; wrap the response in a pager, which provides
# an `__aiter__` convenience method.
response = pagers.SearchDataItemsAsyncPager(
method=rpc,
request=request,
response=response,
metadata=metadata,
)

# Done; return the response.
return response

async def list_saved_queries(
self,
request: Union[dataset_service.ListSavedQueriesRequest, dict] = None,
Expand Down
95 changes: 95 additions & 0 deletions google/cloud/aiplatform_v1/services/dataset_service/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1526,6 +1526,101 @@ def sample_list_data_items():
# Done; return the response.
return response

def search_data_items(
self,
request: Union[dataset_service.SearchDataItemsRequest, dict] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.SearchDataItemsPager:
r"""Searches DataItems in a Dataset.
.. code-block:: python
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import aiplatform_v1
def sample_search_data_items():
# Create a client
client = aiplatform_v1.DatasetServiceClient()
# Initialize request argument(s)
request = aiplatform_v1.SearchDataItemsRequest(
order_by_data_item="order_by_data_item_value",
dataset="dataset_value",
)
# Make the request
page_result = client.search_data_items(request=request)
# Handle the response
for response in page_result:
print(response)
Args:
request (Union[google.cloud.aiplatform_v1.types.SearchDataItemsRequest, dict]):
The request object. Request message for
[DatasetService.SearchDataItems][google.cloud.aiplatform.v1.DatasetService.SearchDataItems].
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:
google.cloud.aiplatform_v1.services.dataset_service.pagers.SearchDataItemsPager:
Response message for
[DatasetService.SearchDataItems][google.cloud.aiplatform.v1.DatasetService.SearchDataItems].
Iterating over this object will yield results and
resolve additional pages automatically.
"""
# Create or coerce a protobuf request object.
# Minor optimization to avoid making a copy if the user passes
# in a dataset_service.SearchDataItemsRequest.
# There's no risk of modifying the input as we've already verified
# there are no flattened fields.
if not isinstance(request, dataset_service.SearchDataItemsRequest):
request = dataset_service.SearchDataItemsRequest(request)

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._transport._wrapped_methods[self._transport.search_data_items]

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("dataset", request.dataset),)),
)

# Send the request.
response = rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)

# This method is paged; wrap the response in a pager, which provides
# an `__iter__` convenience method.
response = pagers.SearchDataItemsPager(
method=rpc,
request=request,
response=response,
metadata=metadata,
)

# Done; return the response.
return response

def list_saved_queries(
self,
request: Union[dataset_service.ListSavedQueriesRequest, dict] = None,
Expand Down
128 changes: 128 additions & 0 deletions google/cloud/aiplatform_v1/services/dataset_service/pagers.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,134 @@ def __repr__(self) -> str:
return "{0}<{1!r}>".format(self.__class__.__name__, self._response)


class SearchDataItemsPager:
"""A pager for iterating through ``search_data_items`` requests.
This class thinly wraps an initial
:class:`google.cloud.aiplatform_v1.types.SearchDataItemsResponse` object, and
provides an ``__iter__`` method to iterate through its
``data_item_views`` field.
If there are more pages, the ``__iter__`` method will make additional
``SearchDataItems`` requests and continue to iterate
through the ``data_item_views`` field on the
corresponding responses.
All the usual :class:`google.cloud.aiplatform_v1.types.SearchDataItemsResponse`
attributes are available on the pager. If multiple requests are made, only
the most recent response is retained, and thus used for attribute lookup.
"""

def __init__(
self,
method: Callable[..., dataset_service.SearchDataItemsResponse],
request: dataset_service.SearchDataItemsRequest,
response: dataset_service.SearchDataItemsResponse,
*,
metadata: Sequence[Tuple[str, str]] = ()
):
"""Instantiate the pager.
Args:
method (Callable): The method that was originally called, and
which instantiated this pager.
request (google.cloud.aiplatform_v1.types.SearchDataItemsRequest):
The initial request object.
response (google.cloud.aiplatform_v1.types.SearchDataItemsResponse):
The initial response object.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
"""
self._method = method
self._request = dataset_service.SearchDataItemsRequest(request)
self._response = response
self._metadata = metadata

def __getattr__(self, name: str) -> Any:
return getattr(self._response, name)

@property
def pages(self) -> Iterator[dataset_service.SearchDataItemsResponse]:
yield self._response
while self._response.next_page_token:
self._request.page_token = self._response.next_page_token
self._response = self._method(self._request, metadata=self._metadata)
yield self._response

def __iter__(self) -> Iterator[dataset_service.DataItemView]:
for page in self.pages:
yield from page.data_item_views

def __repr__(self) -> str:
return "{0}<{1!r}>".format(self.__class__.__name__, self._response)


class SearchDataItemsAsyncPager:
"""A pager for iterating through ``search_data_items`` requests.
This class thinly wraps an initial
:class:`google.cloud.aiplatform_v1.types.SearchDataItemsResponse` object, and
provides an ``__aiter__`` method to iterate through its
``data_item_views`` field.
If there are more pages, the ``__aiter__`` method will make additional
``SearchDataItems`` requests and continue to iterate
through the ``data_item_views`` field on the
corresponding responses.
All the usual :class:`google.cloud.aiplatform_v1.types.SearchDataItemsResponse`
attributes are available on the pager. If multiple requests are made, only
the most recent response is retained, and thus used for attribute lookup.
"""

def __init__(
self,
method: Callable[..., Awaitable[dataset_service.SearchDataItemsResponse]],
request: dataset_service.SearchDataItemsRequest,
response: dataset_service.SearchDataItemsResponse,
*,
metadata: Sequence[Tuple[str, str]] = ()
):
"""Instantiates the pager.
Args:
method (Callable): The method that was originally called, and
which instantiated this pager.
request (google.cloud.aiplatform_v1.types.SearchDataItemsRequest):
The initial request object.
response (google.cloud.aiplatform_v1.types.SearchDataItemsResponse):
The initial response object.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
"""
self._method = method
self._request = dataset_service.SearchDataItemsRequest(request)
self._response = response
self._metadata = metadata

def __getattr__(self, name: str) -> Any:
return getattr(self._response, name)

@property
async def pages(self) -> AsyncIterator[dataset_service.SearchDataItemsResponse]:
yield self._response
while self._response.next_page_token:
self._request.page_token = self._response.next_page_token
self._response = await self._method(self._request, metadata=self._metadata)
yield self._response

def __aiter__(self) -> AsyncIterator[dataset_service.DataItemView]:
async def async_generator():
async for page in self.pages:
for response in page.data_item_views:
yield response

return async_generator()

def __repr__(self) -> str:
return "{0}<{1!r}>".format(self.__class__.__name__, self._response)


class ListSavedQueriesPager:
"""A pager for iterating through ``list_saved_queries`` requests.
Expand Down
Loading

0 comments on commit 43468bd

Please sign in to comment.