
                         P   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mZ ddlmZ ddlmZ e
j.                   e
j0                  e
j2                  j4                        e
j6                   G d de
j8                                             Zy)z?Command to add an attestation rule on a workload identity pool.    )absolute_import)division)unicode_literals)util)waiter)base)concepts)identity_pool_waiter)	yaml_data)concept_parsers)log)	resourcesc                   0    e Zd ZdZdddZed        Zd Zy)AddAttestationRulez4Add an attestation rule on a workload identity pool.z{description}a)            The following command adds an attestation rule with a Google Cloud
          resource on a workload identity pool `my-pool`.

            $ {command} my-pool             --location="global"             --google-cloud-resource="//run.googleapis.com/projects/123/type/Service/*"
          )DESCRIPTIONEXAMPLESc                 f   t         j                  j                  d      }t        j                  j                  dt        j                  j                  |j                         d      dd      j                  |        | j                  ddd	       t        j                  j                  |        y )
Nziam.workload_identity_poolworkload_identity_poolT)is_positionalz:The workload identity pool to add the attestation rule on.)requiredz--google-cloud-resourcezpA single workload running on Google Cloud. This will be set
                in the attestation rule to be added.)helpr   )r   ResourceYAMLDataFromPathr   ConceptParserForResourcer	   ResourceSpecFromYamlGetDataAddToParseradd_argumentr   
ASYNC_FLAG)parserworkload_pool_datas     ?lib/surface/iam/workload_identity_pools/add_attestation_rule.pyArgszAddAttestationRule.Args2   s    "33<<$ !!-- &&&&( 	' 	
 	E .  k&
!8	   	OO'    c                 J   t        j                         \  }}|j                  j                  j	                         }|j                  |j                  |j                              }|j                  j                  |j                  |j                         |            }t        j                  j                  dj                  |j                                |j"                  r|S t%        j&                  t)        j*                  |j                  |j,                        t.        j0                  j3                  |j4                  d      dj                  |j4                        d	      }t        j                  j                  d
j                  |j                                |S )N)googleCloudResource)attestationRule)resourceaddAttestationRuleRequestz-Add attestation rule request issued for: [{}]z7iam.projects.locations.workloadIdentityPools.operations)
collectionz&Waiting for operation [{}] to completei )polleroperation_refmessagemax_wait_msz Added attestation rule for [{}].)r   GetClientAndMessagesCONCEPTSr   ParseAddAttestationRuleRequestAttestationRulegoogle_cloud_resource(projects_locations_workloadIdentityPoolsr   BIamProjectsLocationsWorkloadIdentityPoolsAddAttestationRuleRequestRelativeNamer   statusPrintformatworkloadIdentityPoolsIdasync_r   WaitForr
   &IdentityPoolOperationPollerNoResources3projects_locations_workloadIdentityPools_operationssdkresourcesREGISTRYParseRelativeNamename)selfargsclientmessagesworkload_pool_refadd_attestation_rule_requestlro_refresults           r$   RunzAddAttestationRule.RunG   ss   002FH<<BBD#+#E#E 00 $ : : 1 
 $F $  ==PPSS&335&B 	T 	
G JJ7>>55	
 {{n^^#JJ;;FF
 #++==LLI > 
 9??M F" JJ*1155	
 Mr&   N)__name__
__module____qualname____doc__detailed_helpstaticmethodr%   rN    r&   r$   r   r       s1     = %
- ( ((1r&   r   N)rR   
__future__r   r   r   googlecloudsdk.api_lib.iamr   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper    googlecloudsdk.calliope.conceptsr	   googlecloudsdk.command_lib.iamr
   $googlecloudsdk.command_lib.util.apisr   (googlecloudsdk.command_lib.util.conceptsr   googlecloudsdk.corer   r   rB   DefaultUniverseOnlyReleaseTracksReleaseTrackGAHiddenCommandr   rU   r&   r$   <module>re      s    F &  ' + . ( 5 ? : D # 9 D%%(()U U  * Ur&   