def deploy_index( self, request: index_endpoint_service.DeployIndexRequest = None, *, index_endpoint: str = None, deployed_index: gca_index_endpoint.DeployedIndex = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> gac_operation.Operation: r"""Deploys an Index into this IndexEndpoint, creating a DeployedIndex within it. Only non-empty Indexes can be deployed. Args: request (google.cloud.aiplatform_v1beta1.types.DeployIndexRequest): The request object. Request message for [IndexEndpointService.DeployIndex][google.cloud.aiplatform.v1beta1.IndexEndpointService.DeployIndex]. index_endpoint (str): Required. The name of the IndexEndpoint resource into which to deploy an Index. Format: ``projects/{project}/locations/{location}/indexEndpoints/{index_endpoint}`` This corresponds to the ``index_endpoint`` field on the ``request`` instance; if ``request`` is provided, this should not be set. deployed_index (google.cloud.aiplatform_v1beta1.types.DeployedIndex): Required. The DeployedIndex to be created within the IndexEndpoint. This corresponds to the ``deployed_index`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.api_core.operation.Operation: An object representing a long-running operation. The result type for the operation will be :class:`google.cloud.aiplatform_v1beta1.types.DeployIndexResponse` Response message for [IndexEndpointService.DeployIndex][google.cloud.aiplatform.v1beta1.IndexEndpointService.DeployIndex]. """ # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([index_endpoint, deployed_index]) if request is not None and has_flattened_params: raise ValueError('If the `request` argument is set, then none of ' 'the individual field arguments should be set.') # Minor optimization to avoid making a copy if the user passes # in a index_endpoint_service.DeployIndexRequest. # There's no risk of modifying the input as we've already verified # there are no flattened fields. if not isinstance(request, index_endpoint_service.DeployIndexRequest): request = index_endpoint_service.DeployIndexRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if index_endpoint is not None: request.index_endpoint = index_endpoint if deployed_index is not None: request.deployed_index = deployed_index # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.deploy_index] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + (gapic_v1.routing_header.to_grpc_metadata( (("index_endpoint", request.index_endpoint), )), ) # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Wrap the response in an operation future. response = gac_operation.from_gapic( response, self._transport.operations_client, index_endpoint_service.DeployIndexResponse, metadata_type=index_endpoint_service.DeployIndexOperationMetadata, ) # Done; return the response. return response
async def deploy_index( self, request: Union[index_endpoint_service.DeployIndexRequest, dict] = None, *, index_endpoint: str = None, deployed_index: gca_index_endpoint.DeployedIndex = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Deploys an Index into this IndexEndpoint, creating a DeployedIndex within it. Only non-empty Indexes can be deployed. .. code-block:: python from google.cloud import aiplatform_v1beta1 def sample_deploy_index(): # Create a client client = aiplatform_v1beta1.IndexEndpointServiceClient() # Initialize request argument(s) deployed_index = aiplatform_v1beta1.DeployedIndex() deployed_index.id = "id_value" deployed_index.index = "index_value" request = aiplatform_v1beta1.DeployIndexRequest( index_endpoint="index_endpoint_value", deployed_index=deployed_index, ) # Make the request operation = client.deploy_index(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.aiplatform_v1beta1.types.DeployIndexRequest, dict]): The request object. Request message for [IndexEndpointService.DeployIndex][google.cloud.aiplatform.v1beta1.IndexEndpointService.DeployIndex]. index_endpoint (:class:`str`): Required. The name of the IndexEndpoint resource into which to deploy an Index. Format: ``projects/{project}/locations/{location}/indexEndpoints/{index_endpoint}`` This corresponds to the ``index_endpoint`` field on the ``request`` instance; if ``request`` is provided, this should not be set. deployed_index (:class:`google.cloud.aiplatform_v1beta1.types.DeployedIndex`): Required. The DeployedIndex to be created within the IndexEndpoint. This corresponds to the ``deployed_index`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.api_core.operation_async.AsyncOperation: An object representing a long-running operation. The result type for the operation will be :class:`google.cloud.aiplatform_v1beta1.types.DeployIndexResponse` Response message for [IndexEndpointService.DeployIndex][google.cloud.aiplatform.v1beta1.IndexEndpointService.DeployIndex]. """ # Create or coerce a protobuf request object. # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([index_endpoint, deployed_index]) if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." ) request = index_endpoint_service.DeployIndexRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if index_endpoint is not None: request.index_endpoint = index_endpoint if deployed_index is not None: request.deployed_index = deployed_index # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = gapic_v1.method_async.wrap_method( self._client._transport.deploy_index, default_timeout=5.0, client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( gapic_v1.routing_header.to_grpc_metadata( (("index_endpoint", request.index_endpoint),) ), ) # Send the request. response = await rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Wrap the response in an operation future. response = operation_async.from_gapic( response, self._client._transport.operations_client, index_endpoint_service.DeployIndexResponse, metadata_type=index_endpoint_service.DeployIndexOperationMetadata, ) # Done; return the response. return response