
                             d Z ddlmZ ddlmZ ddlmZ ddlmZmZ ddlm	Z	 ddd	d
dddddgddZ
eeeedf   f   Zdeeef   deeef   fdZde	j                  deeef   defdZd ZdefdZy)z'Utilities for working with update mask.    )absolute_import)division)unicode_literals)DictUnion)parser_extensionsz--display-namez--security-posturez!--workload-vulnerability-scanning)modevulnerability_modez--binauthz-evaluation-modez--binauthz-policy-bindings)evaluation_modepolicy_bindingsz--compliancez--compliance-standards)security_posture_configbinary_authorization_configcompliance_posture_config)display_namedefault_cluster_configLevelmessage_to_flagsreturnc                 R    dt         dt        t        t        f   ffd |       S )a  Construct flag to update mask paths during runtime.

  From top level field, combine the string up to the leaf dict.

  Flag fields are unique.

  Args:
    message_to_flags: Receive value from MESSAGE_TO_FLAGS.

  Returns:
    A dictionary that maps each flag to the corresponding field update path.

  Given the below message to flag structure,

    {
      parent: {
        child1: {
          foo: '--flag-for-foo',
          child2: {
            bar: '--flag-for-bar'
          }
        }
      }
    }

  It should produce the following flag to update path mapping:

    {
      '--flag-for-foo': parent.child1.foo,
      '--flag-for-bar': parent.child1.child2.bar,
    }
  levelr   c                     i }| j                         D ]a  \  }}t        |t              r|||<   t        |t              r|D ]  }|||<   	 9 |      j                         D ]  \  }}|dz   |z   ||<    c |S )N.)items
isinstancestrlist)r   ret	curr_pathflag_or_levelflagkeyremain_path	Recursives          =lib/googlecloudsdk/command_lib/container/fleet/update_mask.pyr#   z(FlagToUpdateMaskPaths.<locals>.RecursiveU   s    
C$)KKM 	=	M3	'&MmT*!D#d) " !*- 8 > > @C_{2#c( !A %2 j    )r   r   r   )r   r#   s    @r$   FlagToUpdateMaskPathsr&   1   s-    Hu c3h  
#	$$r%   argsflag_to_update_mask_pathsc                     g }|j                         D ])  \  }}|| j                         v s|j                  |       + dj                  t	        t        |                  S )a)  Maps specified flags to API field paths of mutable fields.

  args.GetSpecifiedArgNames() returns a list of specified flags.

  For example, `gcloud alpha container fleet create --display-name my-fleet
  --format 'yaml(displayName)'`
  args.GetSpecifiedArgNames() = ['--display-name', '--format']

  Args:
    args: All arguments passed from CLI.
    flag_to_update_mask_paths: Mapping for a specific resource, such as user
      cluster, or node pool.

  Returns:
    A string that contains yaml field paths to be used in the API update
    request.
  ,)r   GetSpecifiedArgNamesappendjoinsortedset)r'   r(   r   r    update_masks        r$   GetUpdateMaskr1   f   sX    ( 	#4::<dKt((**	jj = 88F3s8$%%r%   c                 8    t        t              }t        | |      S )N)r&   FLEET_MESSAGE_TO_FLAGSr1   )r'   fleet_flag_to_update_mask_pathss     r$   GetFleetUpdateMaskr5      s     $9%! 
t<	==r%   c                 J    | j                  d      xs | j                  d      S )Nbinauthz_evaluation_modebinauthz_policy_bindings)IsKnownAndSpecified)r'   s    r$   HasBinauthzConfigr:      s,    		!	! 
 
< :;<r%   N)__doc__
__future__r   r   r   typingr   r   googlecloudsdk.callioper   r3   r   r   r&   	Namespacer1   r5   boolr:    r%   r$   <module>rB      s    . &  '  5 % )"E$

  <;(
 '56N%O
 " 	S%W%%&2%3:&2%	#s(^2%j&

%
%&BFsCx.&&8><t <r%   