o
    gZh                     @   sH   d dl Zd dlmZ ddlmZ ddlmZmZm	Z	 G dd deZ
dS )    N)ObjectApiResponse   )NamespacedClient)SKIP_IN_PATH_quote_rewrite_parametersc                (   @   s  e Zd Ze dddddddddedeje deje dejejeej	e f  deje deje d	eje d
ejejddef  de
ej fddZeddiddddddddddd	dejejeej	e f  deje deje deje dejejeej	e f  deje deje d	eje deje de
ej fddZeddidddddddddddejeej	e f deje deje dejejeej	e f  deje deje d	eje deje d
ejejddef  de
ej fddZedddddddddddddddddddeje deje d ejejeejf  deje dejejeej	e f  d!ejejddef  deje d"ejejeejf  d#ejejeejf  d	eje d$ejejeejf  d%ejejeejf  d&ejejeejf  d'ejejeejf  d
ejejddef  de
ej f d(d)Zedd*d+id,ddddddddddddddd-ded ejeejf d&ejeejf d.eje deje deje dejejeej	e f  d!ejejddef  deje d"ejejeejf  d+ejejeejf  d#ejejeejf  d	eje d$ejejeejf  d%ejejeejf  d'ejejeejf  d
ejejddef  de
ej f$d/d0Ze dddddd1dedeje dejejeej	e f  deje deje d	eje de
ej fd2d3Ze dddddd4dedeje dejejeej	e f  deje d	eje d
ejejddef  de
ej fd5d6Zeddidddddddd7dedeje dejejeej	e f  deje deje d	eje d
ejejddef  de
ej fd8d9Ze dddddddddd:	dedeje deje dejejeej	e f  deje deje d	eje d
ejejddef  d;eje d<eje de
ej fd=d>Zedd*d+id,ddddddddddddddd?ded.eje deje d ejejeejf  deje dejejeej	e f  d!ejejddef  deje d+ejejeejf  d	eje d$ejejdejeejf f  d%ejejeejf  d&ejejeejf  d'ejejeejf  d
ejejddef  de
ej f d@dAZe dddddddBdCeje deje dejejeej	e f  deje d	eje d
ejejddef  de
ej fdDdEZdS )FTransformClientN)delete_dest_indexerror_tracefilter_pathforcehumanprettytimeouttransform_idr	   r
   r   r   r   r   r   zt.Literal[-1]zt.Literal[0]returnc                C   s   |t v rtddt| }	i }
|dur||
d< |dur!||
d< |dur)||
d< |dur1||
d< |dur9||
d< |durA||
d	< |durI||
d
< ddi}| jd|	|
|dS )a  
        Deletes an existing transform.

        `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/delete-transform.html>`_

        :param transform_id: Identifier for the transform.
        :param delete_dest_index: If this value is true, the destination index is deleted
            together with the transform. If false, the destination index will not be
            deleted
        :param force: If this value is false, the transform must be stopped before it
            can be deleted. If true, the transform is deleted regardless of its current
            state.
        :param timeout: Period to wait for a response. If no response is received before
            the timeout expires, the request fails and returns an error.
        /Empty value passed for parameter 'transform_id'/_transform/Nr	   r
   r   r   r   r   r   acceptapplication/jsonDELETEparamsheadersr   
ValueErrorr   perform_request)selfr   r	   r
   r   r   r   r   r   _TransformClient__path_TransformClient__query_TransformClient__headers r!   [/var/www/html/lang_env/lib/python3.10/site-packages/elasticsearch/_sync/client/transform.pydelete_transform   s,   z TransformClient.delete_transformfromfrom_)parameter_aliases)	r   allow_no_matchr
   exclude_generatedr   r%   r   r   sizer'   r(   r)   c       	         C   s   |t vrdt| }
nd}
i }|dur||d< |dur ||d< |dur(||d< |dur0||d< |dur8||d< |dur@||d	< |durH||d
< |	durP|	|d< ddi}| jd|
||dS )a  
        Retrieves configuration information for transforms.

        `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/get-transform.html>`_

        :param transform_id: Identifier for the transform. It can be a transform identifier
            or a wildcard expression. You can get information for all transforms by using
            `_all`, by specifying `*` as the `<transform_id>`, or by omitting the `<transform_id>`.
        :param allow_no_match: Specifies what to do when the request: 1. Contains wildcard
            expressions and there are no transforms that match. 2. Contains the _all
            string or no identifiers and there are no matches. 3. Contains wildcard expressions
            and there are only partial matches. If this parameter is false, the request
            returns a 404 status code when there are no matches or only partial matches.
        :param exclude_generated: Excludes fields that were automatically added when
            creating the transform. This allows the configuration to be in an acceptable
            format to be retrieved and then added to another cluster.
        :param from_: Skips the specified number of transforms.
        :param size: Specifies the maximum number of transforms to obtain.
        r   z/_transformNr'   r
   r(   r   r$   r   r   r)   r   r   GETr   r   r   r   )r   r   r'   r
   r(   r   r%   r   r   r)   r   r   r    r!   r!   r"   get_transformN   s0   #zTransformClient.get_transform)r'   r
   r   r%   r   r   r)   r   c       	         C   s   |t v rtddt| d}
