-
Notifications
You must be signed in to change notification settings - Fork 963
/
Ml.php
2864 lines (2661 loc) · 137 KB
/
Ml.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* Elasticsearch PHP Client
*
* @link https://github.com/elastic/elasticsearch-php
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license https://opensource.org/licenses/MIT MIT License
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the MIT License.
* See the LICENSE file in the project root for more information.
*/
declare(strict_types=1);
namespace Elastic\Elasticsearch\Endpoints;
use Elastic\Elasticsearch\Exception\ClientResponseException;
use Elastic\Elasticsearch\Exception\MissingParameterException;
use Elastic\Elasticsearch\Exception\ServerResponseException;
use Elastic\Elasticsearch\Response\Elasticsearch;
use Elastic\Transport\Exception\NoNodeAvailableException;
use Http\Promise\Promise;
/**
* @generated This file is generated, please do not edit
*/
class Ml extends AbstractEndpoint
{
/**
* Clear the cached results from a trained model deployment
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/clear-trained-model-deployment-cache.html
*
* @param array{
* model_id: string, // (REQUIRED) The unique identifier of the trained model.
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function clearTrainedModelDeploymentCache(array $params = [])
{
$this->checkRequiredParameters(['model_id'], $params);
$url = '/_ml/trained_models/' . $this->encode($params['model_id']) . '/deployment/cache/_clear';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Closes one or more anomaly detection jobs. A job can be opened and closed multiple times throughout its lifecycle.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-close-job.html
*
* @param array{
* job_id: string, // (REQUIRED) The name of the job to close
* allow_no_match: boolean, // Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified)
* force: boolean, // True if the job should be forcefully closed
* timeout: time, // Controls the time to wait until a job has closed. Default to 30 minutes
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // The URL params optionally sent in the body
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function closeJob(array $params = [])
{
$this->checkRequiredParameters(['job_id'], $params);
$url = '/_ml/anomaly_detectors/' . $this->encode($params['job_id']) . '/_close';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['allow_no_match','force','timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Deletes a calendar.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-calendar.html
*
* @param array{
* calendar_id: string, // (REQUIRED) The ID of the calendar to delete
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function deleteCalendar(array $params = [])
{
$this->checkRequiredParameters(['calendar_id'], $params);
$url = '/_ml/calendars/' . $this->encode($params['calendar_id']);
$method = 'DELETE';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Deletes scheduled events from a calendar.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-calendar-event.html
*
* @param array{
* calendar_id: string, // (REQUIRED) The ID of the calendar to modify
* event_id: string, // (REQUIRED) The ID of the event to remove from the calendar
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function deleteCalendarEvent(array $params = [])
{
$this->checkRequiredParameters(['calendar_id','event_id'], $params);
$url = '/_ml/calendars/' . $this->encode($params['calendar_id']) . '/events/' . $this->encode($params['event_id']);
$method = 'DELETE';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Deletes anomaly detection jobs from a calendar.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-calendar-job.html
*
* @param array{
* calendar_id: string, // (REQUIRED) The ID of the calendar to modify
* job_id: string, // (REQUIRED) The ID of the job to remove from the calendar
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function deleteCalendarJob(array $params = [])
{
$this->checkRequiredParameters(['calendar_id','job_id'], $params);
$url = '/_ml/calendars/' . $this->encode($params['calendar_id']) . '/jobs/' . $this->encode($params['job_id']);
$method = 'DELETE';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Deletes an existing data frame analytics job.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-dfanalytics.html
*
* @param array{
* id: string, // (REQUIRED) The ID of the data frame analytics to delete
* force: boolean, // True if the job should be forcefully deleted
* timeout: time, // Controls the time to wait until a job is deleted. Defaults to 1 minute
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function deleteDataFrameAnalytics(array $params = [])
{
$this->checkRequiredParameters(['id'], $params);
$url = '/_ml/data_frame/analytics/' . $this->encode($params['id']);
$method = 'DELETE';
$url = $this->addQueryString($url, $params, ['force','timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Deletes an existing datafeed.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-datafeed.html
*
* @param array{
* datafeed_id: string, // (REQUIRED) The ID of the datafeed to delete
* force: boolean, // True if the datafeed should be forcefully deleted
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function deleteDatafeed(array $params = [])
{
$this->checkRequiredParameters(['datafeed_id'], $params);
$url = '/_ml/datafeeds/' . $this->encode($params['datafeed_id']);
$method = 'DELETE';
$url = $this->addQueryString($url, $params, ['force','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Deletes expired and unused machine learning data.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-expired-data.html
*
* @param array{
* job_id: string, // The ID of the job(s) to perform expired data hygiene for
* requests_per_second: number, // The desired requests per second for the deletion processes.
* timeout: time, // How long can the underlying delete processes run until they are canceled
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // deleting expired data parameters
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function deleteExpiredData(array $params = [])
{
if (isset($params['job_id'])) {
$url = '/_ml/_delete_expired_data/' . $this->encode($params['job_id']);
$method = 'DELETE';
} else {
$url = '/_ml/_delete_expired_data';
$method = 'DELETE';
}
$url = $this->addQueryString($url, $params, ['requests_per_second','timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Deletes a filter.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-filter.html
*
* @param array{
* filter_id: string, // (REQUIRED) The ID of the filter to delete
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function deleteFilter(array $params = [])
{
$this->checkRequiredParameters(['filter_id'], $params);
$url = '/_ml/filters/' . $this->encode($params['filter_id']);
$method = 'DELETE';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Deletes forecasts from a machine learning job.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-forecast.html
*
* @param array{
* job_id: string, // (REQUIRED) The ID of the job from which to delete forecasts
* forecast_id: string, // The ID of the forecast to delete, can be comma delimited list. Leaving blank implies `_all`
* allow_no_forecasts: boolean, // Whether to ignore if `_all` matches no forecasts
* timeout: time, // Controls the time to wait until the forecast(s) are deleted. Default to 30 seconds
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function deleteForecast(array $params = [])
{
$this->checkRequiredParameters(['job_id'], $params);
if (isset($params['forecast_id'])) {
$url = '/_ml/anomaly_detectors/' . $this->encode($params['job_id']) . '/_forecast/' . $this->encode($params['forecast_id']);
$method = 'DELETE';
} else {
$url = '/_ml/anomaly_detectors/' . $this->encode($params['job_id']) . '/_forecast';
$method = 'DELETE';
}
$url = $this->addQueryString($url, $params, ['allow_no_forecasts','timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Deletes an existing anomaly detection job.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-job.html
*
* @param array{
* job_id: string, // (REQUIRED) The ID of the job to delete
* force: boolean, // True if the job should be forcefully deleted
* wait_for_completion: boolean, // Should this request wait until the operation has completed before returning
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function deleteJob(array $params = [])
{
$this->checkRequiredParameters(['job_id'], $params);
$url = '/_ml/anomaly_detectors/' . $this->encode($params['job_id']);
$method = 'DELETE';
$url = $this->addQueryString($url, $params, ['force','wait_for_completion','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Deletes an existing model snapshot.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-snapshot.html
*
* @param array{
* job_id: string, // (REQUIRED) The ID of the job to fetch
* snapshot_id: string, // (REQUIRED) The ID of the snapshot to delete
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function deleteModelSnapshot(array $params = [])
{
$this->checkRequiredParameters(['job_id','snapshot_id'], $params);
$url = '/_ml/anomaly_detectors/' . $this->encode($params['job_id']) . '/model_snapshots/' . $this->encode($params['snapshot_id']);
$method = 'DELETE';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Deletes an existing trained inference model that is currently not referenced by an ingest pipeline.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-trained-models.html
*
* @param array{
* model_id: string, // (REQUIRED) The ID of the trained model to delete
* timeout: time, // Controls the amount of time to wait for the model to be deleted.
* force: boolean, // True if the model should be forcefully deleted
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function deleteTrainedModel(array $params = [])
{
$this->checkRequiredParameters(['model_id'], $params);
$url = '/_ml/trained_models/' . $this->encode($params['model_id']);
$method = 'DELETE';
$url = $this->addQueryString($url, $params, ['timeout','force','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Deletes a model alias that refers to the trained model
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-trained-models-aliases.html
*
* @param array{
* model_alias: string, // (REQUIRED) The trained model alias to delete
* model_id: string, // (REQUIRED) The trained model where the model alias is assigned
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function deleteTrainedModelAlias(array $params = [])
{
$this->checkRequiredParameters(['model_alias','model_id'], $params);
$url = '/_ml/trained_models/' . $this->encode($params['model_id']) . '/model_aliases/' . $this->encode($params['model_alias']);
$method = 'DELETE';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Estimates the model memory
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-apis.html
*
* @param array{
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // (REQUIRED) The analysis config, plus cardinality estimates for fields it references
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function estimateModelMemory(array $params = [])
{
$this->checkRequiredParameters(['body'], $params);
$url = '/_ml/anomaly_detectors/_estimate_model_memory';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Evaluates the data frame analytics for an annotated index.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/evaluate-dfanalytics.html
*
* @param array{
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // (REQUIRED) The evaluation definition
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function evaluateDataFrame(array $params = [])
{
$this->checkRequiredParameters(['body'], $params);
$url = '/_ml/data_frame/_evaluate';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Explains a data frame analytics config.
*
* @see http://www.elastic.co/guide/en/elasticsearch/reference/current/explain-dfanalytics.html
*
* @param array{
* id: string, // The ID of the data frame analytics to explain
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // The data frame analytics config to explain
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function explainDataFrameAnalytics(array $params = [])
{
if (isset($params['id'])) {
$url = '/_ml/data_frame/analytics/' . $this->encode($params['id']) . '/_explain';
$method = empty($params['body']) ? 'GET' : 'POST';
} else {
$url = '/_ml/data_frame/analytics/_explain';
$method = empty($params['body']) ? 'GET' : 'POST';
}
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Forces any buffered data to be processed by the job.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-flush-job.html
*
* @param array{
* job_id: string, // (REQUIRED) The name of the job to flush
* calc_interim: boolean, // Calculates interim results for the most recent bucket or all buckets within the latency period
* start: string, // When used in conjunction with calc_interim, specifies the range of buckets on which to calculate interim results
* end: string, // When used in conjunction with calc_interim, specifies the range of buckets on which to calculate interim results
* advance_time: string, // Advances time to the given value generating results and updating the model for the advanced interval
* skip_time: string, // Skips time to the given value without generating results or updating the model for the skipped interval
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // Flush parameters
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function flushJob(array $params = [])
{
$this->checkRequiredParameters(['job_id'], $params);
$url = '/_ml/anomaly_detectors/' . $this->encode($params['job_id']) . '/_flush';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['calc_interim','start','end','advance_time','skip_time','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Predicts the future behavior of a time series by using its historical behavior.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-forecast.html
*
* @param array{
* job_id: string, // (REQUIRED) The ID of the job to forecast for
* duration: time, // The duration of the forecast
* expires_in: time, // The time interval after which the forecast expires. Expired forecasts will be deleted at the first opportunity.
* max_model_memory: string, // The max memory able to be used by the forecast. Default is 20mb.
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // Query parameters can be specified in the body
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function forecast(array $params = [])
{
$this->checkRequiredParameters(['job_id'], $params);
$url = '/_ml/anomaly_detectors/' . $this->encode($params['job_id']) . '/_forecast';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['duration','expires_in','max_model_memory','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Retrieves anomaly detection job results for one or more buckets.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-bucket.html
*
* @param array{
* job_id: string, // (REQUIRED) ID of the job to get bucket results from
* timestamp: string, // The timestamp of the desired single bucket result
* expand: boolean, // Include anomaly records
* exclude_interim: boolean, // Exclude interim results
* from: int, // skips a number of buckets
* size: int, // specifies a max number of buckets to get
* start: string, // Start time filter for buckets
* end: string, // End time filter for buckets
* anomaly_score: double, // Filter for the most anomalous buckets
* sort: string, // Sort buckets by a particular field
* desc: boolean, // Set the sort direction
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // Bucket selection details if not provided in URI
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function getBuckets(array $params = [])
{
$this->checkRequiredParameters(['job_id'], $params);
if (isset($params['timestamp'])) {
$url = '/_ml/anomaly_detectors/' . $this->encode($params['job_id']) . '/results/buckets/' . $this->encode($params['timestamp']);
$method = empty($params['body']) ? 'GET' : 'POST';
} else {
$url = '/_ml/anomaly_detectors/' . $this->encode($params['job_id']) . '/results/buckets';
$method = empty($params['body']) ? 'GET' : 'POST';
}
$url = $this->addQueryString($url, $params, ['expand','exclude_interim','from','size','start','end','anomaly_score','sort','desc','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Retrieves information about the scheduled events in calendars.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-calendar-event.html
*
* @param array{
* calendar_id: string, // (REQUIRED) The ID of the calendar containing the events
* job_id: string, // Get events for the job. When this option is used calendar_id must be '_all'
* start: string, // Get events after this time
* end: date, // Get events before this time
* from: int, // Skips a number of events
* size: int, // Specifies a max number of events to get
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function getCalendarEvents(array $params = [])
{
$this->checkRequiredParameters(['calendar_id'], $params);
$url = '/_ml/calendars/' . $this->encode($params['calendar_id']) . '/events';
$method = 'GET';
$url = $this->addQueryString($url, $params, ['job_id','start','end','from','size','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Retrieves configuration information for calendars.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-calendar.html
*
* @param array{
* calendar_id: string, // The ID of the calendar to fetch
* from: int, // skips a number of calendars
* size: int, // specifies a max number of calendars to get
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // The from and size parameters optionally sent in the body
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function getCalendars(array $params = [])
{
if (isset($params['calendar_id'])) {
$url = '/_ml/calendars/' . $this->encode($params['calendar_id']);
$method = empty($params['body']) ? 'GET' : 'POST';
} else {
$url = '/_ml/calendars';
$method = empty($params['body']) ? 'GET' : 'POST';
}
$url = $this->addQueryString($url, $params, ['from','size','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Retrieves anomaly detection job results for one or more categories.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-category.html
*
* @param array{
* job_id: string, // (REQUIRED) The name of the job
* category_id: long, // The identifier of the category definition of interest
* from: int, // skips a number of categories
* size: int, // specifies a max number of categories to get
* partition_field_value: string, // Specifies the partition to retrieve categories for. This is optional, and should never be used for jobs where per-partition categorization is disabled.
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // Category selection details if not provided in URI
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function getCategories(array $params = [])
{
$this->checkRequiredParameters(['job_id'], $params);
if (isset($params['category_id'])) {
$url = '/_ml/anomaly_detectors/' . $this->encode($params['job_id']) . '/results/categories/' . $this->encode($params['category_id']);
$method = empty($params['body']) ? 'GET' : 'POST';
} else {
$url = '/_ml/anomaly_detectors/' . $this->encode($params['job_id']) . '/results/categories/';
$method = empty($params['body']) ? 'GET' : 'POST';
}
$url = $this->addQueryString($url, $params, ['from','size','partition_field_value','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Retrieves configuration information for data frame analytics jobs.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-dfanalytics.html
*
* @param array{
* id: string, // The ID of the data frame analytics to fetch
* allow_no_match: boolean, // Whether to ignore if a wildcard expression matches no data frame analytics. (This includes `_all` string or when no data frame analytics have been specified)
* from: int, // skips a number of analytics
* size: int, // specifies a max number of analytics to get
* exclude_generated: boolean, // Omits fields that are illegal to set on data frame analytics PUT
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function getDataFrameAnalytics(array $params = [])
{
if (isset($params['id'])) {
$url = '/_ml/data_frame/analytics/' . $this->encode($params['id']);
$method = 'GET';
} else {
$url = '/_ml/data_frame/analytics';
$method = 'GET';
}
$url = $this->addQueryString($url, $params, ['allow_no_match','from','size','exclude_generated','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Retrieves usage information for data frame analytics jobs.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-dfanalytics-stats.html
*
* @param array{
* id: string, // The ID of the data frame analytics stats to fetch
* allow_no_match: boolean, // Whether to ignore if a wildcard expression matches no data frame analytics. (This includes `_all` string or when no data frame analytics have been specified)
* from: int, // skips a number of analytics
* size: int, // specifies a max number of analytics to get
* verbose: boolean, // whether the stats response should be verbose
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function getDataFrameAnalyticsStats(array $params = [])
{
if (isset($params['id'])) {
$url = '/_ml/data_frame/analytics/' . $this->encode($params['id']) . '/_stats';
$method = 'GET';
} else {
$url = '/_ml/data_frame/analytics/_stats';
$method = 'GET';
}
$url = $this->addQueryString($url, $params, ['allow_no_match','from','size','verbose','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}