
    '                         S r SSKJr  SSKJr  SSKJ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Jr  SSKJr  SSKJr  SSKJr  S rS r\
R,                  \
R.                  " \
R0                  R2                  \
R0                  R4                  \
R0                  R6                  5       " S S\
R8                  5      5       5       rg)z6gcloud service-extensions wasm-plugins update command.    )absolute_import)division)unicode_literalsN)wasm_plugin_api)wasm_plugin_version_api)base)
exceptions)flags)util)labels_util)logc                 f    U R                   c  g[        R                  " U R                   S   U5      $ )aC  Converts the dict representation of the log_config to proto.

Args:
  args: args with log_level parsed ordered dict. If log-level flag is set,
    enable option should also be set.
  api_version: API version (e.g. v1apha1)

Returns:
  a value of messages.WasmPluginLogConfig or None,
  if log-level flag were not provided.
Nr   )
log_configr   GetLogConfig)argsapi_versions     5lib/surface/service_extensions/wasm_plugins/update.py_GetLogConfigr   !   s-     
__			4??1-{	;;    c                 @    U R                   =(       d    U R                  $ )N)plugin_configplugin_config_file)r   s    r   GetPluginConfigDatar   3   s    				6t666r   c                   x    \ rS rSrSr\R                  " S5      \R                  " S5      S.r\S 5       r	S r
Srg	)
Update7   zUpdate a `WasmPlugin` resource.a            Update an existing `WasmPlugin` resource and optionally create
          a `WasmPluginVersion` resource and set it as the main (serving) one.

          If `--image` is not specified:
              * the method only updates the `WasmPlugin` resource without
                creating a `WasmPluginVersion`.
              * the `--plugin-config***` flags are disallowed.
              * if `--main-version` is set, then the referenced
                `WasmPluginVersion` must already exist and it is set as the
                main (serving) one.

          If `--image` is specified:
              * the `--main-version` flag must also be specified.
              * the method updates the `WasmPlugin` resource and creates a new
                `WasmPluginVersion` with `--main-version` name and sets it as
                the main (serving) one.
              * the `--plugin-config***` flags are allowed.
              * the `--async` flag is disallowed.
      a            To update a `WasmPlugin` called `my-plugin`, run:

          $ {command} my-plugin --main-version=new-version
          --description="A new description." --labels=label1=value1

          To update a `WasmPlugin` called `my-plugin` and also create a new
          version called `v1` and set it as main:

          $ {command} my-plugin --main-version=v1
          --description="A new description." --labels=label1=value1
          --image=...-docker.pkg.dev/my-project/repository/container:tag
          )DESCRIPTIONEXAMPLESc                    [         R                  " U R                  5       5      n[        R                  " UUSS9  [
        R                  R                  U5        [        R                  " U5        [        R                  " U5        [        R                  " X5        [        R                  " USS9  UR                  R                  S5        g )Nz%The ID of the `WasmPlugin` to update.)parserr   messageap  
            The ID of the `WasmPluginVersion` that should be the currently
            serving one. The version referred to must be a child of this
            `WasmPlugin`.

            If the `--image` flag was also provided, the `WasmPluginVersion`
            will be created for that `WasmPlugin` and will be set as the
            current main version.
        )r    version_messageyaml)r   GetApiVersionReleaseTrackr
   AddWasmPluginResourcer   
