
                         |   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 ddlmZ ddlmZ ddlmZ ddlZej:                   ej<                  ej>                  j@                        ejB                   G d dejD                                             Z#y)z=Command to set attestation rules on a workload identity pool.    )absolute_import)division)unicode_literals)encoding)util)waiter)base)
exceptions)concepts)identity_pool_waiter)	yaml_data)concept_parsers)log)	resources)yamlNc                   0    e Zd ZdZdddZed        Zd Zy)SetAttestationRulesz2Set attestation rules on a workload identity pool.z{description}z          The following command sets attestation rules on a workload identity
          pool `my-pool` using a policy file.

            $ {command} my-pool             --location="global"             --policy-file="policy.json"
          )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_positionalz7The workload identity pool to set attestation rules on.)requiredz--policy-filea?            Path to a local JSON-formatted or YAML-formatted file containing an
          attestation policy, structured as a [list of attestation rules](https://cloud.google.com/iam/docs/reference/rest/v1/projects.locations.workloadIdentityPools.namespaces.managedIdentities/setAttestationRules#request-body).
          )helpr   )r   ResourceYAMLDataFromPathr   ConceptParserForResourcer   ResourceSpecFromYamlGetDataAddToParseradd_argumentr	   
ASYNC_FLAG)parserworkload_pool_datas     @lib/surface/iam/workload_identity_pools/set_attestation_rules.pyArgszSetAttestationRules.Args6   s    "33<<$ !!-- &&&&( 	' 	
 	B .  k&
    	OO'    c           	         t        j                         \  }}|j                  j                  j	                         }t        j                  |j                        }	 t        j                  |j                  |      }|j"                  j%                  |j'                  |j)                         |            }t*        j,                  j/                  dj                  |j0                               |j2                  r|S t5        j6                  t9        j:                  |j"                  |j<                        t>        j@                  jC                  |jD                  d      dj                  |jD                        d      }	t*        j,                  j/                  d	j                  |j0                               |	S # t        $ rG}t        j                  dj                  |j                  t        j                   |                  d }~ww xY w)
NzKPolicy file [{0}] is not a properly formatted YAML or JSON policy file. {1})resourcesetAttestationRulesRequestz.Set attestation rules request issued for: [{}]z7iam.projects.locations.workloadIdentityPools.operations)
collectionz&Waiting for operation [{}] to completei )polleroperation_refmessagemax_wait_mszSet attestation rules for [{}].)#r   GetClientAndMessagesCONCEPTSr   Parser   	load_pathpolicy_filer   PyValueToMessageSetAttestationRulesRequestAttributeErrorgcloud_exceptionsBadFileExceptionformatsix	text_type(projects_locations_workloadIdentityPoolsr   CIamProjectsLocationsWorkloadIdentityPoolsSetAttestationRulesRequestRelativeNamer   statusPrintworkloadIdentityPoolsIdasync_r   WaitForr   &IdentityPoolOperationPollerNoResources3projects_locations_workloadIdentityPools_operationssdkresourcesREGISTRYParseRelativeNamename)
selfargsclientmessagesworkload_pool_refpolicy_to_parseset_attestation_rules_requestelro_refresults
             r'   RunzSetAttestationRules.RunM   s   002FH<<BBDnnT%5%56O	&.&?&?

-
-'# ==QQTT&335'D 	U 	
G JJ8??55	
 {{n^^#JJ;;FF
 #++==LLI > 
 9??M F" JJ)0055	
 M]  ..#VD$4$4cmmA6FG s    F9 9	H	AHH	N)__name__
__module____qualname____doc__detailed_helpstaticmethodr(   rW    r)   r'   r   r   $   s1     ; %
- ( (,8r)   r   )$r[   
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.iamr   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper	   r
   r:    googlecloudsdk.calliope.conceptsr   googlecloudsdk.command_lib.iamr   $googlecloudsdk.command_lib.util.apisr   (googlecloudsdk.command_lib.util.conceptsr   googlecloudsdk.corer   r   rI   r   r=   DefaultUniverseOnlyReleaseTracksReleaseTrackGAHiddenCommandr   r^   r)   r'   <module>ro      s    D &  ' % + . ( C 5 ? : D # 9 $ 
 D%%(()^$,, ^  * ^r)   