
    +                        S r SSKrSSKrSSKrSSKrSSKrSSKJrJr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SrSrSr Sr!Sr"Sr#Sr$Sr%Sr&Sr'Sr(Sr)Sr*Sr+Sr,Sr-S r.S!r/S"r0S#r1S$r2S%r3S&r4\'\&\!/r5/ S'Q\5-   r6S(r7S)r8S*r9S+r:S,r;S-r<S.r=S/r>Sr&\R~                   " S0 S1\R                  5      5       rA\R                   " S2 S35      5       rCS4\D\   S5\D\E\F\4      S6\FS7\E\A\D\   4   4S8 jrGS9\E\F\4   S:\HS7\A4S; jrIS9\E\F\4   S:\HS7\F4S< jrJS=\E\K\A\F4   \D\   4   S7S4S> jrLS?\E\F\4   S@\CS7S4SA jrMSB\E\F\4   S@\CS7S4SC jrNS\E\F\F4   S@\CS7\E\F\F4   4SD jrOS\E\F\4   S@\CS7\E\F\4   4SE jrPSF\E\F\4   S@\CS7\E\F\4   4SG jrQSF\E\F\4   S@\CS7\E\F\4   4SH jrRSI\E\F\4   S@\CS7\E\F\4   4SJ jrSS?\FS7\F4SK jrTS\FS@\CS7\F4SL jrUS?\E\F\4   S@\CS7\E\F\4   4SM jrVSN\FSO\FSP\E\F\F4   S@\CS7S4
