
                         V   S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r
  SSK	Jr  SS	KJr  \R                  \R                  " \R                   R"                  \R                   R$                  \R                   R&                  5       " S
 S\R(                  5      5       5       rg)z9The gcloud Firestore databases connection-string command.    )absolute_import)division)unicode_literals)	databases)base)connection_util)flags)
propertiesc                   6    \ rS rSrSrSrSr\S 5       rS r	Sr
g)	ConnectionString   a  Prints the mongo connection string for the given Firestore database.

## EXAMPLES

To get the connection string for a Firestore database with a databaseId
`testdb` without auth configuration.

    $ {command} --database=testdb --auth=none

To get the connection string for a Firestore database with a databaseId
`testdb` with Google Compute Engine VM auth.

    $ {command} --database=testdb --auth=gce-vm
zTmongodb://{}{}.{}.firestore.goog:443/{}?loadBalanced=true&tls=true&retryWrites=falsez\&authMechanism=MONGODB-OIDC&authMechanismProperties=ENVIRONMENT:gcp,TOKEN_RESOURCE:FIRESTOREc                     [         R                  " U SS9  U R                  5       nUR                  SSSS[        SS9  UR                  SS	SS[        / S
QSSS9  g )NTrequiredz
--validateVALIDATEFa  
        Validate the specified connection string for the current database. This
        command checks that the connection string is well formed, contains the
        required parameters, and specifies correct configuration values for the
        current database.
        )metavarr   hiddentypehelpz--authAUTH)nonegce-vmaccess-tokenscram-sha-256r   aH  
        The auth configuration for the connection string.

        If connecting from a Google Compute Engine VM, use `gce-vm`. For short
        term access using the gcloud CLI's access token, use `access-token`.
        For password auth use scram-sha-256. Otherwise, use `none` and configure
        auth manually.
        )r   r   r   r   choicesdefaultr   )r	   AddDatabaseIdFlagadd_mutually_exclusive_groupadd_argumentstr)parsergroups     4lib/surface/firestore/databases/connection_string.pyArgsConnectionString.Args4   sv    	FT2//1E	   
C      c                    [         R                  R                  R                  R	                  SS9n[
        R                  " X!R                  5      nUR                  S:X  a  SOUR                  nUR                  (       aV  [        R                  " [        R                  " UR                  UR                  UR                  UR                  5      5        g UR                  S:X  a?  U R                  R!                  SUR                  UR                  U5      U R"                  -   $ UR                  S:X  a5  U R                  R!                  SUR                  UR                  U5      S	-   $ UR                  S
:X  a5  U R                  R!                  SUR                  UR                  U5      S-   $ U R                  R!                  SUR                  UR                  U5      $ )NTr   z	(default)_r    r   z/access_token:$(gcloud auth print-access-token)@z)&authMechanism=PLAIN&authSource=$externalr   zusername:password@z&authMechanism=SCRAM-SHA-256)r
   VALUEScoreprojectGetr   GetDatabasedatabasevalidater   PrettyPrintValidationResultsValidateConnectionStringuid
locationIdauth_BASE_OUTPUTformat_GCE_VM_AUTH)selfargsr,   dbdatabase_ids        r#   RunConnectionString.RunW   s   $$,,00$0?G			w	6B+5#4==K}}22

2
2mmRVVR]]DMM
 	h	



"
"2rvvr}}k
J 
n	$



"
"?ffmm	 88 
o	%



"
""ffmm	 ++ ##B{KKr&    N)__name__
__module____qualname____firstlineno____doc__r6   r8   staticmethodr$   r=   __static_attributes__r?   r&   r#   r   r      s-    
 h,o,   D$Lr&   r   N)rD   
__future__r   r   r    googlecloudsdk.api_lib.firestorer   googlecloudsdk.callioper   $googlecloudsdk.command_lib.firestorer   r	   googlecloudsdk.corer
   DefaultUniverseOnlyReleaseTracksReleaseTrackALPHABETAGACommandr   r?   r&   r#   <module>rS      s    @ &  ' 6 ( @ 6 * T..33T5F5F5I5I[Lt|| [L [Lr&   