i }|dur||d< |dur"||d< |dur*||d< |dur2||d< |dur:||d	< |durB||d
< |durJ||d< |	durR|	|d< ddi}| jd|
||dS )aH  
        Retrieves usage information for transforms.

        `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/get-transform-stats.html>`_

        :param transform_id: Identifier for the transform. It can be a transform identifier
            or a wildcard expression. You can get information for all transforms by using
            `_all`, by specifying `*` as the `<transform_id>`, or by omitting the `<transform_id>`.
        :param allow_no_match: Specifies what to do when the request: 1. Contains wildcard
            expressions and there are no transforms that match. 2. Contains the _all
            string or no identifiers and there are no matches. 3. Contains wildcard expressions
            and there are only partial matches. If this parameter is false, the request
            returns a 404 status code when there are no matches or only partial matches.
        :param from_: Skips the specified number of transforms.
        :param size: Specifies the maximum number of transforms to obtain.
        :param timeout: Controls the time to wait for the stats
        r   r   z/_statsNr'   r
   r   r$   r   r   r)   r   r   r   r*   r   r   )r   r   r'   r
   r   r%   r   r   r)   r   r   r   r    r!   r!   r"   get_transform_stats   s0   !z#TransformClient.get_transform_statsT)body_fields)r   descriptiondestr
   r   	frequencyr   latestpivotr   retention_policysettingssourcesyncr   r/   r0   r1   r2   r3   r4   r5   r6   r7   c                C   s:  |t vrdt| d}nd}i }i }|dur||d< |dur#||d< |dur+||d< |dur3||d< |dur;||d	< |durC||d
< |durK||d< |	durS|	|d< |
dur[|
|d< |durc||d< |durk||d< |durs||d< |dur{||d< |dur||d< |sd}ddi}|durd|d< | jd||||dS )ax  
        Previews a transform.

        `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/preview-transform.html>`_

        :param transform_id: Identifier for the transform to preview. If you specify
            this path parameter, you cannot provide transform configuration details in
            the request body.
        :param description: Free text description of the transform.
        :param dest: The destination for the transform.
        :param frequency: The interval between checks for changes in the source indices
            when the transform is running continuously. Also determines the retry interval
            in the event of transient failures while the transform is searching or indexing.
            The minimum value is 1s and the maximum is 1h.
        :param latest: The latest method transforms the data by finding the latest document
            for each unique key.
        :param pivot: The pivot method transforms the data by aggregating and grouping
            it. These objects define the group by fields and the aggregation to reduce
            the data.
        :param retention_policy: Defines a retention policy for the transform. Data that
            meets the defined criteria is deleted from the destination index.
        :param settings: Defines optional transform settings.
        :param source: The source of the data for the transform.
        :param sync: Defines the properties transforms require to run continuously.
        :param timeout: Period to wait for a response. If no response is received before
            the timeout expires, the request fails and returns an error.
        r   z	/_previewz/_transform/_previewNr/   r0   r
   r   r1   r   r2   r3   r   r4   r5   r6   r7   r   r   r   content-typePOSTr   r   bodyr+   )r   r   r/   r0   r
   r   r1   r   r2   r3   r   r4   r5   r6   r7   r   r   _TransformClient__bodyr   r    r!   r!   r"   preview_transform   sR   1
z!TransformClient.preview_transform_metameta)r.   r&   )defer_validationr/   r
   r   r1   r   r2   r?   r3   r   r4   r5   r7   r   r@   c                C   sd  |t v rtd|du rtd|du rtddt| }i }i }|dur+||d< |dur3||d< |dur;||d< |durC||d	< |durK||d
