
    "                         d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 ddlm
Z
 dd	lmZ dd
lmZ  G d de      Z G d de      Z G d de
j"                        Zy)z"Cloud vmware Privateclouds client.    )absolute_import)division)unicode_literals)
list_pager)clusters)networks)util)	arg_utils)Errorc                        e Zd Z fdZ xZS )SecondaryZoneNotProvidedErrorc                 ,    t         t        |   d       y )NzRFAILED_PRECONDITION: Secondary Zone value is required for Stretched Private Cloud.)superr   __init__self	__class__s    2lib/googlecloudsdk/api_lib/vmware/privateclouds.pyr   z&SecondaryZoneNotProvidedError.__init__       	
'7	    __name__
__module____qualname__r   __classcell__r   s   @r   r   r           r   r   c                        e Zd Z fdZ xZS )PreferredZoneNotProvidedErrorc                 ,    t         t        |   d       y )NzRFAILED_PRECONDITION: Preferred Zone value is required for Stretched Private Cloud.)r   r   r   r   s    r   r   z&PreferredZoneNotProvidedError.__init__(   r   r   r   r   s   @r   r   r   &   r   r   r   c                        e Zd ZdZ fdZd Z	 	 	 	 	 ddZd Zd ZddZ	d Z
d	 Zd
 Zd Zd Zd Zd Zd ZddZddZd Zd Z xZS )PrivateCloudsClientz"cloud vmware privateclouds client.c                     t         t        |           | j                  j                  | _        t        j                         | _        t        j                         | _        y N)r   r"   r   client projects_locations_privateCloudsservicer   NetworksClientnetworks_clientr   ClustersClientcluster_clientr   s    r   r   zPrivateCloudsClient.__init__2   sD    	
t-/;;??DL#224D"113Dr   c                     | j                   j                  |j                               }| j                  j	                  |      }|S Nname)messages4VmwareengineProjectsLocationsPrivateCloudsGetRequestRelativeNamer'   Get)r   resourcerequestresponses       r   r3   zPrivateCloudsClient.Get8   sF    JJ&&( 	K 	
  ||(HOr   c                    |j                         j                         }|j                         j                         j                         }|j                         }| j                  j	                  |      }| j                  |      |_        | j                  j                  ||      }g }|r)|D cg c]  }| j                  j                  |        }}| j                  j                  ||j                  |      }| j                  j                  |      }t        j                  | j                  j                  j                  | j                  j                   |      |_        |j                  | j                  j                  j$                  j&                  u r:|	s
t)               |s
t+               | j                  j-                  |	|      |_        t        j0                  | j                  j2                  | j                  j4                  | j                  j6                  |
      |_        ||_        ||_        | j                  j?                  |||      }| j@                  jC                  |      S c c}w )N)description)ipCidrRange)managementCidrvmwareEngineNetworkserviceSubnets)	clusterId)preferredLocationsecondaryLocation)parentprivateCloudIdprivateCloud)"Parentr2   Namer0   PrivateCloudGetPrivateCloudTypetyper)   GetByIDSubnetNetworkConfigr/   ManagementClusterr	   #ConstructNodeParameterConfigMessageNodeTypeConfigsValueNodeTypeConfignodeTypeConfigsTypeValueValuesEnum	STRETCHEDr   r   StretchedClusterConfigstretchedClusterConfig#ConstructAutoscalingSettingsMessageAutoscalingSettingsAutoscalingPolicy
ThresholdsautoscalingSettingsmanagementClusternetworkConfig7VmwareengineProjectsLocationsPrivateCloudsCreateRequestr'   Create)r   r4   
cluster_idnodes_configsnetwork_cidrvmware_engine_network_idprivate_cloud_typer8   secondary_zonepreferred_zoneautoscaling_settingsservice_subnetr@   projectprivate_cloud_idprivate_cloudvennew_subnetscidrnetwork_configmanagement_clusterr5   s                         r   r\   zPrivateCloudsClient.CreateB   s6    __++-Foo&&(--/G}}MM..;.GM112DEM



&
&w0H
ICK=K=KT$--

4

0^   ]]00#" 1 N
 88:8N00MM++@@MM((	
 & 	==%%99CC	D +--+--
--
.
. .. /  / 	00MM--MM++MM$$ 		
 * '9M#"0MMM+& 	N 	
  <<w''_s   1#I8c                    | j                  |      }g }||_        |j                  d       | j                  j	                  ||j                         dj                  |            }| j                  j                  |      S )Nr8   ,)rB   r/   
updateMask)	r3   r8   appendr0   6VmwareengineProjectsLocationsPrivateCloudsPatchRequestr2   joinr'   Patch)r   r4   r8   rh   update_maskr5   s         r   UpdatezPrivateCloudsClient.Update   sz    HHX&MK +M}%LL&&&(xx, 	M 	
  <<g&&r   c                     | j                   j                  |j                               }| j                  j	                  |      S r-   )r0   9VmwareengineProjectsLocationsPrivateCloudsUndeleteRequestr2   r'   Undeleter   r4   r5   s      r   UnDeletezPrivateCloudsClient.UnDelete   sB    OO&&( 	P 	
 
 <<  ))r   c                     | j                   j                  | j                  j                  |j	                         |            S )N)r/   
