
                             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ZddddddddddddZddddZd Zd)dZdeiZd Zddd d!Zd*d"Zd#d$d%d!Zd+d&Z G d' d(e      Zy),z,Command utilities for `gcloud dns dns-keys`.    )absolute_import)division)unicode_literals)encoding)dns_keys)util)apis)base)flagsN                     
            )rsamd5dhdsarsasha1dsansec3sha1rsasha1nsec3sha1	rsasha256	rsasha512eccgostecdsap256sha256ecdsap384sha384   )sha1sha256sha384c                 v   t        j                  | j                        }t        j                  t        | j                  j
                           }t        j                  t        | j                  d   j                  j
                           }| j                  d   j                  }dj                  ||||g      S )Nr    )six	text_typekeyTagALGORITHM_NUMBERS	algorithmnameDIGEST_TYPE_NUMBERSdigeststypedigestjoin)keykey_tagkey_algorithmdigest_algorithmr1   s        .lib/googlecloudsdk/command_lib/dns/dns_keys.py_GenerateDSRecordr8   5   s    MM#**%'-- 1#--2D2D EF-]]#++a.--2235;;q>  &	7M+;VD	EE    c                     t        j                  dd      }t        j                  | |j                        }	 t        |      S # t        $ r |cY S w xY w)Ndnsv1)r	   GetMessagesModuler   DictToMessageDnsKeyr8   AttributeError)r	undefinedmessagesr3   s       r7   TransformDSRecordrD   >   sO    ##E40(q(//2#S!!	 s   
A AA	ds_recordc                      t         S N)_TRANSFORMS r9   r7   GetTransformsrJ   I   s    	r9   z&Show details about a DNS key resource.z?This command displays the details of a single DNS key resource.aw          To show details about a DNS key resource with ID 3 in a managed zone
        `my_zone`, run:

          $ {command} --zone=my_zone 3

        To get the DS record corresponding for the DNSKEY record from the
        previous example, run (the DNSKEY record must be for a key-signing key):

          $ {command} --zone=my_zone 3 --format='value(ds_record())'
        )briefDESCRIPTIONEXAMPLESc                     t        j                  d|      j                  |        t        j                  |      j                  |        | j                  j                  t                      y )Nz9The name of the managed-zone the DNSKEY record belongs tohide_short_zone_flag)is_beta)r   
GetZoneArgAddToParser	GetKeyArgdisplay_infoAddTransformsrJ   )parserrP   rQ   s      r7   AddDescribeFlagsrX   _   sM    A/11<V1D//'"..v6##MO4r9   zList DNS key resources.z)List DNS key resources in a managed zone.aS          To see the list of all DNS key resources for a managed zone `my_zone`,
        run:

          $ {command} --zone=my_zone

        To see the DS records for every key-signing DnsKey in a managed zone,
        run:

          $ {command} --zone=my_zone --filter='type=keySigning'               --format='value(ds_record())'
        c                 ~   | j                   j                  d       t        j                  j	                  |        t        j
                  j	                  |        t        j                  d|      j                  |        | j                   j                  d        | j                   j                  t                      y )Nz*table(id,keyTag,type,isActive,description)zAThe name of the managed-zone you want to list DNSKEY records for.rO   )rU   	AddFormatr
   URI_FLAGRemoveFromParserPAGE_SIZE_FLAGr   rR   rS   AddCacheUpdaterrV   rJ   )rW   rP   s     r7   AddListFlagsr_   y   s     LM--  (&&v.I/11<V1D%%d+##MO4r9   c                   D    e Zd ZdZd Zd Zd Zd Zd Zd Z	e
d        Zy	)
Keysz(Wrapper object for DNS DNSKEYs commands.c                      || _         || _        y rG   )_keys_client_version)selfkeys_clientversions      r7   __init__zKeys.__init__   s    #DDMr9   c                 @    t        j                  | j                        S rG   )r   GetRegistryrd   )re   s    r7   _GetRegistryzKeys._GetRegistry   s    DMM**r9   c                 L    | j                         j                  |||dd      S )N)projectmanagedZonezdns.dnsKeysparams
collectionrk   Parse)re   key_idzonerm   s       r7   _ParseDnsKeyzKeys._ParseDnsKey   s6    $$
 ! % " "r9   c                 J    | j                         j                  |d|id      S )Nrm   zdns.managedZonesro   rr   )re   zone_idrm   s      r7   
_ParseZonezKeys._ParseZone   s5    $$w
 & % ' 'r9   c                 ^    | j                  |||      }| j                  j                  |      S )z;Calls Get on the DNS DnsKeys API with the given parameters.)rv   rc   Get)re   rt   ru   rm   key_refs        r7   DescribezKeys.Describe   s-    g6G  ))r9   c                 \    | j                  ||      }| j                  j                  |      S rG   )ry   rc   List)re   rx   rm   zone_refs       r7   r   z	Keys.List   s)    w0H!!(++r9   c                 N     | t         j                  j                  |      |      S rG   )r   ClientFromApiVersion)clsrg   s     r7   r   zKeys.FromApiVersion   s    x--g6@@r9   N)__name__
__module____qualname____doc__rh   rk   rv   ry   r}   r   classmethodr   rI   r9   r7   ra   ra      s9    0+"'*
, A Ar9   ra   ) )FF)F)r   
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.dnsr   r   googlecloudsdk.api_lib.utilr	   googlecloudsdk.callioper
   googlecloudsdk.command_lib.dnsr   r(   r+   r.   r8   rD   rH   rJ   DESCRIBE_HELPrX   	LIST_HELPr_   objectra   rI   r9   r7   <module>r      s    3 &  ' % / + , ( 0 
 
    F -.
 6 
	$5 '>	$5&A6 &Ar9   