
                         ~    S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r
  SSKJr  SS	KJr   " S
 S\5      rg)z6Utilities for querying Vertex AI Persistent Resources.    )absolute_import)division)unicode_literals)
list_pager)apis)	constants)util)
console_ioc                   |    \ rS rSrSr\R                  4S jrS rS r	      SS jr
SS jrS	 rS
 rS rS rSrg)PersistentResourcesClient   zAClient used for interacting with the PersistentResource endpoint.c                     [         R                  " [        R                  [        R                  U   5      nUR
                  U l        Xl        UR                  U l	        [        R                  U   U l        g )N)r   GetClientInstancer   AI_PLATFORM_API_NAMEAI_PLATFORM_API_VERSIONMESSAGES_MODULE	_messages_version&projects_locations_persistentResources_serviceAI_PLATFORM_MESSAGE_PREFIX_message_prefix)selfversionclients      <lib/googlecloudsdk/api_lib/ai/persistent_resources/client.py__init__"PersistentResourcesClient.__init__   s[    ##I$B$B$-$E$Eg$NPF++DNMAADM$??HD    c                 `    [        U R                  SR                  U R                  US9S5      $ )z&Returns the API message class by name.z{prefix}{name})prefixnameN)getattrr   formatr   )r   message_names     r   
GetMessage$PersistentResourcesClient.GetMessage'   s9     t';';%1 	  	348: :r   c                 $    U R                  S5      $ )z'Returns the PersistentResource message.PersistentResource)r&   )r   s    r   PersistentResourceMessage3PersistentResourcesClient.PersistentResourceMessage/   s     ??/00r   Nc
                    U R                  5       " XBS9n
Ub  U R                  S5      " US9U
l        U(       a  Xjl        U(       a  Xzl        U(       a.  U R                  S5      " U R                  S5      " SU	S9S9U
l        U R                  [        R                  :X  a4  U R                  R                  U R                  R                  UU
US	95      $ U R                  R                  U R                  R                  UU
US
95      $ )a  Constructs a request and sends it to the endpoint to create a persistent resource.

Args:
  parent: str, The project resource path of the persistent resource to
  create.
  resource_pools: The PersistentResource message instance for the
  creation request.
  persistent_resource_id: The PersistentResource id for the creation
  request.
  display_name: str, The display name of the persistent resource to create.
  kms_key_name: A customer-managed encryption key to use for the persistent
  resource.
  labels: LabelValues, map-like user-defined metadata to organize the
  resource.
  network: Network to peer with the PersistentResource
  enable_custom_service_account: Whether or not to enable this Persistent
    Resource to use a custom service account.
  service_account: A service account (email address string) to use for
    creating the Persistent Resource.

Returns:
  A PersistentResource message instance created.
)displayNameresourcePoolsEncryptionSpec)
kmsKeyNameResourceRuntimeSpecServiceAccountSpecT)enableCustomServiceAccountserviceAccount)serviceAccountSpec)parent)googleCloudAiplatformV1PersistentResourcepersistentResourceId)r6   .googleCloudAiplatformV1beta1PersistentResourcer8   )r*   r&   encryptionSpeclabelsnetworkresourceRuntimeSpecr   r   
GA_VERSIONr   Creater   ;AiplatformProjectsLocationsPersistentResourcesCreateRequest)r   r6   resource_poolspersistent_resource_iddisplay_namekms_key_namer;   r<   enable_custom_service_accountservice_accountpersistent_resources              r   r?    PersistentResourcesClient.Create4   s   B 88: @ +/??;K+L!,#( #) $+!$
///
0!%1E!F-1!0"23 - }}	,,,]]!!
..
T
T8K#9 U   ==RR;N!7 	S 	
 r   c                 t    [         R                  " U R                  U R                  R	                  US9SSUS9$ )zConstructs a list request and sends it to the Persistent Resources endpoint.

Args:
  limit: How many items to return in the list
  region: Which region to list resources from

Returns:
  A Persistent Resource list response message.

)r6   persistentResourcespageSize)fieldbatch_size_attributelimit)r   YieldFromListr   r   9AiplatformProjectsLocationsPersistentResourcesListRequest)r   rN   regions      r   ListPersistentResourcesClient.Listy   sD     ##PP 	Q 	
 $' r   c                 j    U R                   R                  US9nU R                  R                  U5      $ N)r"   )r   8AiplatformProjectsLocationsPersistentResourcesGetRequestr   Getr   r"   requests      r   rW   PersistentResourcesClient.Get   s9    ~~HH I   ==W%%r   c                 j    U R                   R                  US9nU R                  R                  U5      $ rU   )r   ;AiplatformProjectsLocationsPersistentResourcesDeleteRequestr   DeleterX   s      r   r]    PersistentResourcesClient.Delete   6    nnXX Y G ==((r   c                 j    U R                   R                  US9nU R                  R                  U5      $ rU   )r   ;AiplatformProjectsLocationsPersistentResourcesRebootRequestr   RebootrX   s      r   rb    PersistentResourcesClient.Reboot   r_   r   c                 v    [         R                  " USS9nU R                  U5      n[        R                  " XCS9$ )z@Import a messages class instance typed by name from a YAML file.F)binary)message_typestream)r
   ReadFromFileOrStdinr&   export_utilImport)r   	yaml_filer%   datarf   s        r   ImportResourceMessage/PersistentResourcesClient.ImportResourceMessage   s3    )))EBD??<0L<EEr   )r   r   r   r   )NNNNFN)NN)__name__
__module____qualname____firstlineno____doc__r   r>   r   r&   r*   r?   rR   rW   r]   rb   rm   __static_attributes__ r   r   r   r      sS    I&11 I:1 +0!CJ*&))Fr   r   N)rs   
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.utilr   googlecloudsdk.command_lib.air   !googlecloudsdk.command_lib.exportr	   ri   googlecloudsdk.core.consoler
   objectr   ru   r   r   <module>r}      s2    = &  ' ' , 3 A 2HF HFr   