
    J                         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  G d de      Z G d de      Z G d de      Z G d de      Zy)zOCommands for interacting with the Cloud NetApp Files Storage Pool API resource.    )absolute_import)division)unicode_literals)
list_pager)	constants)util)waiter)base)log)	resourcesc                       e Zd ZdZej
                  j                  fdZed        Z	ed        Z
d Zd Z	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZdd	Zd
 Zd Zd Z	 	 	 	 	 	 	 	 	 	 	 	 ddZd Zd Zd Zy)StoragePoolsClientzNWrapper for working with Storage Pool in the Cloud NetApp Files API Client.
  c                    || _         | j                   t        j                  j                  k(  rt	               | _        y | j                   t        j                  j                  k(  rt               | _        y | j                   t        j                  j                  k(  rt               | _        y t        dj                  t        j                  |               )Nz [{}] is not a valid API version.)release_trackr
   ReleaseTrackALPHAAlphaStoragePoolsAdapter_adapterBETABetaStoragePoolsAdapterGAStoragePoolsAdapter
ValueErrorformatnetapp_api_utilVERSION_MAP)selfr   s     9lib/googlecloudsdk/api_lib/netapp/storage_pools/client.py__init__zStoragePoolsClient.__init__"   s    &DT..444.0dm			t0055	5-/dm			t0033	3)+dm9@@

%
%m
46 7 7    c                 .    | j                   j                  S N)r   clientr   s    r   r#   zStoragePoolsClient.client.   s    ==r    c                 .    | j                   j                  S r"   )r   messagesr$   s    r   r&   zStoragePoolsClient.messages2   s    ==!!!r    c                     t        j                  t        j                  | j                  j                        |dj                  |j                                     S )a  Waits on the long-running operation until the done field is True.

    Args:
      operation_ref: the operation reference.

    Raises:
      waiter.OperationError: if the operation contains an error.

    Returns:
      the 'response' field of the Operation.
    zWaiting for [{0}] to finish)r	   WaitForCloudOperationPollerNoResourcesr#   projects_locations_operationsr   Name)r   operation_refs     r   WaitForOperationz#StoragePoolsClient.WaitForOperation6   sL     >>..KK55	78E%,,]-?-?-ABD Dr    c                 x   | j                   j                  |j                         j                         |j	                         |      }| j
                  j                  j                  |      }|r|S t        j                  j                  |j                  t        j                        }| j                  |      S )z#Create a Cloud NetApp Storage Pool.)parentstoragePoolIdstoragePool