delayHours)r'   Deleter0   7VmwareengineProjectsLocationsPrivateCloudsDeleteRequestr2   )r   r4   delay_hourss      r   r~   zPrivateCloudsClient.Delete   s?    <<MM&&([ 	N 	
 r   c                     | j                   j                  |j                               }| j                  j	                  |      S r-   )r0   HVmwareengineProjectsLocationsPrivateCloudsPrivateCloudDeletionNowRequestr2   r'   PrivateCloudDeletionNowrz   s      r   	DeleteNowzPrivateCloudsClient.DeleteNow   sB    ^^&&( 	_ 	
 
 <<//88r   c                     |j                         }| j                  j                  |      }t        j                  | j
                  |dd      S )N)r@   pageSizeprivateClouds)batch_size_attributefield)r2   r0   5VmwareengineProjectsLocationsPrivateCloudsListRequestr   YieldFromListr'   )r   location_resourcelocationr5   s       r   ListzPrivateCloudsClient.List   sU     --/HKK 	L 	
 
 ##'	 r   c                     | j                   j                  |j                         dz         }| j                  j	                  |      S )N/dnsForwardingr.   )r0   AVmwareengineProjectsLocationsPrivateCloudsGetDnsForwardingRequestr2   r'   GetDnsForwardingrz   s      r   r   z$PrivateCloudsClient.GetDnsForwarding   sE    mm]]""$'77 ^ G <<((11r   c                     | j                  |      }| j                  j                  |      }d}| j                  j                  |j	                         dz   ||      }| j
                  j                  |      S )N)forwardingRulesr   r   )r/   dnsForwardingrp   )_ParseRulesr0   DnsForwardingDVmwareengineProjectsLocationsPrivateCloudsUpdateDnsForwardingRequestr2   r'   UpdateDnsForwarding)r   r4   
args_rulesrulesdns_forwardingru   r5   s          r   r   z'PrivateCloudsClient.UpdateDnsForwarding   sw    Z(E]]000GN#Kmm``""$'77$ a G
 <<++G44r   c                 J    |D cg c]  }| j                  |       c}S c c}w r$   )
_ParseRule)r   r   rules      r   r   zPrivateCloudsClient._ParseRules   s#    .89jdDOOD!j999s    c                 H    | j                   j                  |d   |d         S )Ndomainzname-servers)r   nameServers)r0   ForwardingRule)r   r   s     r   r   zPrivateCloudsClient._ParseRule   s,    ==''H~4+? (  r   c                     | j                   j                  |j                               }| j                  j	                  |      S N)rB   )r0   CVmwareengineProjectsLocationsPrivateCloudsShowNsxCredentialsRequestr2   r'   ShowNsxCredentialsrz   s      r   GetNsxCredentialsz%PrivateCloudsClient.GetNsxCredentials   s?    mm__**, ` G <<**733r   c                     | j                   j                  |j                               }| j                  j	                  |      S r   )r0   DVmwareengineProjectsLocationsPrivateCloudsResetNsxCredentialsRequestr2   r'   ResetNsxCredentialsrz   s      r   r   z'PrivateCloudsClient.ResetNsxCredentials   s?    mm``**, a G <<++G44r   c                     | j                   j                  |j                         |      }| j                  j	                  |      S )N)rB   username)r0   GVmwareengineProjectsLocationsPrivateCloudsShowVcenterCredentialsRequestr2   r'   ShowVcenterCredentials)r   r4   r   r5   s       r   GetVcenterCredentialsz)PrivateCloudsClient.GetVcenterCredentials   sA    mmcc**,x d G <<..w77r   c                     | j                   j                         }||_        | j                   j                  |j	                         |      }| j
                  j                  |      S )N)rB   resetVcenterCredentialsRequest)r0   ResetVcenterCredentialsRequestr   HVmwareengineProjectsLocationsPrivateCloudsResetVcenterCredentialsRequestr2   r'   ResetVcenterCredentials)r   r4   r   vcenterr5   s        r   r   z+PrivateCloudsClient.ResetVcenterCredentials   s\    mm::<GGmmdd**,'. e G <<//88r   c                     t        j                  dd| j                  j                  j                        j                  t        j                  |            }|S )NrG   STANDARD)arg_namedefaultmessage_enum)r
   ChoiceEnumMapperr0   rE   rP   GetEnumForChoiceEnumNameToChoice)r   ra   	type_enums      r   rF   z'PrivateCloudsClient.GetPrivateCloudType   sO    **]]//CC y112DEF	 
 r   c                 d    | j                   j                  |      D ]  }|j                  s|c S  y r$   )r+   r   
management)r   r4   clusters      r   GetManagementClusterz(PrivateCloudsClient.GetManagementCluster   s+    &&++H5			 6r   )NNNNNr$   )r   r   r   __doc__r   r3   r\   rv   r{   r~   r   r   r   r   r   r   r   r   r   r   rF   r   r   r   s   @r   r"   r"   /   ss    *4$ E(N'*92	5:
4589r   r"   N)r   
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.vmwarer   r   r	   $googlecloudsdk.command_lib.util.apisr
   googlecloudsdk.core.exceptionsr   r   r   VmwareClientBaser"    r   r   <module>r      sQ    ) &  ' ' 2 2 . : 0E E L$// Lr   