o
    gZh5                     @   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edeje dejejeej	e f  deje dejejdd	ef  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eje dejejeej	e f  deje d
eje de
ej f
ddZe dddddddd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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dddeje dejejeej	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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jdd	ef  dejejeejf  dejej	ejeejf   d
eje d ejej	ejeejf   dejejdd	ef  d!eje de
ej fd"d#Zedd$ddddddddd%deje d&ej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 d'ejejeejf  d
eje d(eje de
ej fd)d*ZdS )+IngestClientN)error_tracefilter_pathhumanmaster_timeoutprettytimeoutidr	   r
   r   r   zt.Literal[-1]zt.Literal[0]r   r   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
di}
| jd||	|
dS )a  
        Deletes a pipeline.

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

        :param id: Pipeline ID or wildcard expression of pipeline IDs used to limit the
            request. To delete all ingest pipelines in a cluster, use a value of `*`.
        :param master_timeout: Period to wait for a connection to the master node. If
            no response is received before the timeout expires, the request fails and
            returns an error.
        :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 'id'/_ingest/pipeline/Nr	   r
   r   r   r   r   acceptapplication/jsonDELETEparamsheadersr   
ValueErrorr   perform_request)selfr   r	   r
   r   r   r   r   _IngestClient__path_IngestClient__query_IngestClient__headers r    X/var/www/html/lang_env/lib/python3.10/site-packages/elasticsearch/_sync/client/ingest.pydelete_pipeline   s(   zIngestClient.delete_pipeline)r	   r
   r   r   c                C   b   d}i }|dur||d< |dur||d< |dur||d< |dur$||d< ddi}| j d	|||d
S )z
        Returns statistical information about geoip databases

        `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/geoip-processor.html>`_
        z/_ingest/geoip/statsNr	   r
   r   r   r   r   GETr   r   r   r	   r
   r   r   r   r   r   r    r    r!   geo_ip_statsK      zIngestClient.geo_ip_stats)r   r	   r
   r   r   r   summaryr)   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
di}
| jd||	|
dS )a]  
        Returns a pipeline.

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

        :param id: Comma-separated list of pipeline IDs to retrieve. Wildcard (`*`) expressions
            are supported. To get all ingest pipelines, omit this parameter or use `*`.
        :param master_timeout: Period to wait for a connection to the master node. If
            no response is received before the timeout expires, the request fails and
            returns an error.
        :param summary: Return pipelines without their definitions (default: false)
        r   z/_ingest/pipelineNr	   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_pipelineh   s(   zIngestClient.get_pipelinec                C   r#   )z
        Returns a list of the built-in patterns.

        `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/grok-processor.html>`_
        z/_ingest/processor/grokNr	   r
   r   r   r   r   r$   r   r%   r&   r    r    r!   processor_grok   r(   zIngestClient.processor_grokT_metameta)body_fieldsZparameter_aliases)descriptionr	   r
   r   
if_versionr   r.   
on_failurer   
processorsr   versionr0   r1   r2   r3   r4   c                C   s  |t v rtddt| }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dd}| jd||||dS )a  
        Creates or updates a pipeline.

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

        :param id: ID of the ingest pipeline to create or update.
        :param description: Description of the ingest pipeline.
        :param if_version: Required version for optimistic concurrency control for pipeline
            updates
        :param master_timeout: Period to wait for a connection to the master node. If
            no response is received before the timeout expires, the request fails and
            returns an error.
        :param meta: Optional metadata about the ingest pipeline. May have any contents.
            This map is not automatically generated by Elasticsearch.
        :param on_failure: Processors to run immediately after a processor failure. Each
            processor supports a processor-level `on_failure` value. If a processor without
            an `on_failure` value fails, Elasticsearch uses this pipeline-level parameter
            as a fallback. The processors in this parameter run sequentially in the order
            specified. Elasticsearch will not attempt to run the pipeline's remaining
            processors.
        :param processors: Processors used to perform transformations on documents before
            indexing. Processors run sequentially in the order specified.
        :param timeout: Period to wait for a response. If no response is received before
            the timeout expires, the request fails and returns an error.
        :param version: Version number used by external systems to track ingest pipelines.
            This parameter is intended for external systems only. Elasticsearch does
            not use or validate pipeline version numbers.
        r   r   Nr0   r	   r
   r   r1   r   r-   r2   r   r3   r   r4   r   r   zcontent-typePUTr   r   bodyr   )r   r   r0   r	   r
   r   r1   r   r.   r2   r   r3   r   r4   r   _IngestClient__bodyr   r   r    r    r!   put_pipeline   sB   3

zIngestClient.put_pipeline)r/   )r   docsr	   r
   r   pipeliner   verboser;   r<   r=   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dd}| jd|	|||
dS )u  
        Allows to simulate a pipeline with example documents.

        `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/simulate-pipeline-api.html>`_

        :param id: Pipeline to test. If you don’t specify a `pipeline` in the request
            body, this parameter is required.
        :param docs: Sample documents to test in the pipeline.
        :param pipeline: Pipeline to test. If you don’t specify the `pipeline` request
            path parameter, this parameter is required. If you specify both this and
            the request path parameter, the API only uses the request path parameter.
        :param verbose: If `true`, the response includes output data for each processor
            in the executed pipeline.
        r   z
/_simulatez/_ingest/pipeline/_simulateNr;   r	   r
   r   r<   r   r=   r   r5   POSTr7   r*   )r   r   r;   r	   r
   r   r<   r   r=   r   r9   r   r   r    r    r!   simulate
  s.   

zIngestClient.simulate)__name__
__module____qualname__r   strtOptionalboolUnionSequencer   Anyr"   r'   r+   r,   intMappingr:   r?   r    r    r    r!   r      sF   
/
/	Q	
r   )typingrD   Zelastic_transportr   _baser   utilsr   r   r   r   r    r    r    r!   <module>   s
   