
    #                        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
  \R                  \R                  " \R                  R                  \R                  R                  5       " S S	\R                   5      5       5       rg
)z!services policies update command.    )
exceptions)services_util)serviceusage)base)common_flags)yamlc                   .    \ rS rSrSr\S 5       rS rSrg)Update   ak  Update consumer policy for a project, folder or organization.

Update consumer policy for a project, folder or organization.

## EXAMPLES

Update consumer policy

 $ {command} --consumer-policy-file=/path/to/the/file.yaml

Validate the update action on the policy:

 $ {command} --consumer-policy-file=/path/to/the/file.yaml --validate-only

Update consumer policy and bypass dependency check:

 $ {command} --consumer-policy-file=/path/to/the/file.yaml
 --bypass-dependency-check

Update consumer policy and bypass api usage check:

 $ {command} --consumer-policy-file=/path/to/the/file.yaml
 --bypass-api-usage-check
c                    [         R                  " 5       R                  U 5        [         R                  " U SS9  [         R                  " 5       R                  U 5        [         R
                  " 5       R                  U 5        g )Nz	to update)suffix)r   consumer_policy_file_flagAddToParservalidate_only_argsbypass_api_usage_checkbypass_dependency_check)parsers    'lib/surface/services/policies/update.pyArgsUpdate.Args5   sW    **,88@##F;?'')55f=((*66v>    c                    UR                   R                  S5      (       d  [        R                  " S5      e[        R
                  " UR                   5      n[        U[        5      (       d  [        R                  " S5      eSU;  a  [        R                  " S5      e[        R                  " UUR                  UR                  UR                  S9nUR                  (       a'  UR                  (       d  [        R                  " S5      e[        R                   " UR                  [        R"                  5      nUR                  (       a  [        R$                  " U5        g[        R&                  " U5        g)	zRun command.

Args:
  args: an argparse namespace. All the arguments that were provided to this
    command invocation.

Returns:
  Response from longrunning.operations from UpdateConsumerPolicy API call.
z.yamlzHInvalid consumer_policy_file format. Please provide path to a yaml file.z<Invalid consumer-policy-file. Please provide a valid policy.namez/Invalid Consumer Policy. Please provide a name.)validate_onlyr   forcez3No change required for the current consumer policy.N)consumer_policy_fileendswithr   ConfigErrorr   	load_path
isinstancedictr   UpdateConsumerPolicyr   r   r   doner   r   WaitOperationGetOperationV2BetaPrintOperation1PrintOperationWithResponseForUpdateConsumerPolicy)selfargspolicyops       r   Run
Update.Run<   s$    $$--g66"" 
 ^^D556Ffd##""
H  V""
;  
	*	*(( $ < <))	
B 
wwrww""
?  
	$	$RWWl.M.M	NB""2&EEbIr    N)	__name__
__module____qualname____firstlineno____doc__staticmethodr   r,   __static_attributes__r.   r   r   r
   r
      s!    2 ? ?0Jr   r
   N)r3   googlecloudsdk.api_lib.servicesr   r   r   googlecloudsdk.callioper   #googlecloudsdk.command_lib.servicesr   googlecloudsdk.corer   UniverseCompatibleReleaseTracksReleaseTrackALPHABETACommandr
   r.   r   r   <module>r@      su    ( 6 9 8 ( < $ D%%++T->->-C-CDQJT\\ QJ E QJr   