
    l                         S r SSKJr  SSKJr  SSKJr  SSS.r\R                  \R                  \R                  " \R                  R                  5       " S S	\R                  5      5       5       5       r\\l        g
)z''logging saved_queries create' command.    )util)base)logz#
        Create a saved query.
    z
     To create a saved query in a project, run:

        $ {command} --id=my-saved-query --location=global --display-name="My saved query" --visibility=private --sql-query-text="SELECT * FROM my_table"
    )DESCRIPTIONEXAMPLESc                   .    \ rS rSrSr\S 5       rS rSrg)Create'   zCreate a Logging saved query.c                    U R                  SSS9  U R                  SSS9  U R                  SSSS	9  U R                  S
SSS/SS9  [        R                  " U S5        [        R                  " U SS5        U R	                  SSS9nUR                  SSS9  UR	                  5       nUR                  SSS9  UR                  SSS9  UR	                  SS9nUR                  SSS9  UR                  SSS9  g)z Register flags for this command.z--idz ID of the saved query to create.)helpz--descriptionz*A textual description for the saved query.z--display-nameTz!Display name for the saved query.)requiredr   z--visibilityprivatesharedzVisibility of the saved query.)r   choicesr   zsaved query to createz&Location to create the saved query in.)mutexr   z--sql-query-textzSQL query text.z--filterz*Filter expression for the log-based query.z--summary-fieldszComma-separated list of fields to include in the summary. This flag must be specified if --summary-field-start or --summary-field-end are provided.)r   z--summary-field-startzSetting for number of characters to display for each summary field: characters will be counted from the start of the string. Requires the --summary-fields flag to be specified as well.z--summary-field-endzSetting for number of characters to display for each summary field: characters will be counted from the end of the string. Requires the --summary-fields flag to be specified as well.N)add_argumentr   AddParentArgsAddBucketLocationArg	add_group)parserquery_grouplog_query_groupsummary_field_groups       +lib/surface/logging/saved_queries/create.pyArgsCreate.Args-   s^    %GH
J   0  
 H%-	   	v67> """=K/6GH!++-O  E !    1 !  *33$3?$$K %  $$K %     c                 z   [         R                  " 5       n0 nUR                  (       a  UR                  US'   UR                  (       a  UR                  US'   UR                  (       a6  UR
                  R                  UR                  R                  5       5      US'   UR                  (       a  UR                  UR                  S9US'   O0 nUR                  (       a  UR                  US'   UR                  (       a<  UR                  R                  S5       Vs/ s H  nUR                  US9PM     snUS	'   UR                  (       a  UR                  US
'   UR                  (       a  UR                  US'   U(       a  UR                   " S0 UD6US'   [         R"                  " 5       nUR$                  R'                  UR)                  [         R*                  " U5      S-   UR,                  -   UR.                  UR
                  " S0 UD6S95      n[0        R2                  " UR4                  S5        U$ s  snf )zCreates a new saved query.

Args:
  args: An argparse namespace. All the arguments that were provided to this
    command invocation.

Returns:
  Saved query creation operation.
descriptiondisplayName
visibility)sqlQueryTextopsAnalyticsQueryfilter,)fieldsummaryFieldssummaryFieldStartsummaryFieldEndloggingQueryz/locations/)parentsavedQueryId
savedQueryzsaved query )r   GetMessagesr   display_namer!   
SavedQueryVisibilityValueValuesEnumuppersql_query_textOpsAnalyticsQueryr$   summary_fieldssplitSummaryFieldsummary_field_startsummary_field_endLoggingQuery	GetClientprojects_locations_savedQueriesr	   1LoggingProjectsLocationsSavedQueriesCreateRequestGetParentFromArgslocationidr   CreatedResourcename)selfargsmessagessaved_query_datalogging_query_datar&   clientcreated_resources           r   Run
Create.Rund   s    !H(,(8(8}%(,(9(9}%



7
78M8M8O
P |$ .6.H.H** /I /*+ 	'+{{8$			 ,,2237/
7 !!!.7/
?+ 
	!	!262J2J./			040F0F,-	+3+@+@ ,
 ,
( ^^F==DDBB))$/-?$--O**>-=> 	C 	
 (--}=//
s   H8r.   N)	__name__
__module____qualname____firstlineno____doc__staticmethodr   rK   __static_attributes__r.   r   r   r	   r	   '   s     &4 4l5r   r	   N)rQ   googlecloudsdk.api_lib.loggingr   googlecloudsdk.callioper   googlecloudsdk.corer   DETAILED_HELPHiddenDefaultUniverseOnlyReleaseTracksReleaseTrackGACreateCommandr	   detailed_helpr.   r   r   <module>r_      s     . 0 ( #	
	  D%%(()oT o *  od % r   