collection)r&   0NetappProjectsLocationsStoragePoolsCreateRequestParentRelativeNamer+   r#   projects_locations_storagePoolsCreater   REGISTRYParseRelativeNamenamer   OPERATIONS_COLLECTIONr-   )r   storagepool_refasync_configrequest	create_opr,   s          r   CreateStoragePoolz$StoragePoolsClient.CreateStoragePoolG   s    mmLL%%'446%**, M G ;;BB7KI&&889#B#B 9 DM  //r    Nc                 `    | j                   j                  |||||||||	|
||||||||||      S )zHParses the command line arguments for Create Storage Pool into a config.)r;   service_levelnetwork
kms_configactive_directoryenable_ldapcapacitydescriptionallow_auto_tieringzonereplica_zonecustom_performance_enabledtotal_throughput
total_iopshot_tier_sizeenable_hot_tier_auto_resizelabelsunified_poolqos_typestorage_pool_type)r   ParseStoragePoolConfig)r   r;   rD   rE   rG   rF   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   s                        r   rW   z)StoragePoolsClient.ParseStoragePoolConfigT   s\    . ==//#)-!#=)#$?!+) 0  r    c                 f   | j                   j                  |      }| j                  j                  j	                  |      }|j
                  D ]&  }t        j                  dj                  |             ( t        j                  | j                  j                  |t        j                  |d      S )ao  Make API calls to List active Cloud NetApp Storage Pools.

    Args:
      location_ref: The parsed location of the listed NetApp Volumes.
      limit: The number of Cloud NetApp Storage Pools to limit the results to.
        This limit is passed to the server and the server does the limiting.

    Returns:
      Generator that yields the Cloud NetApp Volumes.
    )r/   zLocation {} may be unreachable.pageSize)fieldlimitbatch_size_attribute)r&   .NetappProjectsLocationsStoragePoolsListRequestr#   r7   Listunreachabler   warningr   r   YieldFromListr   STORAGE_POOL_RESOURCE)r   location_refr[   r@   responselocations         r   ListStoragePoolsz#StoragePoolsClient.ListStoragePools   s     mmJJ K G {{::??HH((	kk3::8DE )##33--') )r    c                     | j                   j                  |j                               }| j                  j                  j                  |      S )z*Get Cloud NetApp Storage Pool information.r;   )r&   -NetappProjectsLocationsStoragePoolsGetRequestr6   r#   r7   Get)r   r=   r@   s      r   GetStoragePoolz!StoragePoolsClient.GetStoragePool   sC    mmII))+ J -G;;66::7CCr    c                 z    | j                   j                  |j                               }| j                  ||      S )z.Deletes an existing Cloud NetApp Storage Pool.rh   )r&   0NetappProjectsLocationsStoragePoolsDeleteRequestr6   _DeleteStoragePool)r   r=   r>   r@   s       r   DeleteStoragePoolz$StoragePoolsClient.DeleteStoragePool   s;    mmLL))+ M -G""6733r    c                     | j                   j                  j                  |      }|r|S t        j                  j                  |j                  t        j                        }| j                  |      S )Nr2   )
r#   r7   Deleter   r9   r:   r;   r   r<   r-   )r   r>   r@   	delete_opr,   s        r   rn   z%StoragePoolsClient._DeleteStoragePool   sa    ;;BB7KI&&889#B#B 9 DM  //r    c                 V    | j                   j                  |||||||||	|
|||      }|S )a  Parses updates into a storage pool config.

    Args:
      storagepool_config: The storage pool message to update.
      capacity: capacity of a storage pool
      active_directory: the Active Directory attached to a storage pool
      description: str, a new description, if any.
      allow_auto_tiering: bool indicate whether pool supports auto-tiering
      zone: str, zone for storage pool
      replica_zone: str, replica zone for storage pool
      total_throughput: int, total throughput of the storage pool
      total_iops: int, total IOPS of the storage pool
      hot_tier_size: int, hot tier size of the storage pool
      enable_hot_tier_auto_resize: bool, whether hot tier auto resize is enabled
      for the storage pool
      qos_type: qos (quality of service) type of the storage pool
      labels: LabelsValue message, the new labels value, if any.

    Returns:
      The storage pool message.
    )rI   rG   rJ   rK   rL   rM   rO   rP   rQ   rR   rU   rS   )r   ParseUpdatedStoragePoolConfig)r   storagepool_configrI   rG   rJ   rK   rL   rM   rO   rP   rQ   rR   rU   rS   storage_pools                  r   rt   z0StoragePoolsClient.ParseUpdatedStoragePoolConfig   sM    H ==>>)-!)#$? ? L r    c                     | j                   j                  |||      }|r|S t        j                  j	                  |j
                  t        j                        }| j                  |      S )ai  Updates a Storage Pool.

    Args:
      storagepool_ref: the reference to the storage pool.
      storagepool_config: Storage Pool message, the updated storage pool.
      update_mask: str, a comma-separated list of updated fields.
      async_: bool, if False, wait for the operation to complete.

    Returns:
      an Operation or Storage Pool message.
    r2   )	r   UpdateStoragePoolr   r9   r:   r;   r   r<   r-   )r   r=   ru   update_maskr>   	update_opr,   s          r   rx   z$StoragePoolsClient.UpdateStoragePool   se     //0BKQI&&889#B#B 9 DM  //r    c                     | j                   j                  |      }|r|S t        j                  j	                  |j
                  t        j                        }| j                  |      S )aB  Switch the zone of a Regional Cloud NetApp Storage Pooln.

    Args:
      storagepool_ref: the reference to the storage pool.
      async_: bool, if False, wait for the operation to complete.

    Returns:
      an Operation if async_ is set to true, or a switch message if the
      SwtichStoragePool is successful.
    r2   )	r   SwitchStoragePoolr   r9   r:   r;   r   r<   r-   )r   r=   r>   	switch_opr,   s        r   r|   z$StoragePoolsClient.SwitchStoragePool   s^     //@I&&889#B#B 9 M   //r    c                     | j                   j                  ||      }|r|S t        j                  j	                  |j
                  t        j                        }| j                  |      S )a  Validates the directory service attached to the storage pool.

    Args:
      storagepool_ref: the reference to the storage pool.
      directory_service_type: the type of directory service to validate.
      async_: bool, if False, wait for the operation to complete.

    Returns:
      an Operation if async_ is set to true, or a validate message if the
      validation is successful.
    r2   )	r   ValidateDirectoryServicer   r9   r:   r;   r   r<   r-   )r   r=   directory_service_typer>   validate_opr,   s         r   r   z+StoragePoolsClient.ValidateDirectoryService  sh     --88/K &&88Y%D%D 9 M   //r    )NNNNNNNNNNNNNNNNNNNNr"   NNNNNNNNNNNN)__name__
