
    !P                     h   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 rS	 rS'S
 jrS(S jrS rS rS'S jrS'S jrS'S jrS rS)S jrS)S j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*S" jr&          S+S# jr'S'S$ jr(S'S% jr)S& r*g),z?Flags and helpers for the compute future reservations commands.    )absolute_import)division)unicode_literals)arg_parsers)base)flagsc                  0    Sn [         R                  " SU S9$ )zGets the --name-prefix flag.z  A name prefix for the auto-created reservations when capacity is
  delivered at the start time. Each auto-created reservation name
  starts with the name prefix.
  z--name-prefixhelpr   Argument	help_texts    Clib/googlecloudsdk/command_lib/compute/future_reservations/flags.pyGetNamePrefixFlagr      s    )
 
Y	77    c                  2    Sn [         R                  " SSU S9$ )z"Gets the --clear-name-prefix flag.zB  Clears the name prefix for the system generated reservations.
  z--clear-name-prefix
store_trueactionr   r   r   s    r   GetClearNamePrefixFlagr   %   #    ) 
Ly
 r   c                 <    Sn[         R                  " SU [        US9$ )zGets the --total-count flag.zg  The total number of instances for which capacity assurance is requested at a
  future time period.
  z--total-countrequiredtyper   )r   r   intr   r   s     r   GetTotalCountFlagr   /   s%    ) 
s
 r   c                 H    [         R                  " SU [        [        5       S9$ )zGets the --start-time flag.--start-timer   )r   r   strGetStartTimeHelpTextr   s    r   GetStartTimeFlagr%   :   s     	xc8L8N
 r   c                  
    Sn U $ )z Gets the --start-time help text.a    Start time of the Future Reservation. The start time must be an RFC3339 valid
  string formatted by date, time, and timezone or "YYYY-MM-DDTHH:MM:SSZ"; where
  YYYY = year, MM = month, DD = day, HH = hours, MM = minutes, SS = seconds, and
  Z = timezone (i.e. 2021-11-20T07:00:00Z).
   r   s    r   r#   r#   A       ) 
r   c                  
    Sn U $ )zGets the --end-time help text.a    End time of the Future Reservation. The end time must be an RFC3339 valid
  string formatted by date, time, and timezone or "YYYY-MM-DDTHH:MM:SSZ"; where
  YYYY = year, MM = month, DD = day, HH = hours, MM = minutes, SS = seconds, and
  Z = timezone (i.e. 2021-11-20T07:00:00Z).
  r'   r   s    r   GetEndTimeHelpTextr*   L   r(   r   c                 P    Sn[         R                  " S[        R                  UU S9$ )z6Gets the --auto-delete-auto-created-reservations flag.z  If specified, the auto-created reservations for a future reservation
  are deleted at the end time (default) or at a specified delete time.
  z'--auto-delete-auto-created-reservations)r   r   r   r   r   r   StoreTrueFalseActionr   s     r   (GetAutoDeleteAutoCreatedReservationsFlagr.   W   s.    ) 
/--	
 r   c                 d    Sn[         R                  " SU [        R                  R                  US9$ )z6Gets the --auto-created-reservations-delete-time flag.ai    Automatically deletes an auto-created reservations at a specific time.
  The specified time must be an RFC3339 timestamp, which must be
  formatted as "YYYY-MM-DDTHH:MM:SSZ" where YYYY = year, MM = month, DD = day,
  HH = hours, MM = minutes, SS = seconds, and Z = time zone in
  Coordinated Universal Time (UTC). For example, specify 2021-11-20T07:00:00Z.
  z'--auto-created-reservations-delete-timer   )r   r   r   DatetimeParser   s     r   (GetAutoCreatedReservationsDeleteTimeFlagr2   e   s4    ) 
/%%	
 r   c                 Z    Sn[         R                  " SU [        R                  " 5       US9$ )z3Gets the --auto-created-reservations-duration flag.a    Automatically deletes an auto-created reservations after a specified
  number of days, hours, minutes, or seconds. For example, specify 30m
  for 30 minutes, or 1d2h3m4s for 1 day, 2 hours, 3 minutes, and 4
  seconds. For more information, see $ gcloud topic datetimes.
  z$--auto-created-reservations-durationr   )r   r   r   Durationr   s     r   &GetAutoCreatedReservationsDurationFlagr5   v   s1    ) 
,!	
 r   c                  
    Sn U $ )zGets the --duration help text.z  Alternate way of specifying time in the number of seconds to terminate
  capacity request relative to the start time of a request.
  r'   r   s    r   GetDurationHelpTextr7      s    ) 
