
    >                         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 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S jrg	)zJCommon utility functions to consturct compute future reservations message.    )absolute_import)division)unicode_literals)
exceptions)util)timesc                    [         R                  " U [        USS5      5      n[         R                  " U [        USS5      5      n[	        U UR
                  UR                  UU[        USS5      [        USS5      [        USS5      5      n[        USS5      (       a  [         R                  " X!5      OSn[        U UUR                  U5      n[        U [        USS5      [        US	S5      [        US
S5      5      n	[        XR                  [        USS5      [        USS5      5      n
[        X[        USS5      5      n[        U [        USS5      5      nSnUR                  S5      (       a  [        US5      nSnUR                  S5      (       a  [        US5      nSnUR                  S5      (       a  [        US5      n[        USS5      n[        USS5      nSnUR!                  S5      (       a  [#        U [        USS5      5      n[%        X5      nSnUR!                  S5      (       a  ['        U [        USS5      5      nSnUR!                  S5      (       a  [)        U [        USS5      5      nSnUR!                  S5      (       a  [        USS5      n[+        U UR-                  5       U
UUU	UUUUUUUUUUU5      $ )z9Construct future reservation message from args passed in.	local_ssdNacceleratorlocation_hintmaintenance_freeze_durationmaintenance_intervalsource_instance_templatetpu_version
chip_countworkload_typeend_timedurationshare_settingplanning_status%auto_delete_auto_created_reservations%auto_created_reservations_delete_time"auto_created_reservations_durationrequire_specific_reservationreservation_namedeployment_typescheduling_typereservation_modeenable_emergent_maintenance)reservation_utilMakeLocalSsdsgetattrMakeGuestAcceleratorsMakeAllocatedInstancePropertiesmachine_typemin_cpu_platformResolveSourceInstanceTemplate MakeSpecificSKUPropertiesMessagetotal_count)MakeAggregateReservationPropertiesMessageMakeTimeWindowMessage
start_timeMakeShareSettingsMakePlanningStatusIsSpecifiedIsKnownAndSpecifiedMakeDeploymentTypeMakeCommitmentInfoMakeSchedulingTypeMakeReservationModeMakeFutureReservationMessageName)messages	resourcesargsfuture_reservation_ref
local_ssdsacceleratorsallocated_instance_propertiessource_instance_template_refsku_properties aggregate_reservation_propertiestime_windowshare_settingsr   enable_auto_delete_reservationsr   r   r   r   r   commitment_infor   r   r   s                          Blib/googlecloudsdk/command_lib/compute/future_reservations/util.py$MakeFutureReservationMessageFromArgsrF      s.     --h.5dK.NP*!77mT24, #B

dOT*d148d*D1	# 
14	8	8 44TE  4#
"	. &OdM4(dL$'dOT*	&" &h&-dJ&E&-dJ&EG+ %X%,T?D%IK.&x'.t5F'MO/ %)!	=>>&-5'# +/'	=>>,35-) (,$	:;;)02*& ")
*D" T#5t</	/00()07H$)OQO 'x6//	/00('$ 148O 	011*'$ 2D9 !%	;<<")+T# 
&!!#&%+("!#
     Nc                     Uc  gU R                   nU" UUUUS9n	U(       a  XYl        U(       a
  US-  U	l        U(       a   U R                   R                  U5      U	l        U	$ )zBConstructs an instance propteries for reservations message object.N)machineTypeguestAcceleratorsminCpuPlatform	localSsdsi  )9AllocationSpecificSKUAllocationReservedInstancePropertieslocationHintmaintenanceFreezeDurationHours"MaintenanceIntervalValueValuesEnummaintenanceInterval)
r7   r%   r&   r;   r<   r   freeze_durationfreeze_interval	prop_msgsinstance_propertiess
             rE   r$   r$      sw      HH !$%	
 '4$9HD9P6JJ	+	+O	< + 
rG   c                 n    Uc  Uc  gSnSnU(       a  UR                  5       nOUnU R                  UUUS9$ )zHConstructs a specific sku properties message object if any is specified.N)
totalCountsourceInstanceTemplateinstanceProperties)SelfLink&FutureReservationSpecificSKUProperties)r7   rU   r)   r>   
propertiessource_instance_template_urls         rE   r(   r(      sV      %A%I*!%!#?#H#H#J $J		8	89# 
9 
% %rG   c                    U(       d  gU R                   R                  R                  U R                   R                  R                  U R                   R                  R                  U R                   R                  R
                  S.n/ nU R                  US9nUR                  U R                  US95        U R                  U R                   R                  XA   5      US9nU(       a   U R                   R                  U5      Ul
        U$ )z>Constructs an aggregate reservation properties message object.N)V5EV5PV6ETPU7X)acceleratorCount)r   )vmFamilyreservedResources)AllocationAggregateReservationVmFamilyValueValuesEnum(VM_FAMILY_CLOUD_TPU_LITE_POD_SLICE_CT5LP"VM_FAMILY_CLOUD_TPU_POD_SLICE_CT5P'VM_FAMILY_CLOUD_TPU_LITE_POD_SLICE_CT6E#VM_FAMILY_CLOUD_TPU_POD_SLICE_TPU7X=AllocationAggregateReservationReservedResourceInfoAcceleratorappend2AllocationAggregateReservationReservedResourceInfoWorkloadTypeValueValuesEnumworkloadType)r7   r   r   r   tpu_version_to_vm_familyreserved_resourcesr   r@   s           rE   r*   r*      s    

 
1
1
I
I
r
r 
1
1
I
I
l
l 
1
1
I
I
q
q 
1
1
I
I
m
m LL% M  
 AA! B 
 &.%L%L66NN
"
/ +	 &M &" //KK	
 %1
 
*)rG   c                 f    U(       a  U R                  XS9$ U R                  XR                  US9S9$ )z*Constructs the time window message object.)	startTimeendTimeseconds)rt   r   )FutureReservationTimeWindowDuration)r7   r,   r   r   s       rE   r+   r+      sM    // 0 0 0 //'8'8'8'J 0 L LrG   c                    U(       a  US:X  aZ  UR                  S5      (       a  [        R                  " SS5      eU R                  U R                  R                  R
                  S9$ US:X  ap  UR                  S5      (       d  [        R                  " SS5      eU R                  U R                  R                  R                  [        U [        USS5      5      S	9$ gg)
z-Constructs the share settings message object.local
share_withz--share_withz_The scope this reservation is to be shared with must not be specified with share setting local.)	shareTypeprojectszEThe projects this reservation is to be shared with must be specified.N)r}   
projectMap)	r/   r   InvalidArgumentExceptionShareSettingsShareTypeValueValuesEnumLOCALSPECIFIC_PROJECTSMakeProjectMapFromProjectListr"   )r7   r9   setting_configss      rE   r-   r-      s    '!			,	'	'1123 	3 ##h.D.D%=%=ee $ E E*$l++11 	 ##**CC2lD9; $ < < % rG   c           
          / nU HC  nUR                  U R                  R                  R                  UU R	                  US9S95        ME     U R                  R                  US9$ )N)	projectId)keyvalue)additionalProperties)rm   r   ProjectMapValueAdditionalPropertyShareSettingsProjectConfig)r7   r~   additional_propertiesprojects       rE   r   r     sy    g  ..AA555H 	B 	JK 
 
			/	/0 
0 
2 2rG   c                     U(       aL  US:X  a   U R                   R                  R                  $ US:X  a   U R                   R                  R                  $ g)z*Constructs the planning status enum value.	SUBMITTEDDRAFTN)FutureReservationPlanningStatusValueValuesEnumr   r   )r7   r   s     rE   r.   r.   "  sH    +%''EEOOO'!''EEKKK	rG   c                     U(       aL  US:X  a   U R                   R                  R                  $ US:X  a   U R                   R                  R                  $ g)z*Constructs the deployment type enum value.DENSEFLEXIBLEN)r   DeploymentTypeValueValuesEnumr   r   )r7   r   s     rE   r1   r1   ,  sH    '!''EEKKK*$''EENNN	rG   c                     [        USS5      nSnUR                  S5      (       a  [        U [        USS5      5      nSnUR                  S5      (       a  [        U [        USS5      5      n[	        X#U/5      (       a  U R                  UUUS9$ g)z.Constructs the commitment info message object.commitment_nameNcommitment_planprevious_commitment_terms)commitmentNamecommitmentPlanpreviousCommitmentTerms)r"   r0   MakeCommitmentPlanMakePreviousCommitmentTermsanyFutureReservationCommitmentInfo)r7   r9   r   r   r   s        rE   r2   r2   6  s    D"3T://	/00()07H$)OQO"	9:: ;'$ ;TB! 	/,E	FGG33&& 9 4  
 
