
    B                         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
  G d d	e
j                        ZddZ G d de      Zy
)z,API client library for Cloud DNS operatoins.    )absolute_import)division)unicode_literals)
list_pager)util)waiterc                   *    e Zd ZdZddZd Zd Zd Zy)PollerzlManages a longrunning Operations.

  See https://cloud.google.com/speech/reference/rpc/google.longrunning
  c                      || _         || _        y)zSets up poller for dns operations.

    Args:
      operations_client: Client, client for retrieving information about
          ongoing operation.
      api_version: Cloud DNS api version this poller should use.
    N)operations_clientapi_version)selfr   r   s      ,lib/googlecloudsdk/api_lib/dns/operations.py__init__zPoller.__init__!   s     /D"D    c                 0   | j                   dk(  s| j                   dk(  r4| j                  j                  j                  j                  j
                  n3| j                  j                  j                  j                  j                  }|j                  |k(  ryy)z
Overrides.v2devTF)r   r   messages	OperationStatusValueValuesEnumDONEdonestatus)r   	operation	done_enums      r   IsDonezPoller.IsDone,   s~     t#t'7'75'@ 	''11GGLL##,,66LLQQ 
 9$r   c                 8    | j                   j                  |      S )zOverrides.

    Args:
      operation_ref: googlecloudsdk.core.resources.Resource.

    Returns:
      fetched operation message.
    )r   Get)r   operation_refs     r   PollzPoller.Poll7   s     !!%%m44r   c                 .    |j                   j                  S )zOverrides.

    Args:
      operation: api_name_messages.Operation.

    Returns:
      result of result_service.Get request.
    )zoneContextnewValue)r   r   s     r   	GetResultzPoller.GetResultB   s       )))r   N)v1)__name__
__module____qualname____doc__r   r   r!   r%    r   r   r
   r
      s    
	#		5	*r   r
   Nc                 p    t        t        j                  | |      |       }t        j                  |||      S N)r
   ClientFromApiVersionr   WaitFor)versionr    messagelocationoperation_pollers        r   r0   r0   N   s0    F11'8DgN	(-	AAr   c                   <    e Zd ZdZdZddZed	d       Zd Zd	dZ	y)
r.   z$API client for Cloud DNS operations.dnsNc                     || _         || _        | j                  j                  | _        |xs |j                  | _        || _        y r-   )r1   clientmanagedZoneOperations_serviceMESSAGES_MODULEr   r3   )r   r1   r8   r   r3   s        r   r   zClient.__init__X   s:    DLDKKK55DM6 6 6DMDMr   c                 @     | |t        j                  |      d |      S )N)r   r3   )r   GetApiClient)clsr1   r3   s      r   r/   zClient.FromApiVersion_   s%    ""7+dXO Or   c                     | j                   j                  |j                         |j                  |j                        }| j
                  r| j
                  |_        | j                  j                  |      S )N)r   managedZoneproject)r   "DnsManagedZoneOperationsGetRequestNamer@   rA   r3   r:   r   )r   r    requests      r   r   z
Client.Getd   sc    mm>>$$&!--%% ? 'G }}g==W%%r   c                     | j                   j                  |j                         |j                        }| j                  r| j                  |_        t        j                  | j                  ||d      S )N)r@   rA   
operations)limitfield)r   #DnsManagedZoneOperationsListRequestrC   rA   r3   r   YieldFromListr:   )r   zone_refrG   rD   s       r   ListzClient.Listm   se    mm??MMO   @ "G }}g##we<A Ar   )NNr-   )
r'   r(   r)   r*   	_API_NAMEr   classmethodr/   r   rL   r+   r   r   r.   r.   S   s0    ,) O O&Ar   r.   r-   )r*   
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.dnsr   googlecloudsdk.api_lib.utilr   OperationPollerr
   r0   objectr.   r+   r   r   <module>rU      sC    3 &  ' ' + .0*V## 0*fB
!AV !Ar   