
                         f    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
      Zy
)z/API client library for Cloud DNS managed zones.    )absolute_import)division)unicode_literals)
operations)util)logc                   P    e Zd ZdZddZed	d       Zd Z	 	 	 	 	 	 	 	 	 d
dZd Z	y)Clientz'API client for Cloud DNS managed zones.Nc                     || _         || _        | j                  j                  | _        |xs | j                  j                  | _        || _        y N)versionclientmanagedZones_serviceMESSAGES_MODULEmessageslocation)selfr   r   r   r   s        /lib/googlecloudsdk/api_lib/dns/managed_zones.py__init__zClient.__init__   s>    DLDKKK,,DM; ; ;DMDM    c                 >     | |t        j                  |      |      S )N)r   )r   GetApiClient)clsr   r   s      r   FromApiVersionzClient.FromApiVersion$   s    w))'2XFFr   c                 X   | j                   rU| j                  j                  | j                  j	                  |j
                  |j                  | j                               S | j                  j                  | j                  j	                  |j
                  |j                              S )N)projectmanagedZoner   r   r   )r   r   Getr   DnsManagedZonesGetRequestr   r   )r   zone_refs     r   r    z
Client.Get(   s    }}]]
--
1
1&&"..}} 2 &' '
 ==//$$ ,, 	0 	./ /r   c                    | j                   j                  |j                         |||      }|r||_        |r||_        |r||_        |	r|	|_        |
r|
|_        | j                   j                  ||j                  |j                               }| j                  r| j                  |_
        | j                  j                  |      5  | j                  j                  j                  |      }ddd       |j                  |j                         d}| j                  r| j                  |d<   t        j                   | j"                        j%                  j&                  |d      }|rLt(        j*                  j-                  dj/                  |j                         |j                                      yt1        j2                  | j"                  |d	j/                  |j                               | j                        S # 1 sw Y   xY w)
a
  Managed Zones Update Request.

    Args:
      zone_ref: the managed zones being patched.
      is_async: if the PATCH operation is asynchronous.
      dnssec_config: zone DNSSEC config.
      description: zone description.
      labels: zone labels.
      private_visibility_config: zone visibility config.
      forwarding_config: zone forwarding config.
      peering_config: zone peering config.
      service_directory_config: zone service directory config.
      cloud_logging_config: Stackdriver logging config.
      cleared_fields: the fields that should be included in the request JSON as
        their default value (fields that are their default value will be omitted
        otherwise).

    Returns:
      The PATCH response, if operation is not asynchronous.
    )namednssecConfigdescriptionlabelsmanagedZoneResourcer   r   Nr   r   dns.managedZoneOperationsparams
collectionz$Updating [{0}] with operation [{1}].Updating managed zone [{}])r   ManagedZoneNameprivateVisibilityConfigforwardingConfigpeeringConfigserviceDirectoryConfigcloudLoggingConfigDnsManagedZonesPatchRequestr   r   r   IncludeFieldsr   Patchr   GetRegistryr   Parseidr   statuswriteformatr   WaitFor)r   r"   is_asyncdnssec_configr&   r'   private_visibility_configforwarding_configpeering_configservice_directory_configcloud_logging_configcleared_fieldszonerequest	operationoperation_paramoperation_refs                    r   r8   zClient.Patch4   s   @ ==$$]]_"	 % D
 !%>d"/d)d$<d! 4dmm77   MMO 8 %G
 }}g 
	"	">	2++**009i 
3 ##}}O
 }}$(MMoj!$$T\\288. 9 0M
 	jj
0
7
7mmo}11356 $++HMMO<	 + 
3	2s   	&HHc                 2   | j                  |      }||_        | j                  j                  | j                  j                  ||j                  |j                                     }|j                  |j                         d}| j                  r| j                  |d<   t        j                  | j                        j                  |j                  |d      }t        j                  | j                  |dj!                  |j                                     S )z1Update labels using Managed Zones Update request.r(   r   r   r*   r+   r.   )r    r'   r   Updater   DnsManagedZonesUpdateRequestr   r0   r   r   r9   r   r:   r;   r   r?   r>   )r   r"   r'   rH   rJ   rK   rL   s          r   UpdateLabelszClient.UpdateLabels   s    88HDDK$$22 $$$  	3 	)*I ##}}O
 }}$(MMoj!$$T\\288. 9 0M
 m$++HMMO<> >r   )NNr   )	NNNNNNNNN)
__name__
__module____qualname____doc__r   classmethodr   r    r8   rP    r   r   r
   r
      sN    / G G
/ &*"%)!%Sj>r   r
   N)rT   
__future__r   r   r   googlecloudsdk.api_lib.dnsr   r   googlecloudsdk.corer   objectr
   rV   r   r   <module>r[      s*    6 &  ' 1 + #H>V H>r   