
    2                         S r SSKJr  SSKJr  SSKJr  SSKrSSKJr  SSKJr  SSK	J
r
  S	r " S
 S\5      rS rS rS rS rg)zCloud vmware API utilities.    )absolute_import)division)unicode_literalsN)apis)waiter)	resourcesv1c                   z    \ rS rSrSr\4S jr\S 5       r\S 5       r	S r
S\R                  " SS	94S
 jrS rSrg)VmwareClientBase   z*Base class for vwmare API client wrappers.c                     [         R                  " SU5      U l        [         R                  " SU5      U l        S U l        U R                  R                  U l        g )Nvmwareengine)	r   GetClientInstance_clientGetMessagesModule	_messagesserviceclientprojects_locations_operationsoperations_service)selfapi_versions     )lib/googlecloudsdk/api_lib/vmware/util.py__init__VmwareClientBase.__init__"   sC    )).+FDL++NKHDNDL"kkGGD    c                     U R                   $ N)r   r   s    r   r   VmwareClientBase.client(   s    <<r   c                     U R                   $ r   )r   r   s    r   messagesVmwareClientBase.messages,   s    >>r   c                 R    [         R                  R                  UR                  SS9$ )zPConverts an Operation to a Resource that can be used with `waiter.WaitFor`.
    z*vmwareengine.projects.locations.operations)
collection)r   REGISTRYParseRelativeNamename)r   	operations     r   GetOperationRef VmwareClientBase.GetOperationRef0   s.     //#O 0 Q Qr   Ti  )secondsc                     U(       a,  [         R                  " U R                  U R                  5      nO [         R                  " U R                  5      n[         R
                  " XQX$R                  S-  S9$ )aa  Waits for an operation to complete.

Polls the IDS Operation service until the operation completes, fails, or
max_wait_seconds elapses.

Args:
  operation_ref: a Resource created by GetOperationRef describing the
    operation.
  message: the message to display to the user while they wait.
  has_result: if True, the function will return the target of the operation
    when it completes. If False, nothing will be returned (useful for Delete
    operations)
  max_wait: The time to wait for the operation to succeed before returning.

Returns:
  if has_result = True, an Endpoint entity.
  Otherwise, None.
i  )max_wait_ms)r   CloudOperationPollerr   r   CloudOperationPollerNoResourcesWaitForr,   )r   operation_refmessage
has_resultmax_waitpollers         r   WaitForOperation!VmwareClientBase.WaitForOperation6   sb    . **4<<+/+B+BDf 55d6M6MNf>>w4D4Dt4KM Mr   c                 z    [         R                  " U R                  U R                  5      nUR	                  U5      $ r   )r   r/   r   r   	GetResult)r   r)   r6   s      r   GetResponseVmwareClientBase.GetResponseV   s/    ((t7N7NOFI&&r   )r   r   r   r   N)__name__
__module____qualname____firstlineno____doc___DEFAULT_API_VERSIONr   propertyr   r"   r*   datetime	timedeltar7   r;   __static_attributes__ r   r   r   r      s[    2!5 H    Q #' ( 2 24 @	M@'r   r   c                 *    U R                  S5      S   $ )N/)split)resource_names    r   GetResourceIdrM   [   s    			S	!"	%%r   c                     / nU Hq  nUR                   S:X  a  M  U" UR                   S9nUR                  S:  a  UR                  Ul        U R                  UR                  US9nUR                  U5        Ms     U " US9$ )zConstructs a node configs API message.

Args:
  map_class: The map message class.
  config_class: The config (map-entry) message class.
  nodes_configs: The list of nodes configurations.

Returns:
  The constructed message.
r   )	nodeCountkeyvalueadditionalProperties)countcustom_core_countcustomCoreCountAdditionalPropertytypeappend)	map_classconfig_classnodes_configs
propertiesnodes_confignode_type_configprops          r   #ConstructNodeParameterConfigMessagerb   _   s     *#lQ#l.@.@A%%))5)G)G&''%5 ( D d $ 

	33r   c                    U(       d  gU " 5       nUR                   Ul        UR                  Ul        UR                  Ul        0 nUR                  R                  5        H  u  pgU" 5       nUR                  Ul	        UR                  Ul        UR                  Ul        UR                  Ul        [!        UR"                  U5      Ul        [!        UR&                  U5      Ul        [!        UR*                  U5      Ul        [!        UR.                  U5      Ul        XU'   M     U R3                  UR                  5        VVs/ s H  u  phU R2                  R5                  XhS9PM      snnS9Ul        U$ s  snnf )aZ  Constructs autoscaling settings API message.

Args:
  settings_message_class: Top-level autoscaling settings message class.
  policy_message_class: Autoscaling policy message class.
  thresholds_message_class: Autoscaling policy thresholds message class.
  autoscaling_settings: Desired autoscaling settings.

Returns:
  The constructed message.
NrP   rS   )min_cluster_node_countminClusterNodeCountmax_cluster_node_countmaxClusterNodeCountcool_down_periodcoolDownPeriodautoscaling_policiesitemsnode_type_id
nodeTypeIdscale_out_sizescaleOutSizemin_node_countminNodeCountmax_node_countmaxNodeCount_ConstructThresholdsMessagecpu_thresholdscpuThresholdsgranted_memory_thresholdsgrantedMemoryThresholdsconsumed_memory_thresholdsconsumedMemoryThresholdsstorage_thresholdsstorageThresholdsAutoscalingPoliciesValuerX   autoscalingPolicies)	settings_message_classpolicy_message_classthresholds_message_classautoscaling_settingssettings_messagepolicy_messagesr(   policypolicy_messages	            r   #ConstructAutoscalingSettingsMessager   z   s   " 
+-11 & 11 & %9$I$I!/*??EEGld)+N & 3 3N"("7"7N"("7"7N"("7"7N#>7$N  .I((*B.N* /J))+C/N+ (C!!#;(N$ +D) H, *@)X)X )8(=(=(? )@$ !
9
9
L
L M (? *Y *& 
s   %E3
c                 `    U" 5       nU c  g U R                   Ul        U R                  Ul        U$ r   )scale_inscaleIn	scale_outscaleOut)
thresholdsr   thresholds_messages      r   rt   rt      s8    /1)22 * 4 4	r   )rA   
__future__r   r   r   rD   googlecloudsdk.api_lib.utilr   r   googlecloudsdk.corer   rB   objectr   rM   rb   r   rt   rG   r   r   <module>r      sI    " &  '  , . )  9'v 9'x&46;|r   