
    K                         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	Zd
Z G d de      Z G d de      Z G d de      Z G d de      Zy)z@Useful commands for interacting with the Cloud NetApp Files API.    )absolute_import)division)unicode_literals)
list_pager)util)waiter)basenetappv1alpha1c                       e Zd ZdZej
                  j                  fdZed        Z	ed        Z
d Zd Zd Zd Zdd
ZddZy	)NetAppClientz;Wrapper for working with the Cloud NetApp Files API Client.c                 f   |t         j                  j                  k(  rt               | _        y |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ALPHAAlphaNetappAdapter_adapterBETABetaNetappAdapterGANetappAdapter
ValueErrorformatr   VERSION_MAP)selfrelease_tracks     2lib/googlecloudsdk/api_lib/netapp/netapp_client.py__init__zNetAppClient.__init__!   s    ))///(*dm	$++00	0')dm	$++..	.#odm9@@


=
)+ , ,    c                 .    | j                   j                  S N)r   clientr   s    r   r!   zNetAppClient.client,   s    ==r   c                 .    | j                   j                  S r    )r   messagesr"   s    r   r$   zNetAppClient.messages0   s    ==!!!r   c                     | j                   j                  |j                               }| j                  j                  j                  |      S )zGets description of a long-running operation.

    Args:
      operation_ref: the operation reference.

    Returns:
      messages.GoogleLongrunningOperation, the operation.
    name)r$   +NetappProjectsLocationsOperationsGetRequestRelativeNamer!   projects_locations_operationsGetr   operation_refrequests      r   GetOperationzNetAppClient.GetOperation4   sE     mmGG'') H +G;;4488AAr   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!   r*   r   Name)r   r-   s     r   WaitForOperationzNetAppClient.WaitForOperationA   sL     >>..KK55	78E%,,]-?-?-ABD Dr   c                     | j                   j                  |j                               }| j                  j                  j                  |      S )zCancels a long-running operation.

    Args:
      operation_ref: the operation reference.

    Returns:
      Empty response message.
    r&   )r$   .NetappProjectsLocationsOperationsCancelRequestr)   r!   r*   Cancelr,   s      r   CancelOperationzNetAppClient.CancelOperationR   sE     mmJJ'') K +G;;44;;GDDr   c                     | j                   j                  |      }| j                  j                  j	                  |      S )Nr&   )r$   !NetappProjectsLocationsGetRequestr!   projects_locationsr+   )r   location_refr.   s      r   GetLocationzNetAppClient.GetLocation_   s4    mm==<=PG;;))--g66r   Nc                     | j                   j                  |j                               }t        j                  | j
                  j                  |d|d      S )Nr&   	locationspageSizefieldlimitbatch_size_attribute)r$   "NetappProjectsLocationsListRequestr)   r   YieldFromListr!   r;   )r   project_refrC   r.   s       r   ListLocationszNetAppClient.ListLocationsc   sS    mm>>%%' ? )G##&&') )r   c                     | j                   j                  |      }t        j                  | j                  j
                  |d|d      S )al  Make API calls to List active Cloud NetApp operations.

    Args:
      location_ref: The parsed location of the listed NetApp resources.
      limit: The number of Cloud NetApp resources 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 resources.
    r&   
operationsr@   rA   )r$   ,NetappProjectsLocationsOperationsListRequestr   rF   r!   r*   )r   r<   rC   r.   s       r   ListOperationszNetAppClient.ListOperationsm   sM     mmHH I G##11') )r   r    )__name__
__module____qualname____doc__r	   r   r   r   propertyr!   r$   r/   r4   r8   r=   rH   rL    r   r   r   r      sb    C#'#4#4#:#: 	,     " "BD"E7))r   r   c                       e Zd ZdZd Zy)r   z*Adapter for the Cloud NetApp Files v1 API.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NetappAdapter.__init__   sN    **--D((((DK **((DMr   N)rM   rN   rO   rP   r   rR   r   r   r   r      s
    2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.c                     t         t        |           t        j                  j
                  | _        t        j                  | j                        | _	        t        j                  | j                        | _        y rU   )superr   r   r	   r   r   r   r   rV   r!   rW   r$   r   	__class__s    r   r   zBetaNetappAdapter.__init__   s]    	
T+-**//D((((DK **((DMr   rM   rN   rO   rP   r   __classcell__r\   s   @r   r   r      s    4 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.c                     t         t        |           t        j                  j
                  | _        t        j                  | j                        | _	        t        j                  | j                        | _        y rU   )rZ   r   r   r	   r   r   r   r   rV   r!   rW   r$   r[   s    r   r   zAlphaNetappAdapter.__init__   s]    	
d,.**00D((((DK **((DMr   r]   r_   s   @r   r   r      s    5 r   r   N)rP   
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.netappr   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper	   API_NAMEALPHA_API_VERSIONobjectr   r   r   r   rR   r   r   <module>rj      s_    G &  ' ' . . ( a)6 a)H
F 
 * r   