
    r                         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 dZd Zd Zd Zd Zd Zd Zd Zd Zy)z%Utils for Config Controller commands.    )absolute_import)division)unicode_literals)api_adapter)util)apis)concepts)concept_parsers)logzNConfig Controller {0} is not running. The kubernetes API may not be available.c                       y)z.Sets default location to '-' for list command.- r       @lib/googlecloudsdk/command_lib/anthos/config/controller/utils.pySetLocationr       s    	r   c                  0    t        j                  dd      S )Nnamez+The name of the Config Controller instance.r   	help_textr	    ResourceParameterAttributeConfigr   r   r   InstanceAttributeConfigr   %   s    		2	2=
? ?r   c                  0    t        j                  dd      S )Nlocationa  The name of the Config Controller instance location. Currently, only ``us-central1'', ``us-east1'', ``us-east4'', ``us-east5'', ``us-west2'', ``northamerica-northeast1'', ``northamerica-northeast2'', ``europe-north1'', ``europe-west1'', ``europe-west3'', ``europe-west6'', ``australia-southeast1'', ``australia-southeast2'', ``asia-northeast1'', ``asia-northeast2'' and ``asia-southeast1'' are supported.r   r   r   r   r   LocationAttributeConfigr   +   s    		2	24
 r   c           	      v    t        j                  dd| t               t               t         j                  d      S )Nz,krmapihosting.projects.locations.krmApiHostsinstanceF)resource_nameapi_versionkrmApiHostsIdlocationsId
projectsIddisable_auto_completers)r	   ResourceSpecr   r    DEFAULT_PROJECT_ATTRIBUTE_CONFIG)r   s    r   GetInstanceResourceSpecr&   :   s6    			4+-)+::#
% %r   c                 z    t         j                  j                  dt        |      dd      j	                  |        y )Nr   z0The identifier for a Config Controller instance.T)required)r
   ConceptParserForResourcer&   AddToParser)parserr   s     r   AddInstanceResourceArgr-   E   s8    ++k*8	 ,  ![(r   c                 R   d| z   }|}d}t        j                  d      }t        j                  j	                  d       |j                  |||      }|j                  |      }|j                  |      s2t        j                  t        j                  |j                               ||fS )zLFetches the information about the GKE cluster backing the Config Controller.zkrmapihost-Nv1z(Fetching cluster endpoint and auth data.)container_api_adapterNewAPIAdapterr   statusPrintParseCluster
GetCluster	IsRunningwarningNOT_RUNNING_MSGformat	clusterId)r   r   
cluster_idlocation_idprojectgke_apicluster_refclusters           r   GetGKEClusterrA   M   s     t#*+'!//5'**=>$$ZgF+{+'			7	#KK&&{'<'<=>	+	r   c                     t         j                  j                  dj                  | j                  | j                               | S )z&Print log messages for async commands.z
      Check operation [{}] for status.
      To describe the operation, run:

        $ gcloud anthos config operations describe {})r   r2   r3   r9   r   )	operations    r   AsyncLogrD   _   s7    **9
 vinninn-/ 
r   c                    | j                   j                  j                         }t        j                  d|j                         j                        }t        j                  |j                               }g }|j                         }|j                  |j                               }| j                  r,|j                  d       | j                  |j                  _        |j"                  j$                  rF|j'                         }| j(                  r"| j(                  |_        |j                  d       ||_        nE|j-                         }| j(                  r"| j(                  |_        |j                  d       ||_        |j1                  ||      }	|j3                  |	|j                         dj5                  |            S )	z,Construct a patch request based on the args.krmapihosting)configControllerConfigz=bundles_config.config_controller_config.experimental_featuresz2management_config.full_management_config.man_blockz6management_config.standard_management_config.man_block)managementConfigbundlesConfig,)
krmApiHostr   
updateMask)CONCEPTSr   Parser   GetMessagesModuleGetCollectionInfor   r   GetKrmApiHostRelativeNameManagementConfigBundlesConfigConfigControllerConfigexperimental_featuresappendrG   experimentalFeaturesrH   fullManagementConfigFullManagementConfig	man_blockmanBlockStandardManagementConfigstandardManagementConfig
KrmApiHost5KrmapihostingProjectsLocationsKrmApiHostsPatchRequestjoin)
argsr   messagescurrentupdate_masksmanagement_configbundles_configfull_management_configstandard_management_configpatchs
             r   PatchRequestrk   k   s   ]]%%'(##O$,$>$>$@$L$LN(
 x4467' ,//1))%<<> * @.	GIAEA[A[N))>22%::<~~(,%NO-C*!)!B!B!D~~,0NN )
BD1K.


/@,:  <%		G	G  ",' 
H 
) )r   N)__doc__
__future__r   r   r    googlecloudsdk.api_lib.containerr   r0   $googlecloudsdk.api_lib.krmapihostingr   googlecloudsdk.api_lib.utilr    googlecloudsdk.calliope.conceptsr	   (googlecloudsdk.command_lib.util.conceptsr
   googlecloudsdk.corer   r8   r   r   r   r&   r-   rA   rD   rk   r   r   r   <module>rt      sT    , &  ' Q 5 , 5 D #>
?%)$	')r   