
                            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 rS r\	R*                  \	R,                  " \	R.                  R0                  \	R.                  R2                  \	R.                  R4                  5       " S S\	R6                  5      5       5       rg)z6gcloud service-extensions wasm-plugins create command.    )absolute_import)division)unicode_literalsN)wasm_plugin_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/create.py_GetLogConfigr       s-     
__			4??1-{	;;    c                 @    U R                   =(       d    U R                  $ )N)plugin_configplugin_config_file)r   s    r   GetPluginConfigDatar   2   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	)
Create6   zCreate a `WasmPlugin` resource.z4          Create a new `WasmPlugin` resource.
      a	            To create a `WasmPlugin` called `my-plugin`, together with a new
          version called `v1`, and set it as main, run:

          $ {command} my-plugin --main-version=v1
          --image=...-docker.pkg.dev/my-project/repository/container:tag
          )DESCRIPTIONEXAMPLESc                 d   [         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  g )Nz.The ID of the `WasmPlugin` resource to create.)parserr   messagezID of the `WasmPluginVersion` resource that will be created for that `WasmPlugin` and that will be set as the current main version.)r   version_message)r
   GetApiVersionReleaseTrackr	   AddWasmPluginResourcer   
ASYNC_FLAGAddToParserr   AddCreateLabelsFlagsAddDescriptionFlagAddLogConfigFlagAddWasmPluginVersionArgs)clsr   r   s      r   ArgsCreate.ArgsJ   s    $$S%5%5%78K	@ 	OO'$$V,	V$	6/	""r   c           
      F   [         R                  " U R                  5       5      nUR                  c  [        R
                  " SS5      eUR                  (       d  [        R
                  " SS5      eUR                  c  [        R
                  " SS5      e[        R                  " U R                  5       5      nUR                  R                  R                  5       n[        R                  " XR                  R                  R                   5      n[#        X5      nUR%                  UR                  UR                  ['        U5      UR(                  5      nUR+                  UR-                  5       R/                  5       UR1                  5       UR2                  UUUR                  US9n[4        R6                  R9                  SR;                  UR1                  5       5      5        UR<                  (       a:  [4        R6                  R9                  SR;                  UR>                  5      5        U$ URA                  US	R;                  UR>                  5      S
9n	[4        R6                  R9                  SR;                  UR1                  5       UR                  5      5        U	$ )Nz--main-versionz!Flag --main-version is mandatory.z$Flag --main-version cannot be empty.z--imagezFlag --image is mandatory.)parentnamedescriptionlabelsr   main_versionversionszCreate request issued for: [{}]z Check operation [{}] for status.z&Waiting for operation [{}] to complete)operation_refr    z4Created WasmPlugin [{}] with WasmPluginVersion [{}].)!r
   r"   r#   r3   calliope_exceptionsRequiredArgumentExceptionimager   ClientCONCEPTSwasm_pluginParser   ParseCreateArgsmessages
WasmPluginLabelsValuer   %PrepareVersionDetailsForSingleVersionr   plugin_config_uriCreateWasmPluginParentRelativeNameNamer1   r   statusPrintformatasync_r0   WaitForOperation)
selfr   r   	wp_clientwasm_plugin_refr2   r   r4   op_refresults
             r   Run
Create.Runa   s3   $$T%6%6%89K 99
?  99
B  zz99
1   &&t'8'8':;Imm//557O((  ++77F t1J>>

D!	H ''%%'446!!#$$&& ( F JJ)001E1E1GH {{	jj9@@MNm''8??L ( F
 JJ>EE  "D$5$5	
 Mr    N)__name__
__module____qualname____firstlineno____doc__textwrapdedentdetailed_helpclassmethodr,   rQ   __static_attributes__rS   r   r   r   r   6   sM    
 ( __ &
  // # 	-  ,:r   r   )rX   
__future__r   r   r   rY   )googlecloudsdk.api_lib.service_extensionsr   googlecloudsdk.callioper   r   r6   -googlecloudsdk.command_lib.service_extensionsr	   r
   $googlecloudsdk.command_lib.util.argsr   googlecloudsdk.corer   r   r   DefaultUniverseOnlyReleaseTracksr#   ALPHABETAGACreateCommandr   rS   r   r   <module>rj      s    = &  '  E ( E ? > < #<$7 T..33T5F5F5I5IaT a ar   