r   Nc                 H    Sn[         R                  " U (       a  U OSSS/US9$ )zGets the --share-setting flag.z  Specify if this future reservation is shared, and if so, the type of sharing.
  If you omit this flag, this value is local by default.
  z--share-settinglocalprojectschoicesr   r   custom_namer   s     r   GetSharedSettingFlagr?      s/    ) 
 k&7
#
 r   c                 j    Sn[         R                  " U (       a  U OS[        R                  " SS9SUS9$ )zGets the --share-with flag.z  If this future reservation is shared, provide a comma-separated list
  of projects that this future reservation is shared with.
  The list must contain project IDs or project numbers.
  z--share-with   )
min_lengthPROJECT)r   metavarr   )r   r   r   ArgListr=   s     r   GetShareWithFlagrF      s7    )
 
 kn!,	
 r   c                  2    Sn [         R                  " SSU S9$ )z*Gets the --clear-share-settings help text.ze  Clear share settings on future reservation. This will result in non-shared
  future reservation.
  z--clear-share-settingsr   r   r   r   s    r   GetClearShareSettingsFlagrH      s#    ) 
|)
 r   c                  2    Sn [         R                  " SSU S9$ )z Gets the --clear-local-ssd flag.z@  Remove all local ssd information on the future reservation.
  z--clear-local-ssdr   r   r   r   s    r   GetClearLocalSsdFlagrJ      s    ) 
*<i	PPr   c                  2    Sn [         R                  " SSU S9$ )z"Gets the --clear-accelerator flag.z9  Remove all accelerators from the future reservation.
  z--clear-acceleratorr   r   r   r   s    r   GetClearAcceleratorFlagrL      r   r   c                  <    Sn [         R                  " SS SSS.U S9$ )z Gets the --planning-status flag.a    The planning status of the future reservation. The default value is DRAFT.
  While in DRAFT, any changes to the future reservation's properties will be
  allowed. If set to SUBMITTED, the future reservation will submit and its
  procurementStatus will change to PENDING_APPROVAL. Once the future reservation
  is pending approval, changes to the future reservation's properties will not
  be allowed.
  z--planning-statusc                 "    U R                  5       $ N)upper)xs    r   <lambda>'GetPlanningStatusFlag.<locals>.<lambda>   s
    QWWYr   zDefault planning status value.zCPlanning status value to immediately submit the future reservation.)DRAFT	SUBMITTED)r   r<   r   r   r   s    r   GetPlanningStatusFlagrV      s4    ) 
3 
 r   c                  N    Sn [         R                  " S[        R                  U S9$ )z$--require-specific-reservation flag.at    Indicate whether the auto-created reservations can be consumed by VMs with
  "any reservation" defined. If enabled, then only VMs that target the
  auto-created reservation by name using `--reservation-affinity=specific` can
  consume from this reservation. Auto-created reservations delivered with this
  flag enabled will inherit the name of the future reservation.
  z--require-specific-reservationr   r,   r   s    r   !GetRequireSpecificReservationFlagrX      s+    ) 
&--
 r   c                  :    Sn [         R                  " S[        U S9$ )z--reservation-name flag.aL    Name of reservations where the capacity is provisioned at the time of
  delivery of  future reservations. If the reservation with the given name
  does not exist already, it is created automatically at the time of Approval
  with INACTIVE state till specified start-time. Either provide the
  reservation_name or a name_prefix.
  z--reservation-namer   r   )r   r   r"   r   s    r   GetReservationNameFlagr[      s%    ) 

 r   c                  8    Sn [         R                  " SSSS.U S9$ )z--deployment-type flag.z3  The deployment type for the reserved capacity.
  z--deployment-typez6DENSE mode is for densely deployed reservation blocks.zAFLEXIBLE mode is for highly flexible, logical reservation blocks.)DENSEFLEXIBLEr;   r   r   s    r   GetDeploymentTypeFlagr_      s1    ) 
K 

 
r   c                  
    Sn U $ )Nz  Name of commitment covering the delivered reservation at the time of delivery
  of future reservations. If not specified, it takes the name of the future
  reservation.
  r'   r   s    r   GetCommitmentNameHelpTextra         )
 
r   c                  
    Sn U $ )Nz  The plan for this commitment to be created, which determines duration and
  discount rate. The currently supported plans are TWELVE_MONTH (1 year), and
  THIRTY_SIX_MONTH (3 years).
  r'   r   s    r   GetCommitmentPlanHelpTextrd     rb   r   c                  
    Sn U $ )NaO    Applicable only if future reservation will deliver to an existing reservation
  with a ramp plan. When set to EXTEND, all associated parent Committed Used
  Discount's end-date/term will be extended to the end-time of this future
  reservation. Default is to extend previous commitment's time to the end_time
  of the reservation.
  r'   r   s    r   "GetPreviousCommitmentTermsHelpTextrf   $  s    ) 
