
    Yo                        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  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r\R@                  r  " S S\RB                  5      r" " S S\"5      r# " S S\"5      r$S r%S r&S r'S r(S  r)SNS! jr*S" r+S# r,SNS$ jr-S% r.S& r/S' r0S( r1SNS) jr2S* r3SNS+ jr4S, r5SNS- jr6S. r7S/ r8SOS0 jr9SPS1 jr:SOS2 jr;SPS3 jr<S4 r=S5 r>S6 r?S7 r@S8 rAS9 rBS: rCSPS; jrDS< rES= rFS> rGS? rHSOS@ jrISA rJSB rKSPSC jrLSD rMSE rNSF rOSG rPSH rQSNSI jrRSJ rSSK rTSL rUSM rVg)Qz9Command line processing utilities for service perimeters.    )absolute_import)division)unicode_literals)encoding)acm_printer)util)apis)waiter)base)concepts)common)levels)policies)	arg_utils)repeated)concept_parsers)
exceptions)	resources)yamlNc                   (   ^  \ rS rSrU 4S jrSrU =r$ )
ParseError*   c                 J   > [         [        U ]  SR                  X5      5        g )NzIssue parsing file [{}]: {})superr   __init__format)selfpathreason	__class__s      Alib/googlecloudsdk/command_lib/accesscontextmanager/perimeters.pyr   ParseError.__init__,   s!    	*
6==dKL     __name__
__module____qualname____firstlineno__r   __static_attributes____classcell__r    s   @r!   r   r   *   s    M Mr#   r   c                   (   ^  \ rS rSrU 4S jrSrU =r$ )InvalidMessageParseError1   c           	         > UR                  5        Vs/ s H  oDR                  PM     nn[        [        U ]  USR                  USR                  U5      5      5        g s  snf )NzwThe YAML-compliant file of messages provided contains errors: {}

The objects in this file can contain the fields [{}]., )
all_fieldsnamer   r.   r   r   joinr   r   r   message_classfvalid_fieldsr    s         r!   r   !InvalidMessageParseError.__init__3   sZ    $1$<$<$>?$>qFF$>L?	
"D2   		,(?@	B @   Ar$   r%   r,   s   @r!   r.   r.   1   s    B Br#   r.   c                   (   ^  \ rS rSrU 4S jrSrU =r$ )InvalidFormatError<   c           	         > UR                  5        Vs/ s H  oDR                  PM     nn[        [        U ]  USR                  USR                  U5      5      5        g s  snf )Na  Invalid format: {}

A service perimeter file is a YAML-formatted list of service perimeters, which are YAML objects with the fields [{}]. For example:

- name: my_perimeter
  title: My Perimeter
  description: Perimeter for foo.
  perimeterType: PERIMETER_TYPE_REGULAR
  status:
    resources:
    - projects/0123456789
    accessLevels:
    - accessPolicies/my_policy/accessLevels/my_level
    restrictedServices:
    - storage.googleapis.comr1   )r2   r3   r   r<   r   r   r4   r5   s         r!   r   InvalidFormatError.__init__>   s^    $1$<$<$>?$>qFF$>L?	
d, . 06vf6:ii6M0OP @r:   r$   r%   r,   s   @r!   r<   r<   <   s    P Pr#   r<   c                 4   U R                  5       nU(       dA  UR                  c(  [        U5      R                  R                  5       Ul        UR                  $ UR                  c(  [        U5      R                  R                  5       Ul        UR                  $ )a  Returns the appropriate config for a Service Perimeter.

Args:
  perimeter_result: The perimeter resource.
  dry_run: Whether the requested config is the dry-run config or the enforced
    config.

