Skip to content

Commit

Permalink
[DOCS] Fix ML sync API example (#133585)
Browse files Browse the repository at this point in the history
  • Loading branch information
lcawl authored Jun 8, 2022
1 parent b7c4d89 commit b7ae8a2
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 14 deletions.
4 changes: 2 additions & 2 deletions docs/api/machine-learning/sync.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Retrieve the list of {ml} saved objects that require synchronization:

[source,sh]
--------------------------------------------------
$ curl -X GET api/ml/saved_objects/sync?simulate=true
GET api/ml/saved_objects/sync?simulate=true
--------------------------------------------------
// KIBANA

Expand All @@ -83,7 +83,7 @@ the following response:

[source,sh]
--------------------------------------------------
{{"savedObjectsCreated":{"anomaly_detector":{"myjob1":{"success":true},"myjob2":{"success":true}}},"savedObjectsDeleted":{},"datafeedsAdded":{},"datafeedsRemoved":{}}
{"savedObjectsCreated":{"anomaly_detector":{"myjob1":{"success":true},"myjob2":{"success":true}}},"savedObjectsDeleted":{},"datafeedsAdded":{},"datafeedsRemoved":{}}
--------------------------------------------------

To perform the synchronization, re-run the API and omit the `simulate` parameter.
34 changes: 30 additions & 4 deletions x-pack/plugins/ml/common/openapi/bundled.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@
"content": {
"application/json": {
"schema": {
"items": {
"$ref": "#/components/schemas/syncResponse"
"$ref": "#/components/schemas/syncResponse"
},
"examples": {
"syncExample": {
"$ref": "#/components/examples/syncExample"
}
}
}
Expand All @@ -62,8 +65,11 @@
"content": {
"application/json": {
"schema": {
"items": {
"$ref": "#/components/schemas/syncResponse"
"$ref": "#/components/schemas/syncResponse"
},
"examples": {
"syncExample": {
"$ref": "#/components/examples/syncExample"
}
}
}
Expand Down Expand Up @@ -215,6 +221,26 @@
}
}
}
},
"examples": {
"syncExample": {
"summary": "Two anomaly detection jobs required synchronization in this example.",
"value": {
"savedObjectsCreated": {
"anomaly_detector": {
"myjob1": {
"success": true
},
"myjob2": {
"success": true
}
}
},
"savedObjectsDeleted": {},
"datafeedsAdded": {},
"datafeedsRemoved": {}
}
}
}
},
"security": [
Expand Down
25 changes: 21 additions & 4 deletions x-pack/plugins/ml/common/openapi/bundled.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ paths:
content:
application/json:
schema:
items:
$ref: '#/components/schemas/syncResponse'
$ref: '#/components/schemas/syncResponse'
examples:
syncExample:
$ref: '#/components/examples/syncExample'
/api/ml/saved_objects/sync:
get:
description: >
Expand All @@ -47,8 +49,10 @@ paths:
content:
application/json:
schema:
items:
$ref: '#/components/schemas/syncResponse'
$ref: '#/components/schemas/syncResponse'
examples:
syncExample:
$ref: '#/components/examples/syncExample'
components:
parameters:
spaceParam:
Expand Down Expand Up @@ -163,5 +167,18 @@ components:
success:
type: boolean
example: true
examples:
syncExample:
summary: Two anomaly detection jobs required synchronization in this example.
value:
savedObjectsCreated:
anomaly_detector:
myjob1:
success: true
myjob2:
success: true
savedObjectsDeleted: {}
datafeedsAdded: {}
datafeedsRemoved: {}
security:
- basicAuth: []
27 changes: 23 additions & 4 deletions x-pack/plugins/ml/common/openapi/ml_apis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ paths:
content:
application/json:
schema:
items:
$ref: '#/components/schemas/syncResponse'
$ref: '#/components/schemas/syncResponse'
examples:
syncExample:
$ref: '#/components/examples/syncExample'
/api/ml/saved_objects/sync:
get:
description: >
Expand All @@ -43,8 +45,10 @@ paths:
content:
application/json:
schema:
items:
$ref: '#/components/schemas/syncResponse'
$ref: '#/components/schemas/syncResponse'
examples:
syncExample:
$ref: '#/components/examples/syncExample'
components:
parameters:
spaceParam:
Expand Down Expand Up @@ -142,5 +146,20 @@ components:
success:
type: boolean
example: true
examples:
syncExample:
summary: Two anomaly detection jobs required synchronization in this example.
value:
{
"savedObjectsCreated": {
"anomaly_detector": {
"myjob1": { "success":true },
"myjob2":{ "success":true }
}
},
"savedObjectsDeleted": {},
"datafeedsAdded":{},
"datafeedsRemoved":{}
}
security:
- basicAuth: []

0 comments on commit b7ae8a2

Please sign in to comment.