
    Q                     l   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  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,                  \
R.                  5      5       5       rSS0\l        g)zDCommand for getting effective security policies of backend services.    )absolute_import)division)unicode_literals)base_classes)firewalls_utils)lister)base)flags)logc                   :    \ rS rSrSr\S 5       rS rS rS r	Sr
g)	GetEffectiveSecurityPolicies   a}  Get the effective security policies of a Compute Engine backend service.

*{command}* is used to get the effective security policies applied to the
backend service.

## EXAMPLES

To get the effective security policies for a backend service, run:

  $ {command} example-backend-service

gets the effective security policies applied on the backend service
'example-backend-service'.
c                     [         R                  R                  U SS9  U R                  R	                  [
        R                  5        [        R                  " U 5        g )Nzget effective security policies)operation_type)	r
   GLOBAL_BACKEND_SERVICE_ARGAddArgumentdisplay_info	AddFormatr   %EFFECTIVE_SECURITY_POLICY_LIST_FORMATr   AddBaseListerArgs)parsers    Glib/surface/compute/backend_services/get_effective_security_policies.pyArgs!GetEffectiveSecurityPolicies.Args0   sP    	$$00@ 1  !!== V$    c                 .    UR                  S5      nUS   $ )N/)split)selfsp_refsp_ref_lists      r   _GetSecurityPolicyName3GetEffectiveSecurityPolicies._GetSecurityPolicyName:   s    ,,s#Kr?r   c                 .   [         R                  " U R                  5       5      nUR                  n[        R
                  R                  UUR                  [        R                  " U5      S9nUR                  R                  " S0 UR                  5       D6nUR                  UR                  R                  SU4/5      S   nSnSnUR                  R                   " S0 UR                  5       D6n	UR                  R                  SU	4/n
[#        US5      (       ax  UR$                  (       ag  UR                  R'                  UR(                  U R+                  UR$                  5      S9nU
R-                  UR                  R.                  SU45        Sn[#        US	5      (       ax  UR0                  (       ag  UR                  R'                  UR(                  U R+                  UR0                  5      S9nU
R-                  UR                  R.                  SU45        SnUR                  U
5      nUS   n/ nS nS n/ n[#        US
5      (       a  UR3                  UR.                  5        U(       a  US   nU(       a  US   nOU(       a  US   nUR3                  U5        U(       a  UR-                  U5        U(       a  UR-                  U5        UR5                  S5      (       a)  UR6                  S:X  a  UR                  R9                  US9$ / nU H(  nUR3                  [:        R<                  " U5      5        M*     U(       a%  UR3                  [:        R>                  " U5      5        U(       a%  UR3                  [:        R>                  " U5      5        U$ )N)scope_listerGetr   Fr   edgeSecurityPolicy)projectsecurityPolicyTr*   securityPolicies      formatjson)r+    ) r   ComputeApiHolderReleaseTrackclientr
   r   ResolveAsResource	resourcescompute_flagsGetDefaultScopeListermessages ComputeBackendServicesGetRequestAsDictMakeRequestsapitools_clientbackendServices9ComputeBackendServicesGetEffectiveSecurityPoliciesRequesthasattrr(   !ComputeSecurityPoliciesGetRequestr)   r#   appendr+   r*   extendIsSpecifiedr.   3BackendServicesGetEffectiveSecurityPoliciesResponser   /ConvertOrgSecurityPolicyRulesToEffectiveSpRules,ConvertSecurityPolicyRulesToEffectiveSpRules)r    argsholderr3   backend_service_refget_requestget_responsehas_edge_sphas_spget_effective_sp_requestrequestsget_edge_sp_requestget_sp_request	responsesget_effective_sp_responseorg_policiesedge_policybackend_policyall_policiesresultsps                        r   Run GetEffectiveSecurityPolicies.Run>   sg   **4+<+<+>?F]]F::LL"88@ M 
 //BB 

$
$
&K &&				/	/D( 
L KF%hh  

$
$
&  	..&  H 	233++"OOMM%--44-- N  oo

 
 
1
1

 	
 k|-..<3N3NHH%--44)) I n oo

 
 
1
1

 	
 f##H-I )!LKNL(*<==3DDEaLk	"1	 |n%+&.)!!dkkV&;
//
M
M+ N  Fmm

I
I"
M  mm

F
F
 mm

F
F
 Mr   c                 f    A[         R                  R                  S[        R                  -   5        g )N
)r   statusPrintr   LIST_NOTICE_SECURITY_POLICY)r    resources_were_displayeds     r   Epilog#GetEffectiveSecurityPolicies.Epilog   s"     JJTOGGGHr   r0   N)__name__
__module____qualname____firstlineno____doc__staticmethodr   r#   rZ   rb   __static_attributes__r0   r   r   r   r      s-     % %fPIr   r   EXAMPLESaX      To get the effective security policies of backend_service with name
    example-backend_service, run:

      $ {command} example-backend_service

    To show all fields of the security policy, please show in JSON format with
    option --format=json

    To list more the fields of the effective security policy rules in table
    format, run:

      $ {command} example-backend_service --format="table(
        type,
        security_policy_name,
        priority,
        description,
        action,
        preview,
        expression,
        src_ip_ranges.list():label=SRC_RANGES)"
        N)rh   
__future__r   r   r   googlecloudsdk.api_lib.computer   r   r   googlecloudsdk.callioper	   "googlecloudsdk.command_lib.computer
   r6   3googlecloudsdk.command_lib.compute.backend_servicesgooglecloudsdk.corer   UniverseCompatibleReleaseTracksr2   ALPHABETADescribeCommandListCommandr   detailed_helpr0   r   r   <module>ry      s    K &  ' 7 : 1 ( E E # D%%++T->->-C-CDHI4#7#79I9I HI E HIX  .  *r   