Returns:
  Either the 'status' (enforced) or the 'spec' (dry-run) Perimeter config.
)Getstatustypespec)perimeter_resultdry_run	perimeters      r!   
_GetConfigrH   S   sv     ""$)	i//446i~~I++002in>>r#   c                    [        5       nU H9  nUR                  5       (       d  M  UR                  UR                  5       5        M;     U(       a7  [        U SR	                  SR                  U5      5      [        US   5      5      eg )NzUnrecognized fields: [{}]r1   r   )setall_unrecognized_fieldsupdater<   r   r4   rC   )r   
conditionsunrecognized_fields	conditions       r!   _ValidateAllFieldsRecognizedrP   i   sx    i((**  !B!B!DE  
#**4995H+IJZ]  r#   c                    SnSnSnSnUR                   R                  nU(       d  [        R                  " US9R                  nU R                  S5      (       a  [        U S5      nSnU R                  S5      (       a  [        U S5      nSnU(       a=  [        US5      nU(       d  [        [        R                  " US9S5      nXCl        XSl        [        USU5        XqR                   l        U$ )	zBAdd the particular service filter message based on specified args.NFversionvpc_allowed_servicesTenable_vpc_accessible_servicesvpcAccessibleServicesVpcAccessibleServices)
servicePerimeterrB   r   GetMessagesServicePerimeterConfigIsSpecifiedgetattrallowedServicesenableRestrictionsetattr)argsreqrS   service_restriction_configallowed_servicesenable_restrictionrestriction_modifiedservice_perimeter_configs           r!   _AddVpcAccessibleServicesFilterrg   u   s    # 1188	!)@@  
,--t%;<	677 'GH!()A)@"B%
$""735L
M !1A.3E0	
"$;
$& 8	*r#   c                     A [        XS5      $ )Nv1)AddVpcAccessibleServicesrefr`   ra   s      r!   AddVpcAccessibleServicesGArm      s    		!$T	22r#   c                 L    A UR                  S5      (       d  [        XS5      $ U$ )Nvpc_accessible_servicesv1alpha)r[   rg   rk   s      r!   AddVpcAccessibleServicesAlpharq      s)    				3	4	4*4i@@	*r#   c                     [        XU5      $ )z1Hook to add the VpcAccessibleServices to request.)rg   )r`   ra   rS   s      r!   rj   rj      s    	(G	<<r#   c                     [        XUSS9$ Nri   rR   AddAccessLevelsBaserk   s      r!   AddAccessLevelsGArw      s    	ST	::r#   c                     [        XUSS9$ Nrp   rR   ru   rk   s      r!   AddAccessLevelsAlpharz      s    	SY	??r#   c                    UR                  S5      (       a  / nUR                   H  nUR                  S5      (       a  UR                  U5        M,  [        R
                  R                  "  SSU0U R                  5       R                  5       D6nUR                  UR                  5       5        M     UR                  R                  nU(       d  [        R                  " US9R                  nXGl        XrR                  l        U$ )z%Hook to add access levels to request.access_levelsaccessPoliciesaccessLevelsIdrR   )z0accesscontextmanager.accessPolicies.accessLevels)r[   r|   
startswithappendr   REGISTRYCreateParentAsDictRelativeNamerX   rB   r   rY   rZ   accessLevels)rl   r`   ra   rS   r|   access_level	level_refrf   s           r!   rv   rv      s    	o&&M**		 	 !1	2	2\*&&-->%'% jjl!!#%	 	Y3356 +  #33::#


7
+
B
B ,9)":	*r#   c                 $   A A[         R                  " SS9nUR                  R                  UR                  R
                  R                  :X  aA  UR                  R                  nU(       d  UR                  nS/Ul	        XBR                  l        U$ )a  Add wildcard for unrestricted services to message if type is regular.

Args:
  ref: resources.Resource, the (unused) resource
  args: argparse namespace, the parse arguments
  req: AccesscontextmanagerAccessPoliciesAccessZonesCreateRequest

Returns:
  The modified request.
v1betarR   *)
r   rY   rX   perimeterTypeServicePerimeterPerimeterTypeValueValuesEnumPERIMETER_TYPE_REGULARrB   rZ   unrestrictedServices)rl   r`   ra   mrf   s        r!   &AddImplicitUnrestrictedServiceWildcardr      s     
4
x(!''55LLN"33::#!"!9!958E1":	*r#   c                  ,    [         R                  " SSS9$ )NrG   z The ID of the service perimeter.)r3   	help_text)r    ResourceParameterAttributeConfigr$   r#   r!   _GetAttributeConfigr      s    		2	2"D
F Fr#   c                  f    [         R                  " SS[        R                  " 5       [	        5       S9$ )Nz5accesscontextmanager.accessPolicies.servicePerimetersrG   )resource_nameaccessPoliciesIdservicePerimetersId)r   ResourceSpecr   GetAttributeConfigr   r$   r#   r!   _GetResourceSpecr      s-    			=224-/	
1 1r#   c                     [         R                  R                  S[        5       SR	                  U5      SS9R                  U 5        g)zAdd a resource argument for a service perimeter.