rG   c                     U(       aL  US:X  a   U R                   R                  R                  $ US:X  a   U R                   R                  R                  $ g)z*Constructs the commitment plan enum value.TWELVE_MONTHTHIRTY_SIX_MONTHN)r   CommitmentPlanValueValuesEnumr   r   )r7   r   s     rE   r   r   L  sL    .(66TTl,,66TT!	rG   c                 ^    U(       a&  US:X  a   U R                   R                  R                  $ g)z4Constructs the previous commitment terms enum value.EXTENDN)r   &PreviousCommitmentTermsValueValuesEnumr   )r7   r   s     rE   r   r   X  s)     H,66]]v	rG   c                     U(       aL  US:X  a   U R                   R                  R                  $ US:X  a   U R                   R                  R                  $ g)z*Constructs the scheduling type enum value.GROUPEDINDEPENDENTN)r   SchedulingTypeValueValuesEnumr   r   )r7   r   s     rE   r3   r3   a  sI    )#''EEMMM-'((FF{	rG   c                     U(       aL  US:X  a   U R                   R                  R                  $ US:X  a   U R                   R                  R                  $ g)z+Constructs the reservation mode enum value.CALENDARDEFAULTN)r   ReservationModeValueValuesEnumr   r   )r7   r   s     rE   r4   r4   l  sH    :%''FFOOO9$''FFNNN	rG   c                    U R                  UUUS9nU(       a  UUl        U(       a  UUl        U(       a  UUl        Ub  UUl        Ub  [
        R                  " U5      Ul        U	b  U R                  U	S9Ul	        U