r   c                  8    Sn [         R                  " SSSS.U S9$ )z--scheduling-type flag.z+  Maintenance for the reserved capacity.
  z--scheduling-typezGIn GROUPED mode, maintenance on all reserved instances is synchronized.z|In INDEPENDENT mode, maintenance is not synchronized for this reservation, and each instance has its own maintenance window.)GROUPEDINDEPENDENTr;   r   r   s    r   GetSchedulingTypeFlagrj   /  s4    ) 
P	 
 r   c                  8    Sn [         R                  " SSSS.U S9$ )z--reservation-mode flag.z!  The mode of the reservation.
  z--reservation-modezThis indicates to create a future reservation in calendar mode, which is ideal for reserving GPU VMs. The auto-created reservations for the future reservation are automatically deleted at the end of the reservation period.zThis indicates to create a standard future reservation. If you want to automatically delete the auto-created reservations, then you must use the --auto-delete-auto-created-reservations flag.)CALENDARDEFAULTr;   r   r   s    r   GetReservationModeFlagrn   D  s3    ) 
? !
 r   c                  N    Sn [         R                  " S[        R                  U S9$ )z--emergent-maintenance flag.z  Emergent maintenance flag for the reservation, which enrolls all the
  underlying vms, hosts and SB infrastructure to receive emergent maintenance
  notifications in advance.
  z--enable-emergent-maintenancer   r,   r   s    r    GetEnableEmergentMaintenanceFlagrp   ]  s+    )
 
