
                            d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ d Zd Zej2                   ej4                  ej6                  j8                  ej6                  j:                        ej<                   G d dej>                                             Z y)z3Vertex AI deployment resource pools create command.    )absolute_import)division)unicode_literals)encoding)
operations)client)base)	constants)deployment_resource_pools_util)endpoint_util)flags)operations_util)region_util)
validation)logc                    t         j                  }| j                  dd       t        j                  | |d       t        j
                         j                  |        t        j                  | dt        j                         y)	zAdding deployment resource pool arguments from CLI.

  Args:
    parser: argparse.ArgumentParser, cli argument parser

  Returns:
    None
  deployment_resource_pool_idzThe ID to use for the DeploymentResourcePool, which will become the final component of the DeploymentResourcePool's resource name. The maximum length is 63 characters, and valid characters are /^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$/.)helpT)drpz"to create deployment resource pool)prompt_funcN)
r
   BETA_VERSIONadd_argumentr   AddPredictionResourcesArgsGetAutoscalingMetricSpecsArgAddToParserAddRegionResourceArgr   .PromptForDeploymentResourcePoolSupportedRegion)parserversions     2lib/surface/ai/deployment_resource_pools/create.py_AddArgsBetar!   #   ss     ""'#-  . ""67=$$&226:*LLN    c                    t        j                  | j                  | j                         t        j
                  }| j                  j                  j                         }|j                         d   | _        t        j                  || j                        5  t        j                  |      }|j                  || j                  | j                   | j"                  | j                  | j$                  | j&                  | j(                  | j*                  | j,                  | j.                  | j                        }t1        j2                  t5        j6                         |t9        j:                  |j<                              }|Jt?        j@                  |      }d|v r1tB        jD                  jG                  djI                  |d                ddd       |S # 1 sw Y   S xY w)z0Create a new Vertex AI deployment resource pool.locationsId)region)r   )
autoscaling_metric_specsaccelerator_dictmin_replica_countmax_replica_countmachine_typetpu_topologymultihost_gpu_node_countreservation_affinityspotrequired_replica_countNnamez/Created Vertex AI deployment resource pool: {}.)%r   ValidateRequiredReplicaCountr/   r(   r
   r   CONCEPTSr%   ParseAsDictr   AiplatformEndpointOverridesr   DeploymentResourcePoolsClient
CreateBetar   r&   acceleratorr)   r*   r+   r,   r-   r.   r   WaitForOpMayber   OperationsClientr   ParseOperationr0   r   MessageToPyValuer   statusPrintformat)argsr   
region_ref deployment_resource_pools_clientopresponse_msgresponses          r    _RunBetarF   ;   s   ))$*E*E*.*@*@B""'}}##))+*!!#M2$+00M'-'K'K($	)	4	4((!%!>!>))0000&&&&!%!>!>!66YY#:: 
5 
B #11##%r&55bgg>@L **<8h	8	

>VHV$%	'/ N4 
5 N4 
s   D4GG c                   &    e Zd ZdZed        Zd Zy)CreateV1Beta1a  Create a new Vertex AI deployment resource pool.

  This command creates a new deployment resource pool with a provided deployment
  resource pool id (name) in a provided region (assuming that region provides
  support for this api). You can choose to simply provide the resource pool
  name and create an instance with default arguments, or you can pass in your
  own preferences, such as the accelerator and machine specs. Please note this
  functionality is not yet available in the GA track and is currently only
  part of the v1beta1 API version.

  ## EXAMPLES

  To create a deployment resource pool with name ``example'' in region
  ``us-central1'', run:

    $ {command} example --region=us-central1
  c                     t        |       S N)r!   )r   s    r    ArgszCreateV1Beta1.Argsu   s    r"   c                     t        |      S rJ   )rF   )selfr@   s     r    RunzCreateV1Beta1.Runy   s    D>r"   N)__name__
__module____qualname____doc__staticmethodrK   rN    r"   r    rH   rH   _   s     $    r"   rH   N)!rR   
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.air   3googlecloudsdk.api_lib.ai.deployment_resource_poolsr   googlecloudsdk.callioper	   googlecloudsdk.command_lib.air
   r   r   r   r   r   r   googlecloudsdk.corer   r!   rF   HiddenReleaseTracksReleaseTrackALPHABETAUniverseCompatibleCreateCommandrH   rT   r"   r    <module>rc      s    : &  ' % 0 F ( 3 H 7 / 9 5 4 #N0!H D%%++T->->-C-CDD&&   E r"   