
    r                     r    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SK
Jr   " S	 S
\5      rg)z'Common classes and functions for zones.    )absolute_import)division)unicode_literals)request_helper)utils)
exceptions)
console_ioc                   *    \ rS rSrSrS rS rS rSrg)ZoneResourceFetcher   z5A (small) collection of utils for working with zones.c                     UR                   U l        UR                  U l        UR                   R                  U l        UR                  U l        g)ac  Instantiate ZoneResourceFetcher and embed all required data into it.

ZoneResourceFetcher is a class depending on "base_classes"
class layout (properties side-derived from one of base_class class). This
function can be used to avoid unfeasible inheritance and use composition
instead when refactoring away from base_classes into stateless style.

This constructor embeds following properties into ZoneResourceFetcher
instance:
 - compute
 - messages
 - http
 - batch_url

Example:
  compute_holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
  client = compute_holder.client

  zone_resource_fetcher = ZoneResourceFetcher(client)
    or
  zone_resource_fetcher = ZoneResourceFetcher(self.compute_client)
    to use in a class derived from some of base_classes

  zone_resource_fetcher.WarnForZonalCreation(...)

Args:
  compute_client: compute_holder.client
N)apitools_client_computemessages	_messageshttp_http	batch_url
_batch_url)selfcompute_clients     0lib/googlecloudsdk/api_lib/compute/zone_utils.py__init__ZoneResourceFetcher.__init__   s>    : #22DM#,,DN//44DJ$..DO    c           
         / n/ n[        5       nU H  nUR                  U;  d  M  UR                  UR                  5        UR                  U R                  R
                  SU R                  R                  UR                  UR                  S945        M     [        [        R                  " UU R                  U R                  US95      nU(       a  gU$ )zFetches zone resources.Get)projectzone)requestsr   r   errorsN)setr   addappendr   zonesr   ComputeZonesGetRequestr   listr   MakeRequestsr   r   )r   resource_refsr!   r    
zone_namesresource_refress          r   GetZonesZoneResourceFetcher.GetZones@   s    FHJ%			*	,|(()MMNN11$,,!&& 2 () 	* & ~**ZZ//	 C jr   c                    U R                  U5      nU(       d  g/ n/ nU H'  nUR                  (       d  M  UR                  U5        M)     U(       d  gU(       a  / n[        U5      S:X  a  SnOSnSR	                  US   US   US   5      n/ nU H  nUR                  R
                  (       aA  UR                  SR	                  UR                  UR                  R
                  5      5        M_  UR                  S	R	                  UR                  5      5        M     UR                  [        R                  " Xx5      5        S
R                  U5      n	[        R                  " U	S9(       d  [        R                  " S5      eg)z2Warns the user if a zone has upcoming deprecation.N   )zzone isz	this zonethe)z	zones arezthese zonestheirzn
WARNING: The following selected {0} deprecated. All resources in {1} will be deleted after {2} turndown date.r      z	[{0}] {1}z[{0}] )messagezCreation aborted by user.)r-   
deprecatedr$   lenformatdeletednamer   ConstructListjoinr	   PromptContinuer   AbortedError)
r   r)   r%   promptszones_with_deprecatedr   phrasestitleprintable_deprecated_zonesfinal_messages
             r   WarnForZonalCreation(ZoneResourceFetcher.WarnForZonalCreationZ   sG   MM-(EG	$$T*  !g	"	#q	(17% &,VGAJ
GAJ%O  $& '$??""
$
+
+[,@,@AEBI'-K L %
+
+GNN499,E
F ( nnU((KLHHW%M$$];##$?@@ <r   )r   r   r   r   N)	__name__
__module____qualname____firstlineno____doc__r   r-   rE   __static_attributes__ r   r   r   r      s    = /D4%Ar   r   N)rK   
__future__r   r   r   googlecloudsdk.api_lib.computer   r   "googlecloudsdk.command_lib.computer   googlecloudsdk.core.consoler	   objectr   rM   r   r   <module>rS      s/    . &  ' 9 0 9 2dA& dAr   