
                             S r SSKJr  SSKJr  SSKJr  SSKJr  Sr " S S\R                  5      r
 " S	 S
\R                  5      rg)z.Policy Controller content policy library code.    )messages)protos)
exceptions)flagsbundle_namec                       \ rS rSrSrS rSrg)Flags   z>Flags common to Policy Controller content management commands.c                     U R                   R                  SSS9nUR                  S[        SS9  UR                  SSS	S
9  g)zEAdds handling for configuring exempted namespaces on content bundles.zExempted Namespaces flags.T)mutexz--exempted-namespaceszdExempted namespaces are ignored by Policy Controller when applying constraints added by this bundle.)typehelpz--no-exempted-namespaces
store_truez:Removes all exempted namespaces from the specified bundle.)actionr   N)parseradd_argument_groupadd_argumentstr)selfgroups     Jlib/googlecloudsdk/command_lib/container/fleet/policycontroller/content.pyadd_exempted_namespacesFlags.add_exempted_namespaces   s^    KK**$D + E 
1	   
"I       N)__name__
__module____qualname____firstlineno____doc__r   __static_attributes__r   r   r   r	   r	      s
    Fr   r	   c                      \ rS rSrSr\S 5       r\S\R                  4S j5       r	S\R                  S\R                  4S jr
S rS\R                  S\R                  4S	 jrS
\S\R                  4S jrS\R                  4S jrS\R                  S
\S\R                  4S jrS\R                  S\R                  4S jrS\R                  S\R                  4S jrSrg)
FlagParser3   z:Parses content flags for content policy library functions.c                 ~    U R                   R                  b%  U R                   R                  R                  S5      $ / $ )N,)argsexempted_namespacessplitr   s    r   r(   FlagParser.exempted_namespaces6   s=     99((4 			%%++C0 r   returnc                 B    U R                   R                  R                  $ )zDReturns an reference to the BundlesValue class for this API channel.)r   !PolicyControllerPolicyContentSpecBundlesValuer*   s    r   bundle_messageFlagParser.bundle_message>   s     ==::GGGr   policy_content_specc                 :   [        U R                  [        5      nUc  [        R                  " S5      e[
        R                  " UR                  5      nU R                  U R                  5      X2'   [
        R                  " U R                  5       U5      Ul        U$ )a>  Installs a bundle to provided policy content spec message.

This assumes the bundle is passed in the args of the namespace used to build
this parser.

Args:
  policy_content_spec: A 'PolicyControllerPolicyContentSpec' proto message.

Returns:
  A modified policy_content_spec, adding the bundle from args.bundle_name.
No bundle name specified!)getattrr'   ARG_LABEL_BUNDLEr   SafetyErrorr   additional_properties_to_dictbundles_ns_msgsr(   set_additional_propertiesr0   )r   r2   
new_bundler9   s       r   install_bundleFlagParser.install_bundleC   s     $45J""#>??223F3N3NOG--(@(@AG"("B"Bw# r   c                 F    U R                   R                  5       nXl        U$ )zABuilds the PolicyControllerBundleInstallSpec from namespace list.)r   !PolicyControllerBundleInstallSpecexemptedNamespaces)r   nsinstall_specs      r   r:   FlagParser._ns_msgs\   s     ==BBDL&(#r   c                 t   [        U R                  [        5      nUc  [        R                  " S5      e[
        R                  " UR                  5      nUR                  US 5      nUc%  [        R                  " SR                  U5      5      e[
        R                  " U R                  5       U5      Ul        U$ )Nr4   zC{} is not installed.  Check that the name of the bundle is correct.)r5   r'   r6   r   r7   r   r8   r9   popNoSuchContentErrorformatr;   r0   )r   r2   doomed_bundler9   founds        r   remove_bundleFlagParser.remove_bundleb   s     DII'78M""#>??223F3N3NOGKKt,E}));;A6-;P  #)"B"Bw# r   statec                     U R                   R                  R                  n[        X!S 5      nUc%  [        R
                  " SR                  U5      5      eU$ )Nz"Invalid template install state: {})r   %PolicyControllerTemplateLibraryConfigInstallationValueValuesEnumr5   r   r7   rH   )r   rM   enumsenums       r   _get_template_install_enum%FlagParser._get_template_install_enumu   sU    ;;WW 
 5&D|""
.
5
5e
<  Kr   c                     UR                   R                  R                   c  U R                  R	                  5       $ UR                   R                  R                  $ )zGets the PolicyControllerPolicyContentSpec message from the hub config.

Args:
  poco_cfg: The MembershipFeatureSpec message.

Returns:
  The PolicyControllerPolicyContentSpec message or an empty one if not
  found.
)policycontrollerpolicyControllerHubConfigpolicyContentr   r.   r   poco_cfgs     r   _extract_policy_content"FlagParser._extract_policy_content   sN     	!!;;II	 ]]<<>>$$>>LLLr   rZ   c                     U R                  U5      nU R                  R                  U R                  U5      S9nXCl        UUR
                  R                  l        U$ )N)installation)r[   r   rO   rS   templateLibraryrV   rW   rX   )r   rZ   rM   policy_contentnew_cfgs        r   _update_template_cfgFlagParser._update_template_cfg   sb     11(;NmmAA44U; B G &-" 77E Or   c                 &    U R                  US5      $ )NALLrb   rY   s     r   install_template_library#FlagParser.install_template_library   s     $$Xu55r   c                 &    U R                  US5      $ )NNOT_INSTALLEDrf   rY   s     r   uninstall_template_library%FlagParser.uninstall_template_library   s     $$X??r   r   N)r   r   r   r   r    propertyr(   r   Messager0   r=   r:   rK   r   rS   r[   rb   rg   rk   r!   r   r   r   r#   r#   3   s   B  Hh.. H H!)!1!12!)!1!1&	c 	h6F6F 	M1A1A M"&&/26&&66
@&&@@r   r#   N)r    apitools.base.protorpcliter   7googlecloudsdk.api_lib.container.fleet.policycontrollerr   ;googlecloudsdk.command_lib.container.fleet.policycontrollerr   r   r6   	PocoFlagsr	   PocoFlagParserr#   r   r   r   <module>rt      sF    5 0 J R M ! EOO .s@%% s@r   