b  U
Ul
        Ub  UUl        Ub  UUl        Ub  UUl        Ub  UUl        Ub  UUl        Ub  UUl        U$ )z/Constructs a future reservation message object.)name
timeWindowplanningStatusrv   )r   aggregateReservationspecificSkuPropertiesshareSettings!autoDeleteAutoCreatedReservationsr   FormatDateTime!autoCreatedReservationsDeleteTimery   autoCreatedReservationsDurationspecificReservationRequiredreservationNamedeploymentTypecommitmentInfoschedulingTypereservationModeenableEmergentMaintenance)r7   future_reservation_namerA   rB   r   r@   r?   rC   r   r   r   r   r   rD   r   r   r   future_reservation_messages                     rE   r5   r5   v  s   (  (99"$  :   &( 3 7E4/=,$0' @ +6BC @ (3"DE > "-$ : !1A. 0?- 0?- 0?-!1A. ,# 8 
$#rG   )NNN)N)NNNNNNNNNNNN)__doc__
__future__r   r   r   googlecloudsdk.callioper   /googlecloudsdk.command_lib.compute.reservationsr   r    googlecloudsdk.core.utilr   rF   r$   r(   r*   r+   r-   r   r.   r1   r2   r   r   r3   r4   r5    rG   rE   <module>r      s    Q &  ' . T *pp 374848D "&	%,/*dL42,	  &*$(*.'+!% $#E$rG   