o
    gZhIp                     @   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                   @   sr  e Zd Ze ddddddddddedej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	 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ddddddddddejejeejf  deje deje	 deje	 deje	 deje	 dejej
ejej
def  ej
def f  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 deje deje	 deje	 dejej
d ef  d!eje	 d"ejeje  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ddddddddddddddddddddddddddddddddddddddddddddddddddddddd,Bded-ejejeejeejf f  d.ejejeejeejf f  deje	 deje	 d/eje	 d0eje d1eje deje	 d2ejejeejf  d3ejej
d4ef  d5eje d6ejejejeejf   deje	 dejej
ejej
def  ej
def f  d7eje	 d8ejejeejf  d9ejejejeejf   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je	 d;ejejejeef   d<eje	 deje d=eje 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 dAeje deje	 dBeje	 dCeje dDejejeejf  dEeje	 dFejej
ejeejf ejejeejf  f  deje	 dGeje dHejejeejeejf f  dIejejeejeejf f  dJejej
d
def  dKejejej
de	eeeejf   dejej
d ef  dLeje	 dMeje dNejejeejf  dOejej
ejej
eejeejf f  ej
eejeejf f f  d&ejej
e	ejeejf f  d'ejej
eeje f  d(ejej
eeje f  dPejeje  dQejej
eeje f  dRejejeejf  dSeje dTejej
dUef  dVeje dWeje dXeje d	eje dYeje	 dZejej
e	ef  d!eje	 d[eje	 d"ejeje  deej fd\d]ZdS )^FleetClientN)checkpointserror_tracefilter_pathhumanprettytimeoutwait_for_advancewait_for_indexindexr	   r
   r   r   r   r   zt.Literal[-1]zt.Literal[0]r   r   returnc       	         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 )a  
        Returns the current global checkpoints for an index. This API is design for internal
        use by the fleet server project.

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

        :param index: A single index or index alias that resolves to a single index.
        :param checkpoints: A comma separated list of previous global checkpoints. When
            used in combination with `wait_for_advance`, the API will only return once
            the global checkpoints advances past the checkpoints. Providing an empty
            list will cause Elasticsearch to immediately return the current global checkpoints.
        :param timeout: Period to wait for a global checkpoints to advance past `checkpoints`.
        :param wait_for_advance: A boolean value which controls whether to wait (until
            the timeout) for the global checkpoints to advance past the provided `checkpoints`.
        :param wait_for_index: A boolean value which controls whether to wait (until
            the timeout) for the target index to exist and all primary shards be active.
            Can only be true when `wait_for_advance` is true.
        (Empty value passed for parameter 'index'/z/_fleet/global_checkpointsNr	   r
   r   r   r   r   r   r   acceptapplication/jsonGET)paramsheaders)r   
ValueErrorr   perform_request)selfr   r	   r
   r   r   r   r   r   r   _FleetClient__path_FleetClient__query_FleetClient__headers r    W/var/www/html/lang_env/lib/python3.10/site-packages/elasticsearch/_sync/client/fleet.pyglobal_checkpoints   s0    zFleetClient.global_checkpointssearches)Z	body_name)r   allow_no_indicesallow_partial_search_resultsccs_minimize_roundtripsr
   expand_wildcardsr   r   ignore_throttledignore_unavailablemax_concurrent_searchesmax_concurrent_shard_requestspre_filter_shard_sizer   rest_total_hits_as_intsearch_type
