Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable checking for conflicts when copying saved objects #83575

Merged
merged 29 commits into from
Dec 3, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
40a9f4c
Add Spaces telemetry data
jportner Nov 17, 2020
10998e4
Disable checking for conflicts by default when copying objects
jportner Nov 17, 2020
e8ded81
Add Core telemetry data
jportner Nov 18, 2020
ecabf59
Disable checking for conflicts by default when importing objects
jportner Nov 19, 2020
25ee394
Merge branch 'master' into issue-81907-and-82324
kibanamachine Nov 23, 2020
7ecb815
PR review feedback
jportner Nov 23, 2020
e716476
i18n check
jportner Nov 23, 2020
8276465
Rename "telemetry data" to "usage stats"
jportner Nov 24, 2020
358940c
Rename usage stats fields
jportner Nov 24, 2020
fc123a1
node scripts/check_published_api_changes.js --accept
jportner Nov 24, 2020
b2bd013
Merge branch 'master' into pr/jportner/83575
jportner Nov 24, 2020
8bfee38
Tweak usage stats client unit tests
jportner Nov 24, 2020
c526e62
More PR review feedback
jportner Nov 24, 2020
ec2a77c
Merge branch 'master' into pr/jportner/83575
jportner Nov 24, 2020
f9b89a5
Revert "Disable checking for conflicts by default when importing obje…
jportner Nov 24, 2020
9cf6288
Add usage stats fields to differentiate first-party requests
jportner Nov 24, 2020
7129c3b
Merge branch 'master' into issue-81907-and-82324
kibanamachine Nov 29, 2020
b9428d3
Merge branch 'master' into pr/jportner/83575
jportner Nov 30, 2020
cfcf686
Even more PR review feedback
jportner Nov 30, 2020
eb78588
Merge branch 'master' into pr/jportner/83575
jportner Dec 1, 2020
69d7369
Refactor
jportner Dec 1, 2020
60c3820
Use SavedObjectsRepository.incrementCounter()
jportner Dec 1, 2020
d1124f8
Merge branch 'master' into pr/jportner/83575
jportner Dec 1, 2020
07cb882
node scripts/check_published_api_changes.js --accept
jportner Dec 1, 2020
787ee5e
Fix usage stats fields
jportner Dec 2, 2020
33b32bb
Merge branch 'master' into pr/jportner/83575
jportner Dec 2, 2020
8cd3433
node scripts/check_published_api_changes.js --accept
jportner Dec 2, 2020
21188ed
Merge branch 'master' into pr/jportner/83575
jportner Dec 3, 2020
60de78c
Apply suggestions from code review
jportner Dec 3, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions docs/api/saved-objects/import.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ experimental[] Create sets of {kib} saved objects from a file created by the exp
==== Query parameters

`createNewCopies`::
(Optional, boolean) Creates copies of saved objects, regenerates each object ID, and resets the origin. When used, potential conflict
errors are avoided.
(Optional, boolean) Creates new copies of saved objects, regenerates each object ID, and resets the origin. When used, potential conflict
errors are avoided. The default value is `true`.
+
NOTE: This cannot be used with the `overwrite` option.

`overwrite`::
(Optional, boolean) Overwrites saved objects when they already exist. When used, potential conflict errors are automatically resolved by
overwriting the destination object.
overwriting the destination object. The default value is `false`.
jportner marked this conversation as resolved.
Show resolved Hide resolved
+
NOTE: This cannot be used with the `createNewCopies` option.

Expand Down Expand Up @@ -80,7 +80,7 @@ Import an index pattern and dashboard:

[source,sh]
--------------------------------------------------
$ curl -X POST api/saved_objects/_import?createNewCopies=true -H "kbn-xsrf: true" --form [email protected]
$ curl -X POST api/saved_objects/_import -H "kbn-xsrf: true" --form [email protected]
--------------------------------------------------
// KIBANA

Expand Down Expand Up @@ -132,7 +132,7 @@ Import an index pattern and dashboard:

