Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/dataset_service/__pycache__/__init__.cpython-311.pycAdded
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/dataset_service/__pycache__/pagers.cpython-311.pycAdded
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/dataset_service/transports/__init__.pyAdded+54
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/dataset_service/transports/__pycache__/grpc.cpython-311.pycAdded
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/dataset_service/transports/base.pyAdded+611
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/dataset_service/transports/grpc.pyAdded+1087
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/dataset_service/transports/grpc_asyncio.pyAdded+1269
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/dataset_service/transports/rest.pyAdded
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/dataset_service/transports/rest_asyncio.pyAdded
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/dataset_service/transports/rest_base.pyAdded
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/endpoint_service/__pycache__/__init__.cpython-311.pycAdded
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/endpoint_service/__pycache__/async_client.cpython-311.pycAdded
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/endpoint_service/__pycache__/pagers.cpython-311.pycAdded
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/endpoint_service/transports/__init__.pyAdded+54
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/endpoint_service/transports/__pycache__/__init__.cpython-311.pycAdded
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/endpoint_service/transports/__pycache__/base.cpython-311.pycAdded
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/endpoint_service/transports/__pycache__/grpc.cpython-311.pycAdded
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/endpoint_service/transports/__pycache__/grpc_asyncio.cpython-311.pycAdded
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/endpoint_service/transports/__pycache__/rest_base.cpython-311.pycAdded
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/endpoint_service/transports/base.pyAdded+446
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/endpoint_service/transports/grpc.pyAdded+809
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/endpoint_service/transports/grpc_asyncio.pyAdded+935
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/endpoint_service/transports/rest.pyAdded
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/endpoint_service/transports/rest_asyncio.pyAdded
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/endpoint_service/transports/rest_base.pyAdded
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/feature_online_store_service/__pycache__/__init__.cpython-311.pycAdded
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/feature_online_store_service/__pycache__/async_client.cpython-311.pycAdded
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/feature_online_store_service/__pycache__/client.cpython-311.pycAdded
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/feature_online_store_service/transports/__init__.pyAdded+56
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/feature_online_store_service/transports/__pycache__/__init__.cpython-311.pycAdded
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/feature_online_store_service/transports/__pycache__/base.cpython-311.pycAdded
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/feature_online_store_service/transports/__pycache__/grpc.cpython-311.pycAdded
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/feature_online_store_service/transports/__pycache__/grpc_asyncio.cpython-311.pycAdded
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/feature_online_store_service/transports/__pycache__/rest.cpython-311.pycAdded
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/feature_online_store_service/transports/__pycache__/rest_base.cpython-311.pycAdded
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/feature_online_store_service/transports/base.pyAdded+377
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/feature_online_store_service/transports/grpc.pyAdded+668
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/feature_online_store_service/transports/grpc_asyncio.pyAdded+756
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/feature_online_store_service/transports/rest.pyAdded
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/feature_online_store_service/transports/rest_asyncio.pyAdded
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/feature_online_store_service/transports/rest_base.pyAdded
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/featurestore_service/__pycache__/__init__.cpython-311.pycAdded
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/featurestore_service/__pycache__/pagers.cpython-311.pycAdded
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/featurestore_service/transports/__init__.pyAdded+56
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/featurestore_service/transports/__pycache__/__init__.cpython-311.pycAdded
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/featurestore_service/transports/__pycache__/base.cpython-311.pycAdded
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/featurestore_service/transports/__pycache__/grpc.cpython-311.pycAdded
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/featurestore_service/transports/__pycache__/grpc_asyncio.cpython-311.pycAdded
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/featurestore_service/transports/base.pyAdded+626
- data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/featurestore_service/transports/grpc.pyAdded+1199
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354# -*- coding: utf-8 -*-# Copyright 2025 Google LLC## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.#from collections import OrderedDictfrom typing import Dict, Type, Tuple
from .base import DatasetServiceTransportfrom .grpc import DatasetServiceGrpcTransportfrom .grpc_asyncio import DatasetServiceGrpcAsyncIOTransportfrom .rest import DatasetServiceRestTransportfrom .rest import DatasetServiceRestInterceptor
ASYNC_REST_CLASSES: Tuple[str, ...]try: from .rest_asyncio import AsyncDatasetServiceRestTransport from .rest_asyncio import AsyncDatasetServiceRestInterceptor
ASYNC_REST_CLASSES = ( "AsyncDatasetServiceRestTransport", "AsyncDatasetServiceRestInterceptor", ) HAS_REST_ASYNC = Trueexcept ImportError: # pragma: NO COVER ASYNC_REST_CLASSES = () HAS_REST_ASYNC = False
# Compile a registry of transports._transport_registry = OrderedDict() # type: Dict[str, Type[DatasetServiceTransport]]_transport_registry["grpc"] = DatasetServiceGrpcTransport_transport_registry["grpc_asyncio"] = DatasetServiceGrpcAsyncIOTransport_transport_registry["rest"] = DatasetServiceRestTransportif HAS_REST_ASYNC: # pragma: NO COVER _transport_registry["rest_asyncio"] = AsyncDatasetServiceRestTransport
__all__ = ( "DatasetServiceTransport", "DatasetServiceGrpcTransport", "DatasetServiceGrpcAsyncIOTransport", "DatasetServiceRestTransport", "DatasetServiceRestInterceptor",) + ASYNC_REST_CLASSES123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611# -*- coding: utf-8 -*-# Copyright 2025 Google LLC## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.#import abcfrom typing import Awaitable, Callable, Dict, Optional, Sequence, Union
from google.cloud.aiplatform_v1 import gapic_version as package_version
import google.auth # type: ignoreimport google.api_corefrom google.api_core import exceptions as core_exceptionsfrom google.api_core import gapic_v1from google.api_core import retry as retriesfrom google.api_core import operations_v1from google.auth import credentials as ga_credentials # type: ignorefrom google.oauth2 import service_account # type: ignoreimport google.protobuf
from google.cloud.aiplatform_v1.types import annotation_specfrom google.cloud.aiplatform_v1.types import datasetfrom google.cloud.aiplatform_v1.types import dataset as gca_datasetfrom google.cloud.aiplatform_v1.types import dataset_servicefrom google.cloud.aiplatform_v1.types import dataset_versionfrom google.cloud.aiplatform_v1.types import dataset_version as gca_dataset_versionfrom google.cloud.location import locations_pb2 # type: ignorefrom google.iam.v1 import iam_policy_pb2 # type: ignorefrom google.iam.v1 import policy_pb2 # type: ignorefrom google.longrunning import operations_pb2 # type: ignore
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=package_version.__version__)
if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
class DatasetServiceTransport(abc.ABC): """Abstract transport class for DatasetService."""
AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",)
DEFAULT_HOST: str = "aiplatform.googleapis.com"
def __init__( self, *, host: str = DEFAULT_HOST, credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, api_audience: Optional[str] = None, **kwargs, ) -> None: """Instantiate the transport.
Args: host (Optional[str]): The hostname to connect to (default: 'aiplatform.googleapis.com'). credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none are specified, the client will attempt to ascertain the credentials from the environment. credentials_file (Optional[str]): Deprecated. A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is mutually exclusive with credentials. This argument will be removed in the next major version of this library. scopes (Optional[Sequence[str]]): A list of scopes. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): The client info used to send a user-agent string along with API requests. If ``None``, then default info will be used. Generally, you only need to set this if you're developing your own client library. always_use_jwt_access (Optional[bool]): Whether self signed JWT should be used for service account credentials. """
# Save the scopes. self._scopes = scopes if not hasattr(self, "_ignore_credentials"): self._ignore_credentials: bool = False
# If no credentials are provided, then determine the appropriate # defaults. if credentials and credentials_file: raise core_exceptions.DuplicateCredentialArgs( "'credentials_file' and 'credentials' are mutually exclusive" )
if credentials_file is not None: credentials, _ = google.auth.load_credentials_from_file( credentials_file, scopes=scopes, quota_project_id=quota_project_id, default_scopes=self.AUTH_SCOPES, ) elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( scopes=scopes, quota_project_id=quota_project_id, default_scopes=self.AUTH_SCOPES, ) # Don't apply audience if the credentials file passed from user. if hasattr(credentials, "with_gdch_audience"): credentials = credentials.with_gdch_audience( api_audience if api_audience else host )
# If the credentials are service account credentials, then always try to use self signed JWT. if ( always_use_jwt_access and isinstance(credentials, service_account.Credentials) and hasattr(service_account.Credentials, "with_always_use_jwt_access") ): credentials = credentials.with_always_use_jwt_access(True)
# Save the credentials. self._credentials = credentials
# Save the hostname. Default to port 443 (HTTPS) if none is specified. if ":" not in host: host += ":443" self._host = host
@property def host(self): return self._host
def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { self.create_dataset: gapic_v1.method.wrap_method( self.create_dataset, default_timeout=None, client_info=client_info, ), self.get_dataset: gapic_v1.method.wrap_method( self.get_dataset, default_timeout=None, client_info=client_info, ), self.update_dataset: gapic_v1.method.wrap_method( self.update_dataset, default_timeout=None, client_info=client_info, ), self.list_datasets: gapic_v1.method.wrap_method( self.list_datasets, default_timeout=None, client_info=client_info, ), self.delete_dataset: gapic_v1.method.wrap_method( self.delete_dataset, default_timeout=None, client_info=client_info, ), self.import_data: gapic_v1.method.wrap_method( self.import_data, default_timeout=None, client_info=client_info, ), self.export_data: gapic_v1.method.wrap_method( self.export_data, default_timeout=None, client_info=client_info, ), self.create_dataset_version: gapic_v1.method.wrap_method( self.create_dataset_version, default_timeout=None, client_info=client_info, ), self.update_dataset_version: gapic_v1.method.wrap_method( self.update_dataset_version, default_timeout=None, client_info=client_info, ), self.delete_dataset_version: gapic_v1.method.wrap_method( self.delete_dataset_version, default_timeout=None, client_info=client_info, ), self.get_dataset_version: gapic_v1.method.wrap_method( self.get_dataset_version, default_timeout=None, client_info=client_info, ), self.list_dataset_versions: gapic_v1.method.wrap_method( self.list_dataset_versions, default_timeout=None, client_info=client_info, ), self.restore_dataset_version: gapic_v1.method.wrap_method( self.restore_dataset_version, default_timeout=None, client_info=client_info, ), self.list_data_items: gapic_v1.method.wrap_method( self.list_data_items, default_timeout=None, client_info=client_info, ), self.search_data_items: gapic_v1.method.wrap_method( self.search_data_items, default_timeout=None, client_info=client_info, ), self.list_saved_queries: gapic_v1.method.wrap_method( self.list_saved_queries, default_timeout=None, client_info=client_info, ), self.delete_saved_query: gapic_v1.method.wrap_method( self.delete_saved_query, default_timeout=None, client_info=client_info, ), self.get_annotation_spec: gapic_v1.method.wrap_method( self.get_annotation_spec, default_timeout=None, client_info=client_info, ), self.list_annotations: gapic_v1.method.wrap_method( self.list_annotations, default_timeout=None, client_info=client_info, ), self.get_location: gapic_v1.method.wrap_method( self.get_location, default_timeout=None, client_info=client_info, ), self.list_locations: gapic_v1.method.wrap_method( self.list_locations, default_timeout=None, client_info=client_info, ), self.get_iam_policy: gapic_v1.method.wrap_method( self.get_iam_policy, default_timeout=None, client_info=client_info, ), self.set_iam_policy: gapic_v1.method.wrap_method( self.set_iam_policy, default_timeout=None, client_info=client_info, ), self.test_iam_permissions: gapic_v1.method.wrap_method( self.test_iam_permissions, default_timeout=None, client_info=client_info, ), self.cancel_operation: gapic_v1.method.wrap_method( self.cancel_operation, default_timeout=None, client_info=client_info, ), self.delete_operation: gapic_v1.method.wrap_method( self.delete_operation, default_timeout=None, client_info=client_info, ), self.get_operation: gapic_v1.method.wrap_method( self.get_operation, default_timeout=None, client_info=client_info, ), self.list_operations: gapic_v1.method.wrap_method( self.list_operations, default_timeout=None, client_info=client_info, ), self.wait_operation: gapic_v1.method.wrap_method( self.wait_operation, default_timeout=None, client_info=client_info, ), }
def close(self): """Closes resources associated with the transport.
.. warning:: Only call this method if the transport is NOT shared with other clients - this may cause errors in other clients! """ raise NotImplementedError()
@property def operations_client(self): """Return the client designed to process long-running operations.""" raise NotImplementedError()
@property def create_dataset( self, ) -> Callable[ [dataset_service.CreateDatasetRequest], Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError()
@property def get_dataset( self, ) -> Callable[ [dataset_service.GetDatasetRequest], Union[dataset.Dataset, Awaitable[dataset.Dataset]], ]: raise NotImplementedError()
@property def update_dataset( self, ) -> Callable[ [dataset_service.UpdateDatasetRequest], Union[gca_dataset.Dataset, Awaitable[gca_dataset.Dataset]], ]: raise NotImplementedError()
@property def list_datasets( self, ) -> Callable[ [dataset_service.ListDatasetsRequest], Union[ dataset_service.ListDatasetsResponse, Awaitable[dataset_service.ListDatasetsResponse], ], ]: raise NotImplementedError()
@property def delete_dataset( self, ) -> Callable[ [dataset_service.DeleteDatasetRequest], Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError()
@property def import_data( self, ) -> Callable[ [dataset_service.ImportDataRequest], Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError()
@property def export_data( self, ) -> Callable[ [dataset_service.ExportDataRequest], Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError()
@property def create_dataset_version( self, ) -> Callable[ [dataset_service.CreateDatasetVersionRequest], Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError()
@property def update_dataset_version( self, ) -> Callable[ [dataset_service.UpdateDatasetVersionRequest], Union[ gca_dataset_version.DatasetVersion, Awaitable[gca_dataset_version.DatasetVersion], ], ]: raise NotImplementedError()
@property def delete_dataset_version( self, ) -> Callable[ [dataset_service.DeleteDatasetVersionRequest], Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError()
@property def get_dataset_version( self, ) -> Callable[ [dataset_service.GetDatasetVersionRequest], Union[ dataset_version.DatasetVersion, Awaitable[dataset_version.DatasetVersion] ], ]: raise NotImplementedError()
@property def list_dataset_versions( self, ) -> Callable[ [dataset_service.ListDatasetVersionsRequest], Union[ dataset_service.ListDatasetVersionsResponse, Awaitable[dataset_service.ListDatasetVersionsResponse], ], ]: raise NotImplementedError()
@property def restore_dataset_version( self, ) -> Callable[ [dataset_service.RestoreDatasetVersionRequest], Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError()
@property def list_data_items( self, ) -> Callable[ [dataset_service.ListDataItemsRequest], Union[ dataset_service.ListDataItemsResponse, Awaitable[dataset_service.ListDataItemsResponse], ], ]: raise NotImplementedError()
@property def search_data_items( self, ) -> Callable[ [dataset_service.SearchDataItemsRequest], Union[ dataset_service.SearchDataItemsResponse, Awaitable[dataset_service.SearchDataItemsResponse], ], ]: raise NotImplementedError()
@property def list_saved_queries( self, ) -> Callable[ [dataset_service.ListSavedQueriesRequest], Union[ dataset_service.ListSavedQueriesResponse, Awaitable[dataset_service.ListSavedQueriesResponse], ], ]: raise NotImplementedError()
@property def delete_saved_query( self, ) -> Callable[ [dataset_service.DeleteSavedQueryRequest], Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError()
@property def get_annotation_spec( self, ) -> Callable[ [dataset_service.GetAnnotationSpecRequest], Union[ annotation_spec.AnnotationSpec, Awaitable[annotation_spec.AnnotationSpec] ], ]: raise NotImplementedError()
@property def list_annotations( self, ) -> Callable[ [dataset_service.ListAnnotationsRequest], Union[ dataset_service.ListAnnotationsResponse, Awaitable[dataset_service.ListAnnotationsResponse], ], ]: raise NotImplementedError()
@property def list_operations( self, ) -> Callable[ [operations_pb2.ListOperationsRequest], Union[ operations_pb2.ListOperationsResponse, Awaitable[operations_pb2.ListOperationsResponse], ], ]: raise NotImplementedError()
@property def get_operation( self, ) -> Callable[ [operations_pb2.GetOperationRequest], Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError()
@property def cancel_operation( self, ) -> Callable[ [operations_pb2.CancelOperationRequest], None, ]: raise NotImplementedError()
@property def delete_operation( self, ) -> Callable[ [operations_pb2.DeleteOperationRequest], None, ]: raise NotImplementedError()
@property def wait_operation( self, ) -> Callable[ [operations_pb2.WaitOperationRequest], Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError()
@property def set_iam_policy( self, ) -> Callable[ [iam_policy_pb2.SetIamPolicyRequest], Union[policy_pb2.Policy, Awaitable[policy_pb2.Policy]], ]: raise NotImplementedError()
@property def get_iam_policy( self, ) -> Callable[ [iam_policy_pb2.GetIamPolicyRequest], Union[policy_pb2.Policy, Awaitable[policy_pb2.Policy]], ]: raise NotImplementedError()
@property def test_iam_permissions( self, ) -> Callable[ [iam_policy_pb2.TestIamPermissionsRequest], Union[ iam_policy_pb2.TestIamPermissionsResponse, Awaitable[iam_policy_pb2.TestIamPermissionsResponse], ], ]: 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()
__all__ = ("DatasetServiceTransport",)1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087# -*- coding: utf-8 -*-# Copyright 2025 Google LLC## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.#import jsonimport logging as std_loggingimport pickleimport warningsfrom typing import Callable, Dict, Optional, Sequence, Tuple, Union
from google.api_core import grpc_helpersfrom google.api_core import operations_v1from google.api_core import gapic_v1import google.auth # type: ignorefrom google.auth import credentials as ga_credentials # type: ignorefrom google.auth.transport.grpc import SslCredentials # type: ignorefrom google.protobuf.json_format import MessageToJsonimport google.protobuf.message
import grpc # type: ignoreimport proto # type: ignore
from google.cloud.aiplatform_v1.types import annotation_specfrom google.cloud.aiplatform_v1.types import datasetfrom google.cloud.aiplatform_v1.types import dataset as gca_datasetfrom google.cloud.aiplatform_v1.types import dataset_servicefrom google.cloud.aiplatform_v1.types import dataset_versionfrom google.cloud.aiplatform_v1.types import dataset_version as gca_dataset_versionfrom google.cloud.location import locations_pb2 # type: ignorefrom google.iam.v1 import iam_policy_pb2 # type: ignorefrom google.iam.v1 import policy_pb2 # type: ignorefrom google.longrunning import operations_pb2 # type: ignorefrom .base import DatasetServiceTransport, DEFAULT_CLIENT_INFO
try: from google.api_core import client_logging # type: ignore
CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVERexcept ImportError: # pragma: NO COVER CLIENT_LOGGING_SUPPORTED = False
_LOGGER = std_logging.getLogger(__name__)
class _LoggingClientInterceptor(grpc.UnaryUnaryClientInterceptor): # pragma: NO COVER def intercept_unary_unary(self, continuation, client_call_details, request): logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( std_logging.DEBUG ) if logging_enabled: # pragma: NO COVER request_metadata = client_call_details.metadata if isinstance(request, proto.Message): request_payload = type(request).to_json(request) elif isinstance(request, google.protobuf.message.Message): request_payload = MessageToJson(request) else: request_payload = f"{type(request).__name__}: {pickle.dumps(request)}"
request_metadata = { key: value.decode("utf-8") if isinstance(value, bytes) else value for key, value in request_metadata } grpc_request = { "payload": request_payload, "requestMethod": "grpc", "metadata": dict(request_metadata), } _LOGGER.debug( f"Sending request for {client_call_details.method}", extra={ "serviceName": "google.cloud.aiplatform.v1.DatasetService", "rpcName": str(client_call_details.method), "request": grpc_request, "metadata": grpc_request["metadata"], }, ) response = continuation(client_call_details, request) if logging_enabled: # pragma: NO COVER response_metadata = response.trailing_metadata() # Convert gRPC metadata `<class 'grpc.aio._metadata.Metadata'>` to list of tuples metadata = ( dict([(k, str(v)) for k, v in response_metadata]) if response_metadata else None ) result = response.result() if isinstance(result, proto.Message): response_payload = type(result).to_json(result) elif isinstance(result, google.protobuf.message.Message): response_payload = MessageToJson(result) else: response_payload = f"{type(result).__name__}: {pickle.dumps(result)}" grpc_response = { "payload": response_payload, "metadata": metadata, "status": "OK", } _LOGGER.debug( f"Received response for {client_call_details.method}.", extra={ "serviceName": "google.cloud.aiplatform.v1.DatasetService", "rpcName": client_call_details.method, "response": grpc_response, "metadata": grpc_response["metadata"], }, ) return response
class DatasetServiceGrpcTransport(DatasetServiceTransport): """gRPC backend transport for DatasetService.
The service that manages Vertex AI Dataset and its child resources.
This class defines the same methods as the primary client, so the primary client can load the underlying transport implementation and call it.
It sends protocol buffers over the wire using gRPC (which is built on top of HTTP/2); the ``grpcio`` package must be installed. """
_stubs: Dict[str, Callable]
def __init__( self, *, host: str = "aiplatform.googleapis.com", credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, channel: Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]] = None, api_mtls_endpoint: Optional[str] = None, client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, api_audience: Optional[str] = None, ) -> None: """Instantiate the transport.
Args: host (Optional[str]): The hostname to connect to (default: 'aiplatform.googleapis.com'). credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none are specified, the client will attempt to ascertain the credentials from the environment. This argument is ignored if a ``channel`` instance is provided. credentials_file (Optional[str]): Deprecated. A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is ignored if a ``channel`` instance is provided. This argument will be removed in the next major version of this library. scopes (Optional(Sequence[str])): A list of scopes. This argument is ignored if a ``channel`` instance is provided. channel (Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]]): A ``Channel`` instance through which to make calls, or a Callable that constructs and returns one. If set to None, ``self.create_channel`` is used to create the channel. If a Callable is given, it will be called with the same arguments as used in ``self.create_channel``. api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials for the grpc channel. It is ignored if a ``channel`` instance is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, both in PEM format. It is used to configure a mutual TLS channel. It is ignored if a ``channel`` instance or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): The client info used to send a user-agent string along with API requests. If ``None``, then default info will be used. Generally, you only need to set this if you're developing your own client library. always_use_jwt_access (Optional[bool]): Whether self signed JWT should be used for service account credentials.
Raises: google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport creation failed for any reason. google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ self._grpc_channel = None self._ssl_channel_credentials = ssl_channel_credentials self._stubs: Dict[str, Callable] = {} self._operations_client: Optional[operations_v1.OperationsClient] = None
if api_mtls_endpoint: warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) if client_cert_source: warnings.warn("client_cert_source is deprecated", DeprecationWarning)
if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. credentials = None self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None
else: if api_mtls_endpoint: host = api_mtls_endpoint
# Create SSL credentials with client_cert_source or application # default SSL credentials. if client_cert_source: cert, key = client_cert_source() self._ssl_channel_credentials = grpc.ssl_channel_credentials( certificate_chain=cert, private_key=key ) else: self._ssl_channel_credentials = SslCredentials().ssl_credentials
else: if client_cert_source_for_mtls and not ssl_channel_credentials: cert, key = client_cert_source_for_mtls() self._ssl_channel_credentials = grpc.ssl_channel_credentials( certificate_chain=cert, private_key=key )
# The base transport sets the host, credentials and scopes super().__init__( host=host, credentials=credentials, credentials_file=credentials_file, scopes=scopes, quota_project_id=quota_project_id, client_info=client_info, always_use_jwt_access=always_use_jwt_access, api_audience=api_audience, )
if not self._grpc_channel: # initialize with the provided callable or the default channel channel_init = channel or type(self).create_channel self._grpc_channel = channel_init( self._host, # use the credentials which are saved credentials=self._credentials, # Set ``credentials_file`` to ``None`` here as # the credentials that we saved earlier should be used. credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, options=[ ("grpc.max_send_message_length", -1), ("grpc.max_receive_message_length", -1), ], )
self._interceptor = _LoggingClientInterceptor() self._logged_channel = grpc.intercept_channel( self._grpc_channel, self._interceptor )
# Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info)
@classmethod def create_channel( cls, host: str = "aiplatform.googleapis.com", credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, **kwargs, ) -> grpc.Channel: """Create and return a gRPC channel object. Args: host (Optional[str]): The host for the channel to use. credentials (Optional[~.Credentials]): The authorization credentials to attach to requests. These credentials identify this application to the service. If none are specified, the client will attempt to ascertain the credentials from the environment. credentials_file (Optional[str]): Deprecated. A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is mutually exclusive with credentials. This argument will be removed in the next major version of this library. scopes (Optional[Sequence[str]]): A optional list of scopes needed for this service. These are only used when credentials are not specified and are passed to :func:`google.auth.default`. quota_project_id (Optional[str]): An optional project to use for billing and quota. kwargs (Optional[dict]): Keyword arguments, which are passed to the channel creation. Returns: grpc.Channel: A gRPC channel object.
Raises: google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """
return grpc_helpers.create_channel( host, credentials=credentials, credentials_file=credentials_file, quota_project_id=quota_project_id, default_scopes=cls.AUTH_SCOPES, scopes=scopes, default_host=cls.DEFAULT_HOST, **kwargs, )
@property def grpc_channel(self) -> grpc.Channel: """Return the channel designed to connect to this service.""" return self._grpc_channel
@property def operations_client(self) -> operations_v1.OperationsClient: """Create the client designed to process long-running operations.
This property caches on the instance; repeated calls return the same client. """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsClient( self._logged_channel )
# Return the client from cache. return self._operations_client
@property def create_dataset( self, ) -> Callable[[dataset_service.CreateDatasetRequest], operations_pb2.Operation]: r"""Return a callable for the create dataset method over gRPC.
Creates a Dataset.
Returns: Callable[[~.CreateDatasetRequest], ~.Operation]: A function that, when called, will call the underlying RPC on the server. """ # 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 "create_dataset" not in self._stubs: self._stubs["create_dataset"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/CreateDataset", request_serializer=dataset_service.CreateDatasetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_dataset"]
@property def get_dataset( self, ) -> Callable[[dataset_service.GetDatasetRequest], dataset.Dataset]: r"""Return a callable for the get dataset method over gRPC.
Gets a Dataset.
Returns: Callable[[~.GetDatasetRequest], ~.Dataset]: A function that, when called, will call the underlying RPC on the server. """ # 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_dataset" not in self._stubs: self._stubs["get_dataset"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/GetDataset", request_serializer=dataset_service.GetDatasetRequest.serialize, response_deserializer=dataset.Dataset.deserialize, ) return self._stubs["get_dataset"]
@property def update_dataset( self, ) -> Callable[[dataset_service.UpdateDatasetRequest], gca_dataset.Dataset]: r"""Return a callable for the update dataset method over gRPC.
Updates a Dataset.
Returns: Callable[[~.UpdateDatasetRequest], ~.Dataset]: A function that, when called, will call the underlying RPC on the server. """ # 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 "update_dataset" not in self._stubs: self._stubs["update_dataset"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/UpdateDataset", request_serializer=dataset_service.UpdateDatasetRequest.serialize, response_deserializer=gca_dataset.Dataset.deserialize, ) return self._stubs["update_dataset"]
@property def list_datasets( self, ) -> Callable[ [dataset_service.ListDatasetsRequest], dataset_service.ListDatasetsResponse ]: r"""Return a callable for the list datasets method over gRPC.
Lists Datasets in a Location.
Returns: Callable[[~.ListDatasetsRequest], ~.ListDatasetsResponse]: A function that, when called, will call the underlying RPC on the server. """ # 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_datasets" not in self._stubs: self._stubs["list_datasets"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/ListDatasets", request_serializer=dataset_service.ListDatasetsRequest.serialize, response_deserializer=dataset_service.ListDatasetsResponse.deserialize, ) return self._stubs["list_datasets"]
@property def delete_dataset( self, ) -> Callable[[dataset_service.DeleteDatasetRequest], operations_pb2.Operation]: r"""Return a callable for the delete dataset method over gRPC.
Deletes a Dataset.
Returns: Callable[[~.DeleteDatasetRequest], ~.Operation]: A function that, when called, will call the underlying RPC on the server. """ # 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 "delete_dataset" not in self._stubs: self._stubs["delete_dataset"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/DeleteDataset", request_serializer=dataset_service.DeleteDatasetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_dataset"]
@property def import_data( self, ) -> Callable[[dataset_service.ImportDataRequest], operations_pb2.Operation]: r"""Return a callable for the import data method over gRPC.
Imports data into a Dataset.
Returns: Callable[[~.ImportDataRequest], ~.Operation]: A function that, when called, will call the underlying RPC on the server. """ # 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 "import_data" not in self._stubs: self._stubs["import_data"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/ImportData", request_serializer=dataset_service.ImportDataRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["import_data"]
@property def export_data( self, ) -> Callable[[dataset_service.ExportDataRequest], operations_pb2.Operation]: r"""Return a callable for the export data method over gRPC.
Exports data from a Dataset.
Returns: Callable[[~.ExportDataRequest], ~.Operation]: A function that, when called, will call the underlying RPC on the server. """ # 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 "export_data" not in self._stubs: self._stubs["export_data"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/ExportData", request_serializer=dataset_service.ExportDataRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["export_data"]
@property def create_dataset_version( self, ) -> Callable[ [dataset_service.CreateDatasetVersionRequest], operations_pb2.Operation ]: r"""Return a callable for the create dataset version method over gRPC.
Create a version from a Dataset.
Returns: Callable[[~.CreateDatasetVersionRequest], ~.Operation]: A function that, when called, will call the underlying RPC on the server. """ # 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 "create_dataset_version" not in self._stubs: self._stubs["create_dataset_version"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/CreateDatasetVersion", request_serializer=dataset_service.CreateDatasetVersionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_dataset_version"]
@property def update_dataset_version( self, ) -> Callable[ [dataset_service.UpdateDatasetVersionRequest], gca_dataset_version.DatasetVersion, ]: r"""Return a callable for the update dataset version method over gRPC.
Updates a DatasetVersion.
Returns: Callable[[~.UpdateDatasetVersionRequest], ~.DatasetVersion]: A function that, when called, will call the underlying RPC on the server. """ # 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 "update_dataset_version" not in self._stubs: self._stubs["update_dataset_version"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/UpdateDatasetVersion", request_serializer=dataset_service.UpdateDatasetVersionRequest.serialize, response_deserializer=gca_dataset_version.DatasetVersion.deserialize, ) return self._stubs["update_dataset_version"]
@property def delete_dataset_version( self, ) -> Callable[ [dataset_service.DeleteDatasetVersionRequest], operations_pb2.Operation ]: r"""Return a callable for the delete dataset version method over gRPC.
Deletes a Dataset version.
Returns: Callable[[~.DeleteDatasetVersionRequest], ~.Operation]: A function that, when called, will call the underlying RPC on the server. """ # 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 "delete_dataset_version" not in self._stubs: self._stubs["delete_dataset_version"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/DeleteDatasetVersion", request_serializer=dataset_service.DeleteDatasetVersionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_dataset_version"]
@property def get_dataset_version( self, ) -> Callable[ [dataset_service.GetDatasetVersionRequest], dataset_version.DatasetVersion ]: r"""Return a callable for the get dataset version method over gRPC.
Gets a Dataset version.
Returns: Callable[[~.GetDatasetVersionRequest], ~.DatasetVersion]: A function that, when called, will call the underlying RPC on the server. """ # 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_dataset_version" not in self._stubs: self._stubs["get_dataset_version"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/GetDatasetVersion", request_serializer=dataset_service.GetDatasetVersionRequest.serialize, response_deserializer=dataset_version.DatasetVersion.deserialize, ) return self._stubs["get_dataset_version"]
@property def list_dataset_versions( self, ) -> Callable[ [dataset_service.ListDatasetVersionsRequest], dataset_service.ListDatasetVersionsResponse, ]: r"""Return a callable for the list dataset versions method over gRPC.
Lists DatasetVersions in a Dataset.
Returns: Callable[[~.ListDatasetVersionsRequest], ~.ListDatasetVersionsResponse]: A function that, when called, will call the underlying RPC on the server. """ # 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_dataset_versions" not in self._stubs: self._stubs["list_dataset_versions"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/ListDatasetVersions", request_serializer=dataset_service.ListDatasetVersionsRequest.serialize, response_deserializer=dataset_service.ListDatasetVersionsResponse.deserialize, ) return self._stubs["list_dataset_versions"]
@property def restore_dataset_version( self, ) -> Callable[ [dataset_service.RestoreDatasetVersionRequest], operations_pb2.Operation ]: r"""Return a callable for the restore dataset version method over gRPC.
Restores a dataset version.
Returns: Callable[[~.RestoreDatasetVersionRequest], ~.Operation]: A function that, when called, will call the underlying RPC on the server. """ # 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 "restore_dataset_version" not in self._stubs: self._stubs["restore_dataset_version"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/RestoreDatasetVersion", request_serializer=dataset_service.RestoreDatasetVersionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["restore_dataset_version"]
@property def list_data_items( self, ) -> Callable[ [dataset_service.ListDataItemsRequest], dataset_service.ListDataItemsResponse ]: r"""Return a callable for the list data items method over gRPC.
Lists DataItems in a Dataset.
Returns: Callable[[~.ListDataItemsRequest], ~.ListDataItemsResponse]: A function that, when called, will call the underlying RPC on the server. """ # 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_data_items" not in self._stubs: self._stubs["list_data_items"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/ListDataItems", request_serializer=dataset_service.ListDataItemsRequest.serialize, response_deserializer=dataset_service.ListDataItemsResponse.deserialize, ) return self._stubs["list_data_items"]
@property def search_data_items( self, ) -> Callable[ [dataset_service.SearchDataItemsRequest], dataset_service.SearchDataItemsResponse, ]: r"""Return a callable for the search data items method over gRPC.
Searches DataItems in a Dataset.
Returns: Callable[[~.SearchDataItemsRequest], ~.SearchDataItemsResponse]: A function that, when called, will call the underlying RPC on the server. """ # 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 "search_data_items" not in self._stubs: self._stubs["search_data_items"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/SearchDataItems", request_serializer=dataset_service.SearchDataItemsRequest.serialize, response_deserializer=dataset_service.SearchDataItemsResponse.deserialize, ) return self._stubs["search_data_items"]
@property def list_saved_queries( self, ) -> Callable[ [dataset_service.ListSavedQueriesRequest], dataset_service.ListSavedQueriesResponse, ]: r"""Return a callable for the list saved queries method over gRPC.
Lists SavedQueries in a Dataset.
Returns: Callable[[~.ListSavedQueriesRequest], ~.ListSavedQueriesResponse]: A function that, when called, will call the underlying RPC on the server. """ # 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_saved_queries" not in self._stubs: self._stubs["list_saved_queries"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/ListSavedQueries", request_serializer=dataset_service.ListSavedQueriesRequest.serialize, response_deserializer=dataset_service.ListSavedQueriesResponse.deserialize, ) return self._stubs["list_saved_queries"]
@property def delete_saved_query( self, ) -> Callable[[dataset_service.DeleteSavedQueryRequest], operations_pb2.Operation]: r"""Return a callable for the delete saved query method over gRPC.
Deletes a SavedQuery.
Returns: Callable[[~.DeleteSavedQueryRequest], ~.Operation]: A function that, when called, will call the underlying RPC on the server. """ # 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 "delete_saved_query" not in self._stubs: self._stubs["delete_saved_query"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/DeleteSavedQuery", request_serializer=dataset_service.DeleteSavedQueryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_saved_query"]
@property def get_annotation_spec( self, ) -> Callable[ [dataset_service.GetAnnotationSpecRequest], annotation_spec.AnnotationSpec ]: r"""Return a callable for the get annotation spec method over gRPC.
Gets an AnnotationSpec.
Returns: Callable[[~.GetAnnotationSpecRequest], ~.AnnotationSpec]: A function that, when called, will call the underlying RPC on the server. """ # 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_annotation_spec" not in self._stubs: self._stubs["get_annotation_spec"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/GetAnnotationSpec", request_serializer=dataset_service.GetAnnotationSpecRequest.serialize, response_deserializer=annotation_spec.AnnotationSpec.deserialize, ) return self._stubs["get_annotation_spec"]
@property def list_annotations( self, ) -> Callable[ [dataset_service.ListAnnotationsRequest], dataset_service.ListAnnotationsResponse, ]: r"""Return a callable for the list annotations method over gRPC.
Lists Annotations belongs to a dataitem.
Returns: Callable[[~.ListAnnotationsRequest], ~.ListAnnotationsResponse]: A function that, when called, will call the underlying RPC on the server. """ # 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_annotations" not in self._stubs: self._stubs["list_annotations"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/ListAnnotations", request_serializer=dataset_service.ListAnnotationsRequest.serialize, response_deserializer=dataset_service.ListAnnotationsResponse.deserialize, ) return self._stubs["list_annotations"]
def close(self): self._logged_channel.close()
@property def delete_operation( self, ) -> Callable[[operations_pb2.DeleteOperationRequest], None]: r"""Return a callable for the delete_operation 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 "delete_operation" not in self._stubs: self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, ) return self._stubs["delete_operation"]
@property def cancel_operation( self, ) -> Callable[[operations_pb2.CancelOperationRequest], None]: r"""Return a callable for the cancel_operation 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 "cancel_operation" not in self._stubs: self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, ) return self._stubs["cancel_operation"]
@property def wait_operation( self, ) -> Callable[[operations_pb2.WaitOperationRequest], None]: r"""Return a callable for the wait_operation 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 "wait_operation" not in self._stubs: self._stubs["wait_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/WaitOperation", request_serializer=operations_pb2.WaitOperationRequest.SerializeToString, response_deserializer=None, ) return self._stubs["wait_operation"]
@property def get_operation( self, ) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]: r"""Return a callable for the get_operation 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_operation" not in self._stubs: self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["get_operation"]
@property def list_operations( self, ) -> Callable[ [operations_pb2.ListOperationsRequest], operations_pb2.ListOperationsResponse ]: r"""Return a callable for the list_operations 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_operations" not in self._stubs: self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, ) return self._stubs["list_operations"]
@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._logged_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._logged_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 set_iam_policy( self, ) -> Callable[[iam_policy_pb2.SetIamPolicyRequest], policy_pb2.Policy]: r"""Return a callable for the set iam policy method over gRPC. Sets the IAM access control policy on the specified function. Replaces any existing policy. Returns: Callable[[~.SetIamPolicyRequest], ~.Policy]: A function that, when called, will call the underlying RPC on the server. """ # 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 "set_iam_policy" not in self._stubs: self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, ) return self._stubs["set_iam_policy"]
@property def get_iam_policy( self, ) -> Callable[[iam_policy_pb2.GetIamPolicyRequest], policy_pb2.Policy]: r"""Return a callable for the get iam policy method over gRPC. Gets the IAM access control policy for a function. Returns an empty policy if the function exists and does not have a policy set. Returns: Callable[[~.GetIamPolicyRequest], ~.Policy]: A function that, when called, will call the underlying RPC on the server. """ # 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_iam_policy" not in self._stubs: self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, ) return self._stubs["get_iam_policy"]
@property def test_iam_permissions( self, ) -> Callable[ [iam_policy_pb2.TestIamPermissionsRequest], iam_policy_pb2.TestIamPermissionsResponse, ]: r"""Return a callable for the test iam permissions method over gRPC. Tests the specified permissions against the IAM access control policy for a function. If the function does not exist, this will return an empty set of permissions, not a NOT_FOUND error. Returns: Callable[[~.TestIamPermissionsRequest], ~.TestIamPermissionsResponse]: A function that, when called, will call the underlying RPC on the server. """ # 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 "test_iam_permissions" not in self._stubs: self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, ) return self._stubs["test_iam_permissions"]
@property def kind(self) -> str: return "grpc"
__all__ = ("DatasetServiceGrpcTransport",)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269# -*- coding: utf-8 -*-# Copyright 2025 Google LLC## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.#import inspectimport jsonimport pickleimport logging as std_loggingimport warningsfrom typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union
from google.api_core import gapic_v1from google.api_core import grpc_helpers_asyncfrom google.api_core import exceptions as core_exceptionsfrom google.api_core import retry_async as retriesfrom google.api_core import operations_v1from google.auth import credentials as ga_credentials # type: ignorefrom google.auth.transport.grpc import SslCredentials # type: ignorefrom google.protobuf.json_format import MessageToJsonimport google.protobuf.message
import grpc # type: ignoreimport proto # type: ignorefrom grpc.experimental import aio # type: ignore
from google.cloud.aiplatform_v1.types import annotation_specfrom google.cloud.aiplatform_v1.types import datasetfrom google.cloud.aiplatform_v1.types import dataset as gca_datasetfrom google.cloud.aiplatform_v1.types import dataset_servicefrom google.cloud.aiplatform_v1.types import dataset_versionfrom google.cloud.aiplatform_v1.types import dataset_version as gca_dataset_versionfrom google.cloud.location import locations_pb2 # type: ignorefrom google.iam.v1 import iam_policy_pb2 # type: ignorefrom google.iam.v1 import policy_pb2 # type: ignorefrom google.longrunning import operations_pb2 # type: ignorefrom .base import DatasetServiceTransport, DEFAULT_CLIENT_INFOfrom .grpc import DatasetServiceGrpcTransport
try: from google.api_core import client_logging # type: ignore
CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVERexcept ImportError: # pragma: NO COVER CLIENT_LOGGING_SUPPORTED = False
_LOGGER = std_logging.getLogger(__name__)
class _LoggingClientAIOInterceptor( grpc.aio.UnaryUnaryClientInterceptor): # pragma: NO COVER async def intercept_unary_unary(self, continuation, client_call_details, request): logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( std_logging.DEBUG ) if logging_enabled: # pragma: NO COVER request_metadata = client_call_details.metadata if isinstance(request, proto.Message): request_payload = type(request).to_json(request) elif isinstance(request, google.protobuf.message.Message): request_payload = MessageToJson(request) else: request_payload = f"{type(request).__name__}: {pickle.dumps(request)}"
request_metadata = { key: value.decode("utf-8") if isinstance(value, bytes) else value for key, value in request_metadata } grpc_request = { "payload": request_payload, "requestMethod": "grpc", "metadata": dict(request_metadata), } _LOGGER.debug( f"Sending request for {client_call_details.method}", extra={ "serviceName": "google.cloud.aiplatform.v1.DatasetService", "rpcName": str(client_call_details.method), "request": grpc_request, "metadata": grpc_request["metadata"], }, ) response = await continuation(client_call_details, request) if logging_enabled: # pragma: NO COVER response_metadata = await response.trailing_metadata() # Convert gRPC metadata `<class 'grpc.aio._metadata.Metadata'>` to list of tuples metadata = ( dict([(k, str(v)) for k, v in response_metadata]) if response_metadata else None ) result = await response if isinstance(result, proto.Message): response_payload = type(result).to_json(result) elif isinstance(result, google.protobuf.message.Message): response_payload = MessageToJson(result) else: response_payload = f"{type(result).__name__}: {pickle.dumps(result)}" grpc_response = { "payload": response_payload, "metadata": metadata, "status": "OK", } _LOGGER.debug( f"Received response to rpc {client_call_details.method}.", extra={ "serviceName": "google.cloud.aiplatform.v1.DatasetService", "rpcName": str(client_call_details.method), "response": grpc_response, "metadata": grpc_response["metadata"], }, ) return response
class DatasetServiceGrpcAsyncIOTransport(DatasetServiceTransport): """gRPC AsyncIO backend transport for DatasetService.
The service that manages Vertex AI Dataset and its child resources.
This class defines the same methods as the primary client, so the primary client can load the underlying transport implementation and call it.
It sends protocol buffers over the wire using gRPC (which is built on top of HTTP/2); the ``grpcio`` package must be installed. """
_grpc_channel: aio.Channel _stubs: Dict[str, Callable] = {}
@classmethod def create_channel( cls, host: str = "aiplatform.googleapis.com", credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, **kwargs, ) -> aio.Channel: """Create and return a gRPC AsyncIO channel object. Args: host (Optional[str]): The host for the channel to use. credentials (Optional[~.Credentials]): The authorization credentials to attach to requests. These credentials identify this application to the service. If none are specified, the client will attempt to ascertain the credentials from the environment. credentials_file (Optional[str]): Deprecated. A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument will be removed in the next major version of this library. scopes (Optional[Sequence[str]]): A optional list of scopes needed for this service. These are only used when credentials are not specified and are passed to :func:`google.auth.default`. quota_project_id (Optional[str]): An optional project to use for billing and quota. kwargs (Optional[dict]): Keyword arguments, which are passed to the channel creation. Returns: aio.Channel: A gRPC AsyncIO channel object. """
return grpc_helpers_async.create_channel( host, credentials=credentials, credentials_file=credentials_file, quota_project_id=quota_project_id, default_scopes=cls.AUTH_SCOPES, scopes=scopes, default_host=cls.DEFAULT_HOST, **kwargs, )
def __init__( self, *, host: str = "aiplatform.googleapis.com", credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, channel: Optional[Union[aio.Channel, Callable[..., aio.Channel]]] = None, api_mtls_endpoint: Optional[str] = None, client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, api_audience: Optional[str] = None, ) -> None: """Instantiate the transport.
Args: host (Optional[str]): The hostname to connect to (default: 'aiplatform.googleapis.com'). credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none are specified, the client will attempt to ascertain the credentials from the environment. This argument is ignored if a ``channel`` instance is provided. credentials_file (Optional[str]): Deprecated. A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is ignored if a ``channel`` instance is provided. This argument will be removed in the next major version of this library. scopes (Optional[Sequence[str]]): A optional list of scopes needed for this service. These are only used when credentials are not specified and are passed to :func:`google.auth.default`. channel (Optional[Union[aio.Channel, Callable[..., aio.Channel]]]): A ``Channel`` instance through which to make calls, or a Callable that constructs and returns one. If set to None, ``self.create_channel`` is used to create the channel. If a Callable is given, it will be called with the same arguments as used in ``self.create_channel``. api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials for the grpc channel. It is ignored if a ``channel`` instance is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, both in PEM format. It is used to configure a mutual TLS channel. It is ignored if a ``channel`` instance or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): The client info used to send a user-agent string along with API requests. If ``None``, then default info will be used. Generally, you only need to set this if you're developing your own client library. always_use_jwt_access (Optional[bool]): Whether self signed JWT should be used for service account credentials.
Raises: google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport creation failed for any reason. google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ self._grpc_channel = None self._ssl_channel_credentials = ssl_channel_credentials self._stubs: Dict[str, Callable] = {} self._operations_client: Optional[operations_v1.OperationsAsyncClient] = None
if api_mtls_endpoint: warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) if client_cert_source: warnings.warn("client_cert_source is deprecated", DeprecationWarning)
if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. credentials = None self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None else: if api_mtls_endpoint: host = api_mtls_endpoint
# Create SSL credentials with client_cert_source or application # default SSL credentials. if client_cert_source: cert, key = client_cert_source() self._ssl_channel_credentials = grpc.ssl_channel_credentials( certificate_chain=cert, private_key=key ) else: self._ssl_channel_credentials = SslCredentials().ssl_credentials
else: if client_cert_source_for_mtls and not ssl_channel_credentials: cert, key = client_cert_source_for_mtls() self._ssl_channel_credentials = grpc.ssl_channel_credentials( certificate_chain=cert, private_key=key )
# The base transport sets the host, credentials and scopes super().__init__( host=host, credentials=credentials, credentials_file=credentials_file, scopes=scopes, quota_project_id=quota_project_id, client_info=client_info, always_use_jwt_access=always_use_jwt_access, api_audience=api_audience, )
if not self._grpc_channel: # initialize with the provided callable or the default channel channel_init = channel or type(self).create_channel self._grpc_channel = channel_init( self._host, # use the credentials which are saved credentials=self._credentials, # Set ``credentials_file`` to ``None`` here as # the credentials that we saved earlier should be used. credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, options=[ ("grpc.max_send_message_length", -1), ("grpc.max_receive_message_length", -1), ], )
self._interceptor = _LoggingClientAIOInterceptor() self._grpc_channel._unary_unary_interceptors.append(self._interceptor) self._logged_channel = self._grpc_channel self._wrap_with_kind = ( "kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters ) # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info)
@property def grpc_channel(self) -> aio.Channel: """Create the channel designed to connect to this service.
This property caches on the instance; repeated calls return the same channel. """ # Return the channel from cache. return self._grpc_channel
@property def operations_client(self) -> operations_v1.OperationsAsyncClient: """Create the client designed to process long-running operations.
This property caches on the instance; repeated calls return the same client. """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( self._logged_channel )
# Return the client from cache. return self._operations_client
@property def create_dataset( self, ) -> Callable[ [dataset_service.CreateDatasetRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the create dataset method over gRPC.
Creates a Dataset.
Returns: Callable[[~.CreateDatasetRequest], Awaitable[~.Operation]]: A function that, when called, will call the underlying RPC on the server. """ # 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 "create_dataset" not in self._stubs: self._stubs["create_dataset"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/CreateDataset", request_serializer=dataset_service.CreateDatasetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_dataset"]
@property def get_dataset( self, ) -> Callable[[dataset_service.GetDatasetRequest], Awaitable[dataset.Dataset]]: r"""Return a callable for the get dataset method over gRPC.
Gets a Dataset.
Returns: Callable[[~.GetDatasetRequest], Awaitable[~.Dataset]]: A function that, when called, will call the underlying RPC on the server. """ # 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_dataset" not in self._stubs: self._stubs["get_dataset"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/GetDataset", request_serializer=dataset_service.GetDatasetRequest.serialize, response_deserializer=dataset.Dataset.deserialize, ) return self._stubs["get_dataset"]
@property def update_dataset( self, ) -> Callable[ [dataset_service.UpdateDatasetRequest], Awaitable[gca_dataset.Dataset] ]: r"""Return a callable for the update dataset method over gRPC.
Updates a Dataset.
Returns: Callable[[~.UpdateDatasetRequest], Awaitable[~.Dataset]]: A function that, when called, will call the underlying RPC on the server. """ # 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 "update_dataset" not in self._stubs: self._stubs["update_dataset"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/UpdateDataset", request_serializer=dataset_service.UpdateDatasetRequest.serialize, response_deserializer=gca_dataset.Dataset.deserialize, ) return self._stubs["update_dataset"]
@property def list_datasets( self, ) -> Callable[ [dataset_service.ListDatasetsRequest], Awaitable[dataset_service.ListDatasetsResponse], ]: r"""Return a callable for the list datasets method over gRPC.
Lists Datasets in a Location.
Returns: Callable[[~.ListDatasetsRequest], Awaitable[~.ListDatasetsResponse]]: A function that, when called, will call the underlying RPC on the server. """ # 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_datasets" not in self._stubs: self._stubs["list_datasets"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/ListDatasets", request_serializer=dataset_service.ListDatasetsRequest.serialize, response_deserializer=dataset_service.ListDatasetsResponse.deserialize, ) return self._stubs["list_datasets"]
@property def delete_dataset( self, ) -> Callable[ [dataset_service.DeleteDatasetRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the delete dataset method over gRPC.
Deletes a Dataset.
Returns: Callable[[~.DeleteDatasetRequest], Awaitable[~.Operation]]: A function that, when called, will call the underlying RPC on the server. """ # 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 "delete_dataset" not in self._stubs: self._stubs["delete_dataset"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/DeleteDataset", request_serializer=dataset_service.DeleteDatasetRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_dataset"]
@property def import_data( self, ) -> Callable[ [dataset_service.ImportDataRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the import data method over gRPC.
Imports data into a Dataset.
Returns: Callable[[~.ImportDataRequest], Awaitable[~.Operation]]: A function that, when called, will call the underlying RPC on the server. """ # 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 "import_data" not in self._stubs: self._stubs["import_data"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/ImportData", request_serializer=dataset_service.ImportDataRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["import_data"]
@property def export_data( self, ) -> Callable[ [dataset_service.ExportDataRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the export data method over gRPC.
Exports data from a Dataset.
Returns: Callable[[~.ExportDataRequest], Awaitable[~.Operation]]: A function that, when called, will call the underlying RPC on the server. """ # 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 "export_data" not in self._stubs: self._stubs["export_data"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/ExportData", request_serializer=dataset_service.ExportDataRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["export_data"]
@property def create_dataset_version( self, ) -> Callable[ [dataset_service.CreateDatasetVersionRequest], Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the create dataset version method over gRPC.
Create a version from a Dataset.
Returns: Callable[[~.CreateDatasetVersionRequest], Awaitable[~.Operation]]: A function that, when called, will call the underlying RPC on the server. """ # 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 "create_dataset_version" not in self._stubs: self._stubs["create_dataset_version"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/CreateDatasetVersion", request_serializer=dataset_service.CreateDatasetVersionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_dataset_version"]
@property def update_dataset_version( self, ) -> Callable[ [dataset_service.UpdateDatasetVersionRequest], Awaitable[gca_dataset_version.DatasetVersion], ]: r"""Return a callable for the update dataset version method over gRPC.
Updates a DatasetVersion.
Returns: Callable[[~.UpdateDatasetVersionRequest], Awaitable[~.DatasetVersion]]: A function that, when called, will call the underlying RPC on the server. """ # 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 "update_dataset_version" not in self._stubs: self._stubs["update_dataset_version"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/UpdateDatasetVersion", request_serializer=dataset_service.UpdateDatasetVersionRequest.serialize, response_deserializer=gca_dataset_version.DatasetVersion.deserialize, ) return self._stubs["update_dataset_version"]
@property def delete_dataset_version( self, ) -> Callable[ [dataset_service.DeleteDatasetVersionRequest], Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the delete dataset version method over gRPC.
Deletes a Dataset version.
Returns: Callable[[~.DeleteDatasetVersionRequest], Awaitable[~.Operation]]: A function that, when called, will call the underlying RPC on the server. """ # 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 "delete_dataset_version" not in self._stubs: self._stubs["delete_dataset_version"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/DeleteDatasetVersion", request_serializer=dataset_service.DeleteDatasetVersionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_dataset_version"]
@property def get_dataset_version( self, ) -> Callable[ [dataset_service.GetDatasetVersionRequest], Awaitable[dataset_version.DatasetVersion], ]: r"""Return a callable for the get dataset version method over gRPC.
Gets a Dataset version.
Returns: Callable[[~.GetDatasetVersionRequest], Awaitable[~.DatasetVersion]]: A function that, when called, will call the underlying RPC on the server. """ # 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_dataset_version" not in self._stubs: self._stubs["get_dataset_version"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/GetDatasetVersion", request_serializer=dataset_service.GetDatasetVersionRequest.serialize, response_deserializer=dataset_version.DatasetVersion.deserialize, ) return self._stubs["get_dataset_version"]
@property def list_dataset_versions( self, ) -> Callable[ [dataset_service.ListDatasetVersionsRequest], Awaitable[dataset_service.ListDatasetVersionsResponse], ]: r"""Return a callable for the list dataset versions method over gRPC.
Lists DatasetVersions in a Dataset.
Returns: Callable[[~.ListDatasetVersionsRequest], Awaitable[~.ListDatasetVersionsResponse]]: A function that, when called, will call the underlying RPC on the server. """ # 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_dataset_versions" not in self._stubs: self._stubs["list_dataset_versions"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/ListDatasetVersions", request_serializer=dataset_service.ListDatasetVersionsRequest.serialize, response_deserializer=dataset_service.ListDatasetVersionsResponse.deserialize, ) return self._stubs["list_dataset_versions"]
@property def restore_dataset_version( self, ) -> Callable[ [dataset_service.RestoreDatasetVersionRequest], Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the restore dataset version method over gRPC.
Restores a dataset version.
Returns: Callable[[~.RestoreDatasetVersionRequest], Awaitable[~.Operation]]: A function that, when called, will call the underlying RPC on the server. """ # 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 "restore_dataset_version" not in self._stubs: self._stubs["restore_dataset_version"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/RestoreDatasetVersion", request_serializer=dataset_service.RestoreDatasetVersionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["restore_dataset_version"]
@property def list_data_items( self, ) -> Callable[ [dataset_service.ListDataItemsRequest], Awaitable[dataset_service.ListDataItemsResponse], ]: r"""Return a callable for the list data items method over gRPC.
Lists DataItems in a Dataset.
Returns: Callable[[~.ListDataItemsRequest], Awaitable[~.ListDataItemsResponse]]: A function that, when called, will call the underlying RPC on the server. """ # 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_data_items" not in self._stubs: self._stubs["list_data_items"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/ListDataItems", request_serializer=dataset_service.ListDataItemsRequest.serialize, response_deserializer=dataset_service.ListDataItemsResponse.deserialize, ) return self._stubs["list_data_items"]
@property def search_data_items( self, ) -> Callable[ [dataset_service.SearchDataItemsRequest], Awaitable[dataset_service.SearchDataItemsResponse], ]: r"""Return a callable for the search data items method over gRPC.
Searches DataItems in a Dataset.
Returns: Callable[[~.SearchDataItemsRequest], Awaitable[~.SearchDataItemsResponse]]: A function that, when called, will call the underlying RPC on the server. """ # 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 "search_data_items" not in self._stubs: self._stubs["search_data_items"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/SearchDataItems", request_serializer=dataset_service.SearchDataItemsRequest.serialize, response_deserializer=dataset_service.SearchDataItemsResponse.deserialize, ) return self._stubs["search_data_items"]
@property def list_saved_queries( self, ) -> Callable[ [dataset_service.ListSavedQueriesRequest], Awaitable[dataset_service.ListSavedQueriesResponse], ]: r"""Return a callable for the list saved queries method over gRPC.
Lists SavedQueries in a Dataset.
Returns: Callable[[~.ListSavedQueriesRequest], Awaitable[~.ListSavedQueriesResponse]]: A function that, when called, will call the underlying RPC on the server. """ # 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_saved_queries" not in self._stubs: self._stubs["list_saved_queries"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/ListSavedQueries", request_serializer=dataset_service.ListSavedQueriesRequest.serialize, response_deserializer=dataset_service.ListSavedQueriesResponse.deserialize, ) return self._stubs["list_saved_queries"]
@property def delete_saved_query( self, ) -> Callable[ [dataset_service.DeleteSavedQueryRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the delete saved query method over gRPC.
Deletes a SavedQuery.
Returns: Callable[[~.DeleteSavedQueryRequest], Awaitable[~.Operation]]: A function that, when called, will call the underlying RPC on the server. """ # 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 "delete_saved_query" not in self._stubs: self._stubs["delete_saved_query"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/DeleteSavedQuery", request_serializer=dataset_service.DeleteSavedQueryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_saved_query"]
@property def get_annotation_spec( self, ) -> Callable[ [dataset_service.GetAnnotationSpecRequest], Awaitable[annotation_spec.AnnotationSpec], ]: r"""Return a callable for the get annotation spec method over gRPC.
Gets an AnnotationSpec.
Returns: Callable[[~.GetAnnotationSpecRequest], Awaitable[~.AnnotationSpec]]: A function that, when called, will call the underlying RPC on the server. """ # 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_annotation_spec" not in self._stubs: self._stubs["get_annotation_spec"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/GetAnnotationSpec", request_serializer=dataset_service.GetAnnotationSpecRequest.serialize, response_deserializer=annotation_spec.AnnotationSpec.deserialize, ) return self._stubs["get_annotation_spec"]
@property def list_annotations( self, ) -> Callable[ [dataset_service.ListAnnotationsRequest], Awaitable[dataset_service.ListAnnotationsResponse], ]: r"""Return a callable for the list annotations method over gRPC.
Lists Annotations belongs to a dataitem.
Returns: Callable[[~.ListAnnotationsRequest], Awaitable[~.ListAnnotationsResponse]]: A function that, when called, will call the underlying RPC on the server. """ # 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_annotations" not in self._stubs: self._stubs["list_annotations"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/ListAnnotations", request_serializer=dataset_service.ListAnnotationsRequest.serialize, response_deserializer=dataset_service.ListAnnotationsResponse.deserialize, ) return self._stubs["list_annotations"]
def _prep_wrapped_messages(self, client_info): """Precompute the wrapped methods, overriding the base class method to use async wrappers.""" self._wrapped_methods = { self.create_dataset: self._wrap_method( self.create_dataset, default_timeout=None, client_info=client_info, ), self.get_dataset: self._wrap_method( self.get_dataset, default_timeout=None, client_info=client_info, ), self.update_dataset: self._wrap_method( self.update_dataset, default_timeout=None, client_info=client_info, ), self.list_datasets: self._wrap_method( self.list_datasets, default_timeout=None, client_info=client_info, ), self.delete_dataset: self._wrap_method( self.delete_dataset, default_timeout=None, client_info=client_info, ), self.import_data: self._wrap_method( self.import_data, default_timeout=None, client_info=client_info, ), self.export_data: self._wrap_method( self.export_data, default_timeout=None, client_info=client_info, ), self.create_dataset_version: self._wrap_method( self.create_dataset_version, default_timeout=None, client_info=client_info, ), self.update_dataset_version: self._wrap_method( self.update_dataset_version, default_timeout=None, client_info=client_info, ), self.delete_dataset_version: self._wrap_method( self.delete_dataset_version, default_timeout=None, client_info=client_info, ), self.get_dataset_version: self._wrap_method( self.get_dataset_version, default_timeout=None, client_info=client_info, ), self.list_dataset_versions: self._wrap_method( self.list_dataset_versions, default_timeout=None, client_info=client_info, ), self.restore_dataset_version: self._wrap_method( self.restore_dataset_version, default_timeout=None, client_info=client_info, ), self.list_data_items: self._wrap_method( self.list_data_items, default_timeout=None, client_info=client_info, ), self.search_data_items: self._wrap_method( self.search_data_items, default_timeout=None, client_info=client_info, ), self.list_saved_queries: self._wrap_method( self.list_saved_queries, default_timeout=None, client_info=client_info, ), self.delete_saved_query: self._wrap_method( self.delete_saved_query, default_timeout=None, client_info=client_info, ), self.get_annotation_spec: self._wrap_method( self.get_annotation_spec, default_timeout=None, client_info=client_info, ), self.list_annotations: self._wrap_method( self.list_annotations, default_timeout=None, client_info=client_info, ), self.get_location: self._wrap_method( self.get_location, default_timeout=None, client_info=client_info, ), self.list_locations: self._wrap_method( self.list_locations, default_timeout=None, client_info=client_info, ), self.get_iam_policy: self._wrap_method( self.get_iam_policy, default_timeout=None, client_info=client_info, ), self.set_iam_policy: self._wrap_method( self.set_iam_policy, default_timeout=None, client_info=client_info, ), self.test_iam_permissions: self._wrap_method( self.test_iam_permissions, default_timeout=None, client_info=client_info, ), self.cancel_operation: self._wrap_method( self.cancel_operation, default_timeout=None, client_info=client_info, ), self.delete_operation: self._wrap_method( self.delete_operation, default_timeout=None, client_info=client_info, ), self.get_operation: self._wrap_method( self.get_operation, default_timeout=None, client_info=client_info, ), self.list_operations: self._wrap_method( self.list_operations, default_timeout=None, client_info=client_info, ), self.wait_operation: self._wrap_method( self.wait_operation, default_timeout=None, client_info=client_info, ), }
def _wrap_method(self, func, *args, **kwargs): if self._wrap_with_kind: # pragma: NO COVER kwargs["kind"] = self.kind return gapic_v1.method_async.wrap_method(func, *args, **kwargs)
def close(self): return self._logged_channel.close()
@property def kind(self) -> str: return "grpc_asyncio"
@property def delete_operation( self, ) -> Callable[[operations_pb2.DeleteOperationRequest], None]: r"""Return a callable for the delete_operation 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 "delete_operation" not in self._stubs: self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, ) return self._stubs["delete_operation"]
@property def cancel_operation( self, ) -> Callable[[operations_pb2.CancelOperationRequest], None]: r"""Return a callable for the cancel_operation 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 "cancel_operation" not in self._stubs: self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, ) return self._stubs["cancel_operation"]
@property def wait_operation( self, ) -> Callable[[operations_pb2.WaitOperationRequest], None]: r"""Return a callable for the wait_operation 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 "wait_operation" not in self._stubs: self._stubs["wait_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/WaitOperation", request_serializer=operations_pb2.WaitOperationRequest.SerializeToString, response_deserializer=None, ) return self._stubs["wait_operation"]
@property def get_operation( self, ) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]: r"""Return a callable for the get_operation 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_operation" not in self._stubs: self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["get_operation"]
@property def list_operations( self, ) -> Callable[ [operations_pb2.ListOperationsRequest], operations_pb2.ListOperationsResponse ]: r"""Return a callable for the list_operations 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_operations" not in self._stubs: self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, ) return self._stubs["list_operations"]
@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._logged_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._logged_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 set_iam_policy( self, ) -> Callable[[iam_policy_pb2.SetIamPolicyRequest], policy_pb2.Policy]: r"""Return a callable for the set iam policy method over gRPC. Sets the IAM access control policy on the specified function. Replaces any existing policy. Returns: Callable[[~.SetIamPolicyRequest], ~.Policy]: A function that, when called, will call the underlying RPC on the server. """ # 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 "set_iam_policy" not in self._stubs: self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, ) return self._stubs["set_iam_policy"]
@property def get_iam_policy( self, ) -> Callable[[iam_policy_pb2.GetIamPolicyRequest], policy_pb2.Policy]: r"""Return a callable for the get iam policy method over gRPC. Gets the IAM access control policy for a function. Returns an empty policy if the function exists and does not have a policy set. Returns: Callable[[~.GetIamPolicyRequest], ~.Policy]: A function that, when called, will call the underlying RPC on the server. """ # 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_iam_policy" not in self._stubs: self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, ) return self._stubs["get_iam_policy"]
@property def test_iam_permissions( self, ) -> Callable[ [iam_policy_pb2.TestIamPermissionsRequest], iam_policy_pb2.TestIamPermissionsResponse, ]: r"""Return a callable for the test iam permissions method over gRPC. Tests the specified permissions against the IAM access control policy for a function. If the function does not exist, this will return an empty set of permissions, not a NOT_FOUND error. Returns: Callable[[~.TestIamPermissionsRequest], ~.TestIamPermissionsResponse]: A function that, when called, will call the underlying RPC on the server. """ # 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 "test_iam_permissions" not in self._stubs: self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, ) return self._stubs["test_iam_permissions"]
__all__ = ("DatasetServiceGrpcAsyncIOTransport",)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354# -*- coding: utf-8 -*-# Copyright 2025 Google LLC## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.#from collections import OrderedDictfrom typing import Dict, Type, Tuple
from .base import EndpointServiceTransportfrom .grpc import EndpointServiceGrpcTransportfrom .grpc_asyncio import EndpointServiceGrpcAsyncIOTransportfrom .rest import EndpointServiceRestTransportfrom .rest import EndpointServiceRestInterceptor
ASYNC_REST_CLASSES: Tuple[str, ...]try: from .rest_asyncio import AsyncEndpointServiceRestTransport from .rest_asyncio import AsyncEndpointServiceRestInterceptor
ASYNC_REST_CLASSES = ( "AsyncEndpointServiceRestTransport", "AsyncEndpointServiceRestInterceptor", ) HAS_REST_ASYNC = Trueexcept ImportError: # pragma: NO COVER ASYNC_REST_CLASSES = () HAS_REST_ASYNC = False
# Compile a registry of transports._transport_registry = OrderedDict() # type: Dict[str, Type[EndpointServiceTransport]]_transport_registry["grpc"] = EndpointServiceGrpcTransport_transport_registry["grpc_asyncio"] = EndpointServiceGrpcAsyncIOTransport_transport_registry["rest"] = EndpointServiceRestTransportif HAS_REST_ASYNC: # pragma: NO COVER _transport_registry["rest_asyncio"] = AsyncEndpointServiceRestTransport
__all__ = ( "EndpointServiceTransport", "EndpointServiceGrpcTransport", "EndpointServiceGrpcAsyncIOTransport", "EndpointServiceRestTransport", "EndpointServiceRestInterceptor",) + ASYNC_REST_CLASSES123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446# -*- coding: utf-8 -*-# Copyright 2025 Google LLC## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.#import abcfrom typing import Awaitable, Callable, Dict, Optional, Sequence, Union
from google.cloud.aiplatform_v1 import gapic_version as package_version
import google.auth # type: ignoreimport google.api_corefrom google.api_core import exceptions as core_exceptionsfrom google.api_core import gapic_v1from google.api_core import retry as retriesfrom google.api_core import operations_v1from google.auth import credentials as ga_credentials # type: ignorefrom google.oauth2 import service_account # type: ignoreimport google.protobuf
from google.cloud.aiplatform_v1.types import endpointfrom google.cloud.aiplatform_v1.types import endpoint as gca_endpointfrom google.cloud.aiplatform_v1.types import endpoint_servicefrom google.cloud.location import locations_pb2 # type: ignorefrom google.iam.v1 import iam_policy_pb2 # type: ignorefrom google.iam.v1 import policy_pb2 # type: ignorefrom google.longrunning import operations_pb2 # type: ignore
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=package_version.__version__)
if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
class EndpointServiceTransport(abc.ABC): """Abstract transport class for EndpointService."""
AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",)
DEFAULT_HOST: str = "aiplatform.googleapis.com"
def __init__( self, *, host: str = DEFAULT_HOST, credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, api_audience: Optional[str] = None, **kwargs, ) -> None: """Instantiate the transport.
Args: host (Optional[str]): The hostname to connect to (default: 'aiplatform.googleapis.com'). credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none are specified, the client will attempt to ascertain the credentials from the environment. credentials_file (Optional[str]): Deprecated. A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is mutually exclusive with credentials. This argument will be removed in the next major version of this library. scopes (Optional[Sequence[str]]): A list of scopes. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): The client info used to send a user-agent string along with API requests. If ``None``, then default info will be used. Generally, you only need to set this if you're developing your own client library. always_use_jwt_access (Optional[bool]): Whether self signed JWT should be used for service account credentials. """
# Save the scopes. self._scopes = scopes if not hasattr(self, "_ignore_credentials"): self._ignore_credentials: bool = False
# If no credentials are provided, then determine the appropriate # defaults. if credentials and credentials_file: raise core_exceptions.DuplicateCredentialArgs( "'credentials_file' and 'credentials' are mutually exclusive" )
if credentials_file is not None: credentials, _ = google.auth.load_credentials_from_file( credentials_file, scopes=scopes, quota_project_id=quota_project_id, default_scopes=self.AUTH_SCOPES, ) elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( scopes=scopes, quota_project_id=quota_project_id, default_scopes=self.AUTH_SCOPES, ) # Don't apply audience if the credentials file passed from user. if hasattr(credentials, "with_gdch_audience"): credentials = credentials.with_gdch_audience( api_audience if api_audience else host )
# If the credentials are service account credentials, then always try to use self signed JWT. if ( always_use_jwt_access and isinstance(credentials, service_account.Credentials) and hasattr(service_account.Credentials, "with_always_use_jwt_access") ): credentials = credentials.with_always_use_jwt_access(True)
# Save the credentials. self._credentials = credentials
# Save the hostname. Default to port 443 (HTTPS) if none is specified. if ":" not in host: host += ":443" self._host = host
@property def host(self): return self._host
def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { self.create_endpoint: gapic_v1.method.wrap_method( self.create_endpoint, default_timeout=None, client_info=client_info, ), self.get_endpoint: gapic_v1.method.wrap_method( self.get_endpoint, default_timeout=None, client_info=client_info, ), self.list_endpoints: gapic_v1.method.wrap_method( self.list_endpoints, default_timeout=None, client_info=client_info, ), self.update_endpoint: gapic_v1.method.wrap_method( self.update_endpoint, default_timeout=None, client_info=client_info, ), self.update_endpoint_long_running: gapic_v1.method.wrap_method( self.update_endpoint_long_running, default_timeout=None, client_info=client_info, ), self.delete_endpoint: gapic_v1.method.wrap_method( self.delete_endpoint, default_timeout=None, client_info=client_info, ), self.deploy_model: gapic_v1.method.wrap_method( self.deploy_model, default_timeout=None, client_info=client_info, ), self.undeploy_model: gapic_v1.method.wrap_method( self.undeploy_model, default_timeout=None, client_info=client_info, ), self.mutate_deployed_model: gapic_v1.method.wrap_method( self.mutate_deployed_model, default_timeout=None, client_info=client_info, ), self.get_location: gapic_v1.method.wrap_method( self.get_location, default_timeout=None, client_info=client_info, ), self.list_locations: gapic_v1.method.wrap_method( self.list_locations, default_timeout=None, client_info=client_info, ), self.get_iam_policy: gapic_v1.method.wrap_method( self.get_iam_policy, default_timeout=None, client_info=client_info, ), self.set_iam_policy: gapic_v1.method.wrap_method( self.set_iam_policy, default_timeout=None, client_info=client_info, ), self.test_iam_permissions: gapic_v1.method.wrap_method( self.test_iam_permissions, default_timeout=None, client_info=client_info, ), self.cancel_operation: gapic_v1.method.wrap_method( self.cancel_operation, default_timeout=None, client_info=client_info, ), self.delete_operation: gapic_v1.method.wrap_method( self.delete_operation, default_timeout=None, client_info=client_info, ), self.get_operation: gapic_v1.method.wrap_method( self.get_operation, default_timeout=None, client_info=client_info, ), self.list_operations: gapic_v1.method.wrap_method( self.list_operations, default_timeout=None, client_info=client_info, ), self.wait_operation: gapic_v1.method.wrap_method( self.wait_operation, default_timeout=None, client_info=client_info, ), }
def close(self): """Closes resources associated with the transport.
.. warning:: Only call this method if the transport is NOT shared with other clients - this may cause errors in other clients! """ raise NotImplementedError()
@property def operations_client(self): """Return the client designed to process long-running operations.""" raise NotImplementedError()
@property def create_endpoint( self, ) -> Callable[ [endpoint_service.CreateEndpointRequest], Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError()
@property def get_endpoint( self, ) -> Callable[ [endpoint_service.GetEndpointRequest], Union[endpoint.Endpoint, Awaitable[endpoint.Endpoint]], ]: raise NotImplementedError()
@property def list_endpoints( self, ) -> Callable[ [endpoint_service.ListEndpointsRequest], Union[ endpoint_service.ListEndpointsResponse, Awaitable[endpoint_service.ListEndpointsResponse], ], ]: raise NotImplementedError()
@property def update_endpoint( self, ) -> Callable[ [endpoint_service.UpdateEndpointRequest], Union[gca_endpoint.Endpoint, Awaitable[gca_endpoint.Endpoint]], ]: raise NotImplementedError()
@property def update_endpoint_long_running( self, ) -> Callable[ [endpoint_service.UpdateEndpointLongRunningRequest], Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError()
@property def delete_endpoint( self, ) -> Callable[ [endpoint_service.DeleteEndpointRequest], Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError()
@property def deploy_model( self, ) -> Callable[ [endpoint_service.DeployModelRequest], Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError()
@property def undeploy_model( self, ) -> Callable[ [endpoint_service.UndeployModelRequest], Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError()
@property def mutate_deployed_model( self, ) -> Callable[ [endpoint_service.MutateDeployedModelRequest], Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError()
@property def list_operations( self, ) -> Callable[ [operations_pb2.ListOperationsRequest], Union[ operations_pb2.ListOperationsResponse, Awaitable[operations_pb2.ListOperationsResponse], ], ]: raise NotImplementedError()
@property def get_operation( self, ) -> Callable[ [operations_pb2.GetOperationRequest], Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError()
@property def cancel_operation( self, ) -> Callable[ [operations_pb2.CancelOperationRequest], None, ]: raise NotImplementedError()
@property def delete_operation( self, ) -> Callable[ [operations_pb2.DeleteOperationRequest], None, ]: raise NotImplementedError()
@property def wait_operation( self, ) -> Callable[ [operations_pb2.WaitOperationRequest], Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError()
@property def set_iam_policy( self, ) -> Callable[ [iam_policy_pb2.SetIamPolicyRequest], Union[policy_pb2.Policy, Awaitable[policy_pb2.Policy]], ]: raise NotImplementedError()
@property def get_iam_policy( self, ) -> Callable[ [iam_policy_pb2.GetIamPolicyRequest], Union[policy_pb2.Policy, Awaitable[policy_pb2.Policy]], ]: raise NotImplementedError()
@property def test_iam_permissions( self, ) -> Callable[ [iam_policy_pb2.TestIamPermissionsRequest], Union[ iam_policy_pb2.TestIamPermissionsResponse, Awaitable[iam_policy_pb2.TestIamPermissionsResponse], ], ]: 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()
__all__ = ("EndpointServiceTransport",)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809# -*- coding: utf-8 -*-# Copyright 2025 Google LLC## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.#import jsonimport logging as std_loggingimport pickleimport warningsfrom typing import Callable, Dict, Optional, Sequence, Tuple, Union
from google.api_core import grpc_helpersfrom google.api_core import operations_v1from google.api_core import gapic_v1import google.auth # type: ignorefrom google.auth import credentials as ga_credentials # type: ignorefrom google.auth.transport.grpc import SslCredentials # type: ignorefrom google.protobuf.json_format import MessageToJsonimport google.protobuf.message
import grpc # type: ignoreimport proto # type: ignore
from google.cloud.aiplatform_v1.types import endpointfrom google.cloud.aiplatform_v1.types import endpoint as gca_endpointfrom google.cloud.aiplatform_v1.types import endpoint_servicefrom google.cloud.location import locations_pb2 # type: ignorefrom google.iam.v1 import iam_policy_pb2 # type: ignorefrom google.iam.v1 import policy_pb2 # type: ignorefrom google.longrunning import operations_pb2 # type: ignorefrom .base import EndpointServiceTransport, DEFAULT_CLIENT_INFO
try: from google.api_core import client_logging # type: ignore
CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVERexcept ImportError: # pragma: NO COVER CLIENT_LOGGING_SUPPORTED = False
_LOGGER = std_logging.getLogger(__name__)
class _LoggingClientInterceptor(grpc.UnaryUnaryClientInterceptor): # pragma: NO COVER def intercept_unary_unary(self, continuation, client_call_details, request): logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( std_logging.DEBUG ) if logging_enabled: # pragma: NO COVER request_metadata = client_call_details.metadata if isinstance(request, proto.Message): request_payload = type(request).to_json(request) elif isinstance(request, google.protobuf.message.Message): request_payload = MessageToJson(request) else: request_payload = f"{type(request).__name__}: {pickle.dumps(request)}"
request_metadata = { key: value.decode("utf-8") if isinstance(value, bytes) else value for key, value in request_metadata } grpc_request = { "payload": request_payload, "requestMethod": "grpc", "metadata": dict(request_metadata), } _LOGGER.debug( f"Sending request for {client_call_details.method}", extra={ "serviceName": "google.cloud.aiplatform.v1.EndpointService", "rpcName": str(client_call_details.method), "request": grpc_request, "metadata": grpc_request["metadata"], }, ) response = continuation(client_call_details, request) if logging_enabled: # pragma: NO COVER response_metadata = response.trailing_metadata() # Convert gRPC metadata `<class 'grpc.aio._metadata.Metadata'>` to list of tuples metadata = ( dict([(k, str(v)) for k, v in response_metadata]) if response_metadata else None ) result = response.result() if isinstance(result, proto.Message): response_payload = type(result).to_json(result) elif isinstance(result, google.protobuf.message.Message): response_payload = MessageToJson(result) else: response_payload = f"{type(result).__name__}: {pickle.dumps(result)}" grpc_response = { "payload": response_payload, "metadata": metadata, "status": "OK", } _LOGGER.debug( f"Received response for {client_call_details.method}.", extra={ "serviceName": "google.cloud.aiplatform.v1.EndpointService", "rpcName": client_call_details.method, "response": grpc_response, "metadata": grpc_response["metadata"], }, ) return response
class EndpointServiceGrpcTransport(EndpointServiceTransport): """gRPC backend transport for EndpointService.
A service for managing Vertex AI's Endpoints.
This class defines the same methods as the primary client, so the primary client can load the underlying transport implementation and call it.
It sends protocol buffers over the wire using gRPC (which is built on top of HTTP/2); the ``grpcio`` package must be installed. """
_stubs: Dict[str, Callable]
def __init__( self, *, host: str = "aiplatform.googleapis.com", credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, channel: Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]] = None, api_mtls_endpoint: Optional[str] = None, client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, api_audience: Optional[str] = None, ) -> None: """Instantiate the transport.
Args: host (Optional[str]): The hostname to connect to (default: 'aiplatform.googleapis.com'). credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none are specified, the client will attempt to ascertain the credentials from the environment. This argument is ignored if a ``channel`` instance is provided. credentials_file (Optional[str]): Deprecated. A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is ignored if a ``channel`` instance is provided. This argument will be removed in the next major version of this library. scopes (Optional(Sequence[str])): A list of scopes. This argument is ignored if a ``channel`` instance is provided. channel (Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]]): A ``Channel`` instance through which to make calls, or a Callable that constructs and returns one. If set to None, ``self.create_channel`` is used to create the channel. If a Callable is given, it will be called with the same arguments as used in ``self.create_channel``. api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials for the grpc channel. It is ignored if a ``channel`` instance is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, both in PEM format. It is used to configure a mutual TLS channel. It is ignored if a ``channel`` instance or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): The client info used to send a user-agent string along with API requests. If ``None``, then default info will be used. Generally, you only need to set this if you're developing your own client library. always_use_jwt_access (Optional[bool]): Whether self signed JWT should be used for service account credentials.
Raises: google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport creation failed for any reason. google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ self._grpc_channel = None self._ssl_channel_credentials = ssl_channel_credentials self._stubs: Dict[str, Callable] = {} self._operations_client: Optional[operations_v1.OperationsClient] = None
if api_mtls_endpoint: warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) if client_cert_source: warnings.warn("client_cert_source is deprecated", DeprecationWarning)
if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. credentials = None self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None
else: if api_mtls_endpoint: host = api_mtls_endpoint
# Create SSL credentials with client_cert_source or application # default SSL credentials. if client_cert_source: cert, key = client_cert_source() self._ssl_channel_credentials = grpc.ssl_channel_credentials( certificate_chain=cert, private_key=key ) else: self._ssl_channel_credentials = SslCredentials().ssl_credentials
else: if client_cert_source_for_mtls and not ssl_channel_credentials: cert, key = client_cert_source_for_mtls() self._ssl_channel_credentials = grpc.ssl_channel_credentials( certificate_chain=cert, private_key=key )
# The base transport sets the host, credentials and scopes super().__init__( host=host, credentials=credentials, credentials_file=credentials_file, scopes=scopes, quota_project_id=quota_project_id, client_info=client_info, always_use_jwt_access=always_use_jwt_access, api_audience=api_audience, )
if not self._grpc_channel: # initialize with the provided callable or the default channel channel_init = channel or type(self).create_channel self._grpc_channel = channel_init( self._host, # use the credentials which are saved credentials=self._credentials, # Set ``credentials_file`` to ``None`` here as # the credentials that we saved earlier should be used. credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, options=[ ("grpc.max_send_message_length", -1), ("grpc.max_receive_message_length", -1), ], )
self._interceptor = _LoggingClientInterceptor() self._logged_channel = grpc.intercept_channel( self._grpc_channel, self._interceptor )
# Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info)
@classmethod def create_channel( cls, host: str = "aiplatform.googleapis.com", credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, **kwargs, ) -> grpc.Channel: """Create and return a gRPC channel object. Args: host (Optional[str]): The host for the channel to use. credentials (Optional[~.Credentials]): The authorization credentials to attach to requests. These credentials identify this application to the service. If none are specified, the client will attempt to ascertain the credentials from the environment. credentials_file (Optional[str]): Deprecated. A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is mutually exclusive with credentials. This argument will be removed in the next major version of this library. scopes (Optional[Sequence[str]]): A optional list of scopes needed for this service. These are only used when credentials are not specified and are passed to :func:`google.auth.default`. quota_project_id (Optional[str]): An optional project to use for billing and quota. kwargs (Optional[dict]): Keyword arguments, which are passed to the channel creation. Returns: grpc.Channel: A gRPC channel object.
Raises: google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """
return grpc_helpers.create_channel( host, credentials=credentials, credentials_file=credentials_file, quota_project_id=quota_project_id, default_scopes=cls.AUTH_SCOPES, scopes=scopes, default_host=cls.DEFAULT_HOST, **kwargs, )
@property def grpc_channel(self) -> grpc.Channel: """Return the channel designed to connect to this service.""" return self._grpc_channel
@property def operations_client(self) -> operations_v1.OperationsClient: """Create the client designed to process long-running operations.
This property caches on the instance; repeated calls return the same client. """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsClient( self._logged_channel )
# Return the client from cache. return self._operations_client
@property def create_endpoint( self, ) -> Callable[[endpoint_service.CreateEndpointRequest], operations_pb2.Operation]: r"""Return a callable for the create endpoint method over gRPC.
Creates an Endpoint.
Returns: Callable[[~.CreateEndpointRequest], ~.Operation]: A function that, when called, will call the underlying RPC on the server. """ # 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 "create_endpoint" not in self._stubs: self._stubs["create_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.EndpointService/CreateEndpoint", request_serializer=endpoint_service.CreateEndpointRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_endpoint"]
@property def get_endpoint( self, ) -> Callable[[endpoint_service.GetEndpointRequest], endpoint.Endpoint]: r"""Return a callable for the get endpoint method over gRPC.
Gets an Endpoint.
Returns: Callable[[~.GetEndpointRequest], ~.Endpoint]: A function that, when called, will call the underlying RPC on the server. """ # 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_endpoint" not in self._stubs: self._stubs["get_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.EndpointService/GetEndpoint", request_serializer=endpoint_service.GetEndpointRequest.serialize, response_deserializer=endpoint.Endpoint.deserialize, ) return self._stubs["get_endpoint"]
@property def list_endpoints( self, ) -> Callable[ [endpoint_service.ListEndpointsRequest], endpoint_service.ListEndpointsResponse ]: r"""Return a callable for the list endpoints method over gRPC.
Lists Endpoints in a Location.
Returns: Callable[[~.ListEndpointsRequest], ~.ListEndpointsResponse]: A function that, when called, will call the underlying RPC on the server. """ # 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_endpoints" not in self._stubs: self._stubs["list_endpoints"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.EndpointService/ListEndpoints", request_serializer=endpoint_service.ListEndpointsRequest.serialize, response_deserializer=endpoint_service.ListEndpointsResponse.deserialize, ) return self._stubs["list_endpoints"]
@property def update_endpoint( self, ) -> Callable[[endpoint_service.UpdateEndpointRequest], gca_endpoint.Endpoint]: r"""Return a callable for the update endpoint method over gRPC.
Updates an Endpoint.
Returns: Callable[[~.UpdateEndpointRequest], ~.Endpoint]: A function that, when called, will call the underlying RPC on the server. """ # 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 "update_endpoint" not in self._stubs: self._stubs["update_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.EndpointService/UpdateEndpoint", request_serializer=endpoint_service.UpdateEndpointRequest.serialize, response_deserializer=gca_endpoint.Endpoint.deserialize, ) return self._stubs["update_endpoint"]
@property def update_endpoint_long_running( self, ) -> Callable[ [endpoint_service.UpdateEndpointLongRunningRequest], operations_pb2.Operation ]: r"""Return a callable for the update endpoint long running method over gRPC.
Updates an Endpoint with a long running operation.
Returns: Callable[[~.UpdateEndpointLongRunningRequest], ~.Operation]: A function that, when called, will call the underlying RPC on the server. """ # 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 "update_endpoint_long_running" not in self._stubs: self._stubs["update_endpoint_long_running"] = ( self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.EndpointService/UpdateEndpointLongRunning", request_serializer=endpoint_service.UpdateEndpointLongRunningRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) ) return self._stubs["update_endpoint_long_running"]
@property def delete_endpoint( self, ) -> Callable[[endpoint_service.DeleteEndpointRequest], operations_pb2.Operation]: r"""Return a callable for the delete endpoint method over gRPC.
Deletes an Endpoint.
Returns: Callable[[~.DeleteEndpointRequest], ~.Operation]: A function that, when called, will call the underlying RPC on the server. """ # 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 "delete_endpoint" not in self._stubs: self._stubs["delete_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.EndpointService/DeleteEndpoint", request_serializer=endpoint_service.DeleteEndpointRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_endpoint"]
@property def deploy_model( self, ) -> Callable[[endpoint_service.DeployModelRequest], operations_pb2.Operation]: r"""Return a callable for the deploy model method over gRPC.
Deploys a Model into this Endpoint, creating a DeployedModel within it.
Returns: Callable[[~.DeployModelRequest], ~.Operation]: A function that, when called, will call the underlying RPC on the server. """ # 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 "deploy_model" not in self._stubs: self._stubs["deploy_model"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.EndpointService/DeployModel", request_serializer=endpoint_service.DeployModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["deploy_model"]
@property def undeploy_model( self, ) -> Callable[[endpoint_service.UndeployModelRequest], operations_pb2.Operation]: r"""Return a callable for the undeploy model method over gRPC.
Undeploys a Model from an Endpoint, removing a DeployedModel from it, and freeing all resources it's using.
Returns: Callable[[~.UndeployModelRequest], ~.Operation]: A function that, when called, will call the underlying RPC on the server. """ # 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 "undeploy_model" not in self._stubs: self._stubs["undeploy_model"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.EndpointService/UndeployModel", request_serializer=endpoint_service.UndeployModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["undeploy_model"]
@property def mutate_deployed_model( self, ) -> Callable[ [endpoint_service.MutateDeployedModelRequest], operations_pb2.Operation ]: r"""Return a callable for the mutate deployed model method over gRPC.
Updates an existing deployed model. Updatable fields include ``min_replica_count``, ``max_replica_count``, ``required_replica_count``, ``autoscaling_metric_specs``, ``disable_container_logging`` (v1 only), and ``enable_container_logging`` (v1beta1 only).
Returns: Callable[[~.MutateDeployedModelRequest], ~.Operation]: A function that, when called, will call the underlying RPC on the server. """ # 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 "mutate_deployed_model" not in self._stubs: self._stubs["mutate_deployed_model"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.EndpointService/MutateDeployedModel", request_serializer=endpoint_service.MutateDeployedModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["mutate_deployed_model"]
def close(self): self._logged_channel.close()
@property def delete_operation( self, ) -> Callable[[operations_pb2.DeleteOperationRequest], None]: r"""Return a callable for the delete_operation 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 "delete_operation" not in self._stubs: self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, ) return self._stubs["delete_operation"]
@property def cancel_operation( self, ) -> Callable[[operations_pb2.CancelOperationRequest], None]: r"""Return a callable for the cancel_operation 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 "cancel_operation" not in self._stubs: self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, ) return self._stubs["cancel_operation"]
@property def wait_operation( self, ) -> Callable[[operations_pb2.WaitOperationRequest], None]: r"""Return a callable for the wait_operation 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 "wait_operation" not in self._stubs: self._stubs["wait_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/WaitOperation", request_serializer=operations_pb2.WaitOperationRequest.SerializeToString, response_deserializer=None, ) return self._stubs["wait_operation"]
@property def get_operation( self, ) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]: r"""Return a callable for the get_operation 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_operation" not in self._stubs: self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["get_operation"]
@property def list_operations( self, ) -> Callable[ [operations_pb2.ListOperationsRequest], operations_pb2.ListOperationsResponse ]: r"""Return a callable for the list_operations 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_operations" not in self._stubs: self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, ) return self._stubs["list_operations"]
@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._logged_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._logged_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 set_iam_policy( self, ) -> Callable[[iam_policy_pb2.SetIamPolicyRequest], policy_pb2.Policy]: r"""Return a callable for the set iam policy method over gRPC. Sets the IAM access control policy on the specified function. Replaces any existing policy. Returns: Callable[[~.SetIamPolicyRequest], ~.Policy]: A function that, when called, will call the underlying RPC on the server. """ # 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 "set_iam_policy" not in self._stubs: self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, ) return self._stubs["set_iam_policy"]
@property def get_iam_policy( self, ) -> Callable[[iam_policy_pb2.GetIamPolicyRequest], policy_pb2.Policy]: r"""Return a callable for the get iam policy method over gRPC. Gets the IAM access control policy for a function. Returns an empty policy if the function exists and does not have a policy set. Returns: Callable[[~.GetIamPolicyRequest], ~.Policy]: A function that, when called, will call the underlying RPC on the server. """ # 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_iam_policy" not in self._stubs: self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, ) return self._stubs["get_iam_policy"]
@property def test_iam_permissions( self, ) -> Callable[ [iam_policy_pb2.TestIamPermissionsRequest], iam_policy_pb2.TestIamPermissionsResponse, ]: r"""Return a callable for the test iam permissions method over gRPC. Tests the specified permissions against the IAM access control policy for a function. If the function does not exist, this will return an empty set of permissions, not a NOT_FOUND error. Returns: Callable[[~.TestIamPermissionsRequest], ~.TestIamPermissionsResponse]: A function that, when called, will call the underlying RPC on the server. """ # 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 "test_iam_permissions" not in self._stubs: self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, ) return self._stubs["test_iam_permissions"]
@property def kind(self) -> str: return "grpc"
__all__ = ("EndpointServiceGrpcTransport",)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935# -*- coding: utf-8 -*-# Copyright 2025 Google LLC## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.#import inspectimport jsonimport pickleimport logging as std_loggingimport warningsfrom typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union
from google.api_core import gapic_v1from google.api_core import grpc_helpers_asyncfrom google.api_core import exceptions as core_exceptionsfrom google.api_core import retry_async as retriesfrom google.api_core import operations_v1from google.auth import credentials as ga_credentials # type: ignorefrom google.auth.transport.grpc import SslCredentials # type: ignorefrom google.protobuf.json_format import MessageToJsonimport google.protobuf.message
import grpc # type: ignoreimport proto # type: ignorefrom grpc.experimental import aio # type: ignore
from google.cloud.aiplatform_v1.types import endpointfrom google.cloud.aiplatform_v1.types import endpoint as gca_endpointfrom google.cloud.aiplatform_v1.types import endpoint_servicefrom google.cloud.location import locations_pb2 # type: ignorefrom google.iam.v1 import iam_policy_pb2 # type: ignorefrom google.iam.v1 import policy_pb2 # type: ignorefrom google.longrunning import operations_pb2 # type: ignorefrom .base import EndpointServiceTransport, DEFAULT_CLIENT_INFOfrom .grpc import EndpointServiceGrpcTransport
try: from google.api_core import client_logging # type: ignore
CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVERexcept ImportError: # pragma: NO COVER CLIENT_LOGGING_SUPPORTED = False
_LOGGER = std_logging.getLogger(__name__)
class _LoggingClientAIOInterceptor( grpc.aio.UnaryUnaryClientInterceptor): # pragma: NO COVER async def intercept_unary_unary(self, continuation, client_call_details, request): logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( std_logging.DEBUG ) if logging_enabled: # pragma: NO COVER request_metadata = client_call_details.metadata if isinstance(request, proto.Message): request_payload = type(request).to_json(request) elif isinstance(request, google.protobuf.message.Message): request_payload = MessageToJson(request) else: request_payload = f"{type(request).__name__}: {pickle.dumps(request)}"
request_metadata = { key: value.decode("utf-8") if isinstance(value, bytes) else value for key, value in request_metadata } grpc_request = { "payload": request_payload, "requestMethod": "grpc", "metadata": dict(request_metadata), } _LOGGER.debug( f"Sending request for {client_call_details.method}", extra={ "serviceName": "google.cloud.aiplatform.v1.EndpointService", "rpcName": str(client_call_details.method), "request": grpc_request, "metadata": grpc_request["metadata"], }, ) response = await continuation(client_call_details, request) if logging_enabled: # pragma: NO COVER response_metadata = await response.trailing_metadata() # Convert gRPC metadata `<class 'grpc.aio._metadata.Metadata'>` to list of tuples metadata = ( dict([(k, str(v)) for k, v in response_metadata]) if response_metadata else None ) result = await response if isinstance(result, proto.Message): response_payload = type(result).to_json(result) elif isinstance(result, google.protobuf.message.Message): response_payload = MessageToJson(result) else: response_payload = f"{type(result).__name__}: {pickle.dumps(result)}" grpc_response = { "payload": response_payload, "metadata": metadata, "status": "OK", } _LOGGER.debug( f"Received response to rpc {client_call_details.method}.", extra={ "serviceName": "google.cloud.aiplatform.v1.EndpointService", "rpcName": str(client_call_details.method), "response": grpc_response, "metadata": grpc_response["metadata"], }, ) return response
class EndpointServiceGrpcAsyncIOTransport(EndpointServiceTransport): """gRPC AsyncIO backend transport for EndpointService.
A service for managing Vertex AI's Endpoints.
This class defines the same methods as the primary client, so the primary client can load the underlying transport implementation and call it.
It sends protocol buffers over the wire using gRPC (which is built on top of HTTP/2); the ``grpcio`` package must be installed. """
_grpc_channel: aio.Channel _stubs: Dict[str, Callable] = {}
@classmethod def create_channel( cls, host: str = "aiplatform.googleapis.com", credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, **kwargs, ) -> aio.Channel: """Create and return a gRPC AsyncIO channel object. Args: host (Optional[str]): The host for the channel to use. credentials (Optional[~.Credentials]): The authorization credentials to attach to requests. These credentials identify this application to the service. If none are specified, the client will attempt to ascertain the credentials from the environment. credentials_file (Optional[str]): Deprecated. A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument will be removed in the next major version of this library. scopes (Optional[Sequence[str]]): A optional list of scopes needed for this service. These are only used when credentials are not specified and are passed to :func:`google.auth.default`. quota_project_id (Optional[str]): An optional project to use for billing and quota. kwargs (Optional[dict]): Keyword arguments, which are passed to the channel creation. Returns: aio.Channel: A gRPC AsyncIO channel object. """
return grpc_helpers_async.create_channel( host, credentials=credentials, credentials_file=credentials_file, quota_project_id=quota_project_id, default_scopes=cls.AUTH_SCOPES, scopes=scopes, default_host=cls.DEFAULT_HOST, **kwargs, )
def __init__( self, *, host: str = "aiplatform.googleapis.com", credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, channel: Optional[Union[aio.Channel, Callable[..., aio.Channel]]] = None, api_mtls_endpoint: Optional[str] = None, client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, api_audience: Optional[str] = None, ) -> None: """Instantiate the transport.
Args: host (Optional[str]): The hostname to connect to (default: 'aiplatform.googleapis.com'). credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none are specified, the client will attempt to ascertain the credentials from the environment. This argument is ignored if a ``channel`` instance is provided. credentials_file (Optional[str]): Deprecated. A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is ignored if a ``channel`` instance is provided. This argument will be removed in the next major version of this library. scopes (Optional[Sequence[str]]): A optional list of scopes needed for this service. These are only used when credentials are not specified and are passed to :func:`google.auth.default`. channel (Optional[Union[aio.Channel, Callable[..., aio.Channel]]]): A ``Channel`` instance through which to make calls, or a Callable that constructs and returns one. If set to None, ``self.create_channel`` is used to create the channel. If a Callable is given, it will be called with the same arguments as used in ``self.create_channel``. api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials for the grpc channel. It is ignored if a ``channel`` instance is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, both in PEM format. It is used to configure a mutual TLS channel. It is ignored if a ``channel`` instance or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): The client info used to send a user-agent string along with API requests. If ``None``, then default info will be used. Generally, you only need to set this if you're developing your own client library. always_use_jwt_access (Optional[bool]): Whether self signed JWT should be used for service account credentials.
Raises: google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport creation failed for any reason. google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ self._grpc_channel = None self._ssl_channel_credentials = ssl_channel_credentials self._stubs: Dict[str, Callable] = {} self._operations_client: Optional[operations_v1.OperationsAsyncClient] = None
if api_mtls_endpoint: warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) if client_cert_source: warnings.warn("client_cert_source is deprecated", DeprecationWarning)
if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. credentials = None self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None else: if api_mtls_endpoint: host = api_mtls_endpoint
# Create SSL credentials with client_cert_source or application # default SSL credentials. if client_cert_source: cert, key = client_cert_source() self._ssl_channel_credentials = grpc.ssl_channel_credentials( certificate_chain=cert, private_key=key ) else: self._ssl_channel_credentials = SslCredentials().ssl_credentials
else: if client_cert_source_for_mtls and not ssl_channel_credentials: cert, key = client_cert_source_for_mtls() self._ssl_channel_credentials = grpc.ssl_channel_credentials( certificate_chain=cert, private_key=key )
# The base transport sets the host, credentials and scopes super().__init__( host=host, credentials=credentials, credentials_file=credentials_file, scopes=scopes, quota_project_id=quota_project_id, client_info=client_info, always_use_jwt_access=always_use_jwt_access, api_audience=api_audience, )
if not self._grpc_channel: # initialize with the provided callable or the default channel channel_init = channel or type(self).create_channel self._grpc_channel = channel_init( self._host, # use the credentials which are saved credentials=self._credentials, # Set ``credentials_file`` to ``None`` here as # the credentials that we saved earlier should be used. credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, options=[ ("grpc.max_send_message_length", -1), ("grpc.max_receive_message_length", -1), ], )
self._interceptor = _LoggingClientAIOInterceptor() self._grpc_channel._unary_unary_interceptors.append(self._interceptor) self._logged_channel = self._grpc_channel self._wrap_with_kind = ( "kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters ) # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info)
@property def grpc_channel(self) -> aio.Channel: """Create the channel designed to connect to this service.
This property caches on the instance; repeated calls return the same channel. """ # Return the channel from cache. return self._grpc_channel
@property def operations_client(self) -> operations_v1.OperationsAsyncClient: """Create the client designed to process long-running operations.
This property caches on the instance; repeated calls return the same client. """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( self._logged_channel )
# Return the client from cache. return self._operations_client
@property def create_endpoint( self, ) -> Callable[ [endpoint_service.CreateEndpointRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the create endpoint method over gRPC.
Creates an Endpoint.
Returns: Callable[[~.CreateEndpointRequest], Awaitable[~.Operation]]: A function that, when called, will call the underlying RPC on the server. """ # 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 "create_endpoint" not in self._stubs: self._stubs["create_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.EndpointService/CreateEndpoint", request_serializer=endpoint_service.CreateEndpointRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_endpoint"]
@property def get_endpoint( self, ) -> Callable[[endpoint_service.GetEndpointRequest], Awaitable[endpoint.Endpoint]]: r"""Return a callable for the get endpoint method over gRPC.
Gets an Endpoint.
Returns: Callable[[~.GetEndpointRequest], Awaitable[~.Endpoint]]: A function that, when called, will call the underlying RPC on the server. """ # 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_endpoint" not in self._stubs: self._stubs["get_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.EndpointService/GetEndpoint", request_serializer=endpoint_service.GetEndpointRequest.serialize, response_deserializer=endpoint.Endpoint.deserialize, ) return self._stubs["get_endpoint"]
@property def list_endpoints( self, ) -> Callable[ [endpoint_service.ListEndpointsRequest], Awaitable[endpoint_service.ListEndpointsResponse], ]: r"""Return a callable for the list endpoints method over gRPC.
Lists Endpoints in a Location.
Returns: Callable[[~.ListEndpointsRequest], Awaitable[~.ListEndpointsResponse]]: A function that, when called, will call the underlying RPC on the server. """ # 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_endpoints" not in self._stubs: self._stubs["list_endpoints"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.EndpointService/ListEndpoints", request_serializer=endpoint_service.ListEndpointsRequest.serialize, response_deserializer=endpoint_service.ListEndpointsResponse.deserialize, ) return self._stubs["list_endpoints"]
@property def update_endpoint( self, ) -> Callable[ [endpoint_service.UpdateEndpointRequest], Awaitable[gca_endpoint.Endpoint] ]: r"""Return a callable for the update endpoint method over gRPC.
Updates an Endpoint.
Returns: Callable[[~.UpdateEndpointRequest], Awaitable[~.Endpoint]]: A function that, when called, will call the underlying RPC on the server. """ # 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 "update_endpoint" not in self._stubs: self._stubs["update_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.EndpointService/UpdateEndpoint", request_serializer=endpoint_service.UpdateEndpointRequest.serialize, response_deserializer=gca_endpoint.Endpoint.deserialize, ) return self._stubs["update_endpoint"]
@property def update_endpoint_long_running( self, ) -> Callable[ [endpoint_service.UpdateEndpointLongRunningRequest], Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the update endpoint long running method over gRPC.
Updates an Endpoint with a long running operation.
Returns: Callable[[~.UpdateEndpointLongRunningRequest], Awaitable[~.Operation]]: A function that, when called, will call the underlying RPC on the server. """ # 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 "update_endpoint_long_running" not in self._stubs: self._stubs["update_endpoint_long_running"] = ( self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.EndpointService/UpdateEndpointLongRunning", request_serializer=endpoint_service.UpdateEndpointLongRunningRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) ) return self._stubs["update_endpoint_long_running"]
@property def delete_endpoint( self, ) -> Callable[ [endpoint_service.DeleteEndpointRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the delete endpoint method over gRPC.
Deletes an Endpoint.
Returns: Callable[[~.DeleteEndpointRequest], Awaitable[~.Operation]]: A function that, when called, will call the underlying RPC on the server. """ # 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 "delete_endpoint" not in self._stubs: self._stubs["delete_endpoint"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.EndpointService/DeleteEndpoint", request_serializer=endpoint_service.DeleteEndpointRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_endpoint"]
@property def deploy_model( self, ) -> Callable[ [endpoint_service.DeployModelRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the deploy model method over gRPC.
Deploys a Model into this Endpoint, creating a DeployedModel within it.
Returns: Callable[[~.DeployModelRequest], Awaitable[~.Operation]]: A function that, when called, will call the underlying RPC on the server. """ # 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 "deploy_model" not in self._stubs: self._stubs["deploy_model"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.EndpointService/DeployModel", request_serializer=endpoint_service.DeployModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["deploy_model"]
@property def undeploy_model( self, ) -> Callable[ [endpoint_service.UndeployModelRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the undeploy model method over gRPC.
Undeploys a Model from an Endpoint, removing a DeployedModel from it, and freeing all resources it's using.
Returns: Callable[[~.UndeployModelRequest], Awaitable[~.Operation]]: A function that, when called, will call the underlying RPC on the server. """ # 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 "undeploy_model" not in self._stubs: self._stubs["undeploy_model"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.EndpointService/UndeployModel", request_serializer=endpoint_service.UndeployModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["undeploy_model"]
@property def mutate_deployed_model( self, ) -> Callable[ [endpoint_service.MutateDeployedModelRequest], Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the mutate deployed model method over gRPC.
Updates an existing deployed model. Updatable fields include ``min_replica_count``, ``max_replica_count``, ``required_replica_count``, ``autoscaling_metric_specs``, ``disable_container_logging`` (v1 only), and ``enable_container_logging`` (v1beta1 only).
Returns: Callable[[~.MutateDeployedModelRequest], Awaitable[~.Operation]]: A function that, when called, will call the underlying RPC on the server. """ # 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 "mutate_deployed_model" not in self._stubs: self._stubs["mutate_deployed_model"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.EndpointService/MutateDeployedModel", request_serializer=endpoint_service.MutateDeployedModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["mutate_deployed_model"]
def _prep_wrapped_messages(self, client_info): """Precompute the wrapped methods, overriding the base class method to use async wrappers.""" self._wrapped_methods = { self.create_endpoint: self._wrap_method( self.create_endpoint, default_timeout=None, client_info=client_info, ), self.get_endpoint: self._wrap_method( self.get_endpoint, default_timeout=None, client_info=client_info, ), self.list_endpoints: self._wrap_method( self.list_endpoints, default_timeout=None, client_info=client_info, ), self.update_endpoint: self._wrap_method( self.update_endpoint, default_timeout=None, client_info=client_info, ), self.update_endpoint_long_running: self._wrap_method( self.update_endpoint_long_running, default_timeout=None, client_info=client_info, ), self.delete_endpoint: self._wrap_method( self.delete_endpoint, default_timeout=None, client_info=client_info, ), self.deploy_model: self._wrap_method( self.deploy_model, default_timeout=None, client_info=client_info, ), self.undeploy_model: self._wrap_method( self.undeploy_model, default_timeout=None, client_info=client_info, ), self.mutate_deployed_model: self._wrap_method( self.mutate_deployed_model, default_timeout=None, client_info=client_info, ), self.get_location: self._wrap_method( self.get_location, default_timeout=None, client_info=client_info, ), self.list_locations: self._wrap_method( self.list_locations, default_timeout=None, client_info=client_info, ), self.get_iam_policy: self._wrap_method( self.get_iam_policy, default_timeout=None, client_info=client_info, ), self.set_iam_policy: self._wrap_method( self.set_iam_policy, default_timeout=None, client_info=client_info, ), self.test_iam_permissions: self._wrap_method( self.test_iam_permissions, default_timeout=None, client_info=client_info, ), self.cancel_operation: self._wrap_method( self.cancel_operation, default_timeout=None, client_info=client_info, ), self.delete_operation: self._wrap_method( self.delete_operation, default_timeout=None, client_info=client_info, ), self.get_operation: self._wrap_method( self.get_operation, default_timeout=None, client_info=client_info, ), self.list_operations: self._wrap_method( self.list_operations, default_timeout=None, client_info=client_info, ), self.wait_operation: self._wrap_method( self.wait_operation, default_timeout=None, client_info=client_info, ), }
def _wrap_method(self, func, *args, **kwargs): if self._wrap_with_kind: # pragma: NO COVER kwargs["kind"] = self.kind return gapic_v1.method_async.wrap_method(func, *args, **kwargs)
def close(self): return self._logged_channel.close()
@property def kind(self) -> str: return "grpc_asyncio"
@property def delete_operation( self, ) -> Callable[[operations_pb2.DeleteOperationRequest], None]: r"""Return a callable for the delete_operation 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 "delete_operation" not in self._stubs: self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, ) return self._stubs["delete_operation"]
@property def cancel_operation( self, ) -> Callable[[operations_pb2.CancelOperationRequest], None]: r"""Return a callable for the cancel_operation 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 "cancel_operation" not in self._stubs: self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, ) return self._stubs["cancel_operation"]
@property def wait_operation( self, ) -> Callable[[operations_pb2.WaitOperationRequest], None]: r"""Return a callable for the wait_operation 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 "wait_operation" not in self._stubs: self._stubs["wait_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/WaitOperation", request_serializer=operations_pb2.WaitOperationRequest.SerializeToString, response_deserializer=None, ) return self._stubs["wait_operation"]
@property def get_operation( self, ) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]: r"""Return a callable for the get_operation 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_operation" not in self._stubs: self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["get_operation"]
@property def list_operations( self, ) -> Callable[ [operations_pb2.ListOperationsRequest], operations_pb2.ListOperationsResponse ]: r"""Return a callable for the list_operations 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_operations" not in self._stubs: self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, ) return self._stubs["list_operations"]
@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._logged_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._logged_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 set_iam_policy( self, ) -> Callable[[iam_policy_pb2.SetIamPolicyRequest], policy_pb2.Policy]: r"""Return a callable for the set iam policy method over gRPC. Sets the IAM access control policy on the specified function. Replaces any existing policy. Returns: Callable[[~.SetIamPolicyRequest], ~.Policy]: A function that, when called, will call the underlying RPC on the server. """ # 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 "set_iam_policy" not in self._stubs: self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, ) return self._stubs["set_iam_policy"]
@property def get_iam_policy( self, ) -> Callable[[iam_policy_pb2.GetIamPolicyRequest], policy_pb2.Policy]: r"""Return a callable for the get iam policy method over gRPC. Gets the IAM access control policy for a function. Returns an empty policy if the function exists and does not have a policy set. Returns: Callable[[~.GetIamPolicyRequest], ~.Policy]: A function that, when called, will call the underlying RPC on the server. """ # 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_iam_policy" not in self._stubs: self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, ) return self._stubs["get_iam_policy"]
@property def test_iam_permissions( self, ) -> Callable[ [iam_policy_pb2.TestIamPermissionsRequest], iam_policy_pb2.TestIamPermissionsResponse, ]: r"""Return a callable for the test iam permissions method over gRPC. Tests the specified permissions against the IAM access control policy for a function. If the function does not exist, this will return an empty set of permissions, not a NOT_FOUND error. Returns: Callable[[~.TestIamPermissionsRequest], ~.TestIamPermissionsResponse]: A function that, when called, will call the underlying RPC on the server. """ # 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 "test_iam_permissions" not in self._stubs: self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, ) return self._stubs["test_iam_permissions"]
__all__ = ("EndpointServiceGrpcAsyncIOTransport",)1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556# -*- coding: utf-8 -*-# Copyright 2025 Google LLC## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.#from collections import OrderedDictfrom typing import Dict, Type, Tuple
from .base import FeatureOnlineStoreServiceTransportfrom .grpc import FeatureOnlineStoreServiceGrpcTransportfrom .grpc_asyncio import FeatureOnlineStoreServiceGrpcAsyncIOTransportfrom .rest import FeatureOnlineStoreServiceRestTransportfrom .rest import FeatureOnlineStoreServiceRestInterceptor
ASYNC_REST_CLASSES: Tuple[str, ...]try: from .rest_asyncio import AsyncFeatureOnlineStoreServiceRestTransport from .rest_asyncio import AsyncFeatureOnlineStoreServiceRestInterceptor
ASYNC_REST_CLASSES = ( "AsyncFeatureOnlineStoreServiceRestTransport", "AsyncFeatureOnlineStoreServiceRestInterceptor", ) HAS_REST_ASYNC = Trueexcept ImportError: # pragma: NO COVER ASYNC_REST_CLASSES = () HAS_REST_ASYNC = False
# Compile a registry of transports._transport_registry = ( OrderedDict()) # type: Dict[str, Type[FeatureOnlineStoreServiceTransport]]_transport_registry["grpc"] = FeatureOnlineStoreServiceGrpcTransport_transport_registry["grpc_asyncio"] = FeatureOnlineStoreServiceGrpcAsyncIOTransport_transport_registry["rest"] = FeatureOnlineStoreServiceRestTransportif HAS_REST_ASYNC: # pragma: NO COVER _transport_registry["rest_asyncio"] = AsyncFeatureOnlineStoreServiceRestTransport
__all__ = ( "FeatureOnlineStoreServiceTransport", "FeatureOnlineStoreServiceGrpcTransport", "FeatureOnlineStoreServiceGrpcAsyncIOTransport", "FeatureOnlineStoreServiceRestTransport", "FeatureOnlineStoreServiceRestInterceptor",) + ASYNC_REST_CLASSES123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377# -*- coding: utf-8 -*-# Copyright 2025 Google LLC## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.#import abcfrom typing import Awaitable, Callable, Dict, Optional, Sequence, Union
from google.cloud.aiplatform_v1 import gapic_version as package_version
import google.auth # type: ignoreimport google.api_corefrom google.api_core import exceptions as core_exceptionsfrom google.api_core import gapic_v1from google.api_core import retry as retriesfrom google.auth import credentials as ga_credentials # type: ignorefrom google.oauth2 import service_account # type: ignoreimport google.protobuf
from google.cloud.aiplatform_v1.types import feature_online_store_servicefrom google.cloud.location import locations_pb2 # type: ignorefrom google.iam.v1 import iam_policy_pb2 # type: ignorefrom google.iam.v1 import policy_pb2 # type: ignorefrom google.longrunning import operations_pb2 # type: ignore
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=package_version.__version__)
if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
class FeatureOnlineStoreServiceTransport(abc.ABC): """Abstract transport class for FeatureOnlineStoreService."""
AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",)
DEFAULT_HOST: str = "aiplatform.googleapis.com"
def __init__( self, *, host: str = DEFAULT_HOST, credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, api_audience: Optional[str] = None, **kwargs, ) -> None: """Instantiate the transport.
Args: host (Optional[str]): The hostname to connect to (default: 'aiplatform.googleapis.com'). credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none are specified, the client will attempt to ascertain the credentials from the environment. credentials_file (Optional[str]): Deprecated. A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is mutually exclusive with credentials. This argument will be removed in the next major version of this library. scopes (Optional[Sequence[str]]): A list of scopes. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): The client info used to send a user-agent string along with API requests. If ``None``, then default info will be used. Generally, you only need to set this if you're developing your own client library. always_use_jwt_access (Optional[bool]): Whether self signed JWT should be used for service account credentials. """
# Save the scopes. self._scopes = scopes if not hasattr(self, "_ignore_credentials"): self._ignore_credentials: bool = False
# If no credentials are provided, then determine the appropriate # defaults. if credentials and credentials_file: raise core_exceptions.DuplicateCredentialArgs( "'credentials_file' and 'credentials' are mutually exclusive" )
if credentials_file is not None: credentials, _ = google.auth.load_credentials_from_file( credentials_file, scopes=scopes, quota_project_id=quota_project_id, default_scopes=self.AUTH_SCOPES, ) elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( scopes=scopes, quota_project_id=quota_project_id, default_scopes=self.AUTH_SCOPES, ) # Don't apply audience if the credentials file passed from user. if hasattr(credentials, "with_gdch_audience"): credentials = credentials.with_gdch_audience( api_audience if api_audience else host )
# If the credentials are service account credentials, then always try to use self signed JWT. if ( always_use_jwt_access and isinstance(credentials, service_account.Credentials) and hasattr(service_account.Credentials, "with_always_use_jwt_access") ): credentials = credentials.with_always_use_jwt_access(True)
# Save the credentials. self._credentials = credentials
# Save the hostname. Default to port 443 (HTTPS) if none is specified. if ":" not in host: host += ":443" self._host = host
@property def host(self): return self._host
def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { self.fetch_feature_values: gapic_v1.method.wrap_method( self.fetch_feature_values, default_timeout=None, client_info=client_info, ), self.search_nearest_entities: gapic_v1.method.wrap_method( self.search_nearest_entities, default_timeout=None, client_info=client_info, ), self.feature_view_direct_write: gapic_v1.method.wrap_method( self.feature_view_direct_write, default_timeout=None, client_info=client_info, ), self.generate_fetch_access_token: gapic_v1.method.wrap_method( self.generate_fetch_access_token, default_timeout=None, client_info=client_info, ), self.get_location: gapic_v1.method.wrap_method( self.get_location, default_timeout=None, client_info=client_info, ), self.list_locations: gapic_v1.method.wrap_method( self.list_locations, default_timeout=None, client_info=client_info, ), self.get_iam_policy: gapic_v1.method.wrap_method( self.get_iam_policy, default_timeout=None, client_info=client_info, ), self.set_iam_policy: gapic_v1.method.wrap_method( self.set_iam_policy, default_timeout=None, client_info=client_info, ), self.test_iam_permissions: gapic_v1.method.wrap_method( self.test_iam_permissions, default_timeout=None, client_info=client_info, ), self.cancel_operation: gapic_v1.method.wrap_method( self.cancel_operation, default_timeout=None, client_info=client_info, ), self.delete_operation: gapic_v1.method.wrap_method( self.delete_operation, default_timeout=None, client_info=client_info, ), self.get_operation: gapic_v1.method.wrap_method( self.get_operation, default_timeout=None, client_info=client_info, ), self.list_operations: gapic_v1.method.wrap_method( self.list_operations, default_timeout=None, client_info=client_info, ), self.wait_operation: gapic_v1.method.wrap_method( self.wait_operation, default_timeout=None, client_info=client_info, ), }
def close(self): """Closes resources associated with the transport.
.. warning:: Only call this method if the transport is NOT shared with other clients - this may cause errors in other clients! """ raise NotImplementedError()
@property def fetch_feature_values( self, ) -> Callable[ [feature_online_store_service.FetchFeatureValuesRequest], Union[ feature_online_store_service.FetchFeatureValuesResponse, Awaitable[feature_online_store_service.FetchFeatureValuesResponse], ], ]: raise NotImplementedError()
@property def search_nearest_entities( self, ) -> Callable[ [feature_online_store_service.SearchNearestEntitiesRequest], Union[ feature_online_store_service.SearchNearestEntitiesResponse, Awaitable[feature_online_store_service.SearchNearestEntitiesResponse], ], ]: raise NotImplementedError()
@property def feature_view_direct_write( self, ) -> Callable[ [feature_online_store_service.FeatureViewDirectWriteRequest], Union[ feature_online_store_service.FeatureViewDirectWriteResponse, Awaitable[feature_online_store_service.FeatureViewDirectWriteResponse], ], ]: raise NotImplementedError()
@property def generate_fetch_access_token( self, ) -> Callable[ [feature_online_store_service.GenerateFetchAccessTokenRequest], Union[ feature_online_store_service.GenerateFetchAccessTokenResponse, Awaitable[feature_online_store_service.GenerateFetchAccessTokenResponse], ], ]: raise NotImplementedError()
@property def list_operations( self, ) -> Callable[ [operations_pb2.ListOperationsRequest], Union[ operations_pb2.ListOperationsResponse, Awaitable[operations_pb2.ListOperationsResponse], ], ]: raise NotImplementedError()
@property def get_operation( self, ) -> Callable[ [operations_pb2.GetOperationRequest], Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError()
@property def cancel_operation( self, ) -> Callable[ [operations_pb2.CancelOperationRequest], None, ]: raise NotImplementedError()
@property def delete_operation( self, ) -> Callable[ [operations_pb2.DeleteOperationRequest], None, ]: raise NotImplementedError()
@property def wait_operation( self, ) -> Callable[ [operations_pb2.WaitOperationRequest], Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError()
@property def set_iam_policy( self, ) -> Callable[ [iam_policy_pb2.SetIamPolicyRequest], Union[policy_pb2.Policy, Awaitable[policy_pb2.Policy]], ]: raise NotImplementedError()
@property def get_iam_policy( self, ) -> Callable[ [iam_policy_pb2.GetIamPolicyRequest], Union[policy_pb2.Policy, Awaitable[policy_pb2.Policy]], ]: raise NotImplementedError()
@property def test_iam_permissions( self, ) -> Callable[ [iam_policy_pb2.TestIamPermissionsRequest], Union[ iam_policy_pb2.TestIamPermissionsResponse, Awaitable[iam_policy_pb2.TestIamPermissionsResponse], ], ]: 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()
__all__ = ("FeatureOnlineStoreServiceTransport",)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668# -*- coding: utf-8 -*-# Copyright 2025 Google LLC## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.#import jsonimport logging as std_loggingimport pickleimport warningsfrom typing import Callable, Dict, Optional, Sequence, Tuple, Union
from google.api_core import grpc_helpersfrom google.api_core import gapic_v1import google.auth # type: ignorefrom google.auth import credentials as ga_credentials # type: ignorefrom google.auth.transport.grpc import SslCredentials # type: ignorefrom google.protobuf.json_format import MessageToJsonimport google.protobuf.message
import grpc # type: ignoreimport proto # type: ignore
from google.cloud.aiplatform_v1.types import feature_online_store_servicefrom google.cloud.location import locations_pb2 # type: ignorefrom google.iam.v1 import iam_policy_pb2 # type: ignorefrom google.iam.v1 import policy_pb2 # type: ignorefrom google.longrunning import operations_pb2 # type: ignorefrom .base import FeatureOnlineStoreServiceTransport, DEFAULT_CLIENT_INFO
try: from google.api_core import client_logging # type: ignore
CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVERexcept ImportError: # pragma: NO COVER CLIENT_LOGGING_SUPPORTED = False
_LOGGER = std_logging.getLogger(__name__)
class _LoggingClientInterceptor(grpc.UnaryUnaryClientInterceptor): # pragma: NO COVER def intercept_unary_unary(self, continuation, client_call_details, request): logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( std_logging.DEBUG ) if logging_enabled: # pragma: NO COVER request_metadata = client_call_details.metadata if isinstance(request, proto.Message): request_payload = type(request).to_json(request) elif isinstance(request, google.protobuf.message.Message): request_payload = MessageToJson(request) else: request_payload = f"{type(request).__name__}: {pickle.dumps(request)}"
request_metadata = { key: value.decode("utf-8") if isinstance(value, bytes) else value for key, value in request_metadata } grpc_request = { "payload": request_payload, "requestMethod": "grpc", "metadata": dict(request_metadata), } _LOGGER.debug( f"Sending request for {client_call_details.method}", extra={ "serviceName": "google.cloud.aiplatform.v1.FeatureOnlineStoreService", "rpcName": str(client_call_details.method), "request": grpc_request, "metadata": grpc_request["metadata"], }, ) response = continuation(client_call_details, request) if logging_enabled: # pragma: NO COVER response_metadata = response.trailing_metadata() # Convert gRPC metadata `<class 'grpc.aio._metadata.Metadata'>` to list of tuples metadata = ( dict([(k, str(v)) for k, v in response_metadata]) if response_metadata else None ) result = response.result() if isinstance(result, proto.Message): response_payload = type(result).to_json(result) elif isinstance(result, google.protobuf.message.Message): response_payload = MessageToJson(result) else: response_payload = f"{type(result).__name__}: {pickle.dumps(result)}" grpc_response = { "payload": response_payload, "metadata": metadata, "status": "OK", } _LOGGER.debug( f"Received response for {client_call_details.method}.", extra={ "serviceName": "google.cloud.aiplatform.v1.FeatureOnlineStoreService", "rpcName": client_call_details.method, "response": grpc_response, "metadata": grpc_response["metadata"], }, ) return response
class FeatureOnlineStoreServiceGrpcTransport(FeatureOnlineStoreServiceTransport): """gRPC backend transport for FeatureOnlineStoreService.
A service for fetching feature values from the online store.
This class defines the same methods as the primary client, so the primary client can load the underlying transport implementation and call it.
It sends protocol buffers over the wire using gRPC (which is built on top of HTTP/2); the ``grpcio`` package must be installed. """
_stubs: Dict[str, Callable]
def __init__( self, *, host: str = "aiplatform.googleapis.com", credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, channel: Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]] = None, api_mtls_endpoint: Optional[str] = None, client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, api_audience: Optional[str] = None, ) -> None: """Instantiate the transport.
Args: host (Optional[str]): The hostname to connect to (default: 'aiplatform.googleapis.com'). credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none are specified, the client will attempt to ascertain the credentials from the environment. This argument is ignored if a ``channel`` instance is provided. credentials_file (Optional[str]): Deprecated. A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is ignored if a ``channel`` instance is provided. This argument will be removed in the next major version of this library. scopes (Optional(Sequence[str])): A list of scopes. This argument is ignored if a ``channel`` instance is provided. channel (Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]]): A ``Channel`` instance through which to make calls, or a Callable that constructs and returns one. If set to None, ``self.create_channel`` is used to create the channel. If a Callable is given, it will be called with the same arguments as used in ``self.create_channel``. api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials for the grpc channel. It is ignored if a ``channel`` instance is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, both in PEM format. It is used to configure a mutual TLS channel. It is ignored if a ``channel`` instance or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): The client info used to send a user-agent string along with API requests. If ``None``, then default info will be used. Generally, you only need to set this if you're developing your own client library. always_use_jwt_access (Optional[bool]): Whether self signed JWT should be used for service account credentials.
Raises: google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport creation failed for any reason. google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ self._grpc_channel = None self._ssl_channel_credentials = ssl_channel_credentials self._stubs: Dict[str, Callable] = {}
if api_mtls_endpoint: warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) if client_cert_source: warnings.warn("client_cert_source is deprecated", DeprecationWarning)
if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. credentials = None self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None
else: if api_mtls_endpoint: host = api_mtls_endpoint
# Create SSL credentials with client_cert_source or application # default SSL credentials. if client_cert_source: cert, key = client_cert_source() self._ssl_channel_credentials = grpc.ssl_channel_credentials( certificate_chain=cert, private_key=key ) else: self._ssl_channel_credentials = SslCredentials().ssl_credentials
else: if client_cert_source_for_mtls and not ssl_channel_credentials: cert, key = client_cert_source_for_mtls() self._ssl_channel_credentials = grpc.ssl_channel_credentials( certificate_chain=cert, private_key=key )
# The base transport sets the host, credentials and scopes super().__init__( host=host, credentials=credentials, credentials_file=credentials_file, scopes=scopes, quota_project_id=quota_project_id, client_info=client_info, always_use_jwt_access=always_use_jwt_access, api_audience=api_audience, )
if not self._grpc_channel: # initialize with the provided callable or the default channel channel_init = channel or type(self).create_channel self._grpc_channel = channel_init( self._host, # use the credentials which are saved credentials=self._credentials, # Set ``credentials_file`` to ``None`` here as # the credentials that we saved earlier should be used. credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, options=[ ("grpc.max_send_message_length", -1), ("grpc.max_receive_message_length", -1), ], )
self._interceptor = _LoggingClientInterceptor() self._logged_channel = grpc.intercept_channel( self._grpc_channel, self._interceptor )
# Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info)
@classmethod def create_channel( cls, host: str = "aiplatform.googleapis.com", credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, **kwargs, ) -> grpc.Channel: """Create and return a gRPC channel object. Args: host (Optional[str]): The host for the channel to use. credentials (Optional[~.Credentials]): The authorization credentials to attach to requests. These credentials identify this application to the service. If none are specified, the client will attempt to ascertain the credentials from the environment. credentials_file (Optional[str]): Deprecated. A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is mutually exclusive with credentials. This argument will be removed in the next major version of this library. scopes (Optional[Sequence[str]]): A optional list of scopes needed for this service. These are only used when credentials are not specified and are passed to :func:`google.auth.default`. quota_project_id (Optional[str]): An optional project to use for billing and quota. kwargs (Optional[dict]): Keyword arguments, which are passed to the channel creation. Returns: grpc.Channel: A gRPC channel object.
Raises: google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """
return grpc_helpers.create_channel( host, credentials=credentials, credentials_file=credentials_file, quota_project_id=quota_project_id, default_scopes=cls.AUTH_SCOPES, scopes=scopes, default_host=cls.DEFAULT_HOST, **kwargs, )
@property def grpc_channel(self) -> grpc.Channel: """Return the channel designed to connect to this service.""" return self._grpc_channel
@property def fetch_feature_values( self, ) -> Callable[ [feature_online_store_service.FetchFeatureValuesRequest], feature_online_store_service.FetchFeatureValuesResponse, ]: r"""Return a callable for the fetch feature values method over gRPC.
Fetch feature values under a FeatureView.
Returns: Callable[[~.FetchFeatureValuesRequest], ~.FetchFeatureValuesResponse]: A function that, when called, will call the underlying RPC on the server. """ # 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 "fetch_feature_values" not in self._stubs: self._stubs["fetch_feature_values"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.FeatureOnlineStoreService/FetchFeatureValues", request_serializer=feature_online_store_service.FetchFeatureValuesRequest.serialize, response_deserializer=feature_online_store_service.FetchFeatureValuesResponse.deserialize, ) return self._stubs["fetch_feature_values"]
@property def search_nearest_entities( self, ) -> Callable[ [feature_online_store_service.SearchNearestEntitiesRequest], feature_online_store_service.SearchNearestEntitiesResponse, ]: r"""Return a callable for the search nearest entities method over gRPC.
Search the nearest entities under a FeatureView. Search only works for indexable feature view; if a feature view isn't indexable, returns Invalid argument response.
Returns: Callable[[~.SearchNearestEntitiesRequest], ~.SearchNearestEntitiesResponse]: A function that, when called, will call the underlying RPC on the server. """ # 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 "search_nearest_entities" not in self._stubs: self._stubs["search_nearest_entities"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.FeatureOnlineStoreService/SearchNearestEntities", request_serializer=feature_online_store_service.SearchNearestEntitiesRequest.serialize, response_deserializer=feature_online_store_service.SearchNearestEntitiesResponse.deserialize, ) return self._stubs["search_nearest_entities"]
@property def feature_view_direct_write( self, ) -> Callable[ [feature_online_store_service.FeatureViewDirectWriteRequest], feature_online_store_service.FeatureViewDirectWriteResponse, ]: r"""Return a callable for the feature view direct write method over gRPC.
Bidirectional streaming RPC to directly write to feature values in a feature view. Requests may not have a one-to-one mapping to responses and responses may be returned out-of-order to reduce latency.
Returns: Callable[[~.FeatureViewDirectWriteRequest], ~.FeatureViewDirectWriteResponse]: A function that, when called, will call the underlying RPC on the server. """ # 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 "feature_view_direct_write" not in self._stubs: self._stubs["feature_view_direct_write"] = ( self._logged_channel.stream_stream( "/google.cloud.aiplatform.v1.FeatureOnlineStoreService/FeatureViewDirectWrite", request_serializer=feature_online_store_service.FeatureViewDirectWriteRequest.serialize, response_deserializer=feature_online_store_service.FeatureViewDirectWriteResponse.deserialize, ) ) return self._stubs["feature_view_direct_write"]
@property def generate_fetch_access_token( self, ) -> Callable[ [feature_online_store_service.GenerateFetchAccessTokenRequest], feature_online_store_service.GenerateFetchAccessTokenResponse, ]: r"""Return a callable for the generate fetch access token method over gRPC.
RPC to generate an access token for the given feature view. FeatureViews under the same FeatureOnlineStore share the same access token.
Returns: Callable[[~.GenerateFetchAccessTokenRequest], ~.GenerateFetchAccessTokenResponse]: A function that, when called, will call the underlying RPC on the server. """ # 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 "generate_fetch_access_token" not in self._stubs: self._stubs["generate_fetch_access_token"] = ( self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.FeatureOnlineStoreService/GenerateFetchAccessToken", request_serializer=feature_online_store_service.GenerateFetchAccessTokenRequest.serialize, response_deserializer=feature_online_store_service.GenerateFetchAccessTokenResponse.deserialize, ) ) return self._stubs["generate_fetch_access_token"]
def close(self): self._logged_channel.close()
@property def delete_operation( self, ) -> Callable[[operations_pb2.DeleteOperationRequest], None]: r"""Return a callable for the delete_operation 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 "delete_operation" not in self._stubs: self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, ) return self._stubs["delete_operation"]
@property def cancel_operation( self, ) -> Callable[[operations_pb2.CancelOperationRequest], None]: r"""Return a callable for the cancel_operation 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 "cancel_operation" not in self._stubs: self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, ) return self._stubs["cancel_operation"]
@property def wait_operation( self, ) -> Callable[[operations_pb2.WaitOperationRequest], None]: r"""Return a callable for the wait_operation 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 "wait_operation" not in self._stubs: self._stubs["wait_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/WaitOperation", request_serializer=operations_pb2.WaitOperationRequest.SerializeToString, response_deserializer=None, ) return self._stubs["wait_operation"]
@property def get_operation( self, ) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]: r"""Return a callable for the get_operation 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_operation" not in self._stubs: self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["get_operation"]
@property def list_operations( self, ) -> Callable[ [operations_pb2.ListOperationsRequest], operations_pb2.ListOperationsResponse ]: r"""Return a callable for the list_operations 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_operations" not in self._stubs: self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, ) return self._stubs["list_operations"]
@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._logged_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._logged_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 set_iam_policy( self, ) -> Callable[[iam_policy_pb2.SetIamPolicyRequest], policy_pb2.Policy]: r"""Return a callable for the set iam policy method over gRPC. Sets the IAM access control policy on the specified function. Replaces any existing policy. Returns: Callable[[~.SetIamPolicyRequest], ~.Policy]: A function that, when called, will call the underlying RPC on the server. """ # 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 "set_iam_policy" not in self._stubs: self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, ) return self._stubs["set_iam_policy"]
@property def get_iam_policy( self, ) -> Callable[[iam_policy_pb2.GetIamPolicyRequest], policy_pb2.Policy]: r"""Return a callable for the get iam policy method over gRPC. Gets the IAM access control policy for a function. Returns an empty policy if the function exists and does not have a policy set. Returns: Callable[[~.GetIamPolicyRequest], ~.Policy]: A function that, when called, will call the underlying RPC on the server. """ # 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_iam_policy" not in self._stubs: self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, ) return self._stubs["get_iam_policy"]
@property def test_iam_permissions( self, ) -> Callable[ [iam_policy_pb2.TestIamPermissionsRequest], iam_policy_pb2.TestIamPermissionsResponse, ]: r"""Return a callable for the test iam permissions method over gRPC. Tests the specified permissions against the IAM access control policy for a function. If the function does not exist, this will return an empty set of permissions, not a NOT_FOUND error. Returns: Callable[[~.TestIamPermissionsRequest], ~.TestIamPermissionsResponse]: A function that, when called, will call the underlying RPC on the server. """ # 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 "test_iam_permissions" not in self._stubs: self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, ) return self._stubs["test_iam_permissions"]
@property def kind(self) -> str: return "grpc"
__all__ = ("FeatureOnlineStoreServiceGrpcTransport",)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756# -*- coding: utf-8 -*-# Copyright 2025 Google LLC## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.#import inspectimport jsonimport pickleimport logging as std_loggingimport warningsfrom typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union
from google.api_core import gapic_v1from google.api_core import grpc_helpers_asyncfrom google.api_core import exceptions as core_exceptionsfrom google.api_core import retry_async as retriesfrom google.auth import credentials as ga_credentials # type: ignorefrom google.auth.transport.grpc import SslCredentials # type: ignorefrom google.protobuf.json_format import MessageToJsonimport google.protobuf.message
import grpc # type: ignoreimport proto # type: ignorefrom grpc.experimental import aio # type: ignore
from google.cloud.aiplatform_v1.types import feature_online_store_servicefrom google.cloud.location import locations_pb2 # type: ignorefrom google.iam.v1 import iam_policy_pb2 # type: ignorefrom google.iam.v1 import policy_pb2 # type: ignorefrom google.longrunning import operations_pb2 # type: ignorefrom .base import FeatureOnlineStoreServiceTransport, DEFAULT_CLIENT_INFOfrom .grpc import FeatureOnlineStoreServiceGrpcTransport
try: from google.api_core import client_logging # type: ignore
CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVERexcept ImportError: # pragma: NO COVER CLIENT_LOGGING_SUPPORTED = False
_LOGGER = std_logging.getLogger(__name__)
class _LoggingClientAIOInterceptor( grpc.aio.UnaryUnaryClientInterceptor): # pragma: NO COVER async def intercept_unary_unary(self, continuation, client_call_details, request): logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( std_logging.DEBUG ) if logging_enabled: # pragma: NO COVER request_metadata = client_call_details.metadata if isinstance(request, proto.Message): request_payload = type(request).to_json(request) elif isinstance(request, google.protobuf.message.Message): request_payload = MessageToJson(request) else: request_payload = f"{type(request).__name__}: {pickle.dumps(request)}"
request_metadata = { key: value.decode("utf-8") if isinstance(value, bytes) else value for key, value in request_metadata } grpc_request = { "payload": request_payload, "requestMethod": "grpc", "metadata": dict(request_metadata), } _LOGGER.debug( f"Sending request for {client_call_details.method}", extra={ "serviceName": "google.cloud.aiplatform.v1.FeatureOnlineStoreService", "rpcName": str(client_call_details.method), "request": grpc_request, "metadata": grpc_request["metadata"], }, ) response = await continuation(client_call_details, request) if logging_enabled: # pragma: NO COVER response_metadata = await response.trailing_metadata() # Convert gRPC metadata `<class 'grpc.aio._metadata.Metadata'>` to list of tuples metadata = ( dict([(k, str(v)) for k, v in response_metadata]) if response_metadata else None ) result = await response if isinstance(result, proto.Message): response_payload = type(result).to_json(result) elif isinstance(result, google.protobuf.message.Message): response_payload = MessageToJson(result) else: response_payload = f"{type(result).__name__}: {pickle.dumps(result)}" grpc_response = { "payload": response_payload, "metadata": metadata, "status": "OK", } _LOGGER.debug( f"Received response to rpc {client_call_details.method}.", extra={ "serviceName": "google.cloud.aiplatform.v1.FeatureOnlineStoreService", "rpcName": str(client_call_details.method), "response": grpc_response, "metadata": grpc_response["metadata"], }, ) return response
class FeatureOnlineStoreServiceGrpcAsyncIOTransport(FeatureOnlineStoreServiceTransport): """gRPC AsyncIO backend transport for FeatureOnlineStoreService.
A service for fetching feature values from the online store.
This class defines the same methods as the primary client, so the primary client can load the underlying transport implementation and call it.
It sends protocol buffers over the wire using gRPC (which is built on top of HTTP/2); the ``grpcio`` package must be installed. """
_grpc_channel: aio.Channel _stubs: Dict[str, Callable] = {}
@classmethod def create_channel( cls, host: str = "aiplatform.googleapis.com", credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, **kwargs, ) -> aio.Channel: """Create and return a gRPC AsyncIO channel object. Args: host (Optional[str]): The host for the channel to use. credentials (Optional[~.Credentials]): The authorization credentials to attach to requests. These credentials identify this application to the service. If none are specified, the client will attempt to ascertain the credentials from the environment. credentials_file (Optional[str]): Deprecated. A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument will be removed in the next major version of this library. scopes (Optional[Sequence[str]]): A optional list of scopes needed for this service. These are only used when credentials are not specified and are passed to :func:`google.auth.default`. quota_project_id (Optional[str]): An optional project to use for billing and quota. kwargs (Optional[dict]): Keyword arguments, which are passed to the channel creation. Returns: aio.Channel: A gRPC AsyncIO channel object. """
return grpc_helpers_async.create_channel( host, credentials=credentials, credentials_file=credentials_file, quota_project_id=quota_project_id, default_scopes=cls.AUTH_SCOPES, scopes=scopes, default_host=cls.DEFAULT_HOST, **kwargs, )
def __init__( self, *, host: str = "aiplatform.googleapis.com", credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, channel: Optional[Union[aio.Channel, Callable[..., aio.Channel]]] = None, api_mtls_endpoint: Optional[str] = None, client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, api_audience: Optional[str] = None, ) -> None: """Instantiate the transport.
Args: host (Optional[str]): The hostname to connect to (default: 'aiplatform.googleapis.com'). credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none are specified, the client will attempt to ascertain the credentials from the environment. This argument is ignored if a ``channel`` instance is provided. credentials_file (Optional[str]): Deprecated. A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is ignored if a ``channel`` instance is provided. This argument will be removed in the next major version of this library. scopes (Optional[Sequence[str]]): A optional list of scopes needed for this service. These are only used when credentials are not specified and are passed to :func:`google.auth.default`. channel (Optional[Union[aio.Channel, Callable[..., aio.Channel]]]): A ``Channel`` instance through which to make calls, or a Callable that constructs and returns one. If set to None, ``self.create_channel`` is used to create the channel. If a Callable is given, it will be called with the same arguments as used in ``self.create_channel``. api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials for the grpc channel. It is ignored if a ``channel`` instance is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, both in PEM format. It is used to configure a mutual TLS channel. It is ignored if a ``channel`` instance or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): The client info used to send a user-agent string along with API requests. If ``None``, then default info will be used. Generally, you only need to set this if you're developing your own client library. always_use_jwt_access (Optional[bool]): Whether self signed JWT should be used for service account credentials.
Raises: google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport creation failed for any reason. google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ self._grpc_channel = None self._ssl_channel_credentials = ssl_channel_credentials self._stubs: Dict[str, Callable] = {}
if api_mtls_endpoint: warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) if client_cert_source: warnings.warn("client_cert_source is deprecated", DeprecationWarning)
if isinstance(channel, aio.Channel): # Ignore credentials if a channel was passed. credentials = None self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None else: if api_mtls_endpoint: host = api_mtls_endpoint
# Create SSL credentials with client_cert_source or application # default SSL credentials. if client_cert_source: cert, key = client_cert_source() self._ssl_channel_credentials = grpc.ssl_channel_credentials( certificate_chain=cert, private_key=key ) else: self._ssl_channel_credentials = SslCredentials().ssl_credentials
else: if client_cert_source_for_mtls and not ssl_channel_credentials: cert, key = client_cert_source_for_mtls() self._ssl_channel_credentials = grpc.ssl_channel_credentials( certificate_chain=cert, private_key=key )
# The base transport sets the host, credentials and scopes super().__init__( host=host, credentials=credentials, credentials_file=credentials_file, scopes=scopes, quota_project_id=quota_project_id, client_info=client_info, always_use_jwt_access=always_use_jwt_access, api_audience=api_audience, )
if not self._grpc_channel: # initialize with the provided callable or the default channel channel_init = channel or type(self).create_channel self._grpc_channel = channel_init( self._host, # use the credentials which are saved credentials=self._credentials, # Set ``credentials_file`` to ``None`` here as # the credentials that we saved earlier should be used. credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, options=[ ("grpc.max_send_message_length", -1), ("grpc.max_receive_message_length", -1), ], )
self._interceptor = _LoggingClientAIOInterceptor() self._grpc_channel._unary_unary_interceptors.append(self._interceptor) self._logged_channel = self._grpc_channel self._wrap_with_kind = ( "kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters ) # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info)
@property def grpc_channel(self) -> aio.Channel: """Create the channel designed to connect to this service.
This property caches on the instance; repeated calls return the same channel. """ # Return the channel from cache. return self._grpc_channel
@property def fetch_feature_values( self, ) -> Callable[ [feature_online_store_service.FetchFeatureValuesRequest], Awaitable[feature_online_store_service.FetchFeatureValuesResponse], ]: r"""Return a callable for the fetch feature values method over gRPC.
Fetch feature values under a FeatureView.
Returns: Callable[[~.FetchFeatureValuesRequest], Awaitable[~.FetchFeatureValuesResponse]]: A function that, when called, will call the underlying RPC on the server. """ # 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 "fetch_feature_values" not in self._stubs: self._stubs["fetch_feature_values"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.FeatureOnlineStoreService/FetchFeatureValues", request_serializer=feature_online_store_service.FetchFeatureValuesRequest.serialize, response_deserializer=feature_online_store_service.FetchFeatureValuesResponse.deserialize, ) return self._stubs["fetch_feature_values"]
@property def search_nearest_entities( self, ) -> Callable[ [feature_online_store_service.SearchNearestEntitiesRequest], Awaitable[feature_online_store_service.SearchNearestEntitiesResponse], ]: r"""Return a callable for the search nearest entities method over gRPC.
Search the nearest entities under a FeatureView. Search only works for indexable feature view; if a feature view isn't indexable, returns Invalid argument response.
Returns: Callable[[~.SearchNearestEntitiesRequest], Awaitable[~.SearchNearestEntitiesResponse]]: A function that, when called, will call the underlying RPC on the server. """ # 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 "search_nearest_entities" not in self._stubs: self._stubs["search_nearest_entities"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.FeatureOnlineStoreService/SearchNearestEntities", request_serializer=feature_online_store_service.SearchNearestEntitiesRequest.serialize, response_deserializer=feature_online_store_service.SearchNearestEntitiesResponse.deserialize, ) return self._stubs["search_nearest_entities"]
@property def feature_view_direct_write( self, ) -> Callable[ [feature_online_store_service.FeatureViewDirectWriteRequest], Awaitable[feature_online_store_service.FeatureViewDirectWriteResponse], ]: r"""Return a callable for the feature view direct write method over gRPC.
Bidirectional streaming RPC to directly write to feature values in a feature view. Requests may not have a one-to-one mapping to responses and responses may be returned out-of-order to reduce latency.
Returns: Callable[[~.FeatureViewDirectWriteRequest], Awaitable[~.FeatureViewDirectWriteResponse]]: A function that, when called, will call the underlying RPC on the server. """ # 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 "feature_view_direct_write" not in self._stubs: self._stubs["feature_view_direct_write"] = ( self._logged_channel.stream_stream( "/google.cloud.aiplatform.v1.FeatureOnlineStoreService/FeatureViewDirectWrite", request_serializer=feature_online_store_service.FeatureViewDirectWriteRequest.serialize, response_deserializer=feature_online_store_service.FeatureViewDirectWriteResponse.deserialize, ) ) return self._stubs["feature_view_direct_write"]
@property def generate_fetch_access_token( self, ) -> Callable[ [feature_online_store_service.GenerateFetchAccessTokenRequest], Awaitable[feature_online_store_service.GenerateFetchAccessTokenResponse], ]: r"""Return a callable for the generate fetch access token method over gRPC.
RPC to generate an access token for the given feature view. FeatureViews under the same FeatureOnlineStore share the same access token.
Returns: Callable[[~.GenerateFetchAccessTokenRequest], Awaitable[~.GenerateFetchAccessTokenResponse]]: A function that, when called, will call the underlying RPC on the server. """ # 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 "generate_fetch_access_token" not in self._stubs: self._stubs["generate_fetch_access_token"] = ( self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.FeatureOnlineStoreService/GenerateFetchAccessToken", request_serializer=feature_online_store_service.GenerateFetchAccessTokenRequest.serialize, response_deserializer=feature_online_store_service.GenerateFetchAccessTokenResponse.deserialize, ) ) return self._stubs["generate_fetch_access_token"]
def _prep_wrapped_messages(self, client_info): """Precompute the wrapped methods, overriding the base class method to use async wrappers.""" self._wrapped_methods = { self.fetch_feature_values: self._wrap_method( self.fetch_feature_values, default_timeout=None, client_info=client_info, ), self.search_nearest_entities: self._wrap_method( self.search_nearest_entities, default_timeout=None, client_info=client_info, ), self.feature_view_direct_write: self._wrap_method( self.feature_view_direct_write, default_timeout=None, client_info=client_info, ), self.generate_fetch_access_token: self._wrap_method( self.generate_fetch_access_token, default_timeout=None, client_info=client_info, ), self.get_location: self._wrap_method( self.get_location, default_timeout=None, client_info=client_info, ), self.list_locations: self._wrap_method( self.list_locations, default_timeout=None, client_info=client_info, ), self.get_iam_policy: self._wrap_method( self.get_iam_policy, default_timeout=None, client_info=client_info, ), self.set_iam_policy: self._wrap_method( self.set_iam_policy, default_timeout=None, client_info=client_info, ), self.test_iam_permissions: self._wrap_method( self.test_iam_permissions, default_timeout=None, client_info=client_info, ), self.cancel_operation: self._wrap_method( self.cancel_operation, default_timeout=None, client_info=client_info, ), self.delete_operation: self._wrap_method( self.delete_operation, default_timeout=None, client_info=client_info, ), self.get_operation: self._wrap_method( self.get_operation, default_timeout=None, client_info=client_info, ), self.list_operations: self._wrap_method( self.list_operations, default_timeout=None, client_info=client_info, ), self.wait_operation: self._wrap_method( self.wait_operation, default_timeout=None, client_info=client_info, ), }
def _wrap_method(self, func, *args, **kwargs): if self._wrap_with_kind: # pragma: NO COVER kwargs["kind"] = self.kind return gapic_v1.method_async.wrap_method(func, *args, **kwargs)
def close(self): return self._logged_channel.close()
@property def kind(self) -> str: return "grpc_asyncio"
@property def delete_operation( self, ) -> Callable[[operations_pb2.DeleteOperationRequest], None]: r"""Return a callable for the delete_operation 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 "delete_operation" not in self._stubs: self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, ) return self._stubs["delete_operation"]
@property def cancel_operation( self, ) -> Callable[[operations_pb2.CancelOperationRequest], None]: r"""Return a callable for the cancel_operation 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 "cancel_operation" not in self._stubs: self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, ) return self._stubs["cancel_operation"]
@property def wait_operation( self, ) -> Callable[[operations_pb2.WaitOperationRequest], None]: r"""Return a callable for the wait_operation 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 "wait_operation" not in self._stubs: self._stubs["wait_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/WaitOperation", request_serializer=operations_pb2.WaitOperationRequest.SerializeToString, response_deserializer=None, ) return self._stubs["wait_operation"]
@property def get_operation( self, ) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]: r"""Return a callable for the get_operation 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_operation" not in self._stubs: self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["get_operation"]
@property def list_operations( self, ) -> Callable[ [operations_pb2.ListOperationsRequest], operations_pb2.ListOperationsResponse ]: r"""Return a callable for the list_operations 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_operations" not in self._stubs: self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, ) return self._stubs["list_operations"]
@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._logged_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._logged_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 set_iam_policy( self, ) -> Callable[[iam_policy_pb2.SetIamPolicyRequest], policy_pb2.Policy]: r"""Return a callable for the set iam policy method over gRPC. Sets the IAM access control policy on the specified function. Replaces any existing policy. Returns: Callable[[~.SetIamPolicyRequest], ~.Policy]: A function that, when called, will call the underlying RPC on the server. """ # 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 "set_iam_policy" not in self._stubs: self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, ) return self._stubs["set_iam_policy"]
@property def get_iam_policy( self, ) -> Callable[[iam_policy_pb2.GetIamPolicyRequest], policy_pb2.Policy]: r"""Return a callable for the get iam policy method over gRPC. Gets the IAM access control policy for a function. Returns an empty policy if the function exists and does not have a policy set. Returns: Callable[[~.GetIamPolicyRequest], ~.Policy]: A function that, when called, will call the underlying RPC on the server. """ # 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_iam_policy" not in self._stubs: self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, ) return self._stubs["get_iam_policy"]
@property def test_iam_permissions( self, ) -> Callable[ [iam_policy_pb2.TestIamPermissionsRequest], iam_policy_pb2.TestIamPermissionsResponse, ]: r"""Return a callable for the test iam permissions method over gRPC. Tests the specified permissions against the IAM access control policy for a function. If the function does not exist, this will return an empty set of permissions, not a NOT_FOUND error. Returns: Callable[[~.TestIamPermissionsRequest], ~.TestIamPermissionsResponse]: A function that, when called, will call the underlying RPC on the server. """ # 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 "test_iam_permissions" not in self._stubs: self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, ) return self._stubs["test_iam_permissions"]
__all__ = ("FeatureOnlineStoreServiceGrpcAsyncIOTransport",)1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556# -*- coding: utf-8 -*-# Copyright 2025 Google LLC## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.#from collections import OrderedDictfrom typing import Dict, Type, Tuple
from .base import FeaturestoreServiceTransportfrom .grpc import FeaturestoreServiceGrpcTransportfrom .grpc_asyncio import FeaturestoreServiceGrpcAsyncIOTransportfrom .rest import FeaturestoreServiceRestTransportfrom .rest import FeaturestoreServiceRestInterceptor
ASYNC_REST_CLASSES: Tuple[str, ...]try: from .rest_asyncio import AsyncFeaturestoreServiceRestTransport from .rest_asyncio import AsyncFeaturestoreServiceRestInterceptor
ASYNC_REST_CLASSES = ( "AsyncFeaturestoreServiceRestTransport", "AsyncFeaturestoreServiceRestInterceptor", ) HAS_REST_ASYNC = Trueexcept ImportError: # pragma: NO COVER ASYNC_REST_CLASSES = () HAS_REST_ASYNC = False
# Compile a registry of transports._transport_registry = ( OrderedDict()) # type: Dict[str, Type[FeaturestoreServiceTransport]]_transport_registry["grpc"] = FeaturestoreServiceGrpcTransport_transport_registry["grpc_asyncio"] = FeaturestoreServiceGrpcAsyncIOTransport_transport_registry["rest"] = FeaturestoreServiceRestTransportif HAS_REST_ASYNC: # pragma: NO COVER _transport_registry["rest_asyncio"] = AsyncFeaturestoreServiceRestTransport
__all__ = ( "FeaturestoreServiceTransport", "FeaturestoreServiceGrpcTransport", "FeaturestoreServiceGrpcAsyncIOTransport", "FeaturestoreServiceRestTransport", "FeaturestoreServiceRestInterceptor",) + ASYNC_REST_CLASSES123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626# -*- coding: utf-8 -*-# Copyright 2025 Google LLC## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.#import abcfrom typing import Awaitable, Callable, Dict, Optional, Sequence, Union
from google.cloud.aiplatform_v1 import gapic_version as package_version
import google.auth # type: ignoreimport google.api_corefrom google.api_core import exceptions as core_exceptionsfrom google.api_core import gapic_v1from google.api_core import retry as retriesfrom google.api_core import operations_v1from google.auth import credentials as ga_credentials # type: ignorefrom google.oauth2 import service_account # type: ignoreimport google.protobuf
from google.cloud.aiplatform_v1.types import entity_typefrom google.cloud.aiplatform_v1.types import entity_type as gca_entity_typefrom google.cloud.aiplatform_v1.types import featurefrom google.cloud.aiplatform_v1.types import feature as gca_featurefrom google.cloud.aiplatform_v1.types import featurestorefrom google.cloud.aiplatform_v1.types import featurestore_servicefrom google.cloud.location import locations_pb2 # type: ignorefrom google.iam.v1 import iam_policy_pb2 # type: ignorefrom google.iam.v1 import policy_pb2 # type: ignorefrom google.longrunning import operations_pb2 # type: ignore
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=package_version.__version__)
if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
class FeaturestoreServiceTransport(abc.ABC): """Abstract transport class for FeaturestoreService."""
AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",)
DEFAULT_HOST: str = "aiplatform.googleapis.com"
def __init__( self, *, host: str = DEFAULT_HOST, credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, api_audience: Optional[str] = None, **kwargs, ) -> None: """Instantiate the transport.
Args: host (Optional[str]): The hostname to connect to (default: 'aiplatform.googleapis.com'). credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none are specified, the client will attempt to ascertain the credentials from the environment. credentials_file (Optional[str]): Deprecated. A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is mutually exclusive with credentials. This argument will be removed in the next major version of this library. scopes (Optional[Sequence[str]]): A list of scopes. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): The client info used to send a user-agent string along with API requests. If ``None``, then default info will be used. Generally, you only need to set this if you're developing your own client library. always_use_jwt_access (Optional[bool]): Whether self signed JWT should be used for service account credentials. """
# Save the scopes. self._scopes = scopes if not hasattr(self, "_ignore_credentials"): self._ignore_credentials: bool = False
# If no credentials are provided, then determine the appropriate # defaults. if credentials and credentials_file: raise core_exceptions.DuplicateCredentialArgs( "'credentials_file' and 'credentials' are mutually exclusive" )
if credentials_file is not None: credentials, _ = google.auth.load_credentials_from_file( credentials_file, scopes=scopes, quota_project_id=quota_project_id, default_scopes=self.AUTH_SCOPES, ) elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( scopes=scopes, quota_project_id=quota_project_id, default_scopes=self.AUTH_SCOPES, ) # Don't apply audience if the credentials file passed from user. if hasattr(credentials, "with_gdch_audience"): credentials = credentials.with_gdch_audience( api_audience if api_audience else host )
# If the credentials are service account credentials, then always try to use self signed JWT. if ( always_use_jwt_access and isinstance(credentials, service_account.Credentials) and hasattr(service_account.Credentials, "with_always_use_jwt_access") ): credentials = credentials.with_always_use_jwt_access(True)
# Save the credentials. self._credentials = credentials
# Save the hostname. Default to port 443 (HTTPS) if none is specified. if ":" not in host: host += ":443" self._host = host
@property def host(self): return self._host
def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { self.create_featurestore: gapic_v1.method.wrap_method( self.create_featurestore, default_timeout=None, client_info=client_info, ), self.get_featurestore: gapic_v1.method.wrap_method( self.get_featurestore, default_timeout=None, client_info=client_info, ), self.list_featurestores: gapic_v1.method.wrap_method( self.list_featurestores, default_timeout=None, client_info=client_info, ), self.update_featurestore: gapic_v1.method.wrap_method( self.update_featurestore, default_timeout=None, client_info=client_info, ), self.delete_featurestore: gapic_v1.method.wrap_method( self.delete_featurestore, default_timeout=None, client_info=client_info, ), self.create_entity_type: gapic_v1.method.wrap_method( self.create_entity_type, default_timeout=None, client_info=client_info, ), self.get_entity_type: gapic_v1.method.wrap_method( self.get_entity_type, default_timeout=None, client_info=client_info, ), self.list_entity_types: gapic_v1.method.wrap_method( self.list_entity_types, default_timeout=None, client_info=client_info, ), self.update_entity_type: gapic_v1.method.wrap_method( self.update_entity_type, default_timeout=None, client_info=client_info, ), self.delete_entity_type: gapic_v1.method.wrap_method( self.delete_entity_type, default_timeout=None, client_info=client_info, ), self.create_feature: gapic_v1.method.wrap_method( self.create_feature, default_timeout=None, client_info=client_info, ), self.batch_create_features: gapic_v1.method.wrap_method( self.batch_create_features, default_timeout=None, client_info=client_info, ), self.get_feature: gapic_v1.method.wrap_method( self.get_feature, default_timeout=None, client_info=client_info, ), self.list_features: gapic_v1.method.wrap_method( self.list_features, default_timeout=None, client_info=client_info, ), self.update_feature: gapic_v1.method.wrap_method( self.update_feature, default_timeout=None, client_info=client_info, ), self.delete_feature: gapic_v1.method.wrap_method( self.delete_feature, default_timeout=None, client_info=client_info, ), self.import_feature_values: gapic_v1.method.wrap_method( self.import_feature_values, default_timeout=None, client_info=client_info, ), self.batch_read_feature_values: gapic_v1.method.wrap_method( self.batch_read_feature_values, default_timeout=None, client_info=client_info, ), self.export_feature_values: gapic_v1.method.wrap_method( self.export_feature_values, default_timeout=None, client_info=client_info, ), self.delete_feature_values: gapic_v1.method.wrap_method( self.delete_feature_values, default_timeout=None, client_info=client_info, ), self.search_features: gapic_v1.method.wrap_method( self.search_features, default_timeout=None, client_info=client_info, ), self.get_location: gapic_v1.method.wrap_method( self.get_location, default_timeout=None, client_info=client_info, ), self.list_locations: gapic_v1.method.wrap_method( self.list_locations, default_timeout=None, client_info=client_info, ), self.get_iam_policy: gapic_v1.method.wrap_method( self.get_iam_policy, default_timeout=None, client_info=client_info, ), self.set_iam_policy: gapic_v1.method.wrap_method( self.set_iam_policy, default_timeout=None, client_info=client_info, ), self.test_iam_permissions: gapic_v1.method.wrap_method( self.test_iam_permissions, default_timeout=None, client_info=client_info, ), self.cancel_operation: gapic_v1.method.wrap_method( self.cancel_operation, default_timeout=None, client_info=client_info, ), self.delete_operation: gapic_v1.method.wrap_method( self.delete_operation, default_timeout=None, client_info=client_info, ), self.get_operation: gapic_v1.method.wrap_method( self.get_operation, default_timeout=None, client_info=client_info, ), self.list_operations: gapic_v1.method.wrap_method( self.list_operations, default_timeout=None, client_info=client_info, ), self.wait_operation: gapic_v1.method.wrap_method( self.wait_operation, default_timeout=None, client_info=client_info, ), }
def close(self): """Closes resources associated with the transport.
.. warning:: Only call this method if the transport is NOT shared with other clients - this may cause errors in other clients! """ raise NotImplementedError()
@property def operations_client(self): """Return the client designed to process long-running operations.""" raise NotImplementedError()
@property def create_featurestore( self, ) -> Callable[ [featurestore_service.CreateFeaturestoreRequest], Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError()
@property def get_featurestore( self, ) -> Callable[ [featurestore_service.GetFeaturestoreRequest], Union[featurestore.Featurestore, Awaitable[featurestore.Featurestore]], ]: raise NotImplementedError()
@property def list_featurestores( self, ) -> Callable[ [featurestore_service.ListFeaturestoresRequest], Union[ featurestore_service.ListFeaturestoresResponse, Awaitable[featurestore_service.ListFeaturestoresResponse], ], ]: raise NotImplementedError()
@property def update_featurestore( self, ) -> Callable[ [featurestore_service.UpdateFeaturestoreRequest], Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError()
@property def delete_featurestore( self, ) -> Callable[ [featurestore_service.DeleteFeaturestoreRequest], Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError()
@property def create_entity_type( self, ) -> Callable[ [featurestore_service.CreateEntityTypeRequest], Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError()
@property def get_entity_type( self, ) -> Callable[ [featurestore_service.GetEntityTypeRequest], Union[entity_type.EntityType, Awaitable[entity_type.EntityType]], ]: raise NotImplementedError()
@property def list_entity_types( self, ) -> Callable[ [featurestore_service.ListEntityTypesRequest], Union[ featurestore_service.ListEntityTypesResponse, Awaitable[featurestore_service.ListEntityTypesResponse], ], ]: raise NotImplementedError()
@property def update_entity_type( self, ) -> Callable[ [featurestore_service.UpdateEntityTypeRequest], Union[gca_entity_type.EntityType, Awaitable[gca_entity_type.EntityType]], ]: raise NotImplementedError()
@property def delete_entity_type( self, ) -> Callable[ [featurestore_service.DeleteEntityTypeRequest], Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError()
@property def create_feature( self, ) -> Callable[ [featurestore_service.CreateFeatureRequest], Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError()
@property def batch_create_features( self, ) -> Callable[ [featurestore_service.BatchCreateFeaturesRequest], Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError()
@property def get_feature( self, ) -> Callable[ [featurestore_service.GetFeatureRequest], Union[feature.Feature, Awaitable[feature.Feature]], ]: raise NotImplementedError()
@property def list_features( self, ) -> Callable[ [featurestore_service.ListFeaturesRequest], Union[ featurestore_service.ListFeaturesResponse, Awaitable[featurestore_service.ListFeaturesResponse], ], ]: raise NotImplementedError()
@property def update_feature( self, ) -> Callable[ [featurestore_service.UpdateFeatureRequest], Union[gca_feature.Feature, Awaitable[gca_feature.Feature]], ]: raise NotImplementedError()
@property def delete_feature( self, ) -> Callable[ [featurestore_service.DeleteFeatureRequest], Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError()
@property def import_feature_values( self, ) -> Callable[ [featurestore_service.ImportFeatureValuesRequest], Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError()
@property def batch_read_feature_values( self, ) -> Callable[ [featurestore_service.BatchReadFeatureValuesRequest], Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError()
@property def export_feature_values( self, ) -> Callable[ [featurestore_service.ExportFeatureValuesRequest], Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError()
@property def delete_feature_values( self, ) -> Callable[ [featurestore_service.DeleteFeatureValuesRequest], Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError()
@property def search_features( self, ) -> Callable[ [featurestore_service.SearchFeaturesRequest], Union[ featurestore_service.SearchFeaturesResponse, Awaitable[featurestore_service.SearchFeaturesResponse], ], ]: raise NotImplementedError()
@property def list_operations( self, ) -> Callable[ [operations_pb2.ListOperationsRequest], Union[ operations_pb2.ListOperationsResponse, Awaitable[operations_pb2.ListOperationsResponse], ], ]: raise NotImplementedError()
@property def get_operation( self, ) -> Callable[ [operations_pb2.GetOperationRequest], Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError()
@property def cancel_operation( self, ) -> Callable[ [operations_pb2.CancelOperationRequest], None, ]: raise NotImplementedError()
@property def delete_operation( self, ) -> Callable[ [operations_pb2.DeleteOperationRequest], None, ]: raise NotImplementedError()
@property def wait_operation( self, ) -> Callable[ [operations_pb2.WaitOperationRequest], Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError()
@property def set_iam_policy( self, ) -> Callable[ [iam_policy_pb2.SetIamPolicyRequest], Union[policy_pb2.Policy, Awaitable[policy_pb2.Policy]], ]: raise NotImplementedError()
@property def get_iam_policy( self, ) -> Callable[ [iam_policy_pb2.GetIamPolicyRequest], Union[policy_pb2.Policy, Awaitable[policy_pb2.Policy]], ]: raise NotImplementedError()
@property def test_iam_permissions( self, ) -> Callable[ [iam_policy_pb2.TestIamPermissionsRequest], Union[ iam_policy_pb2.TestIamPermissionsResponse, Awaitable[iam_policy_pb2.TestIamPermissionsResponse], ], ]: 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()
__all__ = ("FeaturestoreServiceTransport",)12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199# -*- coding: utf-8 -*-# Copyright 2025 Google LLC## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.#import jsonimport logging as std_loggingimport pickleimport warningsfrom typing import Callable, Dict, Optional, Sequence, Tuple, Union
from google.api_core import grpc_helpersfrom google.api_core import operations_v1from google.api_core import gapic_v1import google.auth # type: ignorefrom google.auth import credentials as ga_credentials # type: ignorefrom google.auth.transport.grpc import SslCredentials # type: ignorefrom google.protobuf.json_format import MessageToJsonimport google.protobuf.message
import grpc # type: ignoreimport proto # type: ignore
from google.cloud.aiplatform_v1.types import entity_typefrom google.cloud.aiplatform_v1.types import entity_type as gca_entity_typefrom google.cloud.aiplatform_v1.types import featurefrom google.cloud.aiplatform_v1.types import feature as gca_featurefrom google.cloud.aiplatform_v1.types import featurestorefrom google.cloud.aiplatform_v1.types import featurestore_servicefrom google.cloud.location import locations_pb2 # type: ignorefrom google.iam.v1 import iam_policy_pb2 # type: ignorefrom google.iam.v1 import policy_pb2 # type: ignorefrom google.longrunning import operations_pb2 # type: ignorefrom .base import FeaturestoreServiceTransport, DEFAULT_CLIENT_INFO
try: from google.api_core import client_logging # type: ignore
CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVERexcept ImportError: # pragma: NO COVER CLIENT_LOGGING_SUPPORTED = False
_LOGGER = std_logging.getLogger(__name__)
class _LoggingClientInterceptor(grpc.UnaryUnaryClientInterceptor): # pragma: NO COVER def intercept_unary_unary(self, continuation, client_call_details, request): logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( std_logging.DEBUG ) if logging_enabled: # pragma: NO COVER request_metadata = client_call_details.metadata if isinstance(request, proto.Message): request_payload = type(request).to_json(request) elif isinstance(request, google.protobuf.message.Message): request_payload = MessageToJson(request) else: request_payload = f"{type(request).__name__}: {pickle.dumps(request)}"
request_metadata = { key: value.decode("utf-8") if isinstance(value, bytes) else value for key, value in request_metadata } grpc_request = { "payload": request_payload, "requestMethod": "grpc", "metadata": dict(request_metadata), } _LOGGER.debug( f"Sending request for {client_call_details.method}", extra={ "serviceName": "google.cloud.aiplatform.v1.FeaturestoreService", "rpcName": str(client_call_details.method), "request": grpc_request, "metadata": grpc_request["metadata"], }, ) response = continuation(client_call_details, request) if logging_enabled: # pragma: NO COVER response_metadata = response.trailing_metadata() # Convert gRPC metadata `<class 'grpc.aio._metadata.Metadata'>` to list of tuples metadata = ( dict([(k, str(v)) for k, v in response_metadata]) if response_metadata else None ) result = response.result() if isinstance(result, proto.Message): response_payload = type(result).to_json(result) elif isinstance(result, google.protobuf.message.Message): response_payload = MessageToJson(result) else: response_payload = f"{type(result).__name__}: {pickle.dumps(result)}" grpc_response = { "payload": response_payload, "metadata": metadata, "status": "OK", } _LOGGER.debug( f"Received response for {client_call_details.method}.", extra={ "serviceName": "google.cloud.aiplatform.v1.FeaturestoreService", "rpcName": client_call_details.method, "response": grpc_response, "metadata": grpc_response["metadata"], }, ) return response
class FeaturestoreServiceGrpcTransport(FeaturestoreServiceTransport): """gRPC backend transport for FeaturestoreService.
The service that handles CRUD and List for resources for Featurestore.
This class defines the same methods as the primary client, so the primary client can load the underlying transport implementation and call it.
It sends protocol buffers over the wire using gRPC (which is built on top of HTTP/2); the ``grpcio`` package must be installed. """
_stubs: Dict[str, Callable]
def __init__( self, *, host: str = "aiplatform.googleapis.com", credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, channel: Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]] = None, api_mtls_endpoint: Optional[str] = None, client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, api_audience: Optional[str] = None, ) -> None: """Instantiate the transport.
Args: host (Optional[str]): The hostname to connect to (default: 'aiplatform.googleapis.com'). credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none are specified, the client will attempt to ascertain the credentials from the environment. This argument is ignored if a ``channel`` instance is provided. credentials_file (Optional[str]): Deprecated. A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is ignored if a ``channel`` instance is provided. This argument will be removed in the next major version of this library. scopes (Optional(Sequence[str])): A list of scopes. This argument is ignored if a ``channel`` instance is provided. channel (Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]]): A ``Channel`` instance through which to make calls, or a Callable that constructs and returns one. If set to None, ``self.create_channel`` is used to create the channel. If a Callable is given, it will be called with the same arguments as used in ``self.create_channel``. api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials for the grpc channel. It is ignored if a ``channel`` instance is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, both in PEM format. It is used to configure a mutual TLS channel. It is ignored if a ``channel`` instance or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): The client info used to send a user-agent string along with API requests. If ``None``, then default info will be used. Generally, you only need to set this if you're developing your own client library. always_use_jwt_access (Optional[bool]): Whether self signed JWT should be used for service account credentials.
Raises: google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport creation failed for any reason. google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ self._grpc_channel = None self._ssl_channel_credentials = ssl_channel_credentials self._stubs: Dict[str, Callable] = {} self._operations_client: Optional[operations_v1.OperationsClient] = None
if api_mtls_endpoint: warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) if client_cert_source: warnings.warn("client_cert_source is deprecated", DeprecationWarning)
if isinstance(channel, grpc.Channel): # Ignore credentials if a channel was passed. credentials = None self._ignore_credentials = True # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None
else: if api_mtls_endpoint: host = api_mtls_endpoint
# Create SSL credentials with client_cert_source or application # default SSL credentials. if client_cert_source: cert, key = client_cert_source() self._ssl_channel_credentials = grpc.ssl_channel_credentials( certificate_chain=cert, private_key=key ) else: self._ssl_channel_credentials = SslCredentials().ssl_credentials
else: if client_cert_source_for_mtls and not ssl_channel_credentials: cert, key = client_cert_source_for_mtls() self._ssl_channel_credentials = grpc.ssl_channel_credentials( certificate_chain=cert, private_key=key )
# The base transport sets the host, credentials and scopes super().__init__( host=host, credentials=credentials, credentials_file=credentials_file, scopes=scopes, quota_project_id=quota_project_id, client_info=client_info, always_use_jwt_access=always_use_jwt_access, api_audience=api_audience, )
if not self._grpc_channel: # initialize with the provided callable or the default channel channel_init = channel or type(self).create_channel self._grpc_channel = channel_init( self._host, # use the credentials which are saved credentials=self._credentials, # Set ``credentials_file`` to ``None`` here as # the credentials that we saved earlier should be used. credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, options=[ ("grpc.max_send_message_length", -1), ("grpc.max_receive_message_length", -1), ], )
self._interceptor = _LoggingClientInterceptor() self._logged_channel = grpc.intercept_channel( self._grpc_channel, self._interceptor )
# Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info)
@classmethod def create_channel( cls, host: str = "aiplatform.googleapis.com", credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, **kwargs, ) -> grpc.Channel: """Create and return a gRPC channel object. Args: host (Optional[str]): The host for the channel to use. credentials (Optional[~.Credentials]): The authorization credentials to attach to requests. These credentials identify this application to the service. If none are specified, the client will attempt to ascertain the credentials from the environment. credentials_file (Optional[str]): Deprecated. A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is mutually exclusive with credentials. This argument will be removed in the next major version of this library. scopes (Optional[Sequence[str]]): A optional list of scopes needed for this service. These are only used when credentials are not specified and are passed to :func:`google.auth.default`. quota_project_id (Optional[str]): An optional project to use for billing and quota. kwargs (Optional[dict]): Keyword arguments, which are passed to the channel creation. Returns: grpc.Channel: A gRPC channel object.
Raises: google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """
return grpc_helpers.create_channel( host, credentials=credentials, credentials_file=credentials_file, quota_project_id=quota_project_id, default_scopes=cls.AUTH_SCOPES, scopes=scopes, default_host=cls.DEFAULT_HOST, **kwargs, )
@property def grpc_channel(self) -> grpc.Channel: """Return the channel designed to connect to this service.""" return self._grpc_channel
@property def operations_client(self) -> operations_v1.OperationsClient: """Create the client designed to process long-running operations.
This property caches on the instance; repeated calls return the same client. """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsClient( self._logged_channel )
# Return the client from cache. return self._operations_client
@property def create_featurestore( self, ) -> Callable[ [featurestore_service.CreateFeaturestoreRequest], operations_pb2.Operation ]: r"""Return a callable for the create featurestore method over gRPC.
Creates a new Featurestore in a given project and location.
Returns: Callable[[~.CreateFeaturestoreRequest], ~.Operation]: A function that, when called, will call the underlying RPC on the server. """ # 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 "create_featurestore" not in self._stubs: self._stubs["create_featurestore"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.FeaturestoreService/CreateFeaturestore", request_serializer=featurestore_service.CreateFeaturestoreRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_featurestore"]
@property def get_featurestore( self, ) -> Callable[ [featurestore_service.GetFeaturestoreRequest], featurestore.Featurestore ]: r"""Return a callable for the get featurestore method over gRPC.
Gets details of a single Featurestore.
Returns: Callable[[~.GetFeaturestoreRequest], ~.Featurestore]: A function that, when called, will call the underlying RPC on the server. """ # 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_featurestore" not in self._stubs: self._stubs["get_featurestore"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.FeaturestoreService/GetFeaturestore", request_serializer=featurestore_service.GetFeaturestoreRequest.serialize, response_deserializer=featurestore.Featurestore.deserialize, ) return self._stubs["get_featurestore"]
@property def list_featurestores( self, ) -> Callable[ [featurestore_service.ListFeaturestoresRequest], featurestore_service.ListFeaturestoresResponse, ]: r"""Return a callable for the list featurestores method over gRPC.
Lists Featurestores in a given project and location.
Returns: Callable[[~.ListFeaturestoresRequest], ~.ListFeaturestoresResponse]: A function that, when called, will call the underlying RPC on the server. """ # 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_featurestores" not in self._stubs: self._stubs["list_featurestores"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.FeaturestoreService/ListFeaturestores", request_serializer=featurestore_service.ListFeaturestoresRequest.serialize, response_deserializer=featurestore_service.ListFeaturestoresResponse.deserialize, ) return self._stubs["list_featurestores"]
@property def update_featurestore( self, ) -> Callable[ [featurestore_service.UpdateFeaturestoreRequest], operations_pb2.Operation ]: r"""Return a callable for the update featurestore method over gRPC.
Updates the parameters of a single Featurestore.
Returns: Callable[[~.UpdateFeaturestoreRequest], ~.Operation]: A function that, when called, will call the underlying RPC on the server. """ # 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 "update_featurestore" not in self._stubs: self._stubs["update_featurestore"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.FeaturestoreService/UpdateFeaturestore", request_serializer=featurestore_service.UpdateFeaturestoreRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["update_featurestore"]
@property def delete_featurestore( self, ) -> Callable[ [featurestore_service.DeleteFeaturestoreRequest], operations_pb2.Operation ]: r"""Return a callable for the delete featurestore method over gRPC.
Deletes a single Featurestore. The Featurestore must not contain any EntityTypes or ``force`` must be set to true for the request to succeed.
Returns: Callable[[~.DeleteFeaturestoreRequest], ~.Operation]: A function that, when called, will call the underlying RPC on the server. """ # 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 "delete_featurestore" not in self._stubs: self._stubs["delete_featurestore"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.FeaturestoreService/DeleteFeaturestore", request_serializer=featurestore_service.DeleteFeaturestoreRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_featurestore"]
@property def create_entity_type( self, ) -> Callable[ [featurestore_service.CreateEntityTypeRequest], operations_pb2.Operation ]: r"""Return a callable for the create entity type method over gRPC.
Creates a new EntityType in a given Featurestore.
Returns: Callable[[~.CreateEntityTypeRequest], ~.Operation]: A function that, when called, will call the underlying RPC on the server. """ # 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 "create_entity_type" not in self._stubs: self._stubs["create_entity_type"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.FeaturestoreService/CreateEntityType", request_serializer=featurestore_service.CreateEntityTypeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_entity_type"]
@property def get_entity_type( self, ) -> Callable[[featurestore_service.GetEntityTypeRequest], entity_type.EntityType]: r"""Return a callable for the get entity type method over gRPC.
Gets details of a single EntityType.
Returns: Callable[[~.GetEntityTypeRequest], ~.EntityType]: A function that, when called, will call the underlying RPC on the server. """ # 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_entity_type" not in self._stubs: self._stubs["get_entity_type"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.FeaturestoreService/GetEntityType", request_serializer=featurestore_service.GetEntityTypeRequest.serialize, response_deserializer=entity_type.EntityType.deserialize, ) return self._stubs["get_entity_type"]
@property def list_entity_types( self, ) -> Callable[ [featurestore_service.ListEntityTypesRequest], featurestore_service.ListEntityTypesResponse, ]: r"""Return a callable for the list entity types method over gRPC.
Lists EntityTypes in a given Featurestore.
Returns: Callable[[~.ListEntityTypesRequest], ~.ListEntityTypesResponse]: A function that, when called, will call the underlying RPC on the server. """ # 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_entity_types" not in self._stubs: self._stubs["list_entity_types"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.FeaturestoreService/ListEntityTypes", request_serializer=featurestore_service.ListEntityTypesRequest.serialize, response_deserializer=featurestore_service.ListEntityTypesResponse.deserialize, ) return self._stubs["list_entity_types"]
@property def update_entity_type( self, ) -> Callable[ [featurestore_service.UpdateEntityTypeRequest], gca_entity_type.EntityType ]: r"""Return a callable for the update entity type method over gRPC.
Updates the parameters of a single EntityType.
Returns: Callable[[~.UpdateEntityTypeRequest], ~.EntityType]: A function that, when called, will call the underlying RPC on the server. """ # 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 "update_entity_type" not in self._stubs: self._stubs["update_entity_type"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.FeaturestoreService/UpdateEntityType", request_serializer=featurestore_service.UpdateEntityTypeRequest.serialize, response_deserializer=gca_entity_type.EntityType.deserialize, ) return self._stubs["update_entity_type"]
@property def delete_entity_type( self, ) -> Callable[ [featurestore_service.DeleteEntityTypeRequest], operations_pb2.Operation ]: r"""Return a callable for the delete entity type method over gRPC.
Deletes a single EntityType. The EntityType must not have any Features or ``force`` must be set to true for the request to succeed.
Returns: Callable[[~.DeleteEntityTypeRequest], ~.Operation]: A function that, when called, will call the underlying RPC on the server. """ # 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 "delete_entity_type" not in self._stubs: self._stubs["delete_entity_type"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.FeaturestoreService/DeleteEntityType", request_serializer=featurestore_service.DeleteEntityTypeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_entity_type"]
@property def create_feature( self, ) -> Callable[ [featurestore_service.CreateFeatureRequest], operations_pb2.Operation ]: r"""Return a callable for the create feature method over gRPC.
Creates a new Feature in a given EntityType.
Returns: Callable[[~.CreateFeatureRequest], ~.Operation]: A function that, when called, will call the underlying RPC on the server. """ # 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 "create_feature" not in self._stubs: self._stubs["create_feature"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.FeaturestoreService/CreateFeature", request_serializer=featurestore_service.CreateFeatureRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_feature"]
@property def batch_create_features( self, ) -> Callable[ [featurestore_service.BatchCreateFeaturesRequest], operations_pb2.Operation ]: r"""Return a callable for the batch create features method over gRPC.
Creates a batch of Features in a given EntityType.
Returns: Callable[[~.BatchCreateFeaturesRequest], ~.Operation]: A function that, when called, will call the underlying RPC on the server. """ # 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 "batch_create_features" not in self._stubs: self._stubs["batch_create_features"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.FeaturestoreService/BatchCreateFeatures", request_serializer=featurestore_service.BatchCreateFeaturesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["batch_create_features"]
@property def get_feature( self, ) -> Callable[[featurestore_service.GetFeatureRequest], feature.Feature]: r"""Return a callable for the get feature method over gRPC.
Gets details of a single Feature.
Returns: Callable[[~.GetFeatureRequest], ~.Feature]: A function that, when called, will call the underlying RPC on the server. """ # 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_feature" not in self._stubs: self._stubs["get_feature"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.FeaturestoreService/GetFeature", request_serializer=featurestore_service.GetFeatureRequest.serialize, response_deserializer=feature.Feature.deserialize, ) return self._stubs["get_feature"]
@property def list_features( self, ) -> Callable[ [featurestore_service.ListFeaturesRequest], featurestore_service.ListFeaturesResponse, ]: r"""Return a callable for the list features method over gRPC.
Lists Features in a given EntityType.
Returns: Callable[[~.ListFeaturesRequest], ~.ListFeaturesResponse]: A function that, when called, will call the underlying RPC on the server. """ # 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_features" not in self._stubs: self._stubs["list_features"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.FeaturestoreService/ListFeatures", request_serializer=featurestore_service.ListFeaturesRequest.serialize, response_deserializer=featurestore_service.ListFeaturesResponse.deserialize, ) return self._stubs["list_features"]
@property def update_feature( self, ) -> Callable[[featurestore_service.UpdateFeatureRequest], gca_feature.Feature]: r"""Return a callable for the update feature method over gRPC.
Updates the parameters of a single Feature.
Returns: Callable[[~.UpdateFeatureRequest], ~.Feature]: A function that, when called, will call the underlying RPC on the server. """ # 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 "update_feature" not in self._stubs: self._stubs["update_feature"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.FeaturestoreService/UpdateFeature", request_serializer=featurestore_service.UpdateFeatureRequest.serialize, response_deserializer=gca_feature.Feature.deserialize, ) return self._stubs["update_feature"]
@property def delete_feature( self, ) -> Callable[ [featurestore_service.DeleteFeatureRequest], operations_pb2.Operation ]: r"""Return a callable for the delete feature method over gRPC.
Deletes a single Feature.
Returns: Callable[[~.DeleteFeatureRequest], ~.Operation]: A function that, when called, will call the underlying RPC on the server. """ # 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 "delete_feature" not in self._stubs: self._stubs["delete_feature"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.FeaturestoreService/DeleteFeature", request_serializer=featurestore_service.DeleteFeatureRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_feature"]
@property def import_feature_values( self, ) -> Callable[ [featurestore_service.ImportFeatureValuesRequest], operations_pb2.Operation ]: r"""Return a callable for the import feature values method over gRPC.
Imports Feature values into the Featurestore from a source storage. The progress of the import is tracked by the returned operation. The imported features are guaranteed to be visible to subsequent read operations after the operation is marked as successfully done.
If an import operation fails, the Feature values returned from reads and exports may be inconsistent. If consistency is required, the caller must retry the same import request again and wait till the new operation returned is marked as successfully done.
There are also scenarios where the caller can cause inconsistency.
- Source data for import contains multiple distinct Feature values for the same entity ID and timestamp. - Source is modified during an import. This includes adding, updating, or removing source data and/or metadata. Examples of updating metadata include but are not limited to changing storage location, storage class, or retention policy. - Online serving cluster is under-provisioned.
Returns: Callable[[~.ImportFeatureValuesRequest], ~.Operation]: A function that, when called, will call the underlying RPC on the server. """ # 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 "import_feature_values" not in self._stubs: self._stubs["import_feature_values"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.FeaturestoreService/ImportFeatureValues", request_serializer=featurestore_service.ImportFeatureValuesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["import_feature_values"]
@property def batch_read_feature_values( self, ) -> Callable[ [featurestore_service.BatchReadFeatureValuesRequest], operations_pb2.Operation ]: r"""Return a callable for the batch read feature values method over gRPC.
Batch reads Feature values from a Featurestore.
This API enables batch reading Feature values, where each read instance in the batch may read Feature values of entities from one or more EntityTypes. Point-in-time correctness is guaranteed for Feature values of each read instance as of each instance's read timestamp.
Returns: Callable[[~.BatchReadFeatureValuesRequest], ~.Operation]: A function that, when called, will call the underlying RPC on the server. """ # 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 "batch_read_feature_values" not in self._stubs: self._stubs["batch_read_feature_values"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.FeaturestoreService/BatchReadFeatureValues", request_serializer=featurestore_service.BatchReadFeatureValuesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["batch_read_feature_values"]
@property def export_feature_values( self, ) -> Callable[ [featurestore_service.ExportFeatureValuesRequest], operations_pb2.Operation ]: r"""Return a callable for the export feature values method over gRPC.
Exports Feature values from all the entities of a target EntityType.
Returns: Callable[[~.ExportFeatureValuesRequest], ~.Operation]: A function that, when called, will call the underlying RPC on the server. """ # 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 "export_feature_values" not in self._stubs: self._stubs["export_feature_values"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.FeaturestoreService/ExportFeatureValues", request_serializer=featurestore_service.ExportFeatureValuesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["export_feature_values"]
@property def delete_feature_values( self, ) -> Callable[ [featurestore_service.DeleteFeatureValuesRequest], operations_pb2.Operation ]: r"""Return a callable for the delete feature values method over gRPC.
Delete Feature values from Featurestore.
The progress of the deletion is tracked by the returned operation. The deleted feature values are guaranteed to be invisible to subsequent read operations after the operation is marked as successfully done.
If a delete feature values operation fails, the feature values returned from reads and exports may be inconsistent. If consistency is required, the caller must retry the same delete request again and wait till the new operation returned is marked as successfully done.
Returns: Callable[[~.DeleteFeatureValuesRequest], ~.Operation]: A function that, when called, will call the underlying RPC on the server. """ # 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 "delete_feature_values" not in self._stubs: self._stubs["delete_feature_values"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.FeaturestoreService/DeleteFeatureValues", request_serializer=featurestore_service.DeleteFeatureValuesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_feature_values"]
@property def search_features( self, ) -> Callable[ [featurestore_service.SearchFeaturesRequest], featurestore_service.SearchFeaturesResponse, ]: r"""Return a callable for the search features method over gRPC.
Searches Features matching a query in a given project.
Returns: Callable[[~.SearchFeaturesRequest], ~.SearchFeaturesResponse]: A function that, when called, will call the underlying RPC on the server. """ # 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 "search_features" not in self._stubs: self._stubs["search_features"] = self._logged_channel.unary_unary( "/google.cloud.aiplatform.v1.FeaturestoreService/SearchFeatures", request_serializer=featurestore_service.SearchFeaturesRequest.serialize, response_deserializer=featurestore_service.SearchFeaturesResponse.deserialize, ) return self._stubs["search_features"]
def close(self): self._logged_channel.close()
@property def delete_operation( self, ) -> Callable[[operations_pb2.DeleteOperationRequest], None]: r"""Return a callable for the delete_operation 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 "delete_operation" not in self._stubs: self._stubs["delete_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/DeleteOperation", request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, response_deserializer=None, ) return self._stubs["delete_operation"]
@property def cancel_operation( self, ) -> Callable[[operations_pb2.CancelOperationRequest], None]: r"""Return a callable for the cancel_operation 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 "cancel_operation" not in self._stubs: self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, ) return self._stubs["cancel_operation"]
@property def wait_operation( self, ) -> Callable[[operations_pb2.WaitOperationRequest], None]: r"""Return a callable for the wait_operation 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 "wait_operation" not in self._stubs: self._stubs["wait_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/WaitOperation", request_serializer=operations_pb2.WaitOperationRequest.SerializeToString, response_deserializer=None, ) return self._stubs["wait_operation"]
@property def get_operation( self, ) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]: r"""Return a callable for the get_operation 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_operation" not in self._stubs: self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["get_operation"]
@property def list_operations( self, ) -> Callable[ [operations_pb2.ListOperationsRequest], operations_pb2.ListOperationsResponse ]: r"""Return a callable for the list_operations 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_operations" not in self._stubs: self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, ) return self._stubs["list_operations"]
@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._logged_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._logged_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 set_iam_policy( self, ) -> Callable[[iam_policy_pb2.SetIamPolicyRequest], policy_pb2.Policy]: r"""Return a callable for the set iam policy method over gRPC. Sets the IAM access control policy on the specified function. Replaces any existing policy. Returns: Callable[[~.SetIamPolicyRequest], ~.Policy]: A function that, when called, will call the underlying RPC on the server. """ # 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 "set_iam_policy" not in self._stubs: self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, ) return self._stubs["set_iam_policy"]
@property def get_iam_policy( self, ) -> Callable[[iam_policy_pb2.GetIamPolicyRequest], policy_pb2.Policy]: r"""Return a callable for the get iam policy method over gRPC. Gets the IAM access control policy for a function. Returns an empty policy if the function exists and does not have a policy set. Returns: Callable[[~.GetIamPolicyRequest], ~.Policy]: A function that, when called, will call the underlying RPC on the server. """ # 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_iam_policy" not in self._stubs: self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, ) return self._stubs["get_iam_policy"]
@property def test_iam_permissions( self, ) -> Callable[ [iam_policy_pb2.TestIamPermissionsRequest], iam_policy_pb2.TestIamPermissionsResponse, ]: r"""Return a callable for the test iam permissions method over gRPC. Tests the specified permissions against the IAM access control policy for a function. If the function does not exist, this will return an empty set of permissions, not a NOT_FOUND error. Returns: Callable[[~.TestIamPermissionsRequest], ~.TestIamPermissionsResponse]: A function that, when called, will call the underlying RPC on the server. """ # 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 "test_iam_permissions" not in self._stubs: self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.iam.v1.IAMPolicy/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, ) return self._stubs["test_iam_permissions"]
@property def kind(self) -> str: return "grpc"
__all__ = ("FeaturestoreServiceGrpcTransport",)data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/dataset_service/__pycache__/__init__.cpython-311.pycAdded
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/dataset_service/__pycache__/pagers.cpython-311.pycAdded
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/dataset_service/transports/__init__.pyAdded+54
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/dataset_service/transports/__pycache__/grpc.cpython-311.pycAdded
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/dataset_service/transports/base.pyAdded+611
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/dataset_service/transports/grpc.pyAdded+1087
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/dataset_service/transports/grpc_asyncio.pyAdded+1269
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/dataset_service/transports/rest.pyAdded
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/dataset_service/transports/rest_asyncio.pyAdded
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/dataset_service/transports/rest_base.pyAdded
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/endpoint_service/__pycache__/__init__.cpython-311.pycAdded
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/endpoint_service/__pycache__/async_client.cpython-311.pycAdded
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/endpoint_service/__pycache__/pagers.cpython-311.pycAdded
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/endpoint_service/transports/__init__.pyAdded+54
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/endpoint_service/transports/__pycache__/__init__.cpython-311.pycAdded
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/endpoint_service/transports/__pycache__/base.cpython-311.pycAdded
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/endpoint_service/transports/__pycache__/grpc.cpython-311.pycAdded
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/endpoint_service/transports/__pycache__/grpc_asyncio.cpython-311.pycAdded
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/endpoint_service/transports/__pycache__/rest_base.cpython-311.pycAdded
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/endpoint_service/transports/base.pyAdded+446
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/endpoint_service/transports/grpc.pyAdded+809
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/endpoint_service/transports/grpc_asyncio.pyAdded+935
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/endpoint_service/transports/rest.pyAdded
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/endpoint_service/transports/rest_asyncio.pyAdded
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/endpoint_service/transports/rest_base.pyAdded
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/feature_online_store_service/__pycache__/__init__.cpython-311.pycAdded
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/feature_online_store_service/__pycache__/async_client.cpython-311.pycAdded
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/feature_online_store_service/__pycache__/client.cpython-311.pycAdded
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/feature_online_store_service/transports/__init__.pyAdded+56
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/feature_online_store_service/transports/__pycache__/__init__.cpython-311.pycAdded
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/feature_online_store_service/transports/__pycache__/base.cpython-311.pycAdded
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/feature_online_store_service/transports/__pycache__/grpc.cpython-311.pycAdded
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/feature_online_store_service/transports/__pycache__/grpc_asyncio.cpython-311.pycAdded
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/feature_online_store_service/transports/__pycache__/rest.cpython-311.pycAdded
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/feature_online_store_service/transports/__pycache__/rest_base.cpython-311.pycAdded
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/feature_online_store_service/transports/base.pyAdded+377
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/feature_online_store_service/transports/grpc.pyAdded+668
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/feature_online_store_service/transports/grpc_asyncio.pyAdded+756
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/feature_online_store_service/transports/rest.pyAdded
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/feature_online_store_service/transports/rest_asyncio.pyAdded
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/feature_online_store_service/transports/rest_base.pyAdded
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/featurestore_service/__pycache__/__init__.cpython-311.pycAdded
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/featurestore_service/__pycache__/pagers.cpython-311.pycAdded
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/featurestore_service/transports/__init__.pyAdded+56
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/featurestore_service/transports/__pycache__/__init__.cpython-311.pycAdded
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/featurestore_service/transports/__pycache__/base.cpython-311.pycAdded
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/featurestore_service/transports/__pycache__/grpc.cpython-311.pycAdded
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/featurestore_service/transports/__pycache__/grpc_asyncio.cpython-311.pycAdded
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/featurestore_service/transports/base.pyAdded+626
data/conda_envs/evalclaw/lib/python3.11/site-packages/google/cloud/aiplatform_v1/services/featurestore_service/transports/grpc.pyAdded+1199