
    ~                         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*                   G d dej,                               Zy)z+Import Binary Authorization policy command.    )absolute_import)division)unicode_literals)apis)policies)util)messages)base)arg_parsers)parsing)log)
console_ioc                   &    e Zd ZdZed        Zd Zy)Importa  Import a Binary Authorization policy to the current project.

  This command accepts a description of the desired policy in the form of a
  YAML-formatted file. A representation of the current policy can be retrieved
  using the  $ {parent_command} export  command. One method of modifying the
  policy is to run `$ {parent_command} export`, dump the contents to a file,
  modify the policy file to reflect the desired new policy, and provide this
  modified file to `$ {command}`.

  ## EXAMPLES

  To update the current project's policy:

    $ {parent_command} export > my_policy.yaml

    $ edit my_policy.yaml

    $ {command} my_policy.yaml
  c                 r    |j                  dt        j                  d       |j                  dddd       y )	Npolicy_filez:The file containing the YAML-formatted policy description.)typehelpz--strict-validation
store_trueFzHWhether to perform additional checks on the validity of policy contents.)actionrequiredr   )add_argumentr   PolicyFileName)clsparsers     /lib/surface/container/binauthz/policy/import.pyArgszImport.Args7   sH    
''I  K 	      c                    t        j                  | j                               }t        j                  |      }t	        j
                  |j                        }|s.i }t        j                  d       t        j                  dd       t        j                  ||j                        }t        j                  |      j!                  t#        j$                         |      S )NzEmpty Policy provided!z&Do you want to import an empty policy?T)prompt_stringcancel_on_no)r   GetApiVersionReleaseTrackGetMessagesModuler   LoadResourceFiler   r   warningr   PromptContinuemessages_utilDictToMessageWithErrorCheckPolicyr   ClientSetr   GetPolicyRef)selfargsapi_versionr	   
policy_objpolicys         r   Runz
Import.RunD   s    $$T%6%6%89K%%k2H ))$*:*:;J j 
kk*+@ 66HOO%F ??;'++D,=,=,?HHr   N)__name__
__module____qualname____doc__classmethodr   r3    r   r   r   r       s!    ( 
 
Ir   r   N)r7   
__future__r   r   r   )googlecloudsdk.api_lib.container.binauthzr   r   r   googlecloudsdk.api_lib.utilr	   r(   googlecloudsdk.callioper
   -googlecloudsdk.command_lib.container.binauthzr   r   googlecloudsdk.corer   googlecloudsdk.core.consoler   DefaultUniverseOnlyCommandr   r9   r   r   <module>rC      sV    2 &  ' : > : A ( E A # 2 8IT\\ 8I 8Ir   