SQ jrWS?\FS@\CS7\E\F\F4   4SR jrXS?\FS@\CS7\F4SS jrY\R                   " ST SU5      5       rZ\Z" \[" \A5      SV/\MSW9\Z" \[" \A5      SB/\NSXS/SYSZ0SYSZ0SXSYSZ0S[.SXSYSZ0S[.S\.S]S^.S_9\Z" \[" \A5      S/\OSXSYSZ0S[.S`9\Z" \AR                  /Sa/\PSbSXS&SYSX00S&/ScSd.Se.S_9\Z" \AR                  /Sf/\QSg9\Z" \AR                  // ShQ\RSg9\Z" \AR                  /Si/\SSg9\Z" \AR                  /Sj/\TSYSZ0S`9\Z" \AR                  // SkQ\USYSZ0S`9\Z" \AR                  /Sl/\VSg9\Z" \AR                  /SmSn/\XSYSZ0S`9\Z" \AR                  /So/\YSYSZ0S`9/r_\AR                  \R                  \AR                  \R                  \AR                  \R                  \AR                  \R                  \AR                  \R                  0rg\AR                  Sp \AR                  Sq \AR                  Sr \AR                  Ss \AR                  St 0rhSu\AS\FS9\E\F\4   Sv\FS6\FS4\D\   S7\4Sw jriS?\S@\CS7S4Sx jrjS?\S@\CS7S4Sy jrkS?\S@\CS7S4Sz jrlS\FS@\CS7\F4S{ jrmS|\E\F\4   S@\CS7\E\F\4   4S} jrnS~\E\F\F4   S\E\F\F4   S@\CS7\F4S jroS\E\F\F4   S7\F4S jrpS\E\F\F4   S@\CS7\F4S jrq\Z" \[" \A5      S/\jSW9\Z" \[" \A5      \[" \AR                  /5      -
  S/S Sg9\Z" \AR                  /S/S Sg9\Z" \[" \A5      S/\lSW9\Z" \[" \A5      \6\kSW9\Z" \AR                  // SQ\mSg9\Z" \AR                  /Sj/S Sg9\Z" \AR                  /S/S Sg9\Z" \AR                  /Sl/\nSg9\Z" \AR                  /SmSn/\qSg9/
rrS\S\R                  Su\AS7\E\F\4   4S jrtS9\E\F\4   S\D\Z   Su\FS\FSv\FS6\FS7S4S jruS\FS9\E\F\4   S7\4S jrv  SS\S\\/\4   S@\CS\	\   S7\4
S jjrwS9\E\F\4   S\FS?\S7S4S jrxS\FS7\F4S jryg)zCUtilities for parsing the cloud deploy resource to yaml definition.    N)AnyCallableOptional)encoding)parsermessages)automation_util)custom_target_type_util)delivery_pipeline_util)deploy_policy_util)
exceptions)target_util)
properties)	resources)resource_propertyz*,labelszdeploy.cloud.google.com/v1beta1zdeploy.cloud.google.com/v1nameadvanceRolloutpromoteReleaserepairRolloutwaitlabelsannotationsselectorrulesidadvanceRolloutRulepromoteReleaseRulerepairRolloutRuletimedPromoteReleaseRuledestinationTargetIdsourcePhasesphasesdestinationPhasedisableRollbackIfRolloutPendingtarget)
createTimecustomTargetTypeIdetagtargetIduid
updateTimejobsretryattemptsrollbackrepairPhasesbackoffModescheduletimeZonec                   .    \ rS rSrSrSrSrSrSrS r	Sr
g	)
ResourceKindS   TargetDeliveryPipeline
AutomationCustomTargetTypeDeployPolicyc                     U R                   $ N)value)selfs    6lib/googlecloudsdk/command_lib/deploy/manifest_util.py__str__ResourceKind.__str__[   s    ::     N)__name__
__module____qualname____firstlineno__TARGETDELIVERY_PIPELINE
AUTOMATIONCUSTOM_TARGET_TYPEDEPLOY_POLICYrB   __static_attributes__rE   rD   rA   r6   r6   S   s"    &(*) -rD   r6   c                   \    \ rS rSr% \\S'   \\S'   \\S'   \\S'   \\\4   \S'   \\S'   Sr	g	)
_TransformContext_   kindr   projectregionmanifestfieldrE   N)
rF   rG   rH   rI   r6   __annotations__strdictr   rO   rE   rD   rA   rQ   rQ   _   s*    ),
+cN	*rD   rQ   r	   	manifestsrU   returnc                    [         R                  R                  R                  R	                  5       n[
        R                  " [        5      n[        U5       H0  u  pV[        Xe5      n[        Xe5      nXGU4   R                  U5        M2     [        U5        [
        R                  " [        5      n	UR                  5        H*  u  u  pxnX   R                  [        XxUS   X2U 5      5        M,     U	$ )a  Parses the declarative definition of the resources into message.

Args:
  messages: module containing the definitions of messages for Cloud Deploy.
  manifests: [str], the list of parsed resource yaml definitions.
  region: str, location ID.

Returns:
  A dictionary of ResourceKind and list of messages.
Raises:
  exceptions.CloudDeployConfigError, if the declarative definition is
  incorrect.
r   )r   VALUEScorerT   	GetOrFailcollectionsdefaultdictlist	enumerate_GetKind_GetNameappend_CheckDuplicateResourceNamesitems_ParseManifest)
r	   r[   rU   rT   manifests_with_metadatairV   rS   r   resources_by_kinds
             rA   ParseDeployConfigrn   i   s      ""**446''33D9y)kaH DH D4L)00: *
 67!--d3!8!>!>!@ltI"" 	t9Q<(K "A 
rD   rV   	doc_indexc                    U R                  S5      nU(       d   [        R                  R                  US5      eU[        [
        1;  a$  [        R                  R                  USU S35      eU R                  S5      nUc   [        R                  R                  US5      eU[         Vs/ s H  n[        U5      PM     sn;  a$  [        R                  R                  USU S35      e[        U5      $ s  snf )zParses the kind of a resource.
apiVersionz#missing required field "apiVersion"zapi version "z" not supportedrS   zmissing required field "kind"zkind ")getr   CloudDeployConfigErrorfor_unnamed_manifestAPI_VERSION_V1BETA1API_VERSION_V1r6   rY   )rV   ro   api_versionrS   rs        rA   re   re      s    \*+	

+
+
@
@8  ,n==

+
+
@
@];-?  
f	$	\

+
+
@
@2  
,/,Q#a&,//

+
+
@
@VD61  
d		 0s   *C4c                     U R                  S5      nU(       a  UR                  [        5      (       d   [        R                  R	                  US5      eUS   $ )zParses the name of a resource.metadataz&missing required field "metadata.name"r   )rr   
NAME_FIELDr   rs   rt   )rV   ro   rz   s      rA   rf   rf      sM    \\*%(	j11

+
+
@
@;  
&	rD   manifests_by_name_and_kindc                 T   [         R                  " [        5      nU R                  5        H,  u  u  p#n[	        U5      S:  d  M  X   R                  U5        M.     / nUR                  5        H  u  p&UR                  U SU 35        M     U(       a  [        R                  " U5      eg)zCChecks if there are any duplicate resource names per resource type.   z has duplicate name(s): N)ra   rb   rc   ri   lenrg   r   rs   )r|   dupsrS   r   r[   errorsnamess          rA   rh   rh      s     
	 	 	&$!;!A!A!CltI
9~
j "D &ZZ\kd
MMTF25':; "

+
+F
33 rD   r?   transform_contextc                 :    A UR                   S	 UR                   S	 g)z9Removes the apiVersion and kind fields from the manifest.rq   rS   N)rV   r?   r   s     rA   _RemoveApiVersionAndKindr      s#       .  (rD   rz   c                    UR                   nU R                  [        5      U[        '   U R                  [        5      U[        '   SU ;   a  U S   US'   U R                  [        5      n[
        UR                     " X1R                  UR                  5      nSUR                  5       ;   a>  [        R                  R                  UR                  USSUR                  5        S35      eUR                  5       U[        '   US	 g)z>Moves the fields in metadata to the top level of the manifest.description/zmetadata.namezinvalid resource ID ""rz   N)rV   rr   ANNOTATIONS_FIELDLABELS_FIELDr{   _ref_creatorsrS   rT   rU   Namer   rs   for_resource_fieldRelativeName)rz   r   rV   r   resource_refs        rA   _MetadataYamlToProtor      s     ''( (-> ?(#<<5(< h&}5H]	j	!$0556
%%'8'?'?, 	L

+
+
>
>
 1 1 34A6	  &224(:zrD   c                     AU R                  5        VVs0 s H  u  p#[        R                  " U5      U_M     snn$ s  snnf )z,Convert labels from camelCase to snake_case.)ri   r   ConvertToSnakeCase)r   r   kvs       rA   _ConvertLabelsToSnakeCaser      s8     AG	P

.
.q
11
4	PP	Ps   #<c                 l    / nU  H  nUR                  U[           5        M     SU0UR                  S'   g)z6Converts an old automation selector to the new format.targetsr   N)rg   TARGET_FIELDrV   )r   r   r   r&   s       rA   _UpdateOldAutomationSelectorr      s:     'fNN6,'( ,5w+?Z(rD   rulec                     A[         U ;   a  U [            U [        '   U [         	 [        U ;   a  U [           U [        '   U [        	 [        U ;   a  U [           U [
        '   U [        	 U $ )z9Renames the old automation rule fields to the new format.)PROMOTE_RELEASE_FIELDPROMOTE_RELEASE_RULE_FIELDADVANCE_ROLLOUT_FIELDADVANCE_ROLLOUT_RULE_FIELDREPAIR_ROLLOUT_FIELDREPAIR_ROLLOUT_RULE_FIELDr   r   s     rA   _RenameOldAutomationRulesr      sr     d"'+,A'BD	#$"#d"'+,A'BD	#$"#T!&*+?&@D	"#!"	+rD   c                     U b`  [         U ;   aV  [        U ;   a5  [        R                  R	                  UR
                  UR                  S5      eU [            U [        '   U [         	 U $ )z$Move the name field to the id field.z+automation rule has both name and id fields)r{   ID_FIELDr   rs   for_resourcerS   r   r   s     rA   #_ConvertAutomationRuleNameFieldToIdr   
  sd     
*,4--::

 
 

 
 
7 
 *%DNZ	+rD   repair_phasec                 B    A[         U ;   a  U [            c	  0 U [         '   U $ )zIAdd an empty retry field if it's defined in the manifest but set to None.)RETRY_FIELD)r   r   s     rA   %_AddEmptyRepairAutomationRetryMessager     s)     L \+%>%F "L	rD   c                 <    AU R                  S5      (       d  SU -   $ g)z8Converts the backoffMode values to the proto enum names.BACKOFF_MODE_N)
startswithr   s     rA   :_ConvertRepairAutomationBackoffModeEnumValuesToProtoFormatr   $  s(     			/	*	*U"" 
+rD   c                     A[         R                  " SU 5      (       d  [        R                  " 5       eU SS n[	        U5      S-  nSU-  $ )z9Converts the wait time from (for example) "5m" to "300s".z\d+mN<   z%ss)re	fullmatchr   AutomationWaitFormatErrorint)r   r   minssecondss       rA   _ConvertAutomationWaitMinToSecr   .  sI     	gt	$	$

.
.
00	cr$IN'	rD   c                     0 nU R                  S5      (       a  [        U S   SX!5        U R                  S5      (       a  [        U S   SX!5        U$ )z-Converts the one time window to proto format.startend)rr   _SetDateTimeFields)r?   r   proto_formats      rA   (_ConvertPolicyOneTimeWindowToProtoFormatr   ;  sO     ,
YYwuW~wP
YYuuU|ULL 
rD   date_str
field_namer   c                     [         R                  " U 5      nUR                  b6  [        R                  R                  UR                  UR                  US5      eUR                  UR                  UR                  S.nUR                  UR                  UR                  UR                   S-  S.nU S3nXRU'   U S	3nXbU'   g! [         a7    [        R                  R                  UR                  UR                  US5      e[         a7    [        R                  R                  UR                  UR                  US5      ef = f)
zMConvert the date string to proto format and set those fields in proto_format.zqinvalid date string: "{date_str}". Must be a valid date in ISO 8601 format (e.g. {field_name}: "2024-12-24 17:00)zinvalid date string: {date_str}. Make sure to put quotes around the date string (e.g. {field_name}: "2024-09-27 18:30:31.123") so that it is interpreted as a string and not a yaml timestamp.Nzinvalid date string: {date_str}. Do not include a timezone or timezone offset in the date string. Specify the timezone in the timeZone field.)yearmonthday  hoursminutesr   nanosDateTime)r   isoparse
ValueErrorr   rs   r   rS   r   	TypeErrortzinfor   r   r   hourminutesecondmicrosecond)	r   r   r   r   	date_timedate_objtime_obj
date_field
time_fields	            rA   r   r   I  sQ   )I$ !

+
+
>
>		  nn]]( ~~!!!!$$t+	( T"*%zT"*%zQ 
 

+
+
>
>	9	  
 

+
+
>
>	@	 s   C B Ec           	         SnU R                  S5      (       a  SnU R                  SSS5      n  [        R                  R	                  U 5      nUR                  nU(       a  S	nUUR                  UR                  UR                  S
-  S.$ ! [
         aE    [        R                  R                  UR                  UR                  UR                  SU  S35      ef = f)z0Convert the weekly window times to proto format.Fz24:T2400r~   zinvalid time string: "r      r   r   )r   replacedatetimetimefromisoformatr   r   rs   r   rS   r   rW   r   r   r   r   )r?   r   hour_24r   
hour_values        rA   _ConvertPolicyWeeklyWindowTimesr   }  s     '
eGMM$a(E}}**51H }}*J##d*	
  
 

+
+
>
>
 q)	 s   B ACc                     SU ;   a  U $ [         R                  " XR                  UR                  5      R	                  5       $ )a  Converts a custom target type ID or name to a resource name.

This is handled specially because we allow providing either the ID or name for
the custom target type referenced. When the ID is provided we need to
construct the name.

Args:
  value: the current value of the customTargetType field.
  transform_context: _TransformContext, data about the current parsing
    context.

Returns:
  The custom target type resource name.
r   )r   CustomTargetTypeReferencerT   rU   r   r   s     rA   _ReplaceCustomTargetTyper     s<    & 	E\L	 	:	:&&(9(@(@
LNrD   c                       \ rS rSr% Sr\\   \S'   \\	   \S'   Sr
\\\\/\4      \S'   Sr\\\\/S4      \S'   Sr\\\	\4      \S'   S	rg)
TransformConfigi  a  Represents a field that needs transformation during parsing.

Attributes:
  kinds: The ResourceKinds that this transformation applies to.
  fields: A dot separated list of fields that require special handling. These
    are relative to the top level of the manifest and can contain `[]` to
    represent an array field.
  replace: A function that is called when the field is encountered. The return
    value will be used in place of the original value.
  move: A function that is called when the field is encountered. This is used
    for fields that should be moved to a different location in the manifest.
    The function should modify the transform_context.manifest in place.
  schema: An optional JSON schema that is used to validate the field.
kindsfieldsNr   moveschemarE   )rF   rG   rH   rI   __doc__setr6   rX   rZ   rY   r   r   r   r   rQ   r   r   rO   rE   rD   rA   r   r     sw     
\	
s) @D'8Hc#45s:;<C=A$3 12D89:A%)&(4S>
")rD   r   rq   )r   r   r   objecttypestring)r   additionalProperties)r   r   r   r   F)r   requiredr   r   )r   r   r   r   )r   r   r   r   z
selector[]arrayT)r   r   r   r   )r   ri   zrules[])r   r   r   )zrules[].repairRolloutRulezrules[].advanceRolloutRulezrules[].promoteReleaseRulezrules[].timedPromoteReleaseRulez(rules[].repairRolloutRule.repairPhases[]z:rules[].repairRolloutRule.repairPhases[].retry.backoffMode)3rules[].repairRolloutRule.repairPhases[].retry.waitrules[].advanceRolloutRule.waitrules[].promoteReleaseRule.waitz7rules[].rolloutRestriction.timeWindows.oneTimeWindows[]z@rules[].rolloutRestriction.timeWindows.weeklyWindows[].startTimez>rules[].rolloutRestriction.timeWindows.weeklyWindows[].endTimezcustomTarget.customTargetTypec                     U R                   $ r>   )r:   r   s    rA   <lambda>r   M  s
    h.A.ArD   c                     U R                   $ r>   )r;   r   s    rA   r   r   N  s
    h6O6OrD   c                     U R                   $ r>   )r9   r   s    rA   r   r   O  s
    X5N5NrD   c                     U R                   $ r>   )r<   r   s    rA   r   r   P  s
    1F1FrD   c                     U R                   $ r>   )r8   r   s    rA   r   r   Q  s    (//rD   rS   rT   c                     [        U[        XX45         [        R                  " U[        U    " U5      5      nU$ ! [        R
                   a/  n[        R                  R                  X[        U5      5      UeSnAff = f)a  Parses a v1beta1/v1 config manifest into a message using proto transforms.

The parser calls a series of transforms on the manifest dictionary to convert
it into a form expected by the proto message definitions. This transformed
dictionary is then passed to `messages_util.DictToMessageWithErrorCheck` to
convert it into the actual proto message.

Args:
  kind: str, The kind of the resource (e.g., 'Target').
  name: str, The name of the resource.
  manifest: dict[str, Any], The cloud deploy resource YAML definition as a
    dict.
  project: str, The GCP project ID.
  region: str, The ID of the location.
  messages: The module containing the definitions of messages for Cloud
    Deploy.

Returns:
  The parsed resource as a message object (e.g., messages.Target), or an
  empty dictionary if the kind is not TARGET_KIND_V1BETA1.

Raises:
  exceptions.CloudDeployConfigError: If there are errors in the manifest
    because of invalid data.
N)
ApplyTransforms_PARSE_TRANSFORMSmessages_utilDictToMessageWithErrorCheck_message_typesDecodeErrorr   rs   r   rY   )rS   r   rV   rT   rU   r	   resourcees           rA   rj   rj   U  s|    B (-t7K88.&x0H 
/	 
	"	" 

+
+
8
8CFs   $: A=*A88A=c                 r    A [         UR                  S'   UR                  R                  UR                  S'   g)z.Adds the API version and kind to the manifest.rq   rS   N)rv   rV   rS   r?   r   s     rA   AddApiVersionAndKindr    s5     -;\*'8'='='C'CV$rD   c                 4    A UR                   UR                  	 g)z$Removes the field from the manifest.N)rV   rW   r   s     rA   _RemoveFieldr    s      !2!8!89rD   c                     A 0 UR                   S'   [         H?  nX!R                   ;   d  M  UR                   R                  U5      UR                   S   U'   MA     g)z$Converts the metadata proto to YAML.rz   N)rV   METADATA_FIELDSrr   )r?   r   r   s      rA   _MetadataProtoToYamlr    sW     +-Z(a&&&

$
$
(
(
+   ,Q/ rD   c                 F    AU (       d  U $ U S S n[        U5      S-  nSU-  $ )Nr   r   z%smr   )r   r   r   r   s       rA   _ConvertAutomationWaitSecToMinr    s2     	K"I'	W	$	rD   one_time_windowc                 f    0 n[        U S   U S   U5      n[        U S   U S   U5      nX2S'   XBS'   U$ )z?Exports the oneTimeWindows field of the Deploy Policy resource.	startDate	startTimeendDateendTimer   r   )_DateTimeIsoString)r  r   one_timestart_date_timeend_date_times        rA   &ConvertPolicyOneTimeWindowToYamlFormatr    sZ     (&k"k"/
 %i /)"<>O- &7!5/	/rD   r   r   c                 <    [        U 5      n[        X5      nU SU 3$ )z%Converts a date and time to a string. )_FormatDateConvertTimeProtoToString)r   r   r   r   time_strs        rA   r  r    s)     "(%hB(:Qxj	!!rD   datec                 .    U S   S SU S   S SU S   S 3$ )z#Converts a date object to a string.r   04-r   02r   rE   )r$  s    rA   r!  r!    s.    LAd7mB/qeR0@	AArD   c                    AU R                  S5      =(       d    SnU R                  S5      =(       d    SnUS SUS 3nU R                  S5      (       d  U R                  S5      (       a#  U R                  S5      =(       d    SnUSUS 3-  nU R                  S5      (       a  U R                  S5      S-  nUS	US
 3-  nU$ )z#Converts a time object to a string.r   r   r   r(  :r   r   i@B .z03.0f)rr   )r   r   r   r   r#  r   milliss          rA   r"  r"    s     
,,w

$1%LL#(q'bz72,'(\\)W 5 5ll9%*G!GB<  H\\'\\'"W,F!F5>""H	/rD   c                 2    [         R                  " SSU 5      $ )Nz.*/ r   subr   s     rA   r   r     s    E1JrD   c                 2    [         R                  " SSU 5      $ )Nz).*/deliveryPipelines/([^/]+)/automations/z\1/r/  r   s     rA   r   r     s    
 92
rD   )r   r   r   c                 $    U R                  S5      $ )Nr   )removeprefixr   s     rA   r   r     s    1C1C2
rD   z7rules[].repairRolloutRule.repairPhases[].retry.attemptsc                     [        U 5      $ r>   r  r   s     rA   r   r     s    UrD   r  r   c                     [         R                  " U 5      n[        U[        UUR	                  5       UR
                  UR                  5        U$ )af  Converts a resource message to a cloud deploy resource manifest.

The manifest can be applied by 'deploy apply' command.

Args:
  resource: message in googlecloudsdk.generated_clients.apis.clouddeploy.
  resource_ref: cloud deploy resource object.
  kind: kind of the cloud deploy resource

Returns:
  A dictionary that represents the cloud deploy resource.
)r   MessageToDictr  _EXPORT_TRANSFORMSr   
projectsIdlocationsId)r  r   rS   rV   s       rA   ProtoToManifestr:  .  sJ     ##H-(
 