typed_keyswait_for_checkpointsr$   r%   r&   r'   z4t.Literal['all', 'closed', 'hidden', 'none', 'open']r(   r)   r*   r+   r,   r-   r.   z5t.Literal['dfs_query_then_fetch', 'query_then_fetch']r/   r0   c                C   sd  |du rt d|tvrdt| d}nd}i }|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urQ|	|d< |
durY|
|d< |dura||d< |duri||d< |durq||d< |dury||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 )af  
        Multi Search API where the search will only be executed after specified checkpoints
        are available due to a refresh. This API is designed for internal use by the
        fleet server project.

        :param searches:
        :param index: A single target to search. If the target is an index alias, it
            must resolve to a single index.
        :param allow_no_indices: If false, the request returns an error if any wildcard
            expression, index alias, or _all value targets only missing or closed indices.
            This behavior applies even if the request targets other open indices. For
            example, a request targeting foo*,bar* returns an error if an index starts
            with foo but no index starts with bar.
        :param allow_partial_search_results: If true, returns partial results if there
            are shard request timeouts or [shard failures](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-replication.html#shard-failures).
            If false, returns an error with no partial results. Defaults to the configured
            cluster setting `search.default_allow_partial_results` which is true by default.
        :param ccs_minimize_roundtrips: If true, network roundtrips between the coordinating
            node and remote clusters are minimized for cross-cluster search requests.
        :param expand_wildcards: Type of index that wildcard expressions can match. If
            the request can target data streams, this argument determines whether wildcard
            expressions match hidden data streams.
        :param ignore_throttled: If true, concrete, expanded or aliased indices are ignored
            when frozen.
        :param ignore_unavailable: If true, missing or closed indices are not included
            in the response.
        :param max_concurrent_searches: Maximum number of concurrent searches the multi
            search API can execute.
        :param max_concurrent_shard_requests: Maximum number of concurrent shard requests
            that each sub-search request executes per node.
        :param pre_filter_shard_size: Defines a threshold that enforces a pre-filter
            roundtrip to prefilter search shards based on query rewriting if the number
            of shards the search request expands to exceeds the threshold. This filter
            roundtrip can limit the number of shards significantly if for instance a
            shard can not match any documents based on its rewrite method i.e., if date
            filters are mandatory to match but the shard bounds and the query are disjoint.
        :param rest_total_hits_as_int: If true, hits.total are returned as an integer
            in the response. Defaults to false, which returns an object.
        :param search_type: Indicates whether global term and document frequencies should
            be used when scoring returned documents.
        :param typed_keys: Specifies whether aggregation and suggester names should be
            prefixed by their respective types in the response.
        :param wait_for_checkpoints: A comma separated list of checkpoints. When configured,
            the search API will only be executed on a shard after the relevant checkpoint
            has become visible for search. Defaults to an empty list which will cause
            Elasticsearch to immediately execute the search.
        Nz+Empty value passed for parameter 'searches'r   z/_fleet/_fleet_msearchr$   r%   r&   r
   r'   r   r   r(   r)   r*   r+   r,   r   r-   r.   r/   r0   r   zapplication/x-ndjson)r   content-typePOSTr   r   body)r   r   r   r   )r   r#   r   r$   r%   r&   r
   r'   r   r   r(   r)   r*   r+   r,   r   r-   r.   r/   r0   r   r   _FleetClient__bodyr   r    r    r!   msearchT   s^   R
zFleetClient.msearchTsourcesource_excludessource_includesfrom_)_source_source_excludes_source_includesfrom)Zbody_fieldsZparameter_aliases)Baggregationsaggsr$   r%   analyze_wildcardanalyzerbatched_reduce_sizer&   collapsedefault_operatordfdocvalue_fieldsr
   r'   explainextfieldsr   r:   	highlightr   r(   r)   indices_boostlenientr+   min_compatible_shard_node	min_scorepitpost_filterr,   