__module____qualname____doc__r
   r   r   r   propertyr#   r&   r-   rB   rW   rf   rk   ro   rn   rt   rx   r|   r    r    r   r   r      s     $(#4#4#:#: 
7     " "D"0 #'+/%).2(,)-&*)-04"&*.8<.2(,+/9=$(*.&*/3),\)0D40 .259047;)-1559/326@D-1+/3j0,0&0r    r   c                   N    e Zd ZdZd Zd Z	 	 	 	 	 	 	 	 	 	 	 	 d	dZd Zd Zd Z	y)
r   z9Adapter for the Cloud NetApp Files API for Storage Pools.c                     t         j                  j                  | _        t	        j
                  | j                        | _        t	        j                  | j                        | _        y N)r   )	r
   r   r   r   r   GetClientInstancer#   GetMessagesModuler&   r$   s    r   r   zStoragePoolsAdapter.__init__'  sN    **--D!33((DK $55((DMr    c                    | j                   j                         }||_        ||_        |j	                  d      |_        d|v r|j	                  d      |_        ||_        ||_        ||_	        ||_
        ||_        |	|	|_        |
|
|_        |||_        |||_        |||_        |||_        |||_        |||_        |||_        ||_        |||_        |||_        |S )ah  Parses the command line arguments for Create Storage Pool into a config.

    Args:
      name: the name of the Storage Pool
      service_level: the service level of the Storage Pool
      network: the network of the Storage Pool
      kms_config: the KMS Config of the Storage Pool
      active_directory: the Active Directory of the Storage Pool
      enable_ldap: Bool on whether to enable LDAP on Storage Pool
      capacity: the storage capacity of the Storage Pool
      description: the description of the Storage Pool
      allow_auto_tiering: Bool on whether Storage Pool supports auto tiering
      zone: zone of the Storage Pool
      replica_zone: Replica zone for the Storage Pool
      custom_performance_enabled: Bool on whether custom performance is enabled
      total_throughput: Total throughput of the Storage Pool
      total_iops: Total IOPS of the Storage Pool
      hot_tier_size: Hot tier size of the Storage Pool
      enable_hot_tier_auto_resize: Bool on whether hot tier auto resize is
        enabled
      qos_type: qos (quality of service) type of the storage pool
      labels: the parsed labels value
      unified_pool: Bool on whether the Storage Pool is a unified pool
      storage_pool_type: Type of the Storage Pool

    Returns:
      The configuration that will be used as the request body for creating a
      Cloud NetApp Storage Pool.
    r;   z	psa-range)r&   StoragePoolr;   serviceLevelgetrE   psaRange	kmsConfigactiveDirectoryldapEnabledcapacityGibrJ   allowAutoTieringrL   replicaZonecustomPerformanceEnabledtotalThroughputMibps	totalIopshotTierSizeGibenableHotTierAutoResizeqosTyperS   unifiedPooltype)r   r;   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rU   rS   rT   rV   rv   s                         r   rW   z*StoragePoolsAdapter.ParseStoragePoolConfig0  s!   h ==,,.LL -L";;v.Lg%kk+6l'L#3L *L'L*L%&8l#l!-l!-.Hl+#*:l')l $1l!".-Hl*%l L!-l$+lr    Nc                     |||_         |||_        |||_        |||_        |||_        |||_        |	|	|_        |