< |durS||d< |dur[||d< |	durc|	|d< |
durk|
|d< |durs||d< |dur{||d< |dur||d< |dur||d< |dur||d< |dur||d< |dur||d< ddd}| jd||||dS )a>	  
        Instantiates a transform.

        `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/put-transform.html>`_

        :param transform_id: Identifier for the transform. This identifier can contain
            lowercase alphanumeric characters (a-z and 0-9), hyphens, and underscores.
            It has a 64 character limit and must start and end with alphanumeric characters.
        :param dest: The destination for the transform.
        :param source: The source of the data for the transform.
        :param defer_validation: When the transform is created, a series of validations
            occur to ensure its success. For example, there is a check for the existence
            of the source indices and a check that the destination index is not part
            of the source index pattern. You can use this parameter to skip the checks,
            for example when the source index does not exist until after the transform
            is created. The validations are always run when you start the transform,
            however, with the exception of privilege checks.
        :param description: Free text description of the transform.
        :param frequency: The interval between checks for changes in the source indices
            when the transform is running continuously. Also determines the retry interval
            in the event of transient failures while the transform is searching or indexing.
            The minimum value is `1s` and the maximum is `1h`.
        :param latest: The latest method transforms the data by finding the latest document
            for each unique key.
        :param meta: Defines optional transform metadata.
        :param pivot: The pivot method transforms the data by aggregating and grouping
            it. These objects define the group by fields and the aggregation to reduce
            the data.
        :param retention_policy: Defines a retention policy for the transform. Data that
            meets the defined criteria is deleted from the destination index.
        :param settings: Defines optional transform settings.
        :param sync: Defines the properties transforms require to run continuously.
        :param timeout: Period to wait for a response. If no response is received before
            the timeout expires, the request fails and returns an error.
        r   Nz'Empty value passed for parameter 'dest'z)Empty value passed for parameter 'source'r   r0   r6   r@   r/   r
   r   r1   r   r2   r>   r3   r   r4   r5   r7   r   r   r   r8   PUTr:   r   )r   r   r0   r6   r@   r/   r
   r   r1   r   r2   r?   r3   r   r4   r5   r7   r   r   r<   r   r    r!   r!   r"   put_transform!  sZ   <

zTransformClient.put_transform)r
   r   r   r   r   c          
      C      |t v rtddt| d}i }|dur||d< |dur"||d< |dur*||d< |dur2||d< |dur:||d	< d
di}	| jd|||	dS )aa  
        Resets an existing transform.

        `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/reset-transform.html>`_

        :param transform_id: Identifier for the transform. This identifier can contain
            lowercase alphanumeric characters (a-z and 0-9), hyphens, and underscores.
            It has a 64 character limit and must start and end with alphanumeric characters.
        :param force: If this value is `true`, the transform is reset regardless of its
            current state. If it's `false`, the transform must be stopped before it can
            be reset.
        r   r   z/_resetNr
   r   r   r   r   r   r   r9   r   r   )
r   r   r
   r   r   r   r   r   r   r    r!   r!   r"   reset_transform  s$   zTransformClient.reset_transform)r
   r   r   r   r   c          
      C   rD   )a"  
        Schedules now a transform.

        `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/schedule-now-transform.html>`_

        :param transform_id: Identifier for the transform.
        :param timeout: Controls the time to wait for the scheduling to take place
        r   r   z/_schedule_nowNr
   r   r   r   r   r   r   r9   r   r   )
r   r   r
   r   r   r   r   r   r   r    r!   r!   r"   schedule_now_transform  s$   z&TransformClient.schedule_now_transform)r
   r   r%   r   r   r   c                C   s   |t v rtddt| d}i }	|dur||	d< |dur"||	d< |dur*||	d< |dur2||	d< |dur:||	d	< |durB||	d
< ddi}
| jd||	|
dS )a>  
        Starts one or more transforms.

        `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/start-transform.html>`_

        :param transform_id: Identifier for the transform.
        :param from_: Restricts the set of transformed entities to those changed after
            this time. Relative times like now-30d are supported. Only applicable for
            continuous transforms.
        :param timeout: Period to wait for a response. If no response is received before
            the timeout expires, the request fails and returns an error.
        r   r   z/_startNr
   r   r$   r   r   r   r   r   r9   r   r   )r   r   r
   r   r%   r   r   r   r   r   r    r!   r!   r"   start_transform  s(   zTransformClient.start_transform)	r'   r
   r   r   r   r   r   wait_for_checkpointwait_for_completionrH   rI   c       
         C   s   |t v rtddt| d}i }|dur||d< |dur"||d< |dur*||d< |dur2||d< |dur:||d	< |durB||d