[source,sh]
--------------------------------------------------
$ curl -X POST api/saved_objects/_import -H "kbn-xsrf: true" --form [email protected]
$ curl -X POST api/saved_objects/_import?createNewCopies=false -H "kbn-xsrf: true" --form [email protected]
--------------------------------------------------
// KIBANA

Expand Down Expand Up @@ -181,7 +181,7 @@ Import an index pattern, visualization, *Canvas* workpad, and dashboard that inc

[source,sh]
--------------------------------------------------
$ curl -X POST api/saved_objects/_import -H "kbn-xsrf: true" --form [email protected]
$ curl -X POST api/saved_objects/_import?createNewCopies=false -H "kbn-xsrf: true" --form [email protected]
--------------------------------------------------
// KIBANA

Expand Down Expand Up @@ -292,7 +292,7 @@ Import a visualization and dashboard when the index pattern for the visualizatio

[source,sh]
--------------------------------------------------
$ curl -X POST api/saved_objects/_import -H "kbn-xsrf: true" --form [email protected]
$ curl -X POST api/saved_objects/_import?createNewCopies=false -H "kbn-xsrf: true" --form [email protected]
--------------------------------------------------
// KIBANA

Expand Down
8 changes: 4 additions & 4 deletions docs/api/saved-objects/resolve_import_errors.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ To resolve errors, you can:
==== Query parameters

`createNewCopies`::
(Optional, boolean) Creates copies of the saved objects, regenerates each object ID, and resets the origin. When enabled during the
initial import, also enable when resolving import errors.
(Optional, boolean) Creates new copies of the saved objects, regenerates each object ID, and resets the origin. When enabled during the
initial import, also enable when resolving import errors. The default value is `true`.

[[saved-objects-api-resolve-import-errors-request-body]]
==== Request body
Expand Down Expand Up @@ -103,7 +103,7 @@ Resolve conflict errors for an index pattern, visualization, and *Canvas* workpa

[source,sh]
--------------------------------------------------
$ curl -X POST api/saved_objects/_resolve_import_errors -H "kbn-xsrf: true" --form [email protected] --form retries='[{"type":"index-pattern","id":"my-pattern","overwrite":true},{"type":"visualization","id":"my-vis","overwrite":true,"destinationId":"another-vis"},{"type":"canvas","id":"my-canvas","overwrite":true,"destinationId":"yet-another-canvas"},{"type":"dashboard","id":"my-dashboard"}]'
$ curl -X POST api/saved_objects/_resolve_import_errors?createNewCopies=false -H "kbn-xsrf: true" --form [email protected] --form retries='[{"type":"index-pattern","id":"my-pattern","overwrite":true},{"type":"visualization","id":"my-vis","overwrite":true,"destinationId":"another-vis"},{"type":"canvas","id":"my-canvas","overwrite":true,"destinationId":"yet-another-canvas"},{"type":"dashboard","id":"my-dashboard"}]'
--------------------------------------------------
// KIBANA

Expand Down Expand Up @@ -178,7 +178,7 @@ a search by ignoring it:

[source,sh]
--------------------------------------------------
$ curl -X POST api/saved_objects/_resolve_import_errors -H "kbn-xsrf: true" --form [email protected] --form retries='[{"type":"visualization","id":"my-vis","replaceReferences":[{"type":"index-pattern","from":"my-pattern-*","to":"existing-pattern"}]},{"type":"search","id":"my-search","ignoreMissingReferences":true},{"type":"dashboard","id":"my-dashboard"}]'
$ curl -X POST api/saved_objects/_resolve_import_errors?createNewCopies=false -H "kbn-xsrf: true" --form [email protected] --form retries='[{"type":"visualization","id":"my-vis","replaceReferences":[{"type":"index-pattern","from":"my-pattern-*","to":"existing-pattern"}]},{"type":"search","id":"my-search","ignoreMissingReferences":true},{"type":"dashboard","id":"my-dashboard"}]'
--------------------------------------------------
// KIBANA

Expand Down
20 changes: 15 additions & 5 deletions docs/api/spaces-management/copy_saved_objects.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,17 @@ You can request to overwrite any objects that already exist in the target space
(Optional, boolean) When set to `true`, all saved objects related to the specified saved objects will also be copied into the target
spaces. The default value is `false`.

