
    }                     h    S 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S
 rS rS rS rg)zUtility functions for advice.    )	arg_utils)
exceptions)
properties)timesc                 (   [        X5      n[        R                  R                  R                  R                  5       nU R                  =(       d2    [        R                  R                  R                  R                  5       nUR                  UUUS9$ )z@Helper function to get the compute advice calendar mode request.)calendarModeAdviceRequestprojectregion)
GetCalendarModeAdviceRequestr   VALUEScorer	   	GetOrFailr
   computeGet ComputeAdviceCalendarModeRequest)argsmessagescalendar_mode_advice_requestr	   r
   s        5lib/googlecloudsdk/command_lib/compute/advice/util.py#GetComputeAdviceCalendarModeRequestr      s{     ">d!M""**446' ;;@*++33::>>@&		2	2 < 
3 
     c                    UR                  5       nU R                  (       a:  [        R                  " U R                  UR                   R                  5      Ul        U R                  (       a  [        X5      Ul        [        X5      Ul
        [        X5      Ul        UR                  R                  UR                  R                  R                  SUS9/S9nUR                  US9$ )z8Helper function to get the calendar mode advice request.speckeyvalueadditionalProperties)futureResourcesSpecs)FutureResourcesSpecdeployment_typer   ChoiceToEnumDeploymentTypeValueValuesEnumdeploymentTypelocation_policyGetLocationPolicylocationPolicyGetTargetResourcestargetResourcesGetTimeRangeSpectimeRangeSpecCalendarModeAdviceRequestFutureResourcesSpecsValueAdditionalProperty)r   r   future_resources_specfuture_resources_specs_values       r   r   r   )   s     #668	+4+A+A$$BB,(
 
+<T+L(*<T*L'(8(H%!)!C!C!]!]

,
,
F
F
Y
Y 5 Z  "^ " 
	+	+7 
, 
 r   c           
         U R                   (       d  g/ nU R                   R                  5        H  u  p4[        R                  " UUR                  R
                  5      nUR                  UR                  R                  R                  SR                  U5      UR	                  US9S95        M     UR                  UR                  R                  US9S9$ )z+Helper function to get the location policy.Nzzones/{})
preferencer   r   )	locations)r%   itemsr   r"   )FutureResourcesSpecLocationPolicyLocationPreferenceValueValuesEnumappend!FutureResourcesSpecLocationPolicyLocationsValuer.   format)r   r   r3   zonepolicyzone_policys         r   r&   r&   G   s     
		)**002ld((::TTK 22AATT!!$'DD& E  	U 	
 3 
	3	3::II( J  
4 
 r   c                    UR                  5       nU R                  (       a  U R                  Ul        U R                  (       a  U R                  Ul        U R
                  (       aw  / nU R
                   H_  nUR                  US   S9nUR                  S5      nU(       a!  UR                  R                  U5      nXul	        UR                  U5        Ma     X2l        U$ )z2Helper function to get the specific SKU resources.size)
diskSizeGb	interface)'FutureResourcesSpecSpecificSKUResourcesvm_countinstanceCountmachine_typemachineType	local_ssd$FutureResourcesSpecLocalSsdPartitiongetDiskInterfaceValueValuesEnumdiskInterfacer7   localSsdPartitions)r   r   specific_sku_resourceslocal_ssd_partitionsssd	partitioninterface_strrA   s           r   GetSkuResourcesrR   c   s     $KKM	]]+/==(	)-):):&	^^~~??[ @ i ggk*m	AA^^
	 #,!!),  1E-	r   c           	      $   UR                   R                  nUR                  UR                  UR                  UR
                  S.nX;  aC  [        R                  " SSR                  SR                  UR                  5       5      5      5      eX0   $ )z%Helper function to get the VM family.)V5EV5PV6ETPU7Xz--tpu-versionz%Must specify a valid TPU version ({})z, )%FutureResourcesSpecAggregateResources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_TPU7Xr   InvalidArgumentExceptionr:   joinkeys)tpu_versionr   	vm_familytpu_version_to_vm_familys       r   GetVmFamilyrd      s    
 44LL  ??99>><<	 0

-
-/66II.3356	
  
"	..r   c                 X   UR                  5       nU R                  (       a  U R                  Ul        U R                  (       a  [	        U R                  U5      Ul        U R                  (       a:  [        R                  " U R                  UR                   R                  5      Ul
        U$ )z/Helper function to get the aggregate resources.)rX   
chip_countacceleratorCountra   rd   vmFamilyworkload_typer   r"   WorkloadTypeValueValuesEnumworkloadType)r   r   aggregate_resourcess      r   GetAggregateResourcesrm      s     !FFH	__+/??(	#.t/?/?#J 	'0'='=66RR($
 
r   c                     UR                  5       nU R                  (       a  [        X5      Ul        U R                  (       a  [        X5      Ul        U$ )z,Helper function to get the target resources.)"FutureResourcesSpecTargetResourcesrE   rR   specificSkuResourcesra   rm   aggregateResources)r   r   &future_resources_spec_target_resourcess      r   r(   r(      sS     113 ) 
' +?
 
d- += 
0/r   c                     UR                  5       nU R                  (       at  U R                  R                  SS5      nUb  [        R                  " U5      Ul        U R                  R                  SS5      nUb  [        R                  " U5      Ul        U R                  (       at  U R                  R                  SS5      nUb  [        R                  " U5      Ul        U R                  R                  SS5      nUb  [        R                  " U5      Ul	        U R                  (       aR  U R                  R                  SS5      nUb
  U S3Ul        U R                  R                  SS5      nUb
  U S3Ul        U$ )z'Helper function to get the time ranges.fromNtomaxsmin)FlexibleTimeRangestart_time_rangerI   r   FormatDateTimestartTimeNotEarlierThanstartTimeNotLaterThanend_time_rangeendTimeNotEarlierThanendTimeNotLaterThanduration_rangemaxDurationminDuration)	r   r   flexible_time_rangestart_time_fromstart_time_toend_time_fromend_time_tomax_durationmin_durations	            r   r*   r*      sl    224 
++//=O"494H4H
51 ))--dD9M 272F2F
3/
 
''++FD9M 272F2F
3/ %%))$5K050D0D
1-
 
&&**5$7L+7.(:%&&**5$7L+7.(:%	r   N)__doc__$googlecloudsdk.command_lib.util.apisr   googlecloudsdk.corer   r   googlecloudsdk.core.utilr   r   r   r&   rR   rd   rm   r(   r*    r   r   <module>r      s>    $ : * * *$<8 :/6(00'r   