preferencer   profileqqueryrequest_cacherescorer-   routingruntime_mappingsscript_fieldsscrollsearch_afterr.   seq_no_primary_termsizeslicesortr7   r8   r9   statsstored_fieldssuggestsuggest_fieldsuggest_modesuggest_sizesuggest_textterminate_afterr   track_scorestrack_total_hitsr/   versionr0   r?   r@   rA   rB   rC   rD   rE   zt.Literal['and', 'or']rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   z)t.Literal['always', 'missing', 'popular']rf   rg   rh   ri   rj   rk   c       C   H      C   s.  |t v rtddt| d}Di }Ei }F|2dur@t|2tr!d|2v s:t|2ttfr@tdd |2D r@tdd |2D r@|2|Fd	< d}2|durH||Ed
< |durP||Ed< |durX||Fd< |dur`||Fd< |durh||Fd< |durp||Fd< |durx||Fd< |	dur|	|Fd< |
dur|
|Ed< |dur||Fd< |dur||Fd< |dur||Ed< |dur||Fd< |dur||Fd< |dur||Ed< |dur||Ed< |dur||Ed< |dur||Fd< |dur||Ed< |dur||Ed< |dur||Fd< |dur||Fd< |dur||Fd < |dur||Ed!< |dur
||Fd"< |dur||Fd#< |dur||Fd$< |dur%||Ed%< |dur.||Ed&< |dur7||Ed'< | dur@| |Fd(< |!durI|!|Fd)< |"durR|"|Fd*< |#dur[|#|Ed+< |$durd|$|Fd,< |%durm|%|Ed-< |&durv|&|Fd.< |'dur|'|Ed/< |(dur|(|Fd0< |)dur|)|Fd1< |*dur|*|Ed2< |+dur|+|Ed3< |,dur|,|Fd4< |-dur|-|Ed5< |.dur|.|Fd6< |/dur|/|Ed7< |0dur|0|Ed8< |1dur|1|Ed9< |2dur|2|Ed	< |3dur|3|Ed:< |4dur|4|Fd;< |5dur|5|Fd<< |6dur|6|Ed=< |7dur|7|Ed>< |8dur|8|Ed?< |9dur!|9|Fd@< |:dur*|:|FdA< |;dur3|;|FdB< |<dur<|<|FdC< |=durE|=|EdD< |>durN|>|EdE< |?durW|?|EdF< |@dur`|@|EdG< |Aduri|A|FdH< |Bdurr|B|EdI< |Cdur{|C|FdJ< |Esd}EdKdLi}G|EdurdL|GdM< | j	dN|D|F|G|EdOS )Pa  
        Search API where the search will only be executed after specified checkpoints
        are available due to a refresh. This API is designed for internal use by the
        fleet server project.

        :param index: A single target to search. If the target is an index alias, it
            must resolve to a single index.
        :param aggregations:
        :param aggs:
        :param allow_no_indices:
        :param allow_partial_search_results: If true, returns partial results if there
            are shard request timeouts or [shard failures](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-replication.html#shard-failures).
            If false, returns an error with no partial results. Defaults to the configured
            cluster setting `search.default_allow_partial_results` which is true by default.
        :param analyze_wildcard:
        :param analyzer:
        :param batched_reduce_size:
        :param ccs_minimize_roundtrips:
        :param collapse:
        :param default_operator:
        :param df:
        :param docvalue_fields: Array of wildcard (*) patterns. The request returns doc
            values for field names matching these patterns in the hits.fields property
            of the response.
        :param expand_wildcards:
        :param explain: If true, returns detailed information about score computation
            as part of a hit.
        :param ext: Configuration of search extensions defined by Elasticsearch plugins.
        :param fields: Array of wildcard (*) patterns. The request returns values for
            field names matching these patterns in the hits.fields property of the response.
        :param from_: Starting document offset. By default, you cannot page through more
            than 10,000 hits using the from and size parameters. To page through more
            hits, use the search_after parameter.
        :param highlight:
        :param ignore_throttled:
        :param ignore_unavailable:
        :param indices_boost: Boosts the _score of documents from specified indices.
        :param lenient:
        :param max_concurrent_shard_requests:
        :param min_compatible_shard_node:
        :param min_score: Minimum _score for matching documents. Documents with a lower
            _score are not included in the search results.
        :param pit: Limits the search to a point in time (PIT). If you provide a PIT,
            you cannot specify an <index> in the request path.
        :param post_filter:
        :param pre_filter_shard_size:
        :param preference:
        :param profile:
        :param q:
        :param query: Defines the search definition using the Query DSL.
        :param request_cache:
        :param rescore:
        :param rest_total_hits_as_int:
        :param routing:
        :param runtime_mappings: Defines one or more runtime fields in the search request.
            These fields take precedence over mapped fields with the same name.
        :param script_fields: Retrieve a script evaluation (based on different fields)
            for each hit.
        :param scroll:
        :param search_after:
        :param search_type:
        :param seq_no_primary_term: If true, returns sequence number and primary term
            of the last modification of each hit. See Optimistic concurrency control.
        :param size: The number of hits to return. By default, you cannot page through
            more than 10,000 hits using the from and size parameters. To page through
            more hits, use the search_after parameter.
        :param slice:
        :param sort:
        :param source: Indicates which source fields are returned for matching documents.
            These fields are returned in the hits._source property of the search response.
        :param source_excludes:
        :param source_includes:
        :param stats: Stats groups to associate with the search. Each group maintains
            a statistics aggregation for its associated searches. You can retrieve these
            stats using the indices stats API.
        :param stored_fields: List of stored fields to return as part of a hit. If no
            fields are specified, no stored fields are included in the response. If this
            field is specified, the _source parameter defaults to false. You can pass
            _source: true to return both source fields and stored fields in the search
            response.
        :param suggest:
        :param suggest_field: Specifies which field to use for suggestions.
        :param suggest_mode:
        :param suggest_size:
        :param suggest_text: The source text for which the suggestions should be returned.
        :param terminate_after: Maximum number of documents to collect for each shard.
            If a query reaches this limit, Elasticsearch terminates the query early.
            Elasticsearch collects documents before sorting. Defaults to 0, which does
            not terminate query execution early.
        :param timeout: Specifies the period of time to wait for a response from each
            shard. If no response is received before the timeout expires, the request
            fails and returns an error. Defaults to no timeout.
        :param track_scores: If true, calculate and return document scores, even if the
            scores are not used for sorting.
        :param track_total_hits: Number of hits matching the query to count accurately.
            If true, the exact number of hits is returned at the cost of some performance.
            If false, the response does not include the total number of hits matching
            the query. Defaults to 10,000 hits.
        :param typed_keys:
        :param version: If true, returns document version as part of a hit.
        :param wait_for_checkpoints: A comma separated list of checkpoints. When configured,
            the search API will only be executed on a shard after the relevant checkpoint
            has become visible for search. Defaults to an empty list which will cause
            Elasticsearch to immediately execute the search.
        r   r   z/_fleet/_fleet_searchN:c                 s   s    | ]}t |tV  qd S )N)
