
                         j   S 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*                  " \R,                  R.                  \R,                  R0                  \R,                  R2                  5       " S S\R4                  5      5       5       rg)z6gcloud service-extensions wasm-plugins create command.    N)wasm_plugin_api)base)
exceptions)resource_args)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   0   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	)
Create4   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           	      ,   [         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                  5       [
        R                  R                  [
        R                  R                  4;   a  SS0n[        R                   " USSSUS	S
9  g 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_messagezkms-key--kms-key-name
WasmPluginzrThe 'Network Actions Service Agent' service account must hold permission 'Cloud KMS CryptoKey Encrypter/Decrypter'T)permission_infonameflag_overrideshidden)r   GetApiVersionReleaseTrackr   AddWasmPluginResourcer   
ASYNC_FLAGAddToParserr	   AddCreateLabelsFlagsAddDescriptionFlagAddLogConfigFlagAddWasmPluginVersionArgsALPHABETAkms_resource_argsAddKmsKeyResourceArg)clsr   r   kms_flag_overridess       r   ArgsCreate.ArgsH   s    $$S%5%5%78K	@ 	OO'$$V,	V$	6/	"" d//55t7H7H7M7MNN
% ,,

F  +
	 Or   c                    [         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S nU R                  5       [*        R                  R,                  [*        R                  R.                  4;   a`  UR0                  bS  UR                  R0                  R                  5       =n	(       a  U	R3                  5       nO[        R4                  " SS5      eUR7                  UR9                  5       R3                  5       UR;                  5       UR<                  UUUR                  UUS9n
[>        R@                  RC                  S	RE                  UR;                  5       5      5        URF                  (       a:  [>        R@                  RC                  S
RE                  U
RH                  5      5        U
$ URK                  U
SRE                  U
RH                  5      S9n[>        R@                  RC                  SRE                  UR;                  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.r    zFlag --kms-key-name must be a fully qualified resource name, or all of --kms-location, --kms-keyring, --kms-project must be specified.)parentr#   descriptionlabelsr   main_versionversionskms_key_namezCreate request issued for: [{}]z Check operation [{}] for status.z&Waiting for operation [{}] to complete)operation_refr   z4Created WasmPlugin [{}] with WasmPluginVersion [{}].)&r   r&   r'   r;   calliope_exceptionsRequiredArgumentExceptionimager   ClientCONCEPTSwasm_pluginParser	   ParseCreateArgsmessagesr!   LabelsValuer   %PrepareVersionDetailsForSingleVersionr   plugin_config_urir   r/   r0   r=   RelativeNameInvalidArgumentExceptionCreateWasmPluginParentNamer9   r
   statusPrintformatasync_r#   WaitForOperation)selfr   r   	wp_clientwasm_plugin_refr:   r   r<   r=   kms_refop_refresults               r   Run
Create.Runn   s   $$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 Lt00668I8I8N8NOO				&mm00668878 --/,#<<$  ''%%'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classmethodr5   r[   __static_attributes__r]   r   r   r   r   4   sO    
 ( __ &
  // # 	- # #JGr   r   )rb   rc   )googlecloudsdk.api_lib.service_extensionsr   googlecloudsdk.callioper   r   r?   googlecloudsdk.command_lib.kmsr   r1   -googlecloudsdk.command_lib.service_extensionsr   r   $googlecloudsdk.command_lib.util.argsr	   googlecloudsdk.corer
   r   r   DefaultUniverseOnlyReleaseTracksr'   r/   r0   GACreateCommandr   r]   r   r   <module>rr      s    =  E ( E M ? > < #<$7 T..33T5F5F5I5I}T } }r   