
                         :   d Z ddl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Zd	Zd
Zej                  ej                   ej                   ej"                  j$                  ej"                  j&                         G d dej(                                             Zy)z3services MCP policies get-effective-policy command.    N)serviceusage)base)common_flags)log)
propertieszprojects/{}z
folders/{}zorganizations/{}c                   &    e Zd ZdZed        Zd Zy)GetEffectivePolicya6  Get effective MCP policy for a project, folder or organization.

  Get effective MCP policy for a project, folder or organization.

  ## EXAMPLES

   Get effective MCP policy for the current project:

   $ {command}

   Get effective MCP policy for project `my-project`:

   $ {command} --project=my-project
  c                     | j                  ddddgd       t        j                  |        | j                  j	                  d       y )Nz--viewzThe view of the effective MCP policy. BASIC includes basic metadata about the effective MCP policy. FULL includes every information related to effective MCP policy.BASICFULL)helpchoicesdefaultz
          table(
            EnabledMcpService:label=EnabledMcpService:sort=1,
            EnabledMcpPolicies:label=EnabledMcpPolicies
          )
        )add_argumentr   add_resource_argsdisplay_info	AddFormat)parsers    2lib/surface/services/mcp/policies/get_effective.pyArgszGetEffectivePolicy.Args4   sS    
< &!  	 ""6*
!! #     c                    |j                  d      r t        j                  |j                        }n|j                  d      r t        j                  |j
                        }nz|j                  d      r t        j                  |j                        }nIt        j                  j                  j                  j                  d      }t        j                  |      }t        j                  |dz   |j                        }|j                  d      r|S t        j                   j#                  d       |j$                  D ]^  }t        j                   j#                  d	       |j&                  D ].  }t        j                   j#                  d
|j(                  z         0 ` |j                  dk(  rt        j                   j#                  d       g }t+        j,                  dddg      }|j.                  D ]S  }	|	j0                  j2                  D ]8  }
|j5                   ||
j6                  |
j8                  j:                               : U |S y)zRun command.

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

    Returns:
      Effective Policy.
    folderorganizationprojectT)requiredz/effectiveMcpPolicyformatzMcpEnableRules:z McpServices:z  - %sr   z
Metadata of effective policy:serviceMcpSourcesEnabledMcpServiceEnabledMcpPoliciesN)IsSpecified_FOLDER_RESOURCEr   r   _ORGANIZATION_RESOURCEr   _PROJECT_RESOURCEr   r   VALUEScoreGetr   GetEffectiveMcpPolicyviewr   statusPrintmcpEnableRulesmcpServicesservicecollections
namedtuplemcpEnableRuleMetadatar   additionalPropertiesappendkeyvaluepolicies)selfargsresource_namer   responseenable_rulemcp_serviceresult	resourcesmetadatavaluess              r   RunzGetEffectivePolicy.RunI   s    !&--dkk:m			.	),33D4E4EFm			)	$'..t||<m!!&&..22D2Ag'..w7m11--tyyH !o	jj()!00+

)&22K
**

8k&9&99
: 3 1 
f	

:;**"57K!L
	 !66H 22GGfMM)FJJ0E0EFG H 7  
r   N)__name__
__module____qualname____doc__staticmethodr   rA    r   r   r	   r	   !   s       (,r   r	   )rE   r/   googlecloudsdk.api_lib.servicesr   googlecloudsdk.callioper   #googlecloudsdk.command_lib.servicesr   googlecloudsdk.corer   r   r$   r"   r#   UniverseCompatibleHiddenReleaseTracksReleaseTrackALPHABETACommandr	   rG   r   r   <module>rS      s   " :  8 ( < # *!  +  D%%++T->->-C-CDQ Q E  Qr   