
                         X   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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>                  5       " S S\R@                  5      5       r!g)z6gcloud service-extensions wasm-actions create command.    )absolute_import)division)unicode_literalsN)apis)waiter)arg_parsers)base)concepts)flags)util)	yaml_data)labels_util)concept_parsers)presentation_specs)log)	resourcesc                  
    SS/$ )zYReturns the possible values of the --supported-events flag.

Returns:
  List of strings.
zrequest-headerszresponse-headers r       5lib/surface/service_extensions/wasm_actions/create.py#_GetPossibleValuesOfSupportedEventsr   &   s     /	00r   c                     UR                  5       R                  SS5      n[        U R                  R                  U5      (       d  [        SU-   5      e[        U R                  R                  U5      $ )an  Converts the text representation of an event to enum.

Args:
  messages: module containing the definitions of messages for the API.
  supported_event: string, for example 'request_headers'.

Returns:
  a value of messages.WasmAction.SupportedEventsValueListEntryValuesEnum,
  for example
  messages.WasmAction.SupportedEventsValueListEntryValuesEnum.REQUEST_HEADERS
-_zUnsupported value: )upperreplacehasattr
WasmAction'SupportedEventsValueListEntryValuesEnum
ValueErrorgetattr)messagessupported_eventuppercase_events      r   "_ConvertStringSupportedEventToEnumr%   /   sn     $))+33C=/	$$LL 
" 
" *_<
==	$$LL 
" "r   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	)
CreateG   zCreate a `WasmAction` resource.zS          Create a `WasmAction` resource that uses the specified plugin.
          a>            To create a `WasmAction` called `my-action` using the
          `my-plugin` plugin, run:

          $ {command} my-action --wasm-plugin=my-plugin

          You may also specify the full resource path to a plugin, for example,
          `projects/my-project/locations/global/wasmPlugins/my-plugin`
          )DESCRIPTIONEXAMPLESc                 v   [         R                  R                  S5      n[         R                  R                  S5      n[        R                  " [
        R                  " S[        R                  R                  UR                  5       [        R                  " U R                  5       5      S9SSS9[
        R                  " S[        R                  R                  UR                  5       [        R                  " U R                  5       5      S9S	S
S0SS9/SS/0S9R                  U5        UR                  S[         R"                  " [%        5       S9SS/ [&        R(                  " S5      S9  [*        R,                  R                  U5        [.        R0                  " U5        [2        R4                  " U5        g )Nzservice_extensions.wasmActionzservice_extensions.wasmPluginwasm_action)api_versionzThe ID of the `WasmAction`.T)requiredz--wasm-pluginz.ID of the `WasmPlugin` to use for this action.location )flag_name_overridesr.   z--wasm-plugin.locationzwasm_action.location)command_level_fallthroughsz--supported-events)choicesFEVENTzf          Specify the portion of the request/response payload to be processed by
          the plugin.)typer.   metavardefaulthelp)r   ResourceYAMLDataFromPathr   ConceptParserr   ResourcePresentationSpecr
   ResourceSpecFromYamlGetDatar   GetApiVersionReleaseTrackAddToParseradd_argumentr   ArgListr   textwrapdedentr	   
ASYNC_FLAGr   AddCreateLabelsFlagsr   AddDescriptionFlag)clsparserwasm_action_datawasm_plugin_datas       r   ArgsCreate.Args\   s    11::') 11::') !!77%%..$,,. $ 2 233C3C3E F / H . 77%%..$,,. $ 2 233C3C3E F / H A%/$4	
$ %'=&>$
%( ;v
  )L)NO__    	 	OO'$$V,	V$r   c                 l   [         R                  " U R                  5       5      n[        R                  " SU5      nUR
                  R                  R                  5       nUR
                  R                  R                  5       n[        R                  " XR                  R                  5      nUR                   Vs/ s H  n[        X75      PM     nnUR                  UR!                  5       R#                  5       UR%                  5       UR                  UR#                  5       UR&                  UUS9S9n	[        R(                  " SU5      n
U
R*                  R-                  U	5      n[.        R0                  R3                  SR5                  UR%                  5       5      5        UR6                  (       a:  [.        R0                  R3                  SR5                  UR8                  5      5        U$ [:        R<                  R?                  UR8                  SUS9n[@        RB                  " U
R*                  U
RD                  5      n[@        RF                  " XSR5                  UR8                  5      5      n[.        R0                  R3                  S	R5                  UR%                  5       5      5        U$ s  snf )
Nnetworkservices)
wasmPlugindescriptionlabelssupportedEvents)parentwasmActionId
wasmActionzCreate request issued for: [{}]z Check operation [{}] for status.z-networkservices.projects.locations.operations)
collectionr-   z&Waiting for operation [{}] to completezCreated WasmAction [{}].)$r   r@   rA   r   GetMessagesModuleCONCEPTSr,   Parsewasm_pluginr   ParseCreateArgsr   LabelsValuesupported_eventsr%   8NetworkservicesProjectsLocationsWasmActionsCreateRequestParentRelativeNameNamerS   GetClientInstanceprojects_locations_wasmActionsr'   r   statusPrintformatasync_namer   REGISTRYParseRelativeNamer   CloudOperationPollerprojects_locations_operationsWaitFor)selfargsr-   r"   wasm_action_refwasm_plugin_refrT   eventconverted_eventsrequestclientop_refop_resourcepollerresults                  r   Run
Create.Run   s;   $$T%6%6%89K%%&7EHmm//557Omm//557O((/B/B/N/NOF **,*E 	+8;*  , OO%%'446$))+&&&335((,	 ' 
 P 	G ##$5{CF2299'BFJJ6==  ! {{	jj9@@MNm $$66B 7 !K (()N)N)/)M)MOF^^077DFF JJ/667K7K7MNOMO,s   <J1r   N)__name__
__module____qualname____firstlineno____doc__rE   rF   detailed_helpclassmethodrN   r}   __static_attributes__r   r   r   r'   r'   G   sL    ' //   //  -" +% +%Z/r   r'   )"r   
__future__r   r   r   rE   googlecloudsdk.api_lib.utilr   r   googlecloudsdk.callioper   r	    googlecloudsdk.calliope.conceptsr
   -googlecloudsdk.command_lib.service_extensionsr   r   $googlecloudsdk.command_lib.util.apisr   $googlecloudsdk.command_lib.util.argsr   (googlecloudsdk.command_lib.util.conceptsr   r   googlecloudsdk.corer   r   r   r%   ReleaseTracksrA   ALPHACreateCommandr'   r   r   r   <module>r      s    = &  '  , . / ( 5 ? > : < D G # )1"0 D%%++,qT q -qr   