
                             S r SSKJr  SSKJr  SSKJr  SSKrSSKJr  SSKJr  SSK	J
r
  SS	KJr  \R                   " S
 S\R                  5      5       rg)zVCommand to create a configuration file to allow authentication from 3rd party sources.    )absolute_import)division)unicode_literalsN)base)
exceptions)flags)cred_configc                   \    \ rS rSrSrS\R                  " S5      0r\S 5       r	S r
S rSrg	)
CreateCredConfig   zCreate a configuration file for generated credentials.

This command creates a configuration file to allow access to authenticated
Google Cloud actions from a variety of external accounts.
EXAMPLESa            To create a file-sourced credential configuration for your project, run:

            $ {command} projects/$PROJECT_NUMBER/locations/$REGION/workloadIdentityPools/$WORKLOAD_POOL_ID/providers/$PROVIDER_ID --service-account=$EMAIL --credential-source-file=$PATH_TO_OIDC_ID_TOKEN --output-file=credentials.json

          To create a URL-sourced credential configuration for your project, run:

            $ {command} projects/$PROJECT_NUMBER/locations/$REGION/workloadIdentityPools/$WORKLOAD_POOL_ID/providers/$PROVIDER_ID --service-account=$EMAIL --credential-source-url=$URL_FOR_OIDC_TOKEN --credential-source-headers=Key=Value --output-file=credentials.json

          To create an executable-source credential configuration for your project, run the following command:

            $ {command} locations/$REGION/workforcePools/$WORKFORCE_POOL_ID/providers/$PROVIDER_ID --executable-command=$EXECUTABLE_COMMAND --executable-timeout-millis=30000 --executable-output-file=$CACHE_FILE --output-file=credentials.json

          To create an AWS-based credential configuration for your project, run:

            $ {command} projects/$PROJECT_NUMBER/locations/$REGION/workloadIdentityPools/$WORKLOAD_POOL_ID/providers/$PROVIDER_ID --service-account=$EMAIL --aws --enable-imdsv2 --output-file=credentials.json

          To create an Azure-based credential configuration for your project, run:

            $ {command} projects/$PROJECT_NUMBER/locations/$REGION/workloadIdentityPools/$WORKLOAD_POOL_ID/providers/$PROVIDER_ID --service-account=$EMAIL --azure --app-id-uri=$URI_FOR_AZURE_APP_ID --output-file=credentials.json

          To create an X.509 certificate-based credential configuration for your project, run:

            $ {command} projects/$PROJECT_NUMBER/locations/$REGION/workloadIdentityPools/$WORKLOAD_POOL_ID/providers/$PROVIDER_ID --service-account=$EMAIL --credential-cert-path=$PATH_TO_CERTIFICATE_FILE --credential-cert-private-key-path=$PATH_TO_PRIVATE_KEY_FILE --output-file=credentials.json

          To use the resulting file for any of these commands, set the GOOGLE_APPLICATION_CREDENTIALS environment variable to point to the generated file
          c                 j   [         R                  " U[        R                  R                  5        UR                  SSS9  UR                  SSSS9nUR                  SSS9  UR                  S	S
S9  UR                  SSS9  UR                  SSSS9  UR                  SSSS9  UR                  SSS9  UR                  SSS9  UR                  SSS9  UR                  SSSS9  UR                  SS9nUR                  SSSS9  UR                  SS S9  UR                  S!S"S9  UR                  S#S$S9  g )%Naudiencez?The workload identity pool provider fully qualified identifier.)helpTzCredential types.)mutexrequiredr   z--credential-source-filez'Location of the credential source file.z--credential-source-urlz"URL to obtain the credential from.z--executable-commandzqThe full command to run to retrieve the credential. Must be an absolute path for the program including arguments.z--awszUse AWS.
store_true)r   actionz--azurez
Use Azure.z--credential-cert-pathz#Path of the X.509 certificate file.z--subject-token-typezfThe type of token being used for authorization. This defaults to urn:ietf:params:oauth:token-type:jwt.z--app-id-uriz9The custom Application ID URI for the Azure access token.z--enable-imdsv2z^Adds the AWS IMDSv2 session token Url to the credential source to enforce the AWS IMDSv2 flow.z:Arguments for an X.509 certificate type credential source.z"--credential-cert-private-key-pathz#Path of the X.509 private key file.)r   r   z+--credential-cert-configuration-output-filezPath for the certificate configuration file. If specified, a certificate configuration file will be created at the specified path. If not specified, the certificate configuration will be created at the default gcloud location.z"--credential-cert-trust-chain-patha:  Path for the trust chain file. A trust chain file is required if there are intermediate certificates in the certificate chain in between the root certificate stored in the workload identity pool provider trust store. This trust chain file should be a list of PEM certificates, with the leaf certificate at the top.z--sts-locationa	  The location to use for the Security Token Service token endpoint. For example, specifying `us-central1` will configure the client to use the regional endpoint `sts.us-central1.rep.googleapis.com`. If not specified, the global endpoint `sts.googleapis.com` is used.)r   AddCommonByoidCreateConfigFlagsr	   
ConfigTypeWORKLOAD_IDENTITY_POOLSadd_argument	add_group)clsparsercredential_typescertificate_argss       =lib/surface/iam/workload_identity_pools/create_cred_config.pyArgsCreateCredConfig.ArgsC   s    
))&&>>@ N  
 ''T(; (  !!"6 "  !!!(L "  !!B "  !!'
<!P!!\ "  !! 'L " 
 C  
 H   ,    ''I (  !!,2 " 
 !!57 "  !!,J " 	 <  	    c                    UR                   (       a'  UR                  (       d  [        R                  " S5      eUR                  (       a'  UR
                  (       d  [        R                  " S5      eUR                  (       a[  UR                  S:w  aJ  UR
                  (       d"  UR                  (       d  UR                  (       a  [        R                  " S5      eg g g )Nz9--enable-imdsv2 can be used only for AWS credential typeszZ--credential-cert-private-key-path can be used only for X.509 certificate credential typesglobalzuWorkload Identity Federation with X.509 certificates is not supported on locational Security Token Service endpoints.)enable_imdsv2awsr   ConflictingArgumentsException credential_cert_private_key_pathcredential_cert_pathsts_location credential_cert_trust_chain_pathselfargss     r   _ValidateArgsCreateCredConfig._ValidateArgs   s    $((44
E  ,,T5N5N44*  	d//8;!!0000 44G  1 <r!   c                     U R                  U5        [        R                  " U[        R                  R                  5        g )N)r.   r	   create_credential_configr   r   r+   s     r   RunCreateCredConfig.Run   s/    t((k$$<<r!    N)__name__
__module____qualname____firstlineno____doc__textwrapdedentdetailed_helpclassmethodr   r.   r2   __static_attributes__r4   r!   r   r   r      sD     (// # -< [ [z*r!   r   )r9   
__future__r   r   r   r:   googlecloudsdk.callioper   r   googlecloudsdk.command_lib.iamr   .googlecloudsdk.command_lib.iam.byoid_utilitiesr	   UniverseCompatibleCreateCommandr   r4   r!   r   <module>rE      sM    ] &  '  ( . 0 F \t)) \ \r!   