
                          ^   d Z ddlmZ ddlmZ ddlmZ ddl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  ej                   ej"                  j$                  ej"                  j&                  ej"                  j(                        ej*                   G d dej,                                      Zy)z&gcloud dns record-sets create command.    )absolute_import)division)unicode_literalsN)resource_record_sets)util)apis)base)flagsc                       e Zd ZdZ ej
                  d       ej
                  d      dZed        Zed        Z	d Z
y)	Createz'Creates a record-set in a managed-zone.zm          This command creates a record-set contained within the specified
          managed-zone.
          a            To create a record-set with dnsName foo.bar.com., record type A,
          rrdata [1.2.3.4, 9.8.7.6] and ttl 60 in my_zone run this:

          $ {command} foo.bar.com. --rrdatas=1.2.3.4,9.8.7.6 --type=A --ttl=60
            --zone=my_zone

          To create a geo routed record-set with dnsName foo.bar.com., record
          type A, routing_policy_data "us-centra1=1.2.3.4,2.3.4.5;us-west1=3.4.5.6,9.8.7.6"
          and ttl 60 in my_zone.

          $ {command} foo.bar.com. --routing_policy_data="us-centra1=1.2.3.4,2.3.4.5;us-west1=3.4.5.6,9.8.7.6"
           --routing_policy_type=GEO --type=A --ttl=60 --zone=my_zone --location=us-east1-a

          To create a record-set with dnsName foo.bar.com., record type A,
          rrdata [1.2.3.4, 9.8.7.6] and ttl 60 in my_zone in us-east1-a run this:

          $ {command} us-east1-a.bar.com. --rrdatas=1.2.3.4,9.8.7.6 --type=A --ttl=60
            --zone=my_zone --location=us-east1-a

          To create a failover type health checked routed record-set with dnsName
          foo.bar.com., record type A, primary routing data "config1", backup
          routing data "us-centra1=1.2.3.4,2.3.4.5;us-west1=3.4.5.6,9.8.7.6", with a
          trickle traffic ratio of 10% to the backup data,
          and ttl 60 in my_zone.

          $ {command} foo.bar.com.  --type=A --ttl=60             --zone=routing-policy-test --routing_policy_type=FAILOVER             --routing-policy-primary-data='config1'             --routing-policy-backup-data-type=GEO             --routing-policy-backup-data='us-centra1=1.2.3.4,2.3.4.5;us-west1=3.4.5.6,9.8.7.6'             --backup-data-trickle-ratio=0.1 --enable-health-checking --zone=my_zone

          To create a geo fenced health checked routed record-set with dnsName
          foo.bar.com., record type A, routing-policy-data
          "us-centra1=config1,config2;us-west1=3.4.5.6,9.8.7.6",
          and ttl 60 in my_zone.

          $ {command} foo.bar.com.  --type=A --ttl=60             --zone=routing-policy-test --routing_policy_type=GEO             --routing_policy_data='us-centra1=config1,config2;us-west1=3.4.5.6,9.8.7.6'             --enable-health-checking --enable-geo-fencing --zone=my_zone
          )DESCRIPTIONEXAMPLESc                     | j                         t        j                   j                  t        j                   j                  fv S )N)ReleaseTrackr	   BETAALPHA)clss    %lib/surface/dns/record_sets/create.py_BetaOrAlphazCreate._BetaOrAlphaY   s:    $"3"3"8"8"&"3"3"9"9"; ; ;    c                    t        j                         j                  |       t        j                         j                  |       t        j                  d      j                  |       t        j
                  d      j                  |       t        j                  | j                               j                  |       t        j                         j                  |       |j                  j                  d        |j                  j                  t         j                         |j                  j                  t         j                         y )NTF)use_deprecated_names)r
   
GetZoneArgAddToParserGetResourceRecordSetsNameArgGetResourceRecordSetsTypeArgGetResourceRecordSetsTtlArg$GetResourceRecordSetsRrdatasArgGroupr   GetLocationArgdisplay_infoAddCacheUpdaterAddTransformsRESOURCERECORDSETS_TRANSFORMS	AddFormatRESOURCERECORDSETS_FORMAT)r   parsers     r   ArgszCreate.Args^   s    	""6*	&&(44V<	&&t,88@	%%e,88@	.. --/k&	&&v.
''-
%%e&I&IJ
!!%"A"ABr   c                 >   t        j                  | j                         |      }t        j                  d|      }t        j
                  |      }t        j                  |      j                  |j                  t        j                  ||      d      }|j                  |j                  |j                  t        j                  ||j                  || j                                     }|dk(  r|j                   |_        |j"                  j%                  |      }|S )Ndnszdns.managedZones)params
collection)allow_extended_records)projectmanagedZoneresourceRecordSetv2)r   GetApiFromTrackAndArgsr   r   GetMessagesModuleGetApiClientGetRegistryParsezoneGetParamsForRegistry"DnsResourceRecordSetsCreateRequestr-   r.   rrsets_utilCreateRecordSetFromArgsr   locationresourceRecordSetsr   )selfargsapi_versionmessages
dns_clientzone_refrequestresults           r   Runz
Create.Runm   s    --d.?.?.A4HK%%e[9H"";/J,22		((d;% 3 H
 99  ((%==#'#4#4#6	
 : 	G dg**11':FMr   N)__name__
__module____qualname____doc__textwrapdedentdetailed_helpclassmethodr   r'   rE    r   r   r   r      sh    
 0 (//  
 (// * *2-h ; ; C Cr   r   )rI   
__future__r   r   r   rJ   googlecloudsdk.api_lib.dnsr   r9   r   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper	   googlecloudsdk.command_lib.dnsr
   ReleaseTracksr   r   r   GAUniverseCompatibleCreateCommandr   rN   r   r   <module>rX      s    - &  '  J + , ( 0 T..33T5F5F5I5I gT g gr   