
    n$                         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y)zMCommands for interacting with the Cloud NetApp Files KMS Config 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 Z	 	 ddZd Zd Zy)KmsConfigsClientzJWrapper for working with KMS Configs in the Cloud NetApp Files API Client.c                    |t         j                  j                  k(  rt               | _        y |t         j                  j
                  k(  rt               | _        y t        dj                  t        j                  |               )Nz [{}] is not a valid API version.)r
   ReleaseTrackBETABetaKmsConfigsAdapter_adapterGAKmsConfigsAdapter
ValueErrorformatnetapp_api_utilVERSION_MAP)selfrelease_tracks     7lib/googlecloudsdk/api_lib/netapp/kms_configs/client.py__init__zKmsConfigsClient.__init__!   sg    ))...+-dm	$++..	.')dm9@@

%
%m
46 7 7    c                 .    | j                   j                  S N)r   clientr   s    r   r!   zKmsConfigsClient.client*   s    ==r   c                 .    | j                   j                  S r    )r   messagesr"   s    r   r$   zKmsConfigsClient.messages.   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!KmsConfigsClient.WaitForOperation2   sL     >>..KK55	
 	%,,]-?-?-AB 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 KMS Config.)parentkmsConfigId	kmsConfig
collection)r$   .NetappProjectsLocationsKmsConfigsCreateRequestParentRelativeNamer)   r!   projects_locations_kmsConfigsCreater   REGISTRYParseRelativeNamenamer   OPERATIONS_COLLECTIONr+   )r   kmsconfig_refasync_
kms_configrequest	create_opr*   s          r   CreateKmsConfigz KmsConfigsClient.CreateKmsConfigF   s    mmJJ##%224!&&( K G
 99@@II&&889#B#B 9 M   //r   Nc                 r    | j                   j                         }||_        ||_        ||_        ||_        |S )a  Parses the command line arguments for Create KMS Config into a message.

    Args:
      name: the name of the KMS Config
      crypto_key_name: the crypto key name of the KMS Config
      description: the description of the KMS COnfig
      labels: the parsed labels value

    Returns:
      The configuration that will be used as the request body for creating a
      Cloud NetApp KMS Config.
    )r$   	KmsConfigr9   cryptoKeyNamedescriptionlabels)r   r9   crypto_key_namerD   rE   r=   s         r   ParseKmsConfigzKmsConfigsClient.ParseKmsConfigU   s;     ((*JJO.J(JJr   c                 f   | j                   j                  |      }| j                  j                  j	                  |      }|j
                  D ]&  }t        j                  dj                  |             ( t        j                  | j                  j                  |t        j                  |d      S )ak  Make API calls to List Cloud NetApp KMS Configs.

    Args:
      location_ref: The parsed location of the listed NetApp KMS Configs.
      limit: The number of Cloud NetApp KMS Configs 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 KMS Config.
    )r-   zLocation {} may be unreachable.pageSize)fieldlimitbatch_size_attribute)r$   ,NetappProjectsLocationsKmsConfigsListRequestr!   r5   Listunreachabler   warningr   r   YieldFromListr   KMS_CONFIG_RESOURCE)r   location_refrK   r>   responselocations         r   ListKmsConfigszKmsConfigsClient.ListKmsConfigsk   s     mmHH I G {{88==gFH((	kk3::8DE )##11++') )r   c                     | j                   j                  |j                               }| j                  j                  j                  |      S )z(Get Cloud NetApp KMS Config information.r9   )r$   +NetappProjectsLocationsKmsConfigsGetRequestr4   r!   r5   Getr   r;   r>   s      r   GetKmsConfigzKmsConfigsClient.GetKmsConfig   sC    mmGG'') H +G;;4488AAr   c                 z    | j                   j                  |j                               }| j                  ||      S )z,Deletes an existing Cloud NetApp KMS Config.rX   )r$   .NetappProjectsLocationsKmsConfigsDeleteRequestr4   _DeleteKmsConfig)r   r;   r<   r>   s       r   DeleteKmsConfigz KmsConfigsClient.DeleteKmsConfig   sB     	DD++- 	E 	
 
   11r   c                     | j                   j                  j                  |      }|r|S t        j                  j                  |j                  t        j                        }| j                  |      S )Nr0   )