NOTE: Must be used only if it's the only resource arg in the command.

Args:
  parser: the parser for the command.
  verb: str, the verb to describe the resource, such as 'to update'.
rG   zThe service perimeter {}.T)requiredN)r   ConceptParserForResourcer   r   AddToParser)parserverbs     r!   AddResourceArgr      sC     ++!((.	 ,  ![(r#   c                     [         R                  " S[        R                  " U S9R                  R
                  SSS.SSS9$ )	Nz--typerR   regularbridge)r   PERIMETER_TYPE_BRIDGEFa~            Type of the perimeter.

          A *regular* perimeter allows resources within this service perimeter
          to import and export data amongst themselves. A project may belong to
          at most one regular service perimeter.

          A *bridge* perimeter allows resources in different regular service
          perimeters to import and export data between each other. A project may
          belong to multiple bridge service perimeters (only if it also belongs to a
          regular service perimeter). Both restricted and unrestricted service lists,
          as well as access level lists, must be empty.
          )custom_mappingsr   help_str)r   ChoiceEnumMapperr   rY   r   r   rR   s    r!   GetTypeEnumMapperr      sJ    		#	#
++,H,H$-#+ 
 r#   c                 :    U c  g[        US9R                  U 5      $ )a  Returns the PerimeterTypeValueValuesEnum value for the given short name.

Args:
  perimeter_type_short_name: Either 'regular' or 'bridge'.
  api_version: One of 'v1alpha', 'v1beta', or 'v1'.

Returns:
  The appropriate value of type PerimeterTypeValueValuesEnum.
NrR   )r   GetEnumForChoice)perimeter_type_short_nameapi_versions     r!    GetPerimeterTypeEnumForShortNamer     s*     &	
++,EFGr#   c                 8   [         R                  " S5      [         R                  " S5      [        US9R                  /nU H  nUR                  U 5        M     [        U 5        [        U 5        [        U 5        [        X5        [        U 5        [        X5        g)z'Add args for perimeters update command.zservice perimeterrR   N)r   GetDescriptionArgGetTitleArgr   
choice_argr   _AddResources_AddRestrictedServices_AddLevelsUpdate'AddUpdateVpcAccessibleServicesGroupArgs
AddEtagArg%AddUpdateDirectionalPoliciesGroupArgs)r   rS   r`   args       r!   AddPerimeterUpdateArgsr   (  s     23,-(33
$
 cOOF  6)&:V'8r#   c                 r    US:X  a&  U R                  SS9n[        U5        [        U5        g[        U 5        g)z.Conditional logic for VPC Accessible Services.rp   zMThese flags modify the VpcAccessibleServices of this ServicePerimeter config.)helpN)add_mutually_exclusive_group*_AddSetClearVpcAccessibleServicesArgsAlpha_AddVpcRestrictionArgs)r   rS   mutex_groups      r!   r   r   9  s@    	55' 6 K /{;;' 6"r#   c                 0    [        X5        [        X5        g N)"_AddUpdateIngressPoliciesGroupArgs!_AddUpdateEgressPoliciesGroupArgs)r   rS   s     r!   r   r   I  s    $V5#F4r#   c                     U R                  5       n[        U5        UR                  5       n[        USS9  [	        USS9  [        USS9  [        U5        g)z6Add args for perimeters update-dry-run-config command.F)include_setN)r   _AddClearDryRunConfigArgadd_argument_groupr   r   r   r   )r   update_dry_run_groupconfig_groups      r!   "AddPerimeterUpdateDryRunConfigArgsr   N  sP      <<>/0%88:,%059<U3&r#   c                 R    [         R                  " SSSS9nUR                  U 5        g )Nz--clear
store_truezVIf set, clear all dry run config values on the perimeter and set `dry_run` to `false`.)actionr   )r   Argumentr   )r   r   s     r!   r   r   [  s'    c	#
 //&r#   c           	      6    [         R                  " U SSSSUS9  g )NrG   r   zCResources must be projects, in the form `projects/<projectnumber>`.)additional_helpr   r   AddPrimitiveArgsr   r   s     r!   r   r   d  s$    
5r#   c                 @   ^^ [         R                  " U SUU4S j5      $ )Nr   c                  0   > [        TT 5      R                  $ r   )rH   r   rF   rE   s   r!   <lambda> ParseResources.<locals>.<lambda>r  s    j)73==r#   r   ParsePrimitiveArgsr`   rE   rF   s    ``r!   ParseResourcesr   o  s    		$	$
K=
? ?r#   c           
      8    [         R                  " U SSSSSUS9  g )NrG   zrestricted-serviceszrestricted servicesSERVICEz\The perimeter boundary DOES apply to these services (for example, `storage.googleapis.com`).metavarr   r   r   r   s     r!   r   r   u  s'    
'	r#   c                 @   ^^ [         R                  " U SUU4S j5      $ )Nrestricted_servicesc                  0   > [        TT 5      R                  $ r   )rH   restrictedServicesr   s   r!   r   )ParseRestrictedServices.<locals>.<lambda>  s    j)73FFr#   r   r   s    ``r!   ParseRestrictedServicesr     s!    		$	$
!F
H Hr#   c                     / SQnSnU Vs/ s H  o3U-   PM	     nnSn[        XE/-    Vs/ s H  o`R                  U5      PM     sn5      $ s  snf s  snf )N)remove_add_clear_rT   rU   )anyr[   )r`   list_command_prefixes	list_namecommand	list_argsswitch_namer   s          r!   _IsServiceFilterUpdateSpecifiedr     sa    7$)2GH2Gw"2G)H0+	y=/HI/Hs#/HI	JJ I Js
   A
Ac           
      |    U R                  5       n[        R                  " USSSSSUS9  UR                  SSS	US
9  g)z>Add to the parser arguments for this service restriction type.rG   zvpc-allowed-serviceszvpc allowed servicesVPC_SERVICEF)r   r   r   z --enable-vpc-accessible-servicesNr   )defaultr   r   )r   r   r   add_argument)r   	list_helpenable_helpgroups       r!   _AddVpcAccessibleServicesArgsr     sT    