`createNewCopies`::
(Optional, boolean) Creates new copies of saved objects, regenerates each object ID, and resets the origin. When used, potential conflict
errors are avoided. The default value is `true`.
+
NOTE: This cannot be used with the `overwrite` option.
Comment on lines +54 to +58
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somehow I forgot to document this when I added this option 🙈 Added it now!


`overwrite`::
(Optional, boolean) When set to `true`, all conflicts are automatically overidden. When a saved object with a matching `type` and `id`
exists in the target space, that version is replaced with the version from the source space. The default value is `false`.
+
NOTE: This cannot be used with the `createNewCopies` option.

[role="child_attributes"]
[[spaces-api-copy-saved-objects-response-body]]
Expand Down Expand Up @@ -128,8 +136,7 @@ $ curl -X POST api/spaces/_copy_saved_objects
"id": "my-dashboard"
}],
"spaces": ["marketing"],
"includeReferences": true,
"createNewcopies": true
"includeReferences": true
}
----
// KIBANA
Expand Down Expand Up @@ -193,7 +200,8 @@ $ curl -X POST api/spaces/_copy_saved_objects
"id": "my-dashboard"
}],
"spaces": ["marketing"],
"includeReferences": true
"includeReferences": true,
"createNewCopies": false
}
----
// KIBANA
Expand Down Expand Up @@ -254,7 +262,8 @@ $ curl -X POST api/spaces/_copy_saved_objects
"id": "my-dashboard"
}],
"spaces": ["marketing", "sales"],
"includeReferences": true
"includeReferences": true,
"createNewCopies": false
}
----
// KIBANA
Expand Down Expand Up @@ -405,7 +414,8 @@ $ curl -X POST api/spaces/_copy_saved_objects
"id": "my-dashboard"
}],
"spaces": ["marketing"],
"includeReferences": true
"includeReferences": true,
"createNewCopies": false
}
----
// KIBANA
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ Execute the <<spaces-api-copy-saved-objects,copy saved objects to space API>>, w
`includeReferences`::
(Optional, boolean) When set to `true`, all saved objects related to the specified saved objects are copied into the target spaces. The `includeReferences` must be the same values used during the failed <<spaces-api-copy-saved-objects, copy saved objects to space API>> operation. The default value is `false`.

`createNewCopies`::
(Optional, boolean) Creates new copies of the saved objects, regenerates each object ID, and resets the origin. When enabled during the
initial copy, also enable when resolving copy errors. The default value is `true`.

`retries`::
(Required, object) The retry operations to attempt, which can specify how to resolve different types of errors. Object keys represent the
target space IDs.
Expand Down Expand Up @@ -148,6 +152,7 @@ $ curl -X POST api/spaces/_resolve_copy_saved_objects_errors
"id": "my-dashboard"
}],
"includeReferences": true,
"createNewCopies": false,
"retries": {
"sales": [
{
Expand Down Expand Up @@ -246,6 +251,7 @@ $ curl -X POST api/spaces/_resolve_copy_saved_objects_errors
"id": "my-dashboard"
}],
"includeReferences": true,
"createNewCopies": false,
"retries": {
"marketing": [
{
Expand Down
21 changes: 21 additions & 0 deletions src/core/server/core_telemetry/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

/** @internal */
export const CORE_TELEMETRY_TYPE = 'core-telemetry';
32 changes: 32 additions & 0 deletions src/core/server/core_telemetry/core_telemetry_client.mock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { CoreTelemetryClient } from '.';

const createTelemetryClientMock = () =>
(({
getTelemetryData: jest.fn().mockResolvedValue({}),
incrementSavedObjectsImport: jest.fn().mockResolvedValue(null),
incrementSavedObjectsResolveImportErrors: jest.fn().mockResolvedValue(null),
incrementSavedObjectsExport: jest.fn().mockResolvedValue(null),
} as unknown) as jest.Mocked<CoreTelemetryClient>);

export const coreTelemetryClientMock = {
create: createTelemetryClientMock,
};
Loading