ASYNC_FLAGAddToParserr   AddCreateLabelsFlagsAddDescriptionFlagAddLogConfigFlagAddWasmPluginVersionArgsdisplay_info	AddFormat)clsr    r   s      r   ArgsUpdate.Argsb   s    $$S%5%5%78K	7 	OO'$$V,	V$	6/	"" !!&)r   c           	         [         R                  " U R                  5       5      nS nUR                  b!  UR                  b  UR
                  (       d  SnOKUR                  c  SnO;UR                  c  [        R                  " SS5      e[        R                  " SS5      eUR                  S5      (       a(  UR                  (       d  [        R                  " SS5      eU(       d0  [        U5      c  UR                  b  [        R                  " S	S
5      eUR                  R                  R                  5       nUR                  nU(       a  [        R                   " U R                  5       5      nUR#                  UR%                  5       UUR                  [        U5      UR                  S9n[&        R(                  R+                  SR-                  U5      5        UR/                  USR-                  UR0                  5      S9n[&        R(                  R+                  SR-                  U5      5        [2        R                   " U R                  5       5      n	[4        R6                  " XR8                  R:                  R<                  5      n
[?        X5      n/ nUR                  S5      (       a  URA                  S5        UR                  S5      (       a  URA                  S5        UR                  S5      (       a  URA                  S5        UR                  S5      (       a  URA                  S5        U	RC                  UR%                  5       USRE                  [G        U5      5      URH                  U
US9n[&        R(                  R+                  SR-                  URK                  5       5      5        UR
                  (       a:  [&        R(                  R+                  SR-                  UR0                  5      5        U$ U	R/                  USR-                  UR0                  5      S9n[&        R(                  R+                  SR-                  URK                  5       5      5        U$ )NTFz--main-versionzGBoth flags --image and --main-version should be set or neither of them.z--asynczAIf --async flag is set, --image and --config flags can't be used.main_versionz$Flag --main-version cannot be empty.z>--plugin_config or --plugin_config_file or --plugin_config_urizUIf one of the flags is set, then --image and --main-version flags also should be set.)parentnameimageplugin_config_dataplugin_config_urizCreate request issued for: [{}]z&Waiting for operation [{}] to complete)operation_refr!   zCreated WasmPluginVersion [{}].descriptionlabelsr   	logConfigmainVersionId,)r5   r3   update_maskr:   r;   r   zUpdate request issued for: [{}]z Check operation [{}] for status.zUpdated WasmPlugin [{}].)&r   r$   r%   r3   r6   async_calliope_exceptionsRequiredArgumentExceptionConflictingArgumentsExceptionIsSpecifiedr   r8   CONCEPTSwasm_pluginParser   ClientCreateWasmPluginVersionRelativeNamer   statusPrintformatWaitForOperationr5   r   r   ParseCreateArgsmessages
WasmPluginLabelsValuer   appendUpdateWasmPluginjoinsortedr:   Name)selfr   r   %update_wasm_plugin_and_create_versionwasm_plugin_refr3   
wpv_clientop_ref_	wp_clientr;   r   r?   results                 r   Run
Update.Run   s   $$T%6%6%89K,0)%JJ".2+		.3+				"99
   ==

M 
 ''0A0A99

0  1
d
#
/##/!??L)
 	
 mm//557O$$L,*11$2C2C2EFj11 --/

06 22 2 f 
jj8??MN

%
%:AA&++N & a 
jj8??MN&&t'8'8':;I((  ++77F t1JK&&'!!"%%%'')''))+!HHVK01$$ ( F JJ)001E1E1GH {{	jj9@@MNm''8??L ( F
 JJ/667K7K7MNOMr    N)__name__
__module____qualname____firstlineno____doc__textwrapdedentdetailed_helpclassmethodr0   r`   __static_attributes__rb   r   r   r   r   7   sO    
 ( __ &
 ( // # +"-H * *:cr   r   )rg   
__future__r   r   r   rh   )googlecloudsdk.api_lib.service_extensionsr   r   googlecloudsdk.callioper   r	   rA   -googlecloudsdk.command_lib.service_extensionsr
   r   $googlecloudsdk.command_lib.util.argsr   googlecloudsdk.corer   r   r   DefaultUniverseOnlyReleaseTracksr%   ALPHABETAGAUpdateCommandr   rb   r   r   <module>ry      s    = &  '  E M ( E ? > < #<$7 T..33T5F5F5I5IhT h hr   