@@ -1660,3 +1660,76 @@ def upgrade_job_snapshot(self, job_id, snapshot_id, params=None, headers=None):
16601660 params = params ,
16611661 headers = headers ,
16621662 )
1663+
1664+ @query_params (
1665+ "charset" ,
1666+ "column_names" ,
1667+ "delimiter" ,
1668+ "explain" ,
1669+ "format" ,
1670+ "grok_pattern" ,
1671+ "has_header_row" ,
1672+ "line_merge_size_limit" ,
1673+ "lines_to_sample" ,
1674+ "quote" ,
1675+ "should_trim_fields" ,
1676+ "timeout" ,
1677+ "timestamp_field" ,
1678+ "timestamp_format" ,
1679+ )
1680+ def find_file_structure (self , body , params = None , headers = None ):
1681+ """
1682+ Finds the structure of a text file. The text file must contain data that is
1683+ suitable to be ingested into Elasticsearch.
1684+
1685+ `<https://www.elastic.co/guide/en/elasticsearch/reference/7.12/find-structure.html>`_
1686+
1687+ .. warning::
1688+
1689+ This API is **experimental** so may include breaking changes
1690+ or be removed in a future version
1691+
1692+ :arg body: The contents of the file to be analyzed
1693+ :arg charset: Optional parameter to specify the character set of
1694+ the file
1695+ :arg column_names: Optional parameter containing a comma
1696+ separated list of the column names for a delimited file
1697+ :arg delimiter: Optional parameter to specify the delimiter
1698+ character for a delimited file - must be a single character
1699+ :arg explain: Whether to include a commentary on how the
1700+ structure was derived
1701+ :arg format: Optional parameter to specify the high level file
1702+ format Valid choices: ndjson, xml, delimited, semi_structured_text
1703+ :arg grok_pattern: Optional parameter to specify the Grok
1704+ pattern that should be used to extract fields from messages in a semi-
1705+ structured text file
1706+ :arg has_header_row: Optional parameter to specify whether a
1707+ delimited file includes the column names in its first row
1708+ :arg line_merge_size_limit: Maximum number of characters
1709+ permitted in a single message when lines are merged to create messages.
1710+ Default: 10000
1711+ :arg lines_to_sample: How many lines of the file should be
1712+ included in the analysis Default: 1000
1713+ :arg quote: Optional parameter to specify the quote character
1714+ for a delimited file - must be a single character
1715+ :arg should_trim_fields: Optional parameter to specify whether
1716+ the values between delimiters in a delimited file should have whitespace
1717+ trimmed from them
1718+ :arg timeout: Timeout after which the analysis will be aborted
1719+ Default: 25s
1720+ :arg timestamp_field: Optional parameter to specify the
1721+ timestamp field in the file
1722+ :arg timestamp_format: Optional parameter to specify the
1723+ timestamp format in the file - may be either a Joda or Java time format
1724+ """
1725+ if body in SKIP_IN_PATH :
1726+ raise ValueError ("Empty value passed for a required argument 'body'." )
1727+
1728+ body = _bulk_body (self .transport .serializer , body )
1729+ return self .transport .perform_request (
1730+ "POST" ,
1731+ "/_ml/find_file_structure" ,
1732+ params = params ,
1733+ headers = headers ,
1734+ body = body ,
1735+ )
0 commit comments