r!   r5   Deleter   r7   r8   r9   r   r:   r+   )r   r<   r>   	delete_opr*   s        r   r_   z!KmsConfigsClient._DeleteKmsConfig   sb    99@@II&&889#B#B 9 M   //r   c                     | j                   j                  |||      }|r|S t        j                  j	                  |j
                  t        j                        }| j                  |      S )aU  Updates a KMS Config.

    Args:
      kmsconfig_ref: the reference to the kms config.
      kms_config: KMS Config message, the updated kms config.
      update_mask: str, a comma-separated list of updated fields.
      async_: bool, if False, wait for the operation to complete.

    Returns:
      an Operation or KMS Config message.
    r0   )	r   UpdateKmsConfigr   r7   r8   r9   r   r:   r+   )r   r;   r=   update_maskr<   	update_opr*   s          r   re   z KmsConfigsClient.UpdateKmsConfig   se     --m.8+GI&&889#B#B 9 DM  //r   c                 @    | j                   j                  ||||      S )z"Parses updates into an kms config.)r=   rF   rD   rE   )r   ParseUpdatedKmsConfigr   r=   rF   rD   rE   s        r   ri   z&KmsConfigsClient.ParseUpdatedKmsConfig   s,     ==..'	 /  r   c                 <   | j                   j                  |j                               }| j                  j                  j                  |      }|r|S t        j                  j                  |j                  t        j                        }| j                  |      S )z=Encrypts the volumes attached to the Cloud NetApp KMS Config.rX   r0   )r$   /NetappProjectsLocationsKmsConfigsEncryptRequestr4   r!   r5   Encryptr   r7   r8   r9   r   r:   r+   )r   r;   r<   r>   
encrypt_opr*   s         r   EncryptKmsConfigz!KmsConfigsClient.EncryptKmsConfig   s     	EE++- 	F 	
 
 ::BB7KJ&&88I$C$C 9 EM  //r   c                     | j                   j                  |j                               }| j                  j                  j                  |      S )z:Verifies the Cloud NetApp Volumes KMS Config is reachable.rX   )r$   .NetappProjectsLocationsKmsConfigsVerifyRequestr4   r!   r5   Verifyr[   s      r   VerifyKmsConfigz KmsConfigsClient.VerifyKmsConfig   sO     	DD++- 	E 	
 
 ;;44;; r   )NNNNr    )NN)__name__
__module____qualname____doc__r
   r   r   r   propertyr!   r$   r+   r@   rG   rV   r\   r`   r_   re   ri   ro   rs    r   r   r   r      s    R#'#4#4#9#9 7     " "(0  GK,)0B200. )-#'	
0	r   r   c                   &    e Zd ZdZd Z	 ddZd Zy)r   z7Adapter for the Cloud NetApp Files API for KMS Configs.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KmsConfigsAdapter.__init__   sN    **--D!33((DK $55((DMr   Nc                 <    |||_         |||_        |||_        |S )z%Parses updates into a new kms config.)rC   rD   rE   rj   s        r   ri   z'KmsConfigsAdapter.ParseUpdatedKmsConfig   s4     "!0j*j jr   c                     | j                   j                  ||j                         |      }| j                  j                  j                  |      }|S )z5Send a Patch request for the Cloud NetApp KMS Config.)r/   r9   
updateMask)r$   -NetappProjectsLocationsKmsConfigsPatchRequestr4   r!   r5   Patch)r   r;   r=   rf   update_requestrg   s         r   re   z!KmsConfigsAdapter.UpdateKmsConfig   sX     	CC ++-" 	D 	$ 
 99??Ir   )NNN)rt   ru   rv   rw   r   ri   re   ry   r   r   r   r      s    ? HL
	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 KMS Configs.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BetaKmsConfigsAdapter.__init__   s]    	
/1**//D!33((DK $55((DMr   )rt   ru   rv   rw   r   __classcell__)r   s   @r   r   r      s    D r   r   N)rw   
__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   ry   r   r   <module>r      sR    T &  ' ' 3 A . ( # )tv tn! !H- r   