|
44 | 44 | except AttributeError: # pragma: NO COVER
|
45 | 45 | OptionalRetry = Union[retries.AsyncRetry, object, None] # type: ignore
|
46 | 46 |
|
| 47 | +from google.api_core import operation # type: ignore |
| 48 | +from google.api_core import operation_async # type: ignore |
47 | 49 | from google.cloud.aiplatform_v1beta1.services.model_garden_service import pagers
|
48 | 50 | from google.cloud.aiplatform_v1beta1.types import model
|
49 | 51 | from google.cloud.aiplatform_v1beta1.types import model_garden_service
|
@@ -78,6 +80,10 @@ class ModelGardenServiceAsyncClient:
|
78 | 80 | _DEFAULT_ENDPOINT_TEMPLATE = ModelGardenServiceClient._DEFAULT_ENDPOINT_TEMPLATE
|
79 | 81 | _DEFAULT_UNIVERSE = ModelGardenServiceClient._DEFAULT_UNIVERSE
|
80 | 82 |
|
| 83 | + endpoint_path = staticmethod(ModelGardenServiceClient.endpoint_path) |
| 84 | + parse_endpoint_path = staticmethod(ModelGardenServiceClient.parse_endpoint_path) |
| 85 | + model_path = staticmethod(ModelGardenServiceClient.model_path) |
| 86 | + parse_model_path = staticmethod(ModelGardenServiceClient.parse_model_path) |
81 | 87 | publisher_model_path = staticmethod(ModelGardenServiceClient.publisher_model_path)
|
82 | 88 | parse_publisher_model_path = staticmethod(
|
83 | 89 | ModelGardenServiceClient.parse_publisher_model_path
|
@@ -536,6 +542,111 @@ async def sample_list_publisher_models():
|
536 | 542 | # Done; return the response.
|
537 | 543 | return response
|
538 | 544 |
|
| 545 | + async def deploy_publisher_model( |
| 546 | + self, |
| 547 | + request: Optional[ |
| 548 | + Union[model_garden_service.DeployPublisherModelRequest, dict] |
| 549 | + ] = None, |
| 550 | + *, |
| 551 | + retry: OptionalRetry = gapic_v1.method.DEFAULT, |
| 552 | + timeout: Union[float, object] = gapic_v1.method.DEFAULT, |
| 553 | + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), |
| 554 | + ) -> operation_async.AsyncOperation: |
| 555 | + r"""Deploys publisher models. |
| 556 | +
|
| 557 | + .. code-block:: python |
| 558 | +
|
| 559 | + # This snippet has been automatically generated and should be regarded as a |
| 560 | + # code template only. |
| 561 | + # It will require modifications to work: |
| 562 | + # - It may require correct/in-range values for request initialization. |
| 563 | + # - It may require specifying regional endpoints when creating the service |
| 564 | + # client as shown in: |
| 565 | + # https://googleapis.dev/python/google-api-core/latest/client_options.html |
| 566 | + from google.cloud import aiplatform_v1beta1 |
| 567 | +
|
| 568 | + async def sample_deploy_publisher_model(): |
| 569 | + # Create a client |
| 570 | + client = aiplatform_v1beta1.ModelGardenServiceAsyncClient() |
| 571 | +
|
| 572 | + # Initialize request argument(s) |
| 573 | + request = aiplatform_v1beta1.DeployPublisherModelRequest( |
| 574 | + model="model_value", |
| 575 | + destination="destination_value", |
| 576 | + ) |
| 577 | +
|
| 578 | + # Make the request |
| 579 | + operation = client.deploy_publisher_model(request=request) |
| 580 | +
|
| 581 | + print("Waiting for operation to complete...") |
| 582 | +
|
| 583 | + response = (await operation).result() |
| 584 | +
|
| 585 | + # Handle the response |
| 586 | + print(response) |
| 587 | +
|
| 588 | + Args: |
| 589 | + request (Optional[Union[google.cloud.aiplatform_v1beta1.types.DeployPublisherModelRequest, dict]]): |
| 590 | + The request object. Request message for |
| 591 | + [ModelGardenService.DeployPublisherModel][google.cloud.aiplatform.v1beta1.ModelGardenService.DeployPublisherModel]. |
| 592 | + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, |
| 593 | + should be retried. |
| 594 | + timeout (float): The timeout for this request. |
| 595 | + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be |
| 596 | + sent along with the request as metadata. Normally, each value must be of type `str`, |
| 597 | + but for metadata keys ending with the suffix `-bin`, the corresponding values must |
| 598 | + be of type `bytes`. |
| 599 | +
|
| 600 | + Returns: |
| 601 | + google.api_core.operation_async.AsyncOperation: |
| 602 | + An object representing a long-running operation. |
| 603 | +
|
| 604 | + The result type for the operation will be :class:`google.cloud.aiplatform_v1beta1.types.DeployPublisherModelResponse` Response message for |
| 605 | + [ModelGardenService.DeployPublisherModel][google.cloud.aiplatform.v1beta1.ModelGardenService.DeployPublisherModel]. |
| 606 | +
|
| 607 | + """ |
| 608 | + # Create or coerce a protobuf request object. |
| 609 | + # - Use the request object if provided (there's no risk of modifying the input as |
| 610 | + # there are no flattened fields), or create one. |
| 611 | + if not isinstance(request, model_garden_service.DeployPublisherModelRequest): |
| 612 | + request = model_garden_service.DeployPublisherModelRequest(request) |
| 613 | + |
| 614 | + # Wrap the RPC method; this adds retry and timeout information, |
| 615 | + # and friendly error handling. |
| 616 | + rpc = self._client._transport._wrapped_methods[ |
| 617 | + self._client._transport.deploy_publisher_model |
| 618 | + ] |
| 619 | + |
| 620 | + # Certain fields should be provided within the metadata header; |
| 621 | + # add these here. |
| 622 | + metadata = tuple(metadata) + ( |
| 623 | + gapic_v1.routing_header.to_grpc_metadata( |
| 624 | + (("destination", request.destination),) |
| 625 | + ), |
| 626 | + ) |
| 627 | + |
| 628 | + # Validate the universe domain. |
| 629 | + self._client._validate_universe_domain() |
| 630 | + |
| 631 | + # Send the request. |
| 632 | + response = await rpc( |
| 633 | + request, |
| 634 | + retry=retry, |
| 635 | + timeout=timeout, |
| 636 | + metadata=metadata, |
| 637 | + ) |
| 638 | + |
| 639 | + # Wrap the response in an operation future. |
| 640 | + response = operation_async.from_gapic( |
| 641 | + response, |
| 642 | + self._client._transport.operations_client, |
| 643 | + model_garden_service.DeployPublisherModelResponse, |
| 644 | + metadata_type=model_garden_service.DeployPublisherModelOperationMetadata, |
| 645 | + ) |
| 646 | + |
| 647 | + # Done; return the response. |
| 648 | + return response |
| 649 | + |
539 | 650 | async def list_operations(
|
540 | 651 | self,
|
541 | 652 | request: Optional[operations_pb2.ListOperationsRequest] = None,
|
|
0 commit comments