isinstancestr.0Z_xr    r    r!   	<genexpr>  s    z%FleetClient.search.<locals>.<genexpr>c                 s   s    | ]}d |v V  qdS )rl   Nr    ro   r    r    r!   rq     s    r`   r?   r@   r$   r%   rA   rB   rC   r&   rD   rE   rF   rG   r
   r'   rH   rI   rJ   r   r>   rK   r   r(   r)   rL   rM   r+   rN   rO   rP   rQ   r,   rR   r   rS   rT   rU   rV   rW   r-   rX   rY   rZ   r[   r\   r.   r]   r^   r_   r;   r<   r=   ra   rb   rc   rd   re   rf   rg   rh   r   ri   rj   r/   rk   r0   r   r   r1   r2   r3   )
r   r   r   rm   rn   listtupleallanyr   )Hr   r   r?   r@   r$   r%   rA   rB   rC   r&   rD   rE   rF   rG   r
   r'   rH   rI   rJ   r   r:   rK   r   r(   r)   rL   rM   r+   rN   rO   rP   rQ   r,   rR   r   rS   rT   rU   rV   rW   r-   rX   rY   rZ   r[   r\   r.   r]   r^   r_   r`   r7   r8   r9   ra   rb   rc   rd   re   rf   rg   rh   r   ri   rj   r/   rk   r0   r   r5   r   r   r    r    r!   search   s<   N












































zFleetClient.search)__name__
__module____qualname__r   rn   tOptionalSequenceintboolUnionr   Anyr"   Mappingr6   floatrv   r    r    r    r!   r      s   	
8	 	
 !"#$%&'()*+,-./0*345678;>?@AGHIJKLMNQRSTUVWXYZr   )typingrz   Zelastic_transportr   _baser   utilsr   r   r   r   r    r    r    r!   <module>   s
   