%--
 r   c                    [        5       R                  U 5        [        5       R                  U 5        U(       a  [        5       R                  U 5        [        R
                  " SS9R                  U 5        U(       a  [        5       R                  U 5        [        R                  " SSSS9nU(       a$  UR                  [        R                  " 5       5        [        U SS9  [        R                  " S5      nUR                  [        R                  " 5       5        UR                  [        R                  " 5       5        U(       a%  UR                  [        R                  " 5       5        O$UR                  [        R                  " 5       5        UR                  [        R                   " 5       5        U(       a$  UR                  [        R"                  " 5       5        U(       aH  UR                  [$        R&                  " 5       5        UR                  [$        R(                  " 5       5        U(       a  [        R                  " S5      nUR                  [        R*                  " 5       5        UR                  [        R,                  " 5       5        UR                  [        R.                  " 5       5        UR                  U5        UR                  U5        UR                  U 5        U(       aX  [        R                  " SS	S
9nUR                  [1        5       5        UR                  [3        5       5        UR                  U 5        U(       a  [5        U 5        U	(       aK  [7        5       R                  U 5        [9        5       R                  U 5        [;        5       R                  U 5        U
(       a  [=        U 5        U(       a  [?        5       R                  U 5        gg)z-Adds all flags needed for the create command.Tis_fra  To create a future reservation request, specify the properties of the resources that you want to reserve and when you want to start using them. After the request is approved, Compute Engine automatically creates reservations for your requested resources at your specified start time.r   mutextime_window_requirdzGDefine individual instance properties for the specific SKU reservation.z:You must define the version and number of TPUs to reserve.z.Manage the properties of a shared reservation.Fr$   N) r   AddToParserr   rX   reservation_flagsGetDescriptionFlagrV   r   ArgumentGroupAddArgumentGetSourceInstanceTemplateFlagAddTimeWindowFlagsGetMachineTypeGetMinCpuPlatformGetLocalSsdFlagWithCountGetLocalSsdFlagGetAcceleratorFlagGetLocationHintinstance_flagsAddMaintenanceFreezeDurationAddMaintenanceIntervalGetTpuVersionGetChipCountGetWorkloadTyper?   rF   AddAutoDeleteFlagsr[   r_   rj   AddCommitmentInfoFlagsrn   )parsersupport_location_hintsupport_share_settingsupport_fleetsupport_instance_templatesupport_planning_statussupport_local_ssd_countsupport_auto_delete$support_require_specific_reservationsupport_gscsupport_cudssupport_dws_gpusupport_dws_tpureservation_properties_groupinstance_properties_groupaggregate_reservation_groupshare_groups                    r   AddCreateFlagsr   k  s     !!&)!!&))%'33F;&&T2>>vF''/!%!3!3
 "  ,,779 V6"00O ''(9(H(H(JK''(9(K(K(MN))224 ))*;*K*K*MN''(9(L(L(NO))*;*K*K*MN))335 ))--/ "&"4"4D#  ++'')  ++&&(  ++))+ !,,-HI**+DE**62$$85K 023,./F#v((0''/''/6"((0 r   c                    [         R                  " SSSS9nUR                  [        5       5        UR                  [	        5       5        UR                  U 5        [        SS9R                  U 5        [        R                  " SS9R                  U 5        U(       a  [        5       R                  U 5        [         R                  " SSS9nUR                  [        R                  " SS95        UR                  [        R                  " 5       5        [         R                  " SSSS9nUR                  [        R                  " 5       5        UR                  [        5       5        UR                  U5        [         R                  " S	SSS9nU(       a%  UR                  [        R                  " 5       5        O$UR                  [        R                  " 5       5        UR                  [!        5       5        UR                  U5        U(       a$  UR                  [        R"                  " 5       5        U(       a$  UR                  [$        R&                  " 5       5        UR                  U 5        [)        U SS
9  U(       a  [         R                  " SSSS9nUR                  [+        5       5        [         R                  " SSS9nUR                  [-        5       5        UR                  [/        5       5        UR                  U5        UR                  U 5        U(       a
  [1        U SS9  U(       a  [3        5       R                  U 5        U(       aK  [5        5       R                  U 5        [7        5       R                  U 5        [9        5       R                  U 5        U	(       a  [;        U 5        U
(       a  [=        5       R                  U 5        gg)z-Adds all flags needed for the update command.z/Manage the name-prefix of a future reservation.FTrt   r$   rr   z/Manage the specific SKU reservation properties.z0Manage the accelerators of a future reservation.z-Manage the local ssd of a future reservation.rv   z5Manage the properties of a shared future reservation.z2Manage the share settings of a future reservation.)	is_updateN)r   r{   r|   r   r   rx   r   ry   rz   rV   r   r   r   rL   r   r   rJ   r   r   r   r~   rH   r?   rF   r   rX   r[   r_   rj   r   rp   )r   r   r   r   r   r   r   r   r   r   support_emergent_maintenancename_prefix_groupgroupaccelerator_grouplocal_ssd_groupr   share_setting_groups                    r   AddUpdateFlagsr     s    ((7
  1 34 6 89'U#//7&&T2>>vF''/


7%% %44eDE%779:((8
  1 D D FG 7 9:%&&&5/
  1 J J LM 1 A A CD245O$	'779:	n;;=>FV7$$?K
 578,,<u ##$8$:;##$4$67/0F#v.)%'33F;((0''/''/6"!$&226: "r   c                     [        U(       a  SOSS9R                  U 5        [        R                  " SSSS9nUR	                  [        5       5        UR	                  [        5       5        UR                  U 5        g)zCAdds all flags needed for the modifying the auto-delete properties.FTr$   z'Manage the auto-delete time properties.rt   N)r.   rx   r   r{   r|   r2   r5   )r   r   auto_delete_time_settings_groups      r   r   r   5  ss     +!utK$($6$6/%! "--.0 "--,. "--f5r   c                     U R                  SUS9nUR                  SU[        5       S9  UR                  US9nUR                  S[	        5       S9  UR                  S[
        [        5       S	9  g
)zCAdds all flags needed for the modifying the time window properties.zBManage the time specific properties for requesting future capacityr   r   r!   )r   r   r$   z
--end-timer
   z
--durationrZ   N)	add_groupadd_argumentr#   add_mutually_exclusive_groupr*   r   r7   )r   rw   time_window_groupend_time_window_groups       r   r~   r~   L  s     &&O" '    29M9O !  ,HH" I  $$\8J8L$M$$#6#8 % r   c                     U R                  SSS9nUR                  S[        [        5       S9  UR                  SSS/[	        5       S	9  UR                  S
S/[        5       S	9  g)zGAdds all flags needed for the modifying the commitment info properties.z%Manage the commitment info propertiesFr   z--commitment-namerZ   z--commitment-planTWELVE_MONTHTHIRTY_SIX_MONTHr;   z--previous-commitment-termsEXTENDN)r   r   r"   ra   rd   rf   )r   commitment_info_groups     r   r   r   _  s     !**2 +  $$*C*E %  $$12$& % 
 $$#j-/ % r   )F)TrO   )FFFFFFFFFFFF)
FFFFFFFFFF)+__doc__
__future__r   r   r   googlecloudsdk.callioper   r   ,googlecloudsdk.command_lib.compute.instancesr   r   /googlecloudsdk.command_lib.compute.reservationsry   r   r   r   r%   r#   r*   r.   r2   r5   r7   r?   rF   rH   rJ   rL   rV   rX   r[   r_   ra   rd   rf   rj   rn   rp   r   r   r   r~   r   r'   r   r   <module>r      s   F &  ' / ( P V8" 
Q0  $*2   #!!).e1T  !!).!&_;D6.&r   