/rD   
transformsc                 T   U H  nX&R                   ;  a  M  UR                   H  n[        Xp5      nU(       d  M  [        UUUUU [	        U5      5      n	UR
                  (       a*  [        UXi4S jU	UR                  5      n
[        XU
5        Mk  UR                  (       a    [        R                  " UR                  US9  UR!                  X5        M     M     g! [        R                  R                   a0  n[        R                  R                  X#X{R                  5      UeSnAff = f)z1Applies a set of transformations to the manifest.c                 $    UR                  X5      $ r>   )r   )datacurrent_fieldcurrent_transform_contexts      rA   r   !ApplyTransforms.<locals>.<lambda>c  s    anavavbrD   r   instanceN)r   r   	_GetValuerQ   _GetFinalFieldNamer   _TransformNestedListDatar   	_SetValue
jsonschemavalidater   ValidationErrorrs   r   messager   )rV   r;  rS   r   rT   rU   	transformr   r?   r   	new_valuer	  s               rA   r  r  I  s    i??"&&

-e	-z*
 .)2   ) H)
4!!)9)9EJ
 ..
2; ' 8 ((88 55HHj))s    CD'7+D""D'pathc                    SU ;   ax  U R                  SS5      u  p#UR                  S5      n[        X!5      n[        U[        5      (       d  g/ nU(       d  U$ U H  n[        X65      nUR                  U5        M!     U$ U R                  S5      nUn	U HV  n
[        U	[        5      (       a  X;   a  X   n	M#  [        U	[        5      (       a  U	 Vs/ s H  n[        X5      PM     sns  $   g   U	$ s  snf )a  Gets the value at a dot-separated path in a dictionary.

If the path contains [], it returns a list of values at the path. If the path
contains multiple [], it will return nested lists. None values will appear
where there are missing values.

Args:
  path: str, The dot-separated path to the value.
  manifest: dict, The dictionary to search.

Returns:
  The value at the path, or None if it doesn't exist.
[]r~   r+  N)splitlstriprD  
isinstancerc   rg   rZ   )rN  rV   prepostcurrent_listresultsitemresultkeyscurrentkeys              rA   rD  rD  u  s     
T\

4#IC;;sDS+LlD))G$fnnV  N	C$'c'4  S^g	GT	"	"/67wti"w77  
. 8s   C0r>  funcr   c           	         U c  g[        U [        5      (       a(  / nU  H  nUR                  [        XQX#5      5        M      U$ U(       a   [        R
                  " X0S9  U" U 5      $ ! [        R                  R                   aP  n[        R                  R                  UR                  UR                  UR                  UR                  5      UeSnAff = f)a]  Recursively applies a function to elements in a nested structure (lists or single items).

Args:
  data: The nested structure to process.
  func: The callable to apply to non-list, non-None elements.
  transform_context: The parse context for the data.
  schema: the schema for the data

Returns:
  A new nested structure with the function applied.
NrB  )rS  rc   rg   rF  rH  rI  r   rJ  rs   r   rS   r   rW   rK  )r>  r]  r   r   new_listrX  r	  s          rA   rF  rF    s    " 
\dHoo
"4/@
I  O69 : ""22 //BB""""##II	

 	s   
A& &CACCc           	         SU;   Gaf  UR                  SS5      u  p4UR                  S5      n[        X05      n[        U[        5      (       d  [
        R                  " SU SU S35      eU(       dZ  [        U[        5      (       d  [
        R                  " SU S35      eUR                  S5      nU nUSS	  H  nXx   nM	     X'US	   '   g[        U[        5      (       d  [
        R                  " S
U S35      e[        U5      [        U5      :w  a2  [
        R                  " S[        U5       S[        U5       SU S35      e[        U5       H  u  pX)   nUc  M  [        XU5        M     gUR                  S5      nU nUSS	  HB  nX;  a    g[        X   [        5      (       d  [
        R                  " SU SU S35      eX   nMD     US	   nUc	  X;   a  X	 ggX,U'   g)a  Sets the value at a dot-separated path in a dictionary.

If value is None, deletes the value at path.
If path contains [], it updates elements within the list. Since this is a
companion to _GetValue, it processes nested lists the same way.

Args:
  manifest: dict, The dictionary to update.
  path: str, The dot-separated path to the value.
  value: Any, The value to set, or None to delete.

Raises:
  exceptions.ManifestTransformException: a mismatch between the provided path
    and the structure of the manifest or the value being set.
rP  r~   r+  zPath "z0" did not lead to a list in _SetValue for path "r   z-New value must be a list to replace list at "Nr   z$New value must be a list when path "z" contains []z(List length mismatch: len(current_list)=z, len(value)=z for path "zValue at key "z " is not a dictionary for path ")rQ  rR  rD  rS  rc   r   ManifestTransformExceptionr   rd   rG  rZ   )rV   rN  r?   rT  rU  rV  rZ  parentr\  rl   rX  current_valuer[  last_keys                 rA   rG  rG    s     
T\

4#IC;;sDS+LlD))113%GvQ
O  t$$33;C5B
 	
 YYs^dfcr# T"XeT""110m
D  <CJ&114S5F4G HUKvQ8 
 \*hm		M*	 +
 	C$'#2Yc
glD))113%?vQ
G  lG  "X(
]

  HrD   c                     U R                  S5      nUS   nUR                  S5      (       a  UR                  S5      nU$ )z7Returns the final field name from a dot-separated path.r+  r   rP  )rQ  endswithremovesuffix)rN  rZ  final_field_names      rA   rE  rE    sA    	C$"Xt$$'44T:	rD   )NN)zr   ra   dataclassesr   enumr   typingr   r   r   apitools.base.pyr   dateutilr   googlecloudsdk.api_lib.utilr	   r  !googlecloudsdk.command_lib.deployr
   r   r   r   r   r   googlecloudsdk.corer   r   googlecloudsdk.core.resourcer   rH  PIPELINE_UPDATE_MASKru   rv   r{   r   r   r   
WAIT_FIELDr   r   SELECTOR_FIELDRULES_FIELDr   r   r   r    TIMED_PROMOTE_RELEASE_RULE_FIELDDESTINATION_TARGET_ID_FIELDSOURCE_PHASES_FIELDPHASES_FIELDDESTINATION_PHASE_FIELD#DISABLE_ROLLBACK_IF_ROLLOUT_PENDINGr   r  EXCLUDE_FIELDS
JOBS_FIELDr   ATTEMPTS_FIELDROLLBACK_FIELDREPAIR_PHASES_FIELDBACKOFF_MODE_FIELDSCHEDULE_FIELDTIME_ZONE_FIELDuniqueEnumr6   	dataclassrQ   rc   rZ   rY   rn   r   re   rf   tuplerh   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rL   rN   rJ   r  AutomationReferencerM   r   rK   DeliveryPipelineReferenceDeployPolicyReferenceTargetReferencer   r  rj   r  r  r  r  r  r  r!  r"  r7  Resourcer:  r  rD  rF  rG  rE  rE   rD   rA   <module>r     s
   J     	 * * %  A = E D @ 8 9 * ) : ! 7 -
( ( & 
! 1 1 / #<  3 $ , &G #$lJ?  
$ "  499     !3i!$(c3h$8!BE!	,S	
!"!HtCH~ # , 0tCH~ # # 4 $U<+<%=tCy%H I4	4)S>).?)	)38n1B	>QcNQ/@Q	#s(^Q@38n@1B@	#s(^@
sCx.->	#s(^"
sCx.->	#s(^ sCx.5F	#s(^###


"3

S>.?	#s(^1&1&1& sCx.1& )	1&
 
1&h#4	#s(^<#46 * * *> ,~%
 ,|!* &1$-3X,> 
 %-3X,> %*
	, ,z) 68:LM	 &&'~) '&();<%J(,	
	 &&'{)
 &&'
 4	 &&':;5
 &&'LMJ!	 &&'

 /!	 ))*IJ8
 ))*NL
 0! ""#/0(!	Eh X _@@##99""88 2 H H44
 A##%O""$N F9*
*
* 38n* 	*
 * 3i* 	*ZDD#4D	D: :0A :d :

#4
	
	
	"3		#s(^8I	#s(^$"38n"38n" )" 		"Bd38n B B
38n1B$ , x! ,#|'>'>&?"@@xJ	 &&'x
 ,x!
 ,
 &&'

 / &&'H

 &&'E
 <	 ))*IJ6
 ))*NL
 )MN b!*!3!3;G	#s(^6)338n)3_%)3 )3 	)3
 )3 )3 
)3X(C (4S> (c (\ ,0 	%
%
C5#:
% )% SM	%
 	%PJS#X Jc J# J$ JZS S rD   