|
|_        |||_        |||_	        |||_
        |||_        |S )z>Parse update information into an updated Storage Pool message.)r   r   rJ   r   rL   r   r   r   r   r   r   rS   )r   ru   rJ   rG   rS   rI   rK   rL   rM   rO   rP   rQ   rR   rU   s                 r   rt   z1StoragePoolsAdapter.ParseUpdatedStoragePoolConfig  s    " '/$#+;('2$%,>) $'3$#0@-%/" *7'".3N0#+ "(r    c                     | j                   j                  ||j                         |      }| j                  j                  j                  |      }|S )z7Send a Patch request for the Cloud NetApp Storage Pool.)r1   r;   
updateMask)r&   /NetappProjectsLocationsStoragePoolsPatchRequestr6   r#   r7   Patch)r   r=   ru   ry   update_requestrz   s         r   rx   z%StoragePoolsAdapter.UpdateStoragePool  sZ     	EE* --/" 	F 	
  ;;AAI r    c                     | j                   j                  |j                               }| j                  j                  j                  |      S )z=Send a switch zone request for the Cloud NetApp storage pool.rh   )r&   0NetappProjectsLocationsStoragePoolsSwitchRequestr6   r#   r7   Switch)r   r=   switch_requests      r   r|   z%StoragePoolsAdapter.SwitchStoragePool  sJ     	FF --/ 	G 	
 
 ;;66==nMMr    c                     | j                   j                  |      }| j                   j                  |j                         |      }| j                  j
                  j                  |      S )zLSend a validate directory service request for the Cloud NetApp storage pool.)directoryServiceType)r;   validateDirectoryServiceRequest)r&   ValidateDirectoryServiceRequestBNetappProjectsLocationsStoragePoolsValidateDirectoryServiceRequestr6   r#   r7   r   )r   r=   r   r@   validate_requests        r   r   z,StoragePoolsAdapter.ValidateDirectoryService  sl    mm;;3 < G }}gg))+(/ h  ;;66OO r    r   )
r   r   r   r   r   rW   rt   rx   r|   r   r   r    r   r   r   $  sM    AVv "&)VNr    r   c                   "     e Zd ZdZ fdZ xZS )r   z>Adapter for the Beta Cloud NetApp Files API for Storage Pools.c                     t         t        |           t        j                  j
                  | _        t        j                  | j                        | _	        t        j                  | j                        | _        y r   )superr   r   r
   r   r   r   r   r   r#   r   r&   r   	__class__s    r   r   z BetaStoragePoolsAdapter.__init__  s]    	
!413**//D!33((DK $55((DMr    r   r   r   r   r   __classcell__r   s   @r   r   r     s    F r    r   c                   "     e Zd ZdZ fdZ xZS )r   z?Adapter for the Alpha Cloud NetApp Files API for Storage Pools.c                     t         t        |           t        j                  j
                  | _        t        j                  | j                        | _	        t        j                  | j                        | _        y r   )r   r   r   r
   r   r   r   r   r   r#   r   r&   r   s    r   r   z!AlphaStoragePoolsAdapter.__init__  s]    	
"D24**00D!33((DK $55((DMr    r   r   s   @r   r   r     s    G r    r   N)r   
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.netappr   r   r   googlecloudsdk.api_lib.utilr	   googlecloudsdk.callioper
   googlecloudsdk.corer   r   objectr   r   r   r   r   r    r   <module>r      sa    V &  ' ' 3 A . ( # )C0 C0Lq& qh1 6 r    