
    V                     6   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dZ ej                   ej"                  j$                  ej"                  j&                        ej(                   G d dej*                                      Zy)z2Command to update the specified Google API source.    )absolute_import)division)unicode_literals)google_api_sources)base)flags)labels_util)logz{description}a           To update the Google API source `my-google-api-source` in location `us-central1` with destination message bus `my-message-bus`, run:

          $ {command} my-google-api-source --location=us-central1 --destination-message-bus=my-message-bus

        To update the Google API source `my-google-api-source` in location `us-central1` with `INFO` level logging, run:

          $ {command} my-google-api-source --location=us-central1 --logging-config=INFO

        To update the Google API source `my-google-api-source` in location `us-central1` with a Cloud KMS CryptoKey, run:

          $ {command} my-google-api-source --location=us-central1 --crypto-key=projects/PROJECT_ID/locations/KMS_LOCATION/keyRings/KEYRING/cryptoKeys/KEY

        )DESCRIPTIONEXAMPLESc                   *    e Zd ZdZeZed        Zd Zy)Updatez%Update an Eventarc Google API source.c                    t        j                  |       t        j                  |d       t        j                  |d       t        j                  |d       t        j                  |       t        j                  j                  |       y )Nz,The logging config of the Google API source.T)
with_clear)
r   $AddUpdateGoogleApiSourceResourceArgsAddLoggingConfigArgAddWideScopeSubscriptionArgAddCryptoKeyArgr	   AddUpdateLabelsFlagsr   
ASYNC_FLAGAddToParser)clsparsers     1lib/surface/eventarc/google_api_sources/update.pyArgszUpdate.Args5   sf    	..v6	> 
%%f>	&T2$$V,OO'    c                    t        j                         }|j                  j                  j	                         }t        j                  dj                  |j                  |j                  |j                               |j                  |      }t        j                  j                  |      j                  |j!                         |j"                        }|j%                  |j'                  d      |j'                  d      |j'                  d      |j(                  |j*                  |j'                  d      |j'                  d      |j,                        }|j/                  ||j1                  ||j                  j2                  j	                         |j4                  |j6                  |j9                         |j'                  d      r|j:                  nd|j<                  	      |      }|j>                  r|S |jA                  |d
|      S )zRun the update command.z;Updating Google API source {} for project {} in location {}destination_message_buslogging_config
crypto_keyorganization_subscriptionproject_subscriptions)destinationr   r    clear_crypto_keylabelsr!   r"   clear_project_subscriptionsN)google_api_source_refdestination_refr   crypto_key_namer%   r!   r"   Updating)!r   GoogleApiSourceClientV1CONCEPTSgoogle_api_sourceParser
   debugformatgoogleApiSourcesId
projectsIdlocationsIdGetr	   DiffFromUpdateArgsApplyLabelsValueClassr%   BuildUpdateMaskIsSpecifiedr$   needs_updater&   PatchBuildGoogleApiSourcer   r   r    	GetOrNoner!   r"   async_WaitFor)selfargsclientr'   original_google_api_sourcelabels_update_resultupdate_mask	operations           r   Runz
Update.Run@   s   779F MM;;AACIIE	!44!,,!--

 "(,A!B&++::4@FF!#=#D#D (($$%>?''(89##L1..#00"&"2"23N"O"../FG$($D$D ) 	K ##"7 MMAAGGI.. OO'113 ;< '+&D&D"&"<"< 	$ 
	
 	I  {{>>)Z1FGGr   N)	__name__
__module____qualname____doc___DETAILED_HELPdetailed_helpclassmethodr   rH    r   r   r   r   .   s$     . -( (0Hr   r   N)rL   
__future__r   r   r   googlecloudsdk.api_lib.eventarcr   googlecloudsdk.callioper   #googlecloudsdk.command_lib.eventarcr   $googlecloudsdk.command_lib.util.argsr	   googlecloudsdk.corer
   rM   ReleaseTracksReleaseTrackBETAGADefaultUniverseOnlyUpdateCommandr   rP   r   r   <module>r]      s    9 &  ' > ( 5 < # #& D%%**D,=,=,@,@A@HT @H  B@Hr   