
    M                     f   S r SSK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  SS	KJr  S
rSrSrSrSr\R&                  \R(                  \R*                  " \R,                  R.                  \R,                  R0                  5       " S S\R2                  5      5       5       5       rS rS rg)z"services mcp policies get command.    N)serviceusage)base)common_flags)log)
properties)yaml)fileszprojects/{}z
folders/{}zorganizations/{}z/mcpPolicies/{}z1970-01-01T00:00:00Zc                   .    \ rS rSrSr\S 5       rS rSrg)Get&   a  Get MCP policy for a project, folder or organization.

Get MCP policy for a project, folder or
organization.

## EXAMPLES

 Get MCP policy for default policy on current project:

 $ {command}
    OR
 $ {command} --policy-name=default

 Get MCP policy for default policy on current project and save the
 content in an output file:

 $ {command} --output-file=/path/to/the/file.yaml
     OR
 $ {command} --output-file=/path/to/the/file.json
c                 r    U R                  SSSS9  [        R                  " U 5        U R                  SSS9  g )Nz--policy-namez>Name of the MCP policy. Currently only "default" is supported.default)helpr   z--output-filezNPath to the file to write policy contents to. Supported format:.yaml or .json.)r   )add_argumentr   add_resource_args)parsers    (lib/surface/services/mcp/policies/get.pyArgsGet.Args?   sI    
M  
 ""6*
      c                    UR                  S5      (       a   [        R                  UR                  5      nOUR                  S5      (       a   [        R                  UR
                  5      nO|UR                  S5      (       a   [        R                  UR                  5      nOF[        R                  R                  R                  R                  SS9n[        R                  U5      n[        R                  " U[        R                  UR                  5      -   5      nUR                  S5      (       Ga  UR                   R#                  S5      (       d7  UR                   R#                  S5      (       d  [$        R&                  " S	5        gUR                   R#                  S5      (       a  [(        R*                  " [-        U5      S
S9nO[.        R0                  " [-        U5      SS9n[2        R4                  " UR                   U5        [$        R6                  R9                  SUR                   -  5        gUR                  S5      (       a  U$ [-        U5      nUR;                  5        Hw  u  pxUS;  a.  U(       a'  [$        R6                  R9                  US-   U-   5        M9  US:X  d  MA  [$        R6                  R9                  US-   5        U H  n	[=        U	5        M     My     g)zRun command.

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

Returns:
  Resource name and its parent name.
folderorganizationprojectT)requiredoutput_filez.jsonz.yamlzGInvalid output-file format. Please provide path to a yaml or json file.F)	sort_keys)
round_tripz%Policy written to the output file %s format)mcpEnableRulesz: r    :N)IsSpecified_FOLDER_RESOURCEr   r   _ORGANIZATION_RESOURCEr   _PROJECT_RESOURCEr   r   VALUEScorer   r   GetMcpPolicy_MCP_POLICY_DEFAULTpolicy_namer   endswithr   errorjsondumps_ConvertToDictr   dumpr	   WriteFileContentsstatusPrintitems_PrintRules)
selfargsresource_namer   policydataresultkvenable_rules
             r   RunGet.RunP   s.    !!&--dkk:m			.	)	),33D4E4EFm			)	$	$'..t||<m!!&&..22D2Ag'..w7m&&+2243C3CDDF &&



#
#G
,
,&&w//			

 $$W--N62eD$>&1dC$ 0 0$7

3d6F6FF	
 
		(	#	#mf%f,,.$!&&1
**

1t8a<
(""
**

1s7
#k$  ! r    N)	__name__
__module____qualname____firstlineno____doc__staticmethodr   r?   __static_attributes__rA   r   r   r   r   &   s     *   6r   r   c                    U R                   / U R                  U R                  U R                  S.nU R                   H?  nUR
                  (       d  M  US   R                  S[        UR
                  5      05        MA     U R                  (       d  US	 U R                  [        :X  a  US	 U R                  [        :X  a  US	 U$ )ziConvertToDict command.

Args:
  policy: mcpPolicy to be convert to orderedDict.

Returns:
  orderedDict.
)namer    
updateTime
createTimeetagr    mcpservicesrK   rL   )	rJ   rK   rL   rM   r    mcpServicesappendlist_INVALID_TIMESTAMP)r9   outputr>   s      r   r/   r/      s     kk%%%%kk& **k%%${667
8 + 
		 ,,|,,|	-r   c                     S/nU Hs  nX R                  5       ;   d  M  [        R                  R                  SU-   S-   5        X    H.  nU H%  n[        R                  R                  SU-   5        M'     M0     Mu     g )NrO    r!   z  - )keysr   r2   r3   )rulerV   keyrN   servicess        r   r5   r5      sf    
$c
iik	jjsSy3'+#H
**

6H,
- $ # r   )rF   r-   googlecloudsdk.api_lib.servicesr   googlecloudsdk.callioper   #googlecloudsdk.command_lib.servicesr   googlecloudsdk.corer   r   r   googlecloudsdk.core.utilr	   r%   r#   r$   r)   rR   UniverseCompatibleHiddenReleaseTracksReleaseTrackALPHABETACommandr   r/   r5   rA   r   r   <module>rf      s    )  8 ( < # * $ *!  + '    D%%++T->->-C-CD]$,, ] E  ]@ F.r   