kibana/docs/api/machine-learning/sync.asciidoc
Lisa Cawley 2305a34462
[8.9] [DOCS] Remove OAS API previews (#168761) (#169141)
# Backport

This will backport the following commits from `main` to `8.9`:
- [[DOCS] Remove OAS API previews
(#168761)](https://github.com/elastic/kibana/pull/168761)

<!--- Backport version: 8.9.8 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Lisa
Cawley","email":"lcawley@elastic.co"},"sourceCommit":{"committedDate":"2023-10-17T14:49:23Z","message":"[DOCS]
Remove OAS API previews
(#168761)","sha":"382e3f6ec245aec89d52b4a4be1b8c5612c011c5","branchLabelMapping":{"^v8.12.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Docs","release_note:skip","docs","backport:all-open","v8.6.3","v8.11.0","v8.12.0"],"number":168761,"url":"https://github.com/elastic/kibana/pull/168761","mergeCommit":{"message":"[DOCS]
Remove OAS API previews
(#168761)","sha":"382e3f6ec245aec89d52b4a4be1b8c5612c011c5"}},"sourceBranch":"main","suggestedTargetBranches":["8.6"],"targetPullRequestStates":[{"branch":"8.6","label":"v8.6.3","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.11","label":"v8.11.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/169124","number":169124,"state":"MERGED","mergeCommit":{"sha":"ac6ad7878db93ffa1aa5946196f6cf6bbb4af854","message":"[8.11]
[DOCS] Remove OAS API previews (#168761)
(#169124)"}},{"branch":"main","label":"v8.12.0","labelRegex":"^v8.12.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/168761","number":168761,"mergeCommit":{"message":"[DOCS]
Remove OAS API previews
(#168761)","sha":"382e3f6ec245aec89d52b4a4be1b8c5612c011c5"}}]}]
BACKPORT-->
2023-10-17 12:55:47 -04:00

95 lines
No EOL
3.1 KiB
Text

[[machine-learning-api-sync]]
=== Sync {ml} saved objects API
++++
<titleabbrev>Sync {ml} saved objects</titleabbrev>
++++
Synchronizes {kib} saved objects for {ml} jobs and trained models.
[NOTE]
====
For the most up-to-date API details, refer to the
{kib-repo}/tree/{branch}/x-pack/plugins/ml/common/openapi[open API specification].
====
[[machine-learning-api-sync-request]]
==== {api-request-title}
`GET <kibana host>:<port>/api/ml/saved_objects/sync`
`GET <kibana host>:<port>/s/<space_id>/api/ml/saved_objects/sync`
[[machine-learning-api-sync-prereq]]
==== {api-prereq-title}
You must have `all` privileges for the *Machine Learning* feature in the *Analytics* section of the
<<kibana-feature-privileges,{kib} feature privileges>>.
[[machine-learning-api-sync-desc]]
==== {api-description-title}
This API runs automatically when you start {kib} and periodically thereafter.
[[machine-learning-api-sync-path-params]]
==== {api-path-parms-title}
`space_id`::
(Optional, string) An identifier for the space. If `space_id` is not provided in
the URL the default space is used.
[[machine-learning-api-sync-query-params]]
==== {api-query-parms-title}
`simulate`::
(Optional, boolean) When `true`, simulates the synchronization by only returning
the list actions that _would_ be performed.
[[machine-learning-api-sync-response-body]]
==== {api-response-body-title}
`datafeedsAdded`::
(array) If a saved object for an {anomaly-job} is missing a {dfeed} identifier,
it is added. This list contains the {dfeed} identifiers and indicates whether
the synchronization was successful.
`datafeedsRemoved`::
(array) If a saved object for an anomaly detection job references a datafeed
that no longer exists, it is deleted. This list contains the {dfeed} identifiers
and indicates whether the synchronization was successful.
`savedObjectsCreated`::
(array) If saved objects are missing for {ml} jobs or trained models, they are
created. This list contains the job and model identifiers and indicates whether
the synchronization was successful.
`savedObjectsDeleted`::
(array) If saved objects exist for {ml} jobs or trained models that no longer
exist, they are deleted. This list contains the job and model identifiers and
indicates whether the synchronization was successful.
[[machine-learning-api-sync-codes]]
==== {api-response-codes-title}
`200`::
Indicates a successful call.
[[machine-learning-api-sync-example]]
==== {api-examples-title}
Retrieve the list of {ml} saved objects that require synchronization:
[source,sh]
--------------------------------------------------
GET api/ml/saved_objects/sync?simulate=true
--------------------------------------------------
// KIBANA
If there are two jobs that need to be synchronized, for example, the API returns
the following response:
[source,sh]
--------------------------------------------------
{"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.