
    8v                     &   S r SSKrSSKJr  SSKJr  SSKJr  SSKJr  SSKrSSK	rS r
S rS	 rS
 rS rS rS rS rSS 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\R@                  " S/ SQ5      r!0 S \!" S!/ S"QS#\RD                  4S$\RF                  4/SS9_S%\!" S&/ S'QS(\RD                  4S)\RD                  4/SS9_S*\!" S+/ S,QS-S. 4/S/S-/S9_S0\!" S1S2S3\4S4/S5\RF                  4// S6QS9_S7\!" S8/ S9\RF                  4/SS9_S:\!" S;/ S<QS=\RD                  4S>\RD                  4S(\RD                  4/SS9_S?\!" S@/ SAQS(\RD                  4/SS9_SB\!" SCS2SDSE\4SF\
4SG\4SH\4/SI\RD                  4/SS9_SJ\!" SKS2SLSMSNSO\4/S#\RD                  4S)\RF                  4/SS9_SP\!" SQS2SR\4SS// / S9_ST\!" SUS2SV// SS9_SW\!" SX/ SYQ/ SS9_SZ\!" S[/ SYQ/ SS9_S\\!" S]/ S^Q/ SS9_S_\!" S`S2Sa\4SbScSd// SS9_Se\!" Sf/ SgQS(\RD                  4Sh\$4/SS9_Si\!" Sj/ SkQS(\RD                  4Sl\RD                  4Sm\RD                  4/SS9_0 Sn\!" SoS2SpSq\4SrSsStSd/Su\RD                  4Sv\RD                  4Sw\RD                  4S(\RD                  4/SS9_Sx\!" SyS2Sq\4SzS{// SS9_S|\!" S}S2SpS~S\4Sc/S(\RD                  4/SS9_S\!" S/ SQ/ SS9_S\!" S/ / SS9_S\!" SS2SSS\4SdS/S\RF                  4/SS9_S\!" SSSS\4SdS/S\RF                  4/SS9_S\!" S1S2S3\4S4/S5\RF                  4// SQS9_S\!" SS2S\" SSS94S\" SSS94S\" SSS94S\" SSS94S\4S\4/S\RD                  4/SS9_S\!" SS2SDSS\4S/SI\RD                  4/SS9_S\!" S/ SQS\RF                  4/SS9_S\!" SS2S{// SS9_S\!" S/ SQSI\RD                  4S#\RD                  4/SS9_S\!" SS2S/S\RD                  4/SS9_S\!" SS2S\4S/S\RD                  4S\RD                  4/SS9_S\!" SS2SSS\4/S\RD                  4S\RD                  4/SS9_S\!" S/ SQS\RD                  4S(\RD                  4/SS9_E\!" S/ S9\RF                  4/SS9\!" SS2SLSSS\4/S\RD                  4S\RD                  4S\RF                  4S#\RD                  4/SS9\!" S/ SQSI\RD                  4S#\RD                  4/SS9\!" S/ SQ/ / S9\!" SS2SLS\4S\4/S#\RD                  4/SS9\!" S/ SQS#\RD                  4S\RD                  4/SS9\!" S/ SQSI\RD                  4S#\RD                  4/SS9S.Er%\%RM                  5       r'\!" S1S2S3\4S4/S5\RF                  4// SQS9\'S0'   \!" S/ SQ/ / S9\'S'   \'RM                  5       r(\!" SfS2S\4S\4SDSS/Sh\$4/SS9\(Se'   \!" SjS2S\4S\4SSSSS/Sl\RD                  4Sm\RD                  4/SS9\(Si'   S r)\R@                  " S/ SQ5      r*S r+g)z4Annotates the resource types with extra information.    N)messages)instance_utils)path_simplifier)property_selectorc                 6   / nU R                  S/ 5       Hq  nUR                  S5      nU(       d  M  UR                  S5      nU(       a+  U H#  nUR                  SR                  X55      5        M%     M`  UR                  U5        Ms     SR                  U5      $ )z7Returns a compact string describing the firewall rules.allowed
IPProtocolportsz{0}:{1},)getappendformatjoin)firewallrulesr   protocolport_ranges
port_ranges         4lib/googlecloudsdk/api_lib/compute/resource_specs.py_FirewallRulesToCellr      s    
%i,g{{<(H++g&K#*Y%%h;< $ ll8 - 
%    c                 R    SR                  S U R                  S/ 5       5       5      $ )z@Comma-joins the names of health checks of the given target pool.r   c              3   N   #    U  H  n[         R                  " U5      v   M     g 7fNr   Name).0checks     r   	<genexpr>0_TargetPoolHealthChecksToCell.<locals>.<genexpr>1   s%      75 38/&&u--5   #%healthChecksr   r   )target_pools    r   _TargetPoolHealthChecksToCellr%   /   s+    	 7//."57 
7 7r   c                 D    SR                  U R                  S/ 5      5      $ )z9Comma-joins the source ranges of the given firewall rule.r   sourceRangesr#   r   s    r   _FirewallSourceRangesToCellr)   5   s    	(,,~r2	33r   c                 D    SR                  U R                  S/ 5      5      $ )z7Comma-joins the source tags of the given firewall rule.r   
sourceTagsr#   r(   s    r   _FirewallSourceTagsToCellr,   :       	(,,|R0	11r   c                 D    SR                  U R                  S/ 5      5      $ )z7Comma-joins the target tags of the given firewall rule.r   
targetTagsr#   r(   s    r   _FirewallTargetTagsToCellr0   ?   r-   r   c                 T    U R                  SS5      nUb  U$ U R                  SS5      $ )z?Gets the API-level target or backend-service of the given rule.backendServiceNtargetr   )forwarding_rulebackend_services     r   _ForwardingRuleTargetr7   D   s4    #''(8$?/ x..r   c                     U R                  SS5      nU(       a0  SR                  U R                  S5      UR                  S5      5      $ U R                  S5      $ )zGReturns status of a machine with deprecation information if applicable.
deprecated z	{0} ({1})statusstate)r   r   zone_or_regionr9   s     r   _StatusToCellr?   M   sV    !!,3*n00:(nnW57 7 h''r   c                 X    U R                  SS5      nU(       a  UR                  S5      $ g)z=Returns the turndown timestamp of a deprecated machine or ''.r9   r:   deletedr4   r=   s     r   _DeprecatedDateTimeToCellrB   W   s)    !!,3*>>)$$r   Tc                    ^ ^ UU 4S jnU$ )zBReturns a function that can format the given quota as usage/limit.c           	      \  > U R                  S/ 5       H  nUR                  S5      T:w  a  M  T(       aD  SR                  [        UR                  S5      5      [        UR                  S5      5      5      s  $ SR                  UR                  S5      UR                  S5      5      s  $    g)z,Formats the metric from the parent function.quotasmetricz	{0:6}/{1}usagelimitz{0:7.2f}/{1:.2f}r:   )r   r   int)regionquota
is_integerrF   s     r   QuotaToCell!_QuotaToCell.<locals>.QuotaToCellc   s    Hb)	8		&	!!		'"#		'"#% 	% "((IIgIIg  	  * r    )rF   rL   rM   s   `` r   _QuotaToCellrP   `   s    " 
r   c                     SU ;   a  [         R                  " U S   5      $ SU ;   a  [         R                  " U S   5      $ g)z;Returns a location name, could be region name or zone name.zonerJ   Nr   instance_groups    r   _LocationNamerU   w   sA    ~v 677>!x 899r   c                      SU ;   a  gSU ;   a  gg)z7Returns a location scope type, could be region or zone.rR   rJ   NrO   rS   s    r   _LocationScopeTyperW      s    ~>!r   c                 n    U R                  S5      nU(       a  SR                  [        U5      S-  5      $ g)z3Returns the memory of the given machine type in GB.memoryMbz{0:5.2f}   r:   )r   r   float)machine_typememorys     r   _MachineTypeMemoryToCellr^      s2    J'&U6]U233r   c                     [         R                  " U 5      u  pnU(       a4  U(       a-  U(       a&  SR                  US-  5      nSR                  XU5      n U $ )a  Checks for custom machine type and modifies output.

Args:
  mt: machine type to be formatted

Returns:
  If mt was a custom type, then it will be formatted into the desired custom
    machine type output. Otherwise, it is returned unchanged.

Helper function for _MachineTypeNameToCell
z{0:.2f}rZ   zcustom ({0}, {1} vCPU, {2} GiB))r   GetCpuRamVmFamilyFromCustomNamer   )mtcustom_family
custom_cpu
custom_ramcustom_ram_gbs        r   _FormatCustomMachineTypeNamerf      sR     2226 (-ZJ=$$Z5%9:M	*	1	1-2?
AB	)r   c                 l    U R                  SU 5      R                  S5      nU(       a  [        U5      $ U$ )aN  Returns the formatted name of the given machine type.

Most machine types will be untouched, with the exception of the custom machine
type. This modifies the 'custom-N-M' custom machine types with
'custom (N vCPU, M GiB)'.

For example, given the following custom machine_type:

  custom-2-3500

This function will return:

  custom (2 vCPU, 3.41 GiB)

in the MACHINE_TYPE field when listing out the current instances.

Args:
  machine_type: The machine type of the given instance

Returns:
  A formatted version of the given custom machine type (as shown in example
  in docstring above).

propertiesmachineType)r   rf   )r\   ra   s     r   _MachineTypeNameToCellrj      s4    0 l377F"'++	)r   c                     SU;   aU  SU;   aO  U (       d  gSU ;  a  gU S   R                  S5      nUS   nSU;  a  g[        U5      nXBS'   SR                  U5      $ g)a/  Formats a custom machine type when 'instances describe' is called.

Args:
  resources: dict of resources available for the instance in question
  com_path: command path of the calling command

Returns:
  If input is a custom type, returns the formatted custom machine type.
    Otherwise, returns None.
	instancesdescribeNri   /custom)splitrf   r   )	resourcescom_pathmt_splitlistra   formatted_mts        r   FormatDescribeMachineTypeNamerv      sr     XJ($:I%]+11#6L	b	Br/3L#88L!!r   c                     U R                  S5      S:X  a<  U R                  S5      =(       d$    [        R                  R                  R                  $ g)z6Returns the HTTP response code of the given operation.r;   DONEhttpErrorStatusCoder:   )r   sixmoveshttp_clientOK)	operations    r   _OperationHttpStatusToCellr      s;    ]]8&==./K3993H3H3K3KKr   c                     U R                  S5      nU(       a(  [        R                  " U5      R                  S5      S   $ g)z/Returns the project name of the given resource.selfLinkrn   r   r:   )r   r   ProjectSuffixrq   )resource	self_links     r   _ProjectToCellr      s7    ll:&)((399#>qAAr   c                 J    U R                  S5      nU(       a  [        U5      $ g)Nmembers0)r   len)groupr   s     r   _MembersToCellr      s     IIi 'w<	r   c                 R    SR                  S U R                  S/ 5       5       5      $ )z.Comma-joins the names of the backend services.r   c              3   D   #    U  H  nUR                  S 5      v   M     g7f)r   Nr4   )r   backends     r   r   "_BackendsToCell.<locals>.<genexpr>   s$      F!Dg ++g&&!Ds    backendsr#   )r6   s    r   _BackendsToCellr      s1    	 F!0!4!4Z!DF 
F Fr   c                    U R                  S5      (       a%  [        R                  " U R                  S5      5      $ U R                  S5      (       a%  [        R                  " U R                  S5      5      $ U R                  S5      (       a  U R                  S5      $ U R                  S5      (       a%  [        R                  " U R                  S5      5      $ U R                  S5      (       a  U R                  S5      $ g)z-Returns the next hop value in a compact form.nextHopInstancenextHopGateway	nextHopIpnextHopVpnTunnelnextHopPeeringr:   )r   r   ScopedSuffix)routes    r   _RoutesNextHopToCellr     s    
YY !!''		2C(DEEyy!""''		2B(CDDyy99[!!yy#$$''		2D(EFFyy!""99%&&r   c                 R    SR                  S U R                  S/ 5       5       5      $ )zDJoins the names of ssl certificates of the given HTTPS or SSL proxy.r   c              3   N   #    U  H  n[         R                  " U5      v   M     g 7fr   r   )r   certs     r   r   4_TargetProxySslCertificatesToCell.<locals>.<genexpr>  s%      ;9 26/&&t,,9r!   sslCertificatesr#   )target_proxys    r   !_TargetProxySslCertificatesToCellr     s.    	 ;""#4b9; 
; ;r   c              #     #    [        U R                  5       S S9 H  n[        U[        R                  5      (       aY  [        UR                  5       H>  nUR                  (       a  UR                  S-   U-   v   M*  UR                  S-   U-   v   M@     M{  UR                  (       a  UR                  S-   v   M  UR                  v   M     g7f)aV  Flattens the fields in a protocol buffer definition.

For example, given the following definition:

  message Point {
    required int32 x = 1;
    required int32 y = 2;
    optional string label = 3;
  }

  message Polyline {
    repeated Point point = 1;
    optional string label = 2;
  }

a call to this function with the Polyline class would produce:

  ['label',
   'point[].label',
   'point[].x',
   'point[].y']

Args:
  message_class: A class that inherits from protorpc.self.messages.Message
      and defines a protocol buffer.

Yields:
  The flattened fields, in non-decreasing order.
c                     U R                   $ r   )name)fields    r   <lambda>-_ProtobufDefinitionToFields.<locals>.<lambda>6  s    EJJr   )keyz[]..z[]N)	sorted
all_fields
isinstancer   MessageField_ProtobufDefinitionToFieldstyperepeatedr   )message_classr   	remainders      r   r   r     s     < m..06NOe%..//25::>)>>

U"Y.
.

S 9,
,	 ? 
jj4jj Ps   CCSpec)message_class_name
table_colstransformations	editables	addressesAddress)NAMEr   REGIONrJ   )ADDRESSaddressSTATUSr;   rJ   zusers[]autoscalers
Autoscaler)r   )TARGETr3   )POLICYautoscalingPolicyrR   r3   backendBucketsBackendBucket)r   )GCS_BUCKET_NAME
bucketName)
ENABLE_CDN	enableCdnr   c                 4    [        U 5      R                  5       $ r   )strlower)xs    r   r   r   n  s    CFLLNr   bucketNamedescriptionbackendServicesBackendServicer   BACKENDS)PROTOCOLr   zbackends[].group)r   description	enableCDNr"   iap.enablediap.oauth2ClientIdiap.oauth2ClientSecretportportNamer   
timeoutSecbackendServiceGroupHealthBackendServiceGroupHealthzhealthStatus[].instancedisksDisk)r   ZONErR   )SIZE_GBsizeGb)TYPEr   r   sourceSnapshotr   	diskTypesDiskType)r   r   )VALID_DISK_SIZESvalidDiskSize	firewallsFirewallNETWORKnetwork
SRC_RANGESRULESSRC_TAGSTARGET_TAGSr   forwardingRulesForwardingRuler   )
IP_ADDRESS	IPAddress)IP_PROTOCOLr	   r   groupsGroupNUM_MEMBERSDESCRIPTIONr   r"   HealthCheck)r   r   httpHealthChecksHttpHealthCheck)r   )HOSThost)PORTr   )REQUEST_PATHrequestPathhttpsHealthChecksHttpsHealthCheckiapBackendServiceIAP)r   )ENABLEDenabled)OAUTH2_CLIENT_IDoauth2ClientId)OAUTH2_CLIENT_SECREToauth2ClientSecret)OAUTH2_CLIENT_SECRET_SHA256oauth2ClientSecretSha256imagesImagePROJECT)FAMILYfamily)
DEPRECATEDzdeprecated.stater   instanceGroupsInstanceGroup)r   r   r   MANAGED	isManaged	INSTANCESsizer   instanceGroupManagersInstanceGroupManager)r   r   BASE_INSTANCE_NAMEbaseInstanceNameSIZEr   TARGET_SIZE
targetSizeINSTANCE_TEMPLATEinstanceTemplate
AUTOSCALED
autoscaledinstanceGroupr-  rl   Instancer   MACHINE_TYPE)PREEMPTIBLEzscheduling.preemptible)INTERNAL_IPz.networkInterfaces[].networkIP.notnull().list())EXTERNAL_IPz;networkInterfaces[].accessConfigs[0].natIP.notnull().list()zdisks[].sourceri   znetworkInterfaces[].networkinstanceTemplatesInstanceTemplate)r4  z!properties.scheduling.preemptible)CREATION_TIMESTAMPcreationTimestampmachineTypesMachineType)CPUS	guestCpus	MEMORY_GBnetworksNetwork)r   )MODEx_gcloud_mode)
IPV4_RANGE	IPv4Range)GATEWAY_IPV4gatewayIPv4projectsProject
operations	Operation)r   operationType)r   
targetLinkHTTP_STATUS)	TIMESTAMP
insertTimerM  invalidationsregionBackendServices)r   r   r   r"   r   r   r   r   regionsRegionr=  F)rL   DISKS_GBDISKS_TOTAL_GB	ADDRESSESIN_USE_ADDRESSESRESERVED_ADDRESSESSTATIC_ADDRESSESr   TURNDOWN_DATEzzones[]routesRoute)
DEST_RANGE	destRangeNEXT_HOP)PRIORITYpriority	snapshotsSnapshot)r   )DISK_SIZE_GB
diskSizeGb)SRC_DISK
sourceDiskr   rh  r   subnetworks
Subnetwork)r   r   r   )RANGEipCidrRangetargetHttpProxiesTargetHttpProxy)URL_MAPurlMaprp  targetHttpsProxiesTargetHttpsProxySSL_CERTIFICATESzsslCertificates[]targetSslProxiesTargetSslProxy)PROXY_HEADERproxyHeader)SERVICEservicery  targetInstancesTargetInstance)r   r   )INSTANCEinstance)
NAT_POLICY	natPolicyr}  TargetPoolInstanceHealth
TargetPool)SESSION_AFFINITYsessionAffinity)BACKUP
backupPoolHEALTH_CHECKSr  zhealthChecks[]zinstances[]TargetVpnGateway)r   r   r   User)r   )OWNERownerr   Zone	VpnTunnel)r   r   )GATEWAYtargetVpnGateway)PEER_ADDRESSpeerIpr  Router)r   r   r   )targetPoolInstanceHealthtargetPoolstargetVpnGatewaysuserszones
vpnTunnelsrouters)r   r   r   r  affinityCookieTTLr"   r   r   r   r   r   r   r   
Commitment)r   )ENDSendTimestampr   r   commitmentsLOCATIONSCOPEr  r  r#  r&  r(  r+  r.  c                 J    U S:X  d  U S:X  a  [         $ SU ;   a  [        $ [        $ )aN  Get Specs for the given API version.

This currently always returns _SPECS_V1, but is left here for the future,
as a pattern for providing different specs for different versions.

Args:
  api_version: A string identifying the API version, e.g. 'v1'.

Returns:
  A map associating each message class name with an _InternalSpec object.
v1v2beta1alpha)	_SPECS_V1_SPECS_ALPHA_SPECS_BETA)api_versions    r   _GetSpecsForVersionr    s-     DK94	r   r   fieldsr   r   r   c                    [        U5      nX;  a  [        SU < SU< S35      eX0   n/ nUR                   H  u  pV[        U[        R
                  5      (       a)  UR                  U[        R                  " U5      45        MM  [        U5      (       a  UR                  XV45        Mq  [        SR                  U5      5      e   [        XR                  5      n[        [        U5      5      n[!        UUUUR"                  UR$                  S9$ )z+Returns a Spec for the given resource type."z"" not found in Specs for version "z5expected function or property in table_cols list: {0}r  )r  KeyErrorr   r   rz   string_typesr   r   PropertyGettercallable
ValueErrorr   getattrr   listr   r   r   r   )	resource_typemessage_classesr  specr   r   actionr   r  s	            r   GetSpecr     s    	[	)$
!;0 1 1 
	$*oold&#**++0??GHI	&		'Nt& & & /+B+BC-+M:;&	M#"22	
( (r   )T),__doc__collectionsapitools.base.protorpcliter   googlecloudsdk.api_lib.computer   r   r   rz   six.moves.http_clientr   r%   r)   r,   r0   r7   r?   rB   rP   rU   rW   r^   rf   rj   rv   r   r   r   r   r   r   r   
namedtuple_InternalSpecr   r   r   r  copyr  r  r  r   r  rO   r   r   <module>r     ss   ;  / 9 : < 
 $74
2
2
/(.,<6F ;)X &&
HJR	$
 ++,445
 R	  ='
 _))*++,
 !R	< m*
 23

=R	\ }+)$
  !=!=>

]R	N  6 '(D(DE
 "OR	b ]!
 334_))*_))*

 cR	D %
 _))*
 ER	^ %"67*+2356
 ,,-
 _R	~ }+ '),-
 ++,334
 R	^ m"N+*

 	_R	t M( 
 uR	H ,
IR	b -
cR	| 
=.
 }R	V m"' . 
 WR	p m*
 _))*SM
 qR	P ]1
 _))*o223!5!56

 !QR	v %345ML 	
 334O001*O,@,@A_))*	
 %wR	` -34@7	
 
aR	x M(!23.
 _))*
 yR	V	 $
 
W	R	n	 $o	R	B
 -&%$67 '
 ?778
 C
R	b
 ]&*67 '	
 ?778
 c
R	~
 ]+)$
  !=!=>
	

R	j }#\&U;<&64HI,'9dKL!,>@}%78	
 ,,-
 kR	N m""'-.$
 ,,-
 OR	l %
 ?778
 mR	H }$7
 IR	\ ='
 ,,-++,
 ]R	z ,!

 ++,
 
{R	R --!BC!
 !/"6"67++,
 SR	n ++"!BC	
 !/"6"67,,-
 oR	L }+
 --._))*
 MR	j !.5 '(D(DE
 ! !' 3$;<
 ?//0334O889++,	
 $ '-
 ,,-++,.  !

 	 ! }%78	
 ++,
   &
 ++,!5!568  #
 ,,-++,
 KR		j nn!.'	_%  
_99:" 2 +# 	M  !!.&	]#	$%  
 "  )6-	]#	$%2%1$	 
/../	_112 !)$ %(& 
MO
(r   