3 ]ߋ@s,ddlmZmZmZmZGdddeZdS))NamespacedClient query_params _make_path SKIP_IN_PATHc@seZdZeddddddZedddZedd d Zedd d Zeddd dZedddZ edddZ edddddZ edddddZ edddZ edddddd d!d"d#d$dd%d& dd'd(Zed)d*d+d,d-dd.d/Zed0d1dd2d3Zed4d5d+d6d7d8d9d:d- dd;d<Zed+d8d=d9d-dd>d?Zed8d9dd@dAZed8d9ddBdCZedDddEdFZedDddGdHZed8d9ddIdJZed5d+d6d8dKd9d:d-ddLdMZedddNdOZedddPdQZed5d+d8d9d:d-ddRdSZeddTd+d6dUd-dVddWdXZed5d+d6d8dYd9d:d-ddZd[Zedd\d]Zedd^d_Zedd`daZ edbdcddddeZ!eddfdgZ"eddhdiZ#eddjdkZ$eddldmZ%eddndoZ&eddpdqZ'edrddsdtZ(edudddvdwZ)ed+d-dddxdyZ*edDddddzd{Z+edd|d}Z,edd~dZ-edddZ.edddZ/edddZ0edddZ1dS)MlClientZ allow_no_jobsforcetimeoutNcCs.|tkrtd|jjdtdd|d||dS)a4 ``_ :arg job_id: The name of the job to close :arg body: The URL params optionally sent in the body :arg allow_no_jobs: Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) :arg force: True if the job should be forcefully closed :arg timeout: Controls the time to wait until a job has closed. Default to 30 minutes z4Empty value passed for a required argument 'job_id'.POST_mlanomaly_detectors_close)paramsbody)r ValueError transportperform_requestr)selfjob_idrr rF/tmp/pip-build-z81i1n8o/elasticsearch/elasticsearch/client/xpack/ml.py close_jobs zMlClient.close_jobcCs*|tkrtd|jjdtdd||dS)zS `<>`_ :arg calendar_id: The ID of the calendar to delete z9Empty value passed for a required argument 'calendar_id'.DELETEr calendars)r )rrrrr)r calendar_idr rrrdelete_calendars zMlClient.delete_calendarcCs@x ||fD]}|tkr tdq W|jjdtdd|d||dS)z `<>`_ :arg calendar_id: The ID of the calendar to modify :arg event_id: The ID of the event to remove from the calendar z+Empty value passed for a required argument.rr revents)r )rrrrr)rrZevent_idr paramrrrdelete_calendar_event+s zMlClient.delete_calendar_eventcCs@x ||fD]}|tkr tdq W|jjdtdd|d||dS)z `<>`_ :arg calendar_id: The ID of the calendar to modify :arg job_id: The ID of the job to remove from the calendar z+Empty value passed for a required argument.rr rjobs)r )rrrrr)rrrr rrrrdelete_calendar_job<s zMlClient.delete_calendar_jobcCs*|tkrtd|jjdtdd||dS)z ``_ :arg datafeed_id: The ID of the datafeed to delete :arg force: True if the datafeed should be forcefully deleted z9Empty value passed for a required argument 'datafeed_id'.rr datafeeds)r )rrrrr)r datafeed_idr rrrdelete_datafeedMs zMlClient.delete_datafeedcCs|jjdd|dS)z `<>`_ rz/_ml/_delete_expired_data)r )rr)rr rrrdelete_expired_data]szMlClient.delete_expired_datacCs*|tkrtd|jjdtdd||dS)zO `<>`_ :arg filter_id: The ID of the filter to delete z7Empty value passed for a required argument 'filter_id'.rr filters)r )rrrrr)r filter_idr rrr delete_filterfszMlClient.delete_filterZallow_no_forecastscCs.|tkrtd|jjdtdd|d||dS)a  ``_ :arg job_id: The ID of the job from which to delete forecasts :arg forecast_id: The ID of the forecast to delete, can be comma delimited list. Leaving blank implies `_all` :arg allow_no_forecasts: Whether to ignore if `_all` matches no forecasts :arg timeout: Controls the time to wait until the forecast(s) are deleted. Default to 30 seconds z4Empty value passed for a required argument 'job_id'.rr r _forecast)r )rrrrr)rrZ forecast_idr rrrdelete_forecastss zMlClient.delete_forecastZwait_for_completioncCs*|tkrtd|jjdtdd||dS)ar ``_ :arg job_id: The ID of the job to delete :arg force: True if the job should be forcefully deleted, default False :arg wait_for_completion: Should this request wait until the operation has completed before returning, default True z4Empty value passed for a required argument 'job_id'.rr r )r )rrrrr)rrr rrr delete_jobs zMlClient.delete_jobcCs@x ||fD]}|tkr tdq W|jjdtdd|d||dS)z ``_ :arg job_id: The ID of the job to fetch :arg snapshot_id: The ID of the snapshot to delete z+Empty value passed for a required argument.rr r model_snapshots)r )rrrrr)rr snapshot_idr rrrrdelete_model_snapshots  zMlClient.delete_model_snapshotcharsetZ column_names delimiterZexplainformatZ grok_patternZhas_header_rowZlines_to_samplequoteZshould_trim_fieldsZtimestamp_fieldZtimestamp_formatcCs,|tkrtd|jjdd||jj|dS)a ``_ :arg body: The contents of the file to be analyzed :arg charset: Optional parameter to specify the character set of the file :arg column_names: Optional parameter containing a comma separated list of the column names for a delimited file :arg delimiter: Optional parameter to specify the delimiter character for a delimited file - must be a single character :arg explain: Whether to include a commentary on how the structure was derived, default False :arg format: Optional parameter to specify the high level file format, valid choices are: 'ndjson', 'xml', 'delimited', 'semi_structured_text' :arg grok_pattern: Optional parameter to specify the Grok pattern that should be used to extract fields from messages in a semi-structured text file :arg has_header_row: Optional parameter to specify whether a delimited file includes the column names in its first row :arg lines_to_sample: How many lines of the file should be included in the analysis, default 1000 :arg quote: Optional parameter to specify the quote character for a delimited file - must be a single character :arg should_trim_fields: Optional parameter to specify whether the values between delimiters in a delimited file should have whitespace trimmed from them :arg timeout: Timeout after which the analysis will be aborted, default '25s' :arg timestamp_field: Optional parameter to specify the timestamp field in the file :arg timestamp_format: Optional parameter to specify the timestamp format in the file - may be either a Joda or Java time format z2Empty value passed for a required argument 'body'.r z/_ml/find_file_structure)r r)rrrrclient _bulk_body)rrr rrrfind_file_structures2zMlClient.find_file_structureZ advance_timeZ calc_interimendZ skip_timestartcCs.|tkrtd|jjdtdd|d||dS)a| ``_ :arg job_id: The name of the job to flush :arg body: Flush parameters :arg advance_time: Advances time to the given value generating results and updating the model for the advanced interval :arg calc_interim: Calculates interim results for the most recent bucket or all buckets within the latency period :arg end: When used in conjunction with calc_interim, specifies the range of buckets on which to calculate interim results :arg skip_time: Skips time to the given value without generating results or updating the model for the skipped interval :arg start: When used in conjunction with calc_interim, specifies the range of buckets on which to calculate interim results z4Empty value passed for a required argument 'job_id'.r r r _flush)r r)rrrrr)rrrr rrr flush_jobs zMlClient.flush_jobdurationZ expires_incCs,|tkrtd|jjdtdd|d|dS)a `<>`_ :arg job_id: The ID of the job to forecast for :arg duration: The duration of the forecast :arg expires_in: The time interval after which the forecast expires. Expired forecasts will be deleted at the first opportunity. z4Empty value passed for a required argument 'job_id'.r r r r')r )rrrrr)rrr rrrforecasts  zMlClient.forecastZ anomaly_scoredescZexclude_interimexpandfrom_sizesortc Cs2|tkrtd|jjdtdd|dd|||dS)a ``_ :arg job_id: ID of the job to get bucket results from :arg timestamp: The timestamp of the desired single bucket result :arg body: Bucket selection details if not provided in URI :arg anomaly_score: Filter for the most anomalous buckets :arg desc: Set the sort direction :arg end: End time filter for buckets :arg exclude_interim: Exclude interim results :arg expand: Include anomaly records :arg from_: skips a number of buckets :arg size: specifies a max number of buckets to get :arg sort: Sort buckets by a particular field :arg start: Start time filter for buckets z4Empty value passed for a required argument 'job_id'.GETr r resultsZbuckets)r r)rrrrr)rr timestamprr rrr get_bucketsszMlClient.get_bucketsrcCs,|tkrtd|jjdtdd|d|dS)a `<>`_ :arg calendar_id: The ID of the calendar containing the events :arg end: Get events before this time :arg from_: Skips a number of events :arg job_id: Get events for the job. When this option is used calendar_id must be '_all' :arg size: Specifies a max number of events to get :arg start: Get events after this time z9Empty value passed for a required argument 'calendar_id'.r?r rr)r )rrrrr)rrr rrrget_calendar_events:s zMlClient.get_calendar_eventscCs|jjdtdd|||dS)a  `<>`_ :arg calendar_id: The ID of the calendar to fetch :arg body: The from and size parameters optionally sent in the body :arg from_: skips a number of calendars :arg size: specifies a max number of calendars to get r?r r)r r)rrr)rrrr rrr get_calendarsOs zMlClient.get_calendarsc Cs2|tkrtd|jjdtdd|dd|||dS)a ``_ :arg job_id: The name of the job :arg category_id: The identifier of the category definition of interest :arg body: Category selection details if not provided in URI :arg from_: skips a number of categories :arg size: specifies a max number of categories to get z4Empty value passed for a required argument 'job_id'.r?r r r@ categories)r r)rrrrr)rrZ category_idrr rrrget_categories]s zMlClient.get_categoriesZallow_no_datafeedscCs|jjdtdd|d|dS)as ``_ :arg datafeed_id: The ID of the datafeeds stats to fetch :arg allow_no_datafeeds: Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) r?r r _stats)r )rrr)rr!r rrrget_datafeed_statsss zMlClient.get_datafeed_statscCs|jjdtdd||dS)ag ``_ :arg datafeed_id: The ID of the datafeeds to fetch :arg allow_no_datafeeds: Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) r?r r )r )rrr)rr!r rrr get_datafeedss zMlClient.get_datafeedscCs|jjdtdd||dS)z `<>`_ :arg filter_id: The ID of the filter to fetch :arg from_: skips a number of filters :arg size: specifies a max number of filters to get r?r r$)r )rrr)rr%r rrr get_filterss zMlClient.get_filtersZinfluencer_scorecCs0|tkrtd|jjdtdd|dd||dS)a ``_ :arg job_id: None :arg body: Influencer selection criteria :arg desc: whether the results should be sorted in decending order :arg end: end timestamp for the requested influencers :arg exclude_interim: Exclude interim results :arg from_: skips a number of influencers :arg influencer_score: influencer score threshold for the requested influencers :arg size: specifies a max number of influencers to get :arg sort: sort field for the requested influencers :arg start: start timestamp for the requested influencers z4Empty value passed for a required argument 'job_id'.r?r r r@Z influencers)r r)rrrrr)rrrr rrrget_influencersszMlClient.get_influencerscCs|jjdtdd|d|dS)aU ``_ :arg job_id: The ID of the jobs stats to fetch :arg allow_no_jobs: Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) r?r r rG)r )rrr)rrr rrr get_job_statss  zMlClient.get_job_statscCs|jjdtdd||dS)aI ``_ :arg job_id: The ID of the jobs to fetch :arg allow_no_jobs: Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) r?r r )r )rrr)rrr rrrget_jobss zMlClient.get_jobscCs0|tkrtd|jjdtdd|d|||dS)a ``_ :arg job_id: The ID of the job to fetch :arg snapshot_id: The ID of the snapshot to fetch :arg body: Model snapshot selection criteria :arg desc: True if the results should be sorted in descending order :arg end: The filter 'end' query parameter :arg from_: Skips a number of documents :arg size: The default number of documents returned in queries as a string. :arg sort: Name of the field to sort on :arg start: The filter 'start' query parameter z4Empty value passed for a required argument 'job_id'.r?r r r*)r r)rrrrr)rrr+rr rrrget_model_snapshotss zMlClient.get_model_snapshotsZ bucket_spanZ overall_scoreZtop_ncCs0|tkrtd|jjdtdd|dd||dS)a ``_ :arg job_id: The job IDs for which to calculate overall bucket results :arg body: Overall bucket selection details if not provided in URI :arg allow_no_jobs: Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) :arg bucket_span: The span of the overall buckets. Defaults to the longest job bucket_span :arg end: Returns overall buckets with timestamps earlier than this time :arg exclude_interim: If true overall buckets that include interim buckets will be excluded :arg overall_score: Returns overall buckets with overall scores higher than this value :arg start: Returns overall buckets with timestamps after this time :arg top_n: The number of top job bucket scores to be used in the overall_score calculation z4Empty value passed for a required argument 'job_id'.r?r r r@Zoverall_buckets)r r)rrrrr)rrrr rrrget_overall_bucketss zMlClient.get_overall_bucketsZ record_scorecCs0|tkrtd|jjdtdd|dd||dS)a+ ``_ :arg job_id: None :arg body: Record selection criteria :arg desc: Set the sort direction :arg end: End time filter for records :arg exclude_interim: Exclude interim results :arg from_: skips a number of records :arg record_score: :arg size: specifies a max number of records to get :arg sort: Sort records by a particular field :arg start: Start time filter for records z4Empty value passed for a required argument 'job_id'.r?r r r@records)r r)rrrrr)rrrr rrr get_records szMlClient.get_recordscCs|jjdd|dS)z `<>`_ r?z /_ml/info)r )rr)rr rrrinfoBsz MlClient.infocCs,|tkrtd|jjdtdd|d|dS)z ``_ :arg job_id: The ID of the job to open z4Empty value passed for a required argument 'job_id'.r r r _open)r )rrrrr)rrr rrropen_jobIs  zMlClient.open_jobcCs@x ||fD]}|tkr tdq W|jjdtdd|d||dS)zw `<>`_ :arg calendar_id: The ID of the calendar to modify :arg body: A list of events z+Empty value passed for a required argument.r r rr)r r)rrrrr)rrrr rrrrpost_calendar_eventsXs  zMlClient.post_calendar_eventsZ reset_endZ reset_startcCsHx ||fD]}|tkr tdq W|jjdtdd|d||jj|dS)a ``_ :arg job_id: The name of the job receiving the data :arg body: The data to process :arg reset_end: Optional parameter to specify the end of the bucket resetting range :arg reset_start: Optional parameter to specify the start of the bucket resetting range z+Empty value passed for a required argument.r r r _data)r r)rrrrrr1r2)rrrr rrrr post_datajs   zMlClient.post_datacCs,|tkrtd|jjdtdd|d|dS)z ``_ :arg datafeed_id: The ID of the datafeed to preview z9Empty value passed for a required argument 'datafeed_id'.r?r r Z_preview)r )rrrrr)rr!r rrrpreview_datafeeds zMlClient.preview_datafeedcCs,|tkrtd|jjdtdd|||dS)z{ `<>`_ :arg calendar_id: The ID of the calendar to create :arg body: The calendar details z9Empty value passed for a required argument 'calendar_id'.PUTr r)r r)rrrrr)rrrr rrr put_calendars zMlClient.put_calendarcCs@x ||fD]}|tkr tdq W|jjdtdd|d||dS)z `<>`_ :arg calendar_id: The ID of the calendar to modify :arg job_id: The ID of the job to add to the calendar z+Empty value passed for a required argument.rYr rr)r )rrrrr)rrrr rrrrput_calendar_jobs zMlClient.put_calendar_jobcCs>x ||fD]}|tkr tdq W|jjdtdd|||dS)z ``_ :arg datafeed_id: The ID of the datafeed to create :arg body: The datafeed config z+Empty value passed for a required argument.rYr r )r r)rrrrr)rr!rr rrrr put_datafeeds  zMlClient.put_datafeedcCs>x ||fD]}|tkr tdq W|jjdtdd|||dS)zu `<>`_ :arg filter_id: The ID of the filter to create :arg body: The filter details z+Empty value passed for a required argument.rYr r$)r r)rrrrr)rr%rr rrrr put_filters  zMlClient.put_filtercCs>x ||fD]}|tkr tdq W|jjdtdd|||dS)z ``_ :arg job_id: The ID of the job to create :arg body: The job z+Empty value passed for a required argument.rYr r )r r)rrrrr)rrrr rrrrput_jobs  zMlClient.put_jobZdelete_intervening_resultsc CsDx ||fD]}|tkr tdq W|jjdtdd|d|d||dS)at ``_ :arg job_id: The ID of the job to fetch :arg snapshot_id: The ID of the snapshot to revert to :arg body: Reversion options :arg delete_intervening_results: Should we reset the results back to the time of the snapshot? z+Empty value passed for a required argument.r r r r*Z_revert)r r)rrrrr)rrr+rr rrrrrevert_model_snapshots  zMlClient.revert_model_snapshotZenabledcCs|jjdd|dS)aB ``_ :arg enabled: Whether to enable upgrade_mode ML setting or not. Defaults to false. :arg timeout: Controls the time to wait before action times out. Defaults to 30 seconds r z/_ml/set_upgrade_mode)r )rr)rr rrrset_upgrade_modes zMlClient.set_upgrade_modecCs.|tkrtd|jjdtdd|d||dS)a  ``_ :arg datafeed_id: The ID of the datafeed to start :arg body: The start datafeed parameters :arg end: The end time when the datafeed should stop. When not set, the datafeed continues in real time :arg start: The start time from where the datafeed should begin :arg timeout: Controls the time to wait until a datafeed has started. Default to 20 seconds z9Empty value passed for a required argument 'datafeed_id'.r r r Z_start)r r)rrrrr)rr!rr rrrstart_datafeed s  zMlClient.start_datafeedcCs,|tkrtd|jjdtdd|d|dS)a ``_ :arg datafeed_id: The ID of the datafeed to stop :arg allow_no_datafeeds: Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) :arg force: True if the datafeed should be forcefully stopped. :arg timeout: Controls the time to wait until a datafeed has stopped. Default to 20 seconds z9Empty value passed for a required argument 'datafeed_id'.r r r _stop)r )rrrrr)rr!r rrr stop_datafeed$s zMlClient.stop_datafeedcCs@x ||fD]}|tkr tdq W|jjdtdd|d||dS)z ``_ :arg datafeed_id: The ID of the datafeed to update :arg body: The datafeed update settings z+Empty value passed for a required argument.r r r _update)r r)rrrrr)rr!rr rrrrupdate_datafeed9s  zMlClient.update_datafeedcCs@x ||fD]}|tkr tdq W|jjdtdd|d||dS)zt `<>`_ :arg filter_id: The ID of the filter to update :arg body: The filter update z+Empty value passed for a required argument.r r r$rd)r r)rrrrr)rr%rr rrrr update_filterKs  zMlClient.update_filtercCs@x ||fD]}|tkr tdq W|jjdtdd|d||dS)z ``_ :arg job_id: The ID of the job to create :arg body: The job update settings z+Empty value passed for a required argument.r r r rd)r r)rrrrr)rrrr rrrr update_job]s  zMlClient.update_jobc CsFx"|||fD]}|tkr tdq W|jjdtdd|d|d||dS)a ``_ :arg job_id: The ID of the job to fetch :arg snapshot_id: The ID of the snapshot to update :arg body: The model snapshot properties to update z+Empty value passed for a required argument.r r r r*rd)r r)rrrrr)rrr+rr rrrrupdate_model_snapshotos  zMlClient.update_model_snapshotcCs$|tkrtd|jjdd||dS)z: `<>`_ :arg body: The job config z2Empty value passed for a required argument 'body'.r z /_ml/anomaly_detectors/_validate)r r)rrrr)rrr rrrvalidateszMlClient.validatecCs$|tkrtd|jjdd||dS)z8 `<>`_ :arg body: The detector z2Empty value passed for a required argument 'body'.r z)/_ml/anomaly_detectors/_validate/detector)r r)rrrr)rrr rrrvalidate_detectorszMlClient.validate_detector)NN)N)N)N)N)N)N)NN)N)N)N)NN)N)NNN)N)NNN)NNN)NN)NN)NN)NN)NN)NN)NNN)NN)NN)N)N)N)N)N)NN)N)N)N)N)NN)N)NN)N)N)N)N)N)N)N)2__name__ __module__ __qualname__rrrrrr"r#r&r(r)r,r3r7r9rBrCrDrFrHrIrJrKrLrMrNrOrQrRrTrUrWrXrZr[r\r]r^r_r`rarcrerfrgrhrirjrrrrrs            ,                                   rN)utilsrrrrrrrrrs