< |durJ||d< |	durR|	|d< |
durZ|
|d< ddi}| jd|||dS )a7  
        Stops one or more transforms.

        `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/stop-transform.html>`_

        :param transform_id: Identifier for the transform. To stop multiple transforms,
            use a comma-separated list or a wildcard expression. To stop all transforms,
            use `_all` or `*` as the identifier.
        :param allow_no_match: Specifies what to do when the request: contains wildcard
            expressions and there are no transforms that match; contains the `_all` string
            or no identifiers and there are no matches; contains wildcard expressions
            and there are only partial matches. If it is true, the API returns a successful
            acknowledgement message when there are no matches. When there are only partial
            matches, the API stops the appropriate transforms. If it is false, the request
            returns a 404 status code when there are no matches or only partial matches.
        :param force: If it is true, the API forcefully stops the transforms.
        :param timeout: Period to wait for a response when `wait_for_completion` is `true`.
            If no response is received before the timeout expires, the request returns
            a timeout exception. However, the request continues processing and eventually
            moves the transform to a STOPPED state.
        :param wait_for_checkpoint: If it is true, the transform does not completely
            stop until the current checkpoint is completed. If it is false, the transform
            stops as soon as possible.
        :param wait_for_completion: If it is true, the API blocks until the indexer state
            completely stops. If it is false, the API returns immediately and the indexer
            is stopped asynchronously in the background.
        r   r   z/_stopNr'   r
   r   r   r   r   r   rH   rI   r   r   r9   r   r   )r   r   r'   r
   r   r   r   r   r   rH   rI   r   r   r    r!   r!   r"   stop_transform
  s4   *zTransformClient.stop_transform)r@   r/   r0   r
   r   r1   r   r?   r   r4   r5   r6   r7   r   c                C   s&  |t v rtddt| d}i }i }|dur||d< |dur$||d< |dur,||d< |dur4||d< |dur<||d	< |durD||d
< |durL||d< |	durT|	|d< |
dur\|
|d< |durd||d< |durl||d< |durt||d< |dur|||d< |dur||d< ddd}| jd||||dS )a  
        Updates certain properties of a transform.

        `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/update-transform.html>`_

        :param transform_id: Identifier for the transform.
        :param defer_validation: When true, deferrable validations are not run. This
            behavior may be desired if the source index does not exist until after the
            transform is created.
        :param description: Free text description of the transform.
        :param dest: The destination for the transform.
        :param frequency: The interval between checks for changes in the source indices
            when the transform is running continuously. Also determines the retry interval
            in the event of transient failures while the transform is searching or indexing.
            The minimum value is 1s and the maximum is 1h.
        :param meta: Defines optional transform metadata.
        :param retention_policy: Defines a retention policy for the transform. Data that
            meets the defined criteria is deleted from the destination index.
        :param settings: Defines optional transform settings.
        :param source: The source of the data for the transform.
        :param sync: Defines the properties transforms require to run continuously.
        :param timeout: Period to wait for a response. If no response is received before
            the timeout expires, the request fails and returns an error.
        r   r   z/_updateNr@   r/   r0   r
   r   r1   r   r>   r   r4   r5   r6   r7   r   r   rA   r9   r:   r   )r   r   r@   r/   r0   r
   r   r1   r   r?   r   r4   r5   r6   r7   r   r   r   r<   r    r!   r!   r"   update_transformO  sJ   /

z TransformClient.update_transform)dry_runr
   r   r   r   r   rL   c          
      C   s   d}i }|dur||d< |dur||d< |dur||d< |dur$||d< |dur,||d< |dur4||d< d	d
i}	| j d|||	dS )a  
        Upgrades all transforms.

        `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/upgrade-transforms.html>`_

        :param dry_run: When true, the request checks for updates but does not run them.
        :param timeout: Period to wait for a response. If no response is received before
            the timeout expires, the request fails and returns an error.
        z/_transform/_upgradeNrL   r
   r   r   r   r   r   r   r9   r   )r   )
r   rL   r
   r   r   r   r   r   r   r    r!   r!   r"   upgrade_transforms  s$   z"TransformClient.upgrade_transforms)__name__
__module____qualname__r   strtOptionalboolUnionSequencer   Anyr#   intr,   r-   Mappingr=   rC   rE   rF   rG   rJ   rK   rM   r!   r!   r!   r"   r      s   	
2	
:	
7	
Y
	
f	)	%	
,	
D	
Q	r   )typingrR   Zelastic_transportr   _baser   utilsr   r   r   r   r!   r!   r!   r"   <module>   s
   