#
#
%%
 # (	  r#   c                     SnU R                  U5      nSn[        R                  " SSU[        U5      S9nSn[        R                  " SUSS	9nUR	                  U5        UR	                  U5        g
)z(Add args for set/clear ingress-policies.zIThese flags modify the enforced IngressPolicies of this ServicePerimeter.a  Path to a file containing a list of Ingress Policies.

This file contains a list of YAML-compliant objects representing Ingress Policies described in the API reference.

For more information about the alpha version, see:
https://cloud.google.com/access-context-manager/docs/reference/rest/v1alpha/accessPolicies.servicePerimeters
For more information about non-alpha versions, see: 
https://cloud.google.com/access-context-manager/docs/reference/rest/v1/accessPolicies.servicePerimetersz--set-ingress-policies	YAML_FILEr   r   rC   z+Empties existing enforced Ingress Policies.z--clear-ingress-policiesr   r   r   N)r   r   r   ParseIngressPoliciesr   )r   r   
group_helpr   set_ingress_policies_help_textset_ingress_policies_arg clear_ingress_policies_help_textclear_ingress_policies_args           r!   r   r     s    $*

-
-j
9%r ! "]]),	. 4 ##}} +  &&u-((/r#   c                     SnU R                  U5      nSn[        R                  " SSU[        U5      S9nSn[        R                  " SUSS	9nUR	                  U5        UR	                  U5        g
)z'Add args for set/clear egress policies.zHThese flags modify the enforced EgressPolicies of this ServicePerimeter.a  Path to a file containing a list of Egress Policies.

This file contains a list of YAML-compliant objects representing Egress Policies described in the API reference.

For more information about the alpha version, see:
https://cloud.google.com/access-context-manager/docs/reference/rest/v1alpha/accessPolicies.servicePerimeters
For more information about non-alpha versions, see: 
https://cloud.google.com/access-context-manager/docs/reference/rest/v1/accessPolicies.servicePerimetersz--set-egress-policiesr   r  z*Empties existing enforced Egress Policies.z--clear-egress-policiesr   r  N)r   r   r   ParseEgressPoliciesr   )r   r   r  r   set_egress_policies_help_textset_egress_policies_argclear_egress_policies_help_textclear_egress_policies_args           r!   r   r     s    $*

-
-j
9%r   !MM({+	- 3 ""mm* %%e,''.r#   c                     Sn[         R                  " SSU[        S5      S9nSn[         R                  " SUSS	9nUR                  U 5        UR                  U 5        g
)z/Add args for set/clear vpc accessible services.a  Path to a file containing a VpcAccessibleServices object.

This file contains a YAML-compliant object representing VpcAccessibleServices described in the API reference.

For more information about the alpha version, see:
https://cloud.google.com/access-context-manager/docs/reference/rest/v1alpha/accessPolicies.servicePerimeters
For more information about non-alpha versions, see: 
https://cloud.google.com/access-context-manager/docs/reference/rest/v1/accessPolicies.servicePerimetersz--set-vpc-accessible-servicesr   rp   r  z0Empties existing enforced VpcAccessibleServices.z--clear-vpc-accessible-servicesr   r  N)r   r   ParseVpcAccessibleServicesr   )r   %set_vpc_accessible_services_help_textset_vpc_accessible_services_arg'clear_vpc_accessible_services_help_text!clear_vpc_accessible_services_args        r!   r   r     sq    r ( %)MM%0%i0	%! 9 * '+mm'2'#
 "--f5#//7r#   c                     UR                  SS5      n[        U SU-   5      n[        U SU-   S5      nU(       a  gUb  US4$ g)	zcReturn values for clear_/set_ vpc-accessible-services command line args, and whether they were set.-_r   set_N)NTT)NFreplacer\   r`   arg_nameunderscored_nameclearr  s        r!   $ParseUpdateVpcAccessibleServicesArgsr    sT    %%c3/
$#33
4%	v 00$	7$
:r#   c                     UR                  SS5      n[        U SU-   5      n[        U SU-   S5      nU(       a  / $ Ub  U$ g)zHReturn values for clear_/set_ ingress/egress-policies command line args.r  r  r   r  Nr  r  s        r!   "ParseUpdateDirectionalPoliciesArgsr!    sQ    %%c3/
$#33
4%	v 00$	7$
IKr#   c                    ^^ [        U 5      (       aM  [        TT5      n[        USS5      c3  [        [        R                  " SU5      S5      " 5       n[        USU5        UU4S jn[        R                  " U SU5      $ )z,Parse service restriction related arguments.rV   NaccesscontextmanagerrW   c                  D   > [        [        TT 5      S5      R                  $ )NrV   )r\   rH   r]   r   s   r!   FetchAllowed)ParseVpcRestriction.<locals>.FetchAllowed&  s#    #W-!!01r#   rT   )r   rH   r\   r	   GetMessagesModuler_   r   r   )r`   rE   rS   rF   configrestriction_messager%  s    ` `   r!   ParseVpcRestrictionr*    s~    $T** ('2Fv.5=#

 
 !7
A
!# % f-/BC1
 
	$	$T+A<	PPr#   c                 2    [         R                  " XSS9S   $ )z7Parse a YAML representation of a single message object.F)is_listr   )r   )ParseAccessContextManagerMessagesFromYaml)r   r6   s     r!   _ParseSingleMessageFromFiler.  .  s$     
	9	9
5

 r#   c                    ^  U 4S jnU$ )zKReturns a function that parses a VpcAccessibleServices message from a file.c                 V   > [         R                  " TS9n[        XR                  5      $ NrR   )r   rY   r.  rW   )r   messagesr   s     r!   _Parse*ParseVpcAccessibleServices.<locals>._Parse:  s$    4H&t-K-KLLr#   r$   )r   r3  s   ` r!   r  r  7  s    M 
-r#   c                     [        U SSS9  g)zAAdd arguments related to the VPC Accessible Services to 'parser'.zZServices allowed to be called within the Perimeter when VPC Accessible Services is enabledzWhen specified restrict API calls within the Service Perimeter to the set of vpc allowed services. To disable use '--no-enable-vpc-accessible-services'.)r   r   r   N)r   r   s    r!   r   r   A  s    +B	Dr#   c                 (    U R                  SSS SS9  g )Nz--etagetaga  The etag for the version of the Access Policy that this
              operation is to be performed on. If, at the time of the
              operation, the etag for the Access Policy stored in Access
              Context Manager is different from the specified etag, then the
              commit operation will not be performed and the call will fail.
              If etag is not provided, the operation will be performed as if a
              valid etag is provided.)r   r   r   )r   r6  s    r!   r   r   L  s#    )	  
*r#   c           
      8    [         R                  " U SSSSSUS9  g )NrG   zaccess-levelszaccess levelsLEVELzAn intra-perimeter request must satisfy these access levels (for example, `MY_LEVEL`; must be in the same access policy as this perimeter) to be allowed.r   r   r   s     r!   r   r   Z  s)    
& 
r#   c                 Z    [         R                  U [        R                  S9R                  $ )N
collection)r   Parser   
COLLECTIONr~   )
level_names    r!   _GetLevelIdFromLevelNamerA  h  s!    	
v/@/@	A	P	PPr#   c           	          U c  g/ nU  H]  nUR                  S5      (       a  UR                  U5        M,  UR                  [        R                  [        R
                  XS95        M_     U$ )zGReturns the FULL Access Level names, prepending Policy ID if necessary.NzaccessPolicies/)r   r~   )r   r   r   r   r   r?  )	level_ids	policy_idfinal_level_idsls       r!   ExpandLevelNamesIfNecessaryrG  l  sl    /a||%&&Q
//)  OP	  
r#   c                 Z   ^^ UU4S jn[         R                  " U SU5      n[        XR5      $ )zProcess repeated level changes.c                  n   > [        TT5      R                   V s/ s H  n [        U 5      PM     sn $ s  sn f r   )rH   r   rA  )rF  rF   rE   s    r!   GetLevelIds ParseLevels.<locals>.GetLevelIds~  s=     ,g6CCCA 	!#C  s   2r|   )r   r   rG  )r`   rE   rD  rF   rJ  rC  s    ` `  r!   ParseLevelsrL  {  s)     ))$M)	$Y	::r#   c                    ^  U 4S jnU$ )Nc                 T   > [        U [        R                  " TS9R                  5      $ r1  )!ParseAccessContextManagerMessagesr   rY   IngressPolicyr   r   s    r!   ParseVersionedIngressPolicies;ParseIngressPolicies.<locals>.ParseVersionedIngressPolicies  s'    ,-;;= =r#   r$   )r   rR  s   ` r!   r  r    s    =
 
'&r#   c                    ^  U 4S jnU$ )Nc                 T   > [        U [        R                  " TS9R                  5      $ r1  )rO  r   rY   EgressPolicyrQ  s    r!   ParseVersionedEgressPolicies9ParseEgressPolicies.<locals>.ParseVersionedEgressPolicies  s'    ,-::< <r#   r$   )r   rW  s   ` r!   r
  r
    s    <
 
&%r#   c                 ,   [         R                  " U 5      nU(       d  [        U S5      e U Vs/ s H  n[        R                  " X15      PM     nn[        X5        U$ s  snf ! [
         a&  n[        U [        R                  " U5      U5      eSnAff = f)a5  Parse a YAML representation of a list of messages.

Args:
  path: str, path to file containing Ingress/Egress Policies
  message_class: obj, message type to parse the contents of the yaml file to

Returns:
  list of message objects.

Raises:
  ParseError: if the file could not be read into the proper object
File is emptyN)
r   	load_pathr   r   DictToMessage	Exceptionr.   six	text_typerP   )r   r6   datacr2  errs         r!   rO  rO    s     
	$	
T?
++LBFG$Q&&q8$HG t.	/ H	 L
"4s);]
KKLs(   A#  AA# A# #
B-!BBc                     [        U SS9$ ry   ParseServicePerimetersBaser   s    r!   ParseServicePerimetersAlpharg    s    	#D)	<<r#   c                     [        U SS9$ rt   rd  rf  s    r!   ParseServicePerimetersGAri    s    	#D$	77r#   c                 l   [         R                  " U 5      nU(       d  [        U S5      e[        R                  " US9nUR
                  n U Vs/ s H  n[        R                  " XT5      PM     nn[        X5        U$ s  snf ! [         a&  n[        U [        R                  " U5      U5      eSnAff = f)a5  Parse a YAML representation of a list of Service Perimeters.

Args:
  path: str, path to file containing service perimeters
  version: str, api version of ACM to use for proto messages

Returns:
  list of Service Perimeters objects.

Raises:
  ParseError: if the file could not be read into the proper object
rZ  rR   N)r   r[  r   r   rY   r   r   r\  r]  r<   r^  r_  rP   )r   rS   r`  r2  r6   ra  rM   rb  s           r!   re  re    s     
	$	
T?
++g.(++-FDHIDq(((:DJI t0	 J	 F
T3==#5}
EEFs*   B  A>/B >B 
B3!B..B3c                     [        U SS9$ ry   )ParseReplaceServicePerimetersResponseBaselrounused_argss     r!   *ParseReplaceServicePerimetersResponseAlpharq    s    	23		JJr#   c                     [        U SS9$ rt   rl  rn  s     r!   'ParseReplaceServicePerimetersResponseGArs    s    	23	EEr#   c                 :   [         R                  " US9n[        R                  R	                  U R
                  SS9n[        R                  " UR                  UR                  U5      n[        R                  " XCSR                  UR                  5       5      5      $ )a  Parse the Long Running Operation response of the ReplaceServicePerimeters call.

Args:
  lro: Long Running Operation response of ReplaceServicePerimeters.
  version: version of the API. e.g. 'v1beta', 'v1'.

Returns:
  The replacement Service Perimeters created by the ReplaceServicePerimeters
  call.

Raises:
  ParseResponseError: if the response could not be parsed into the proper
  object.
rR   zaccesscontextmanager.operationsr<  z5Waiting for Replace Service Perimeters operation [{}])r   	GetClientr   r   r>  r3   r   BulkAPIOperationPoller accessPolicies_servicePerimeters
operationsr
   WaitForr   Name)ro  rS   clientoperation_refpollers        r!   rm  rm    s     >>'*&$$**	hh< + >-((--v/@/@-Q& 
=DD



 
! !r#   c                 
   U R                   c  U R                  (       a  gU R                  c  U R                   c  g/ nU R                  nU R                  (       d  UnUR                  S5        OU R                   nUc$  [        R
                  " US9nUR                  5       nX0l        X@l         UR                  SR                  U R                  U R                  R                  S5      S-   S 5      5        UR                  S	R                  U R                  5      5        UR                  S
R                  U R                  =(       d    S5      5        [        SR                  U5      5        [        R                  " U S5        g)z6Generates a diff string by comparing status with spec.NzAThis Service Perimeter has been marked for deletion dry-run mode.zAThis Service Perimeter has no dry-run or enforcement mode config.zThis Service Perimeter does not have an explicit dry-run mode configuration. The enforcement config will be used as the dry-run mode configuration.rR   z
  name: {}/   z  title: {}z
  type: {}r   
zdiff[format=yaml](status, spec))rD   useExplicitDryRunSpecrB   r   r   rY   rZ   r   r3   rfindtitler   printr4   r   Print)rG   r   outputrB   rD   r2  s         r!   GenerateDryRunConfigDiffr    sC   ^^	 ? ?N).."8N&&		(	(D
MM D E >>D^4H,,.F.--##INN9>>3G3G3L3445 46 %7 8 9--$$Y__56--##I$;$; %=$<> ? 		&I@Ar#   r   )T)F)W__doc__
__future__r   r   r   apitools.base.pyr   +googlecloudsdk.api_lib.accesscontextmanagerr   r   googlecloudsdk.api_lib.utilr	   r
   googlecloudsdk.callioper    googlecloudsdk.calliope.conceptsr   /googlecloudsdk.command_lib.accesscontextmanagerr   r   r   $googlecloudsdk.command_lib.util.apisr   $googlecloudsdk.command_lib.util.argsr   (googlecloudsdk.command_lib.util.conceptsr   googlecloudsdk.corer   r   r   r^  r   Errorr   r.   r<   rH   rP   rg   rm   rq   rj   rw   rz   rv   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r!  r*  r.  r  r   r   r   rA  rG  rL  r  r
  rO  rg  ri  re  rq  rs  rm  r  r$   r#   r!   <module>r     s   @ &  ' % C < , . ( 5 B B D : 9 D * ) $ 
M!! MBz BP P.,	 F3
=
;@,0F
1) 4G"9"# 5

'?
HK$0:/:8<Q(D*Q
;'&4=8:KF!6Br#   