
    q                     @   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dlmZ ddlmZ d Zej(                   ej*                  ej,                  j.                         G d dej0                                      Zddde_        y)zCommand for updating hubs.    )absolute_import)division)unicode_literals)networkconnectivity_api)networkconnectivity_util)waiter)base)flags)labels_util)log)	resourcesc                    | j                  d      s#| j                  d      s| j                  d      sy|| j                  dfS | j                  )| j                  rd|_        d|fS d|_        d|_        d|fS | j                  | j                  |_        | j
                  | j
                  |_        |j                  xs |j                  }||fS )aX  UpdatedPscFields returns the updated PSC field values.

  This method uses the existing hub and the flags to determine the new values.

  Args:
    args: The arguments that the user specified.
    export_psc_config: The existing hub's exportPscConfig.

  Returns:
    A tuple of the updated exportPsc field and updated exportPscConfig field.
  
export_psc6export_psc_published_services_and_regional_google_apisexport_psc_global_google_apis)NNNTF)IsSpecifiedr   &publishedServicesAndRegionalGoogleApisglobalGoogleApisr   r   )argsexport_psc_configupdated_export_pscs      /lib/surface/network_connectivity/hubs/update.pyUpdatedPscFieldsr   !   s     |$			
B
 
		9	:
 ??D   
__ AE>$$$ @E<).&### 
@@LCC < 
''3)-)K)K&
 >> ,		+	+  
.	..    c                   &    e Zd ZdZed        Zd Zy)Updatez0Update a hub.

  Update the details of a hub.
  c                     t        j                  | d       t        j                  | d       t        j                  |        t        j                  |        t        j                  |        y )Nzto be updatedzNew description of the hub.)r
   AddHubResourceArgAddDescriptionFlagAddPscGroupAddAsyncFlagr   AddUpdateLabelsFlags)parsers    r   ArgszUpdate.Argsd   sM    	FO4	V%BC	f	v$$V,r   c                     t        j                  | j                               }|j                  j                  j                         }g }|j                  }||j                  d       |j                  |      }t        ||j                        \  }}|"|j                  d       |j                  d       d }	t        j                  j                  |      }
|
j                         rc|
j                  |j                   j"                  j$                  |j&                        }|j(                  r|j&                  }	|j                  d       |j                   j#                  ||||	      }|j+                  |||      }t,        j.                  j1                  dj3                  |j5                                      |j6                  r:t,        j.                  j1                  dj3                  |j8                               |S t:        j<                  j?                  |j8                  d	t@        jB                  | j                            
      }tE        jF                  |jH                  |jJ                        }|jL                  r6t-        jN                  |j5                         d       |jQ                  |      S tE        jR                  ||dj3                  |j8                        d      }t-        jN                  |j5                         d       |S )N)release_trackdescription	exportPscexportPscConfiglabels)r'   r(   r)   r*   zUpdate request issued for: [{}]z Check operation [{}] for status.z1networkconnectivity.projects.locations.operations)
collectionapi_versionhub)kindz&Waiting for operation [{}] to completei6 )max_wait_ms)*r   
HubsClientReleaseTrackCONCEPTSr-   Parser'   appendGetr   r)   r   DiffFromUpdateArgsMayHaveUpdatesApplymessages'GoogleCloudNetworkconnectivityV1betaHubLabelsValuer*   needs_updateUpdateHubBetar   statusPrintformatNameasync_namer   REGISTRYParseRelativeNamer   VERSION_MAPr   CloudOperationPollerhub_serviceoperation_servicedoneUpdatedResource	GetResultWaitFor)selfr   clienthub_refupdate_maskr'   original_hubr   updated_export_psc_configr*   labels_difflabels_updater-   op_refop_resourcepollerress                    r   Runz
Update.Runl   s   $//'')F mm%%'GK""K' ::g&L4Dl**511
 %%*+ F""11$7K!!#!''
//
A
A
M
M


m 
	#	#%%8$
//
A
A$1	 B C !!'3<FJJ6==gllnMN{{	jj9@@MNm$$66F,889J9J9LM 7 K
 ((F44F {{	',,.u5k**
..077D	C U3Jr   N)__name__
__module____qualname____doc__staticmethodr$   r[    r   r   r   r   \   s!    
 - -Cr   r   z   To update the description of a hub named ``my-hub'', run:

    $ {command} my-hub --description="The new description of my-hub".
  z   This command uses the networkconnectivity/v1beta API. The full documentation
  for this API can be found at:
  https://cloud.google.com/network-connectivity/docs/reference/networkconnectivity/rest
  )EXAMPLESzAPI REFERENCEN)r_   
__future__r   r   r   +googlecloudsdk.api_lib.network_connectivityr   r   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper	   /googlecloudsdk.command_lib.network_connectivityr
   $googlecloudsdk.command_lib.util.argsr   googlecloudsdk.corer   r   r   DefaultUniverseOnlyReleaseTracksr1   BETACommandr   detailed_helpra   r   r   <module>ro      s   " ! &  ' O P . ( A < # )8/v D%%**+QT\\ Q , Qj
 r   