
    )                        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 rS rS rS r\
R(                  \
R*                  " \
R,                  R.                  \
R,                  R0                  5       " S S\
R2                  5      5       5       r\
R*                  " \
R,                  R6                  5       " S S\5      5       rSSSS.r\\l        \\l        g)zB`gcloud access-context-manager perimeters dry-run update` command.    )absolute_import)division)unicode_literals)util)zones)base)
perimeters)policies)repeatedc                 T    U R                   (       a  U R                  $ U R                  $ )z8Returns the base config to use for the update operation.)useExplicitDryRunSpecspecstatus)	perimeters    ?lib/surface/access_context_manager/perimeters/dry_run/update.py_GetBaseConfigr      s!    $$>>			    c                 ^   ^ [         R                  " XU4S j5      nU(       d	  U(       d  TnU$ )zAReturns the repeated field value to use for the update operation.c                     > T =(       d    / $ N )base_config_values   r   <lambda>(_GetRepeatedFieldValue.<locals>.<lambda>'   s    7H7NB7Nr   )r   ParsePrimitiveArgs)args
field_namer   has_specrepeated_fields     `  r   _GetRepeatedFieldValuer    $   s+    ..t/NP. 
.&N	r   c                 h   ^ / SQnU Vs/ s H  o3U -   PM	     nn[        U4S jU 5       5      $ s  snf )N)remove_add_clear_c              3   F   >#    U  H  nTR                  U5      v   M     g 7fr   )IsSpecified).0argr   s     r   	<genexpr>$_IsFieldSpecified.<locals>.<genexpr>8   s     8isTc""is   !)any)r   r   list_command_prefixescommand	list_argss    `   r   _IsFieldSpecifiedr/   4   s9    73HI3H#3H)I	8i8	88 Js   /c                 J    [         R                  " X5      nU(       d  Uc  UnU$ )zGReturns the ingress/egress field value to use for the update operation.)r	   "ParseUpdateDirectionalPoliciesArgs)r   r   r   r   ingress_egress_fields        r   _GetIngressEgressFieldValuer3   ;   s/    #FF

 
*2, 
r   c                   F    \ rS rSrSrSr\S 5       r\S	S j5       rS r	Sr
g)
UpdatePerimeterDryRunL   ?Updates the dry-run mode configuration for a Service Perimeter.v1c                 ,    [         R                  U SS9  g )Nr8   versionr5   ArgsVersionedparsers    r   ArgsUpdatePerimeterDryRun.ArgsR   s    '''=r   c                    [         R                  " U S5        [         R                  " X5        [         R                  " U 5        [        R
                  " U SSSSS9  [        R
                  " U SSSSS9  [        R
                  " U SS	S
SS9  US:w  a;  U R                  S5      nUR                  SSSS9  [        R
                  " USSSSS9  O[         R                  " X5        U R                  SSSS9  g )Nz	to updatezService Perimeter	resources	ResourcesF)include_setzrestricted-serviceszRestricted Serviceszaccess-levelszAccess Levelv1alphaz>Arguments for configuring VPC accessible service restrictions.z --enable-vpc-accessible-services
store_truezWhen specified restrict API calls within the Service Perimeter to the
          set of vpc allowed services. To disable use
          '--no-enable-vpc-accessible-services'.)actionhelpvpc-allowed-serviceszVPC Allowed Servicesz--asyncz^Return immediately, without waiting for the operation in
                progress to complete.)	r	   AddResourceArg%AddUpdateDirectionalPoliciesGroupArgs
AddEtagArgr   AddPrimitiveArgsadd_argument_groupadd_argument'AddUpdateVpcAccessibleServicesGroupArgs)r?   r;   	vpc_groups      r   r=   #UpdatePerimeterDryRun.ArgsVersionedV   s   fk244VE&!   )++
JLi
,4  5 


 
  88
 )  *r   c                 H   [         R                  " U R                  S9n[        R                  " U R                  S9nUR
                  R                  R                  5       n[        R                  " XA5        UR                  U5      n[        U5      n[        SU5      (       a#  [        USUR                  UR                  5      nOUR                  n[        SU5      (       a#  [        USUR                   UR                  5      nOUR                   n[        SU5      (       a#  [        USUR"                  UR                  5      n	OUR"                  n	UR$                  n
U
c  UR'                  5       n
[        SU5      (       a#  [        USU
R(                  UR                  5      nOUR$                  b  U
R(                  nOS nUR+                  S5      (       a  UR,                  nOUR$                  b  U
R.                  nOS nS nSnU R                  S	:X  a  [0        R2                  " US
5      u  pUc  S nO	U(       d  / n[5        USUR6                  UR                  5      n[5        USUR8                  UR                  5      nUR;                  UUU	UUUUUUUUR<                  S9$ )Nr:   rC   restricted_servicesaccess_levelsvpc_allowed_servicesrJ   enable_vpc_accessible_servicesFrF   zvpc-accessible-serviceszingress-policieszegress-policies)
rC   levelsrU   rW   rX   vpc_yaml_flag_usedvpc_accessible_services_configingress_policiesegress_policiesetag)	zones_apiClient_API_VERSIONr   GetMessagesCONCEPTSr   Parser
   ValidateAccessPolicyArgGetr   r/   r    rC   r   restrictedServicesaccessLevelsvpcAccessibleServicesVpcAccessibleServicesallowedServicesr&   rX   enableRestrictionr	   $ParseUpdateVpcAccessibleServicesArgsr3   ingressPoliciesegressPoliciesPatchDryRunConfigr^   )selfr   clientmessagesperimeter_reforiginal_perimeterbase_configupdated_resourcesupdated_restricted_servicesupdated_access_levelsbase_vpc_configupdated_vpc_servicesupdated_vpc_enabledr[   rZ   updated_ingressupdated_egresss                    r   RunUpdatePerimeterDryRun.Run   s   d&7&78F(9(9:HMM++113M$$]9M2 !34Kd++0
[22

2
24 &//.55$:
%{'E'E

2
2%4! %0$B$B!$//4
!9!9

2
24 *66!77O 668o/663
&(G(G

2
24 
	*	*	6,<<!899 ??		*	*	6+== %)"I%

9
9- 9$ "! 1##00	O 1""00	N ###$71':-'E(&YY $  r   r   N)r8   )__name__
__module____qualname____firstlineno____doc__ra   staticmethodr@   r=   r   __static_attributes__r   r   r   r5   r5   L   s:     H,> > -* -*^Sr   r5   c                   ,    \ rS rSrSrSr\S 5       rSrg)UpdatePerimeterDryRunAlpha   r7   rF   c                 ,    [         R                  U SS9  g )NrF   r:   r<   r>   s    r   r@   UpdatePerimeterDryRunAlpha.Args   s    ''	'Br   r   N)	r   r   r   r   r   ra   r   r@   r   r   r   r   r   r      s    G,C Cr   r   z>Update the dry-run mode configuration for a Service Perimeter.a`  This command updates the dry-run mode configuration (`spec`) for a Service Perimeter.

For Service Perimeters with an explicitly defined dry-run mode configuration (i.e. an explicit `spec`), this operation updates that configuration directly, ignoring enforcement mode configuration.

Service Perimeters that do not have explict dry-run mode configuration will inherit the enforcement mode configuration in the dry-run mode. Therefore, this command effectively clones the enforcement mode configuration, then applies the update on that configuration, and uses that as the explicit dry-run mode configuration.a;  To update the dry-run mode configuration for a Service Perimeter:

  $ {command} my-perimeter --add-resources="projects/123,projects/456" --remove-restricted-services="storage.googleapis.com" --add-access-levels="accessPolicies/123/accessLevels/a_level" --enable-vpc-accessible-services --clear-vpc-allowed-services)briefDESCRIPTIONEXAMPLESN)r   
__future__r   r   r   +googlecloudsdk.api_lib.accesscontextmanagerr   r   r_   googlecloudsdk.callioper   /googlecloudsdk.command_lib.accesscontextmanagerr	   r
   $googlecloudsdk.command_lib.util.argsr   r   r    r/   r3   UniverseCompatibleReleaseTracksReleaseTrackBETAGAUpdateCommandr5   ALPHAr   detailed_helpr   r   r   <module>r      s    I &  ' < J ( F D 9 9" D%%**D,=,=,@,@AKD.. K B K\ D%%++,C!6 C -C 	I	
'
(0 ,9  (&3  #r   