Skip to content

Commit b401bbe

Browse files
authored
Validate ml.get_* API (#394)
1 parent 9cfd5fb commit b401bbe

File tree

11 files changed

+421
-134
lines changed

11 files changed

+421
-134
lines changed

output/schema/schema.json

Lines changed: 306 additions & 84 deletions
Large diffs are not rendered by default.

output/schema/validation-errors.json

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -564,18 +564,6 @@
564564
],
565565
"response": []
566566
},
567-
"ml.get_calendars": {
568-
"request": [
569-
"Endpoint has \"@stability: TODO"
570-
],
571-
"response": []
572-
},
573-
"ml.get_categories": {
574-
"request": [
575-
"Endpoint has \"@stability: TODO"
576-
],
577-
"response": []
578-
},
579567
"ml.get_datafeed_stats": {
580568
"request": [
581569
"Endpoint has \"@stability: TODO"
@@ -588,12 +576,6 @@
588576
],
589577
"response": []
590578
},
591-
"ml.get_influencers": {
592-
"request": [
593-
"Endpoint has \"@stability: TODO"
594-
],
595-
"response": []
596-
},
597579
"ml.get_job_stats": {
598580
"request": [
599581
"Endpoint has \"@stability: TODO"

output/typescript/types.ts

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9918,24 +9918,33 @@ export type MlAppliesTo = 'actual' | 'typical' | 'diff_from_typical' | 'time'
99189918

99199919
export interface MlBucketInfluencer {
99209920
bucket_span: long
9921-
influencer_field_name: string
9922-
influencer_field_value: string
99239921
influencer_score: double
9922+
influencer_field_name: Field
9923+
influencer_field_value: string
99249924
initial_influencer_score: double
99259925
is_interim: boolean
99269926
job_id: Id
99279927
probability: double
99289928
result_type: string
9929-
timestamp: DateString
9929+
timestamp: Time
9930+
foo?: string
99309931
}
99319932

99329933
export interface MlCategoryDefinition {
9933-
category_id: long
9934+
category_id: ulong
99349935
examples: string[]
9936+
grok_pattern?: string
99359937
job_id: Id
9936-
max_matching_length: long
9938+
max_matching_length: ulong
9939+
partition_field_name?: string
9940+
partition_field_value?: string
99379941
regex: string
99389942
terms: string
9943+
num_matches?: long
9944+
preferred_to_categories?: Id[]
9945+
p?: string
9946+
result_type: string
9947+
mlcategory: string
99399948
}
99409949

99419950
export interface MlChunkingConfig {
@@ -10333,8 +10342,8 @@ export interface MlOverallBucketJobInfo {
1033310342
}
1033410343

1033510344
export interface MlPage {
10336-
from: integer
10337-
size: integer
10345+
from?: integer
10346+
size?: integer
1033810347
}
1033910348

1034010349
export interface MlPartitionScore {
@@ -10776,12 +10785,14 @@ export interface MlGetCalendarEventsResponse {
1077610785

1077710786
export interface MlGetCalendarsCalendar {
1077810787
calendar_id: Id
10779-
description: string
10788+
description?: string
1078010789
job_ids: Id[]
1078110790
}
1078210791

1078310792
export interface MlGetCalendarsRequest extends RequestBase {
1078410793
calendar_id?: Id
10794+
from?: integer
10795+
size?: integer
1078510796
body?: {
1078610797
page?: MlPage
1078710798
}
@@ -10795,6 +10806,9 @@ export interface MlGetCalendarsResponse {
1079510806
export interface MlGetCategoriesRequest extends RequestBase {
1079610807
job_id: Id
1079710808
category_id?: CategoryId
10809+
from?: integer
10810+
size?: integer
10811+
partition_field_value?: string
1079810812
body?: {
1079910813
page?: MlPage
1080010814
}
@@ -10970,14 +10984,16 @@ export interface MlGetFiltersResponse {
1097010984

1097110985
export interface MlGetInfluencersRequest extends RequestBase {
1097210986
job_id: Id
10987+
desc?: boolean
10988+
end?: DateString
10989+
exclude_interim?: boolean
10990+
influencer_score?: double
10991+
from?: integer
10992+
size?: integer
10993+
sort?: Field
10994+
start?: DateString
1097310995
body?: {
10974-
descending?: boolean
10975-
end?: DateString
10976-
exclude_interim?: boolean
10977-
influencer_score?: double
1097810996
page?: MlPage
10979-
sort?: Field
10980-
start?: DateString
1098110997
}
1098210998
}
1098310999

specification/ml/_types/BucketInfluencer.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,30 @@
1717
* under the License.
1818
*/
1919

20-
import { Id } from '@_types/common'
20+
import { Field, Id } from '@_types/common'
2121
import { double, long } from '@_types/Numeric'
22-
import { DateString } from '@_types/Time'
22+
import { Time } from '@_types/Time'
2323

2424
export class BucketInfluencer {
25+
/** The length of the bucket in seconds. This value matches the bucket_span that is specified in the job. */
2526
bucket_span: long
26-
influencer_field_name: string
27-
influencer_field_value: string
27+
/** A normalized score between 0-100, which is based on the probability of the influencer in this bucket aggregated across detectors. Unlike initial_influencer_score, this value will be updated by a re-normalization process as new data is analyzed. */
2828
influencer_score: double
29+
/** The field name of the influencer. */
30+
influencer_field_name: Field
31+
/** The entity that influenced, contributed to, or was to blame for the anomaly. */
32+
influencer_field_value: string
33+
/** A normalized score between 0-100, which is based on the probability of the influencer aggregated across detectors. This is the initial value that was calculated at the time the bucket was processed. */
2934
initial_influencer_score: double
35+
/** If true, this is an interim result. In other words, the results are calculated based on partial input data. */
3036
is_interim: boolean
37+
/** Identifier for the anomaly detection job. */
3138
job_id: Id
39+
/** The probability that the influencer has this behavior, in the range 0 to 1. This value can be held to a high precision of over 300 decimal places, so the influencer_score is provided as a human-readable and friendly interpretation of this. */
3240
probability: double
41+
/** Internal. This value is always set to influencer. */
3342
result_type: string
34-
timestamp: DateString
43+
/** The start time of the bucket for which these results were calculated. */
44+
timestamp: Time
45+
foo?: string // TODO ??? - the tests carry this prop but :shrug:
3546
}

specification/ml/_types/CategoryDefinition.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,32 @@
1818
*/
1919

2020
import { Id } from '@_types/common'
21-
import { long } from '@_types/Numeric'
21+
import { long, ulong } from '@_types/Numeric'
2222

2323
export class CategoryDefinition {
24-
category_id: long
24+
/** A unique identifier for the category. category_id is unique at the job level, even when per-partition categorization is enabled. */
25+
category_id: ulong
26+
/** A list of examples of actual values that matched the category. */
2527
examples: string[]
28+
/** [experimental] A Grok pattern that could be used in Logstash or an ingest pipeline to extract fields from messages that match the category. This field is experimental and may be changed or removed in a future release. The Grok patterns that are found are not optimal, but are often a good starting point for manual tweaking. */
29+
grok_pattern?: string
30+
/** Identifier for the anomaly detection job. */
2631
job_id: Id
27-
max_matching_length: long
32+
/** The maximum length of the fields that matched the category. The value is increased by 10% to enable matching for similar fields that have not been analyzed. */
33+
max_matching_length: ulong
34+
/** If per-partition categorization is enabled, this property identifies the field used to segment the categorization. It is not present when per-partition categorization is disabled. */
35+
partition_field_name?: string
36+
/** If per-partition categorization is enabled, this property identifies the value of the partition_field_name for the category. It is not present when per-partition categorization is disabled. */
37+
partition_field_value?: string
38+
/** A regular expression that is used to search for values that match the category. */
2839
regex: string
40+
/** A space separated list of the common tokens that are matched in values of the category. */
2941
terms: string
42+
/** The number of messages that have been matched by this category. This is only guaranteed to have the latest accurate count after a job _flush or _close */
43+
num_matches?: long
44+
/** A list of category_id entries that this current category encompasses. Any new message that is processed by the categorizer will match against this category and not any of the categories in this list. This is only guaranteed to have the latest accurate list of categories after a job _flush or _close */
45+
preferred_to_categories?: Id[]
46+
p?: string
47+
result_type: string
48+
mlcategory: string
3049
}

specification/ml/_types/Page.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@
2020
import { integer } from '@_types/Numeric'
2121

2222
export class Page {
23-
from: integer
24-
size: integer
23+
from?: integer
24+
size?: integer
2525
}

specification/ml/get_calendars/Calendar.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
import { Id } from '@_types/common'
2121

2222
export class Calendar {
23+
/** A string that uniquely identifies a calendar. */
2324
calendar_id: Id
24-
description: string
25+
description?: string
26+
/** An array of anomaly detection job identifiers. */
2527
job_ids: Id[]
2628
}

specification/ml/get_calendars/MlGetCalendarsRequest.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import { Page } from '@ml/_types/Page'
2121
import { RequestBase } from '@_types/Base'
2222
import { Id } from '@_types/common'
23+
import { integer } from '@_types/Numeric'
2324

2425
/**
2526
* @rest_spec_name ml.get_calendars
@@ -28,9 +29,15 @@ import { Id } from '@_types/common'
2829
*/
2930
export interface Request extends RequestBase {
3031
path_parts?: {
32+
/** A string that uniquely identifies a calendar. */
3133
calendar_id?: Id
3234
}
33-
query_parameters?: {}
35+
query_parameters?: {
36+
/** Skips the specified number of calendars. */
37+
from?: integer
38+
/** Specifies the maximum number of calendars to obtain. */
39+
size?: integer
40+
}
3441
body?: {
3542
page?: Page
3643
}

specification/ml/get_categories/MlGetCategoriesRequest.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import { Page } from '@ml/_types/Page'
2121
import { RequestBase } from '@_types/Base'
2222
import { CategoryId, Id } from '@_types/common'
23+
import { integer } from '@_types/Numeric'
2324

2425
/**
2526
* @rest_spec_name ml.get_categories
@@ -28,9 +29,17 @@ import { CategoryId, Id } from '@_types/common'
2829
*/
2930
export interface Request extends RequestBase {
3031
path_parts: {
32+
/** Identifier for the anomaly detection job. */
3133
job_id: Id
34+
/** Identifier for the category, which is unique in the job. If you specify neither the category ID nor the partition_field_value, the API returns information about all categories. If you specify only the partition_field_value, it returns information about all categories for the specified partition. */
3235
category_id?: CategoryId
3336
}
37+
query_parameters?: {
38+
from?: integer
39+
size?: integer
40+
/** Only return categories for the specified partition. */
41+
partition_field_value?: string
42+
}
3443
body?: {
3544
page?: Page
3645
}

specification/ml/get_influencers/MlGetInfluencersRequest.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import { Page } from '@ml/_types/Page'
2121
import { RequestBase } from '@_types/Base'
2222
import { Field, Id } from '@_types/common'
23-
import { double } from '@_types/Numeric'
23+
import { double, integer } from '@_types/Numeric'
2424
import { DateString } from '@_types/Time'
2525

2626
/**
@@ -30,16 +30,31 @@ import { DateString } from '@_types/Time'
3030
*/
3131
export interface Request extends RequestBase {
3232
path_parts: {
33+
/** Identifier for the anomaly detection job. */
3334
job_id: Id
3435
}
35-
query_parameters?: {}
36-
body?: {
37-
descending?: boolean
36+
query_parameters?: {
37+
/**
38+
* If true, the results are sorted in descending order.
39+
* @server_default false
40+
*/
41+
desc?: boolean
42+
/** Returns influencers with timestamps earlier than this time. */
3843
end?: DateString
44+
/** If true, the output excludes interim results. By default, interim results are included. */
3945
exclude_interim?: boolean
46+
/** Returns influencers with anomaly scores greater than or equal to this value. */
4047
influencer_score?: double
41-
page?: Page
48+
/** Skips the specified number of influencers. */
49+
from?: integer
50+
/** Specifies the maximum number of influencers to obtain. */
51+
size?: integer
52+
/** Specifies the sort field for the requested influencers. By default, the influencers are sorted by the influencer_score value. */
4253
sort?: Field
54+
/** Returns influencers with timestamps after this time. */
4355
start?: DateString
4456
}
57+
body?: {
58+
page?: Page
59+
}
4560
}

specification/ml/get_influencers/MlGetInfluencersResponse.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,9 @@ import { BucketInfluencer } from '@ml/_types/BucketInfluencer'
2121
import { long } from '@_types/Numeric'
2222

2323
export class Response {
24-
body: { count: long; influencers: BucketInfluencer[] }
24+
body: {
25+
count: long
26+
/** Array of influencer objects */
27+
influencers: BucketInfluencer[]
28+
}
2529
}

0 commit comments

Comments
 (0)