
                            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dZej                    ej"                  ej$                  j&                         G d dej(                                      Zy)z8'vmware private-clouds identity-sources create' command.    )absolute_import)division)unicode_literals)IdentitySourcesClient)base)flags)log)fileszO
        Create a new identity source resource in a given private cloud.
      a  
        To create an identity source called `my-is` in a private cloud `my-pc` located in project `my-project` and zone `us-west1-a`:

          $ {command} my-is --private-cloud my-pc --project my-project --location us-west1-a --domain example.com
            --base-users-dn dc=example,dc=com --base-groups-dn dc=example,dc=com --domain-user user@example.com
            --domain-password secretPassword123 --protocol LDAP --primary-server ldap://example.com

          Or:

          $ {command} my-is --private-cloud my-pc --domain example.com --base-users-dn dc=example,dc=com
            --base-groups-dn dc=example,dc=com --domain-user user@example.com --domain-password secretPassword123
            --protocol LDAP --primary-server ldap://example.com

          In the second example, the project and location are taken from gcloud properties `core/project` and `compute/zone` respectively.
  )DESCRIPTIONEXAMPLESc                   *    e Zd ZdZeZed        Zd Zy)Createz4Create a Google Cloud VMware Engine identity source.c                 x   t        j                  |        t        j                  j	                  |        t        j                  j                  | d       | j                  j                  d       | j                  ddd       | j                  ddd       | j                  d	dd
       | j                  ddd       | j                  ddd       | j                  ddd       | j                  ddddgd       | j                  ddd       | j                  dd       | j                  ddg d       y) z Register flags for this command.Tyamlz--domainz'The domain name of the identity source.)requiredhelpz--domain-aliasFz(The domain alias of the identity source.z--base-users-dnz&The base distinguished name for users.z--base-groups-dnz'The base distinguished name for groups.z--domain-userzuID of a user in the domain who has a minimum of read-only access to the base distinguished names of users and groups.z--domain-passwordz}Password of the user in the domain who has a minimum of read-only access to the base distinguished names of users and groups.z
--protocolLDAPLDAPSz$The LDAP server connection protocol.)r   choicesr   z--primary-serverz
        Primary domain controller LDAP server for the domain.
        Format `ldap://hostname:port` or `ldaps://hostname:port`
        z--secondary-serverz
        Secondary domain controller LDAP server for the domain.
        Format `ldap://hostname:port` or `ldaps://hostname:port`
        )r   z--ssl-certificate-from-fileappendzgPath to the root CA certificate files in CER format for the LDAPS server. Can be passed multiple times.)actiondefaultr   N)	r   AddIdentitySourceArgToParserr   
ASYNC_FLAGAddToParser
SetDefaultdisplay_info	AddFormatadd_argument)parsers    <lib/surface/vmware/private_clouds/identity_sources/create.pyArgszCreate.Args8   s    
&&v.OO'OOvt,
!!&)
6  
 7  
 5  
 6  
 D	   K	   !3	         %5      c                    |j                   j                  j                         }t               }|j                  }|j
                  D cg c]  }t        j                  |       }}|j                  ||j                  |j                  |j                  |j                  |j                  |j                  |j                  |j                   |j"                  |      }|r#t%        j&                  |j(                  dd       y |j+                  |j-                  |      dj/                  |j1                                     }t%        j&                  |j1                         d       |S c c}w )N)
domaindomain_aliasbase_users_dnbase_groups_dndomain_userdomain_passwordprotocolprimary_serversecondary_serverssl_certificateszidentity sourceT)kindis_asyncz.waiting for identity source [{}] to be created)operation_refmessage)r/   )CONCEPTSidentity_sourceParser   async_ssl_certificate_from_filer
   ReadFileContentsr   r%   r&   r'   r(   r)   r*   r+   r,   r-   r	   CreatedResourcenameWaitForOperationGetOperationRefformatRelativeName)	selfargssourceclientr0   pathcertificates	operationresources	            r!   Runz
Create.Run   sE   ]]**002F"$F{{H 261O1O1Ot$1O   {{&&((**$$,,**..%  I 	)../@4P&&,,Y7@GG!
 ' H ++-4EFO9s   	E(N)	__name__
__module____qualname____doc___DETAILED_HELPdetailed_helpstaticmethodr"   rG    r#   r!   r   r   1   s&     = -G GR!r#   r   N)rK   
__future__r   r   r   -googlecloudsdk.api_lib.vmware.identitysourcesr   googlecloudsdk.callioper   !googlecloudsdk.command_lib.vmwarer   googlecloudsdk.corer	   googlecloudsdk.core.utilr
   rL   HiddenReleaseTracksReleaseTrackGACreateCommandr   rO   r#   r!   <module>r[      s|    ? &  ' O ( 3 # *
	, D%%(()pT p * pr#   