mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
parent
d3fbb91a22
commit
64017d65cc
18 changed files with 347 additions and 11 deletions
|
@ -15,13 +15,16 @@ The following index patterns APIs are available:
|
|||
** <<index-patterns-api-create, Create index pattern API>> to create {kib} index pattern
|
||||
** <<index-patterns-api-update, Update index pattern API>> to partially updated {kib} index pattern
|
||||
** <<index-patterns-api-delete, Delete index pattern API>> to delete {kib} index pattern
|
||||
* Default index pattern
|
||||
** <<index-patterns-api-default-get, Get default index pattern API>> to retrieve a default index pattern
|
||||
** <<index-patterns-api-default-set, Set default index pattern API>> to set a default index pattern
|
||||
* Fields
|
||||
** <<index-patterns-fields-api-update, Update index pattern field>> to change field metadata, such as `count`, `customLabel` and `format`.
|
||||
|
||||
|
||||
** <<index-patterns-fields-api-update, Update index pattern field>> to change field metadata, such as `count`, `customLabel` and `format`
|
||||
|
||||
include::index-patterns/get.asciidoc[]
|
||||
include::index-patterns/create.asciidoc[]
|
||||
include::index-patterns/update.asciidoc[]
|
||||
include::index-patterns/delete.asciidoc[]
|
||||
include::index-patterns/default-get.asciidoc[]
|
||||
include::index-patterns/default-set.asciidoc[]
|
||||
include::index-patterns/update-fields.asciidoc[]
|
||||
|
|
55
docs/api/index-patterns/default-get.asciidoc
Normal file
55
docs/api/index-patterns/default-get.asciidoc
Normal file
|
@ -0,0 +1,55 @@
|
|||
[[index-patterns-api-default-get]]
|
||||
=== Get default index pattern API
|
||||
++++
|
||||
<titleabbrev>Get default index pattern</titleabbrev>
|
||||
++++
|
||||
|
||||
experimental[] Retrieve a default index pattern ID. Kibana UI uses default index pattern unless user picks a different one.
|
||||
|
||||
[[index-patterns-api-default-get-request]]
|
||||
==== Request
|
||||
|
||||
`GET <kibana host>:<port>/api/index_patterns/default`
|
||||
|
||||
`GET <kibana host>:<port>/s/<space_id>/api/index_patterns/default`
|
||||
|
||||
[[index-patterns-api-default-get-params]]
|
||||
==== Path parameters
|
||||
|
||||
`space_id`::
|
||||
(Optional, string) An identifier for the space. If `space_id` is not provided in the URL, the default space is used.
|
||||
|
||||
[[index-patterns-api-default-get-codes]]
|
||||
==== Response code
|
||||
|
||||
`200`::
|
||||
Indicates a successful call.
|
||||
|
||||
[[index-patterns-api-default-get-example]]
|
||||
==== Example
|
||||
|
||||
Retrieve the default index pattern id:
|
||||
|
||||
[source,sh]
|
||||
--------------------------------------------------
|
||||
$ curl -X GET api/index_patterns/default
|
||||
--------------------------------------------------
|
||||
// KIBANA
|
||||
|
||||
The API returns an ID of a default index pattern:
|
||||
|
||||
[source,sh]
|
||||
--------------------------------------------------
|
||||
{
|
||||
"index_pattern_id": "..."
|
||||
}
|
||||
--------------------------------------------------
|
||||
|
||||
In case there is no default index pattern, the API returns:
|
||||
|
||||
[source,sh]
|
||||
--------------------------------------------------
|
||||
{
|
||||
"index_pattern_id": null
|
||||
}
|
||||
--------------------------------------------------
|
84
docs/api/index-patterns/default-set.asciidoc
Normal file
84
docs/api/index-patterns/default-set.asciidoc
Normal file
|
@ -0,0 +1,84 @@
|
|||
[[index-patterns-api-default-set]]
|
||||
=== Set default index pattern API
|
||||
++++
|
||||
<titleabbrev>Set default index pattern</titleabbrev>
|
||||
++++
|
||||
|
||||
experimental[] Set a default index pattern ID. Kibana UI will use default index pattern unless user picks a different one.
|
||||
The API doesn't validate if given `index_pattern_id` is a valid id.
|
||||
|
||||
[[index-patterns-api-default-set-request]]
|
||||
==== Request
|
||||
|
||||
`POST <kibana host>:<port>/api/index_patterns/default`
|
||||
|
||||
`POST <kibana host>:<port>/s/<space_id>/api/index_patterns/default`
|
||||
|
||||
[[index-patterns-api-default-set-params]]
|
||||
==== Path parameters
|
||||
|
||||
`space_id`::
|
||||
(Optional, string) An identifier for the space. If `space_id` is not provided in the URL, the default space is used.
|
||||
|
||||
[[index-patterns-api-default-set-body]]
|
||||
==== Request body
|
||||
|
||||
`index_pattern_id`:: (Required, `string` or `null`) Sets a default index pattern id. Use `null` to unset a default index pattern.
|
||||
|
||||
`force`:: (Optional, boolean) Updates existing default index pattern id. The default is `false`.
|
||||
|
||||
|
||||
[[index-patterns-api-default-set-codes]]
|
||||
==== Response code
|
||||
|
||||
`200`::
|
||||
Indicates a successful call.
|
||||
|
||||
[[index-patterns-api-default-set-example]]
|
||||
==== Example
|
||||
|
||||
Set the default index pattern id if none is set:
|
||||
|
||||
[source,sh]
|
||||
--------------------------------------------------
|
||||
$ curl -X POST api/index_patterns/default
|
||||
{
|
||||
"index_pattern_id": "..."
|
||||
}
|
||||
--------------------------------------------------
|
||||
// KIBANA
|
||||
|
||||
|
||||
Upsert the default index pattern:
|
||||
|
||||
[source,sh]
|
||||
--------------------------------------------------
|
||||
$ curl -X POST api/index_patterns/default
|
||||
{
|
||||
"index_pattern_id": "...",
|
||||
"force": true
|
||||
}
|
||||
--------------------------------------------------
|
||||
// KIBANA
|
||||
|
||||
Unset the default index pattern:
|
||||
|
||||
[source,sh]
|
||||
--------------------------------------------------
|
||||
$ curl -X POST api/index_patterns/default
|
||||
{
|
||||
"index_pattern_id": null,
|
||||
"force": true
|
||||
}
|
||||
--------------------------------------------------
|
||||
// KIBANA
|
||||
|
||||
The API returns:
|
||||
|
||||
[source,sh]
|
||||
--------------------------------------------------
|
||||
{
|
||||
"acknowledged": true
|
||||
}
|
||||
--------------------------------------------------
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [IndexPatternsService](./kibana-plugin-plugins-data-public.indexpatternsservice.md) > [getDefaultId](./kibana-plugin-plugins-data-public.indexpatternsservice.getdefaultid.md)
|
||||
|
||||
## IndexPatternsService.getDefaultId property
|
||||
|
||||
Get default index pattern id
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
getDefaultId: () => Promise<string | null>;
|
||||
```
|
|
@ -27,6 +27,7 @@ export declare class IndexPatternsService
|
|||
| [get](./kibana-plugin-plugins-data-public.indexpatternsservice.get.md) | | <code>(id: string) => Promise<IndexPattern></code> | Get an index pattern by id. Cache optimized |
|
||||
| [getCache](./kibana-plugin-plugins-data-public.indexpatternsservice.getcache.md) | | <code>() => Promise<SavedObject<IndexPatternSavedObjectAttrs>[] | null | undefined></code> | |
|
||||
| [getDefault](./kibana-plugin-plugins-data-public.indexpatternsservice.getdefault.md) | | <code>() => Promise<IndexPattern | null></code> | Get default index pattern |
|
||||
| [getDefaultId](./kibana-plugin-plugins-data-public.indexpatternsservice.getdefaultid.md) | | <code>() => Promise<string | null></code> | Get default index pattern id |
|
||||
| [getFieldsForIndexPattern](./kibana-plugin-plugins-data-public.indexpatternsservice.getfieldsforindexpattern.md) | | <code>(indexPattern: IndexPattern | IndexPatternSpec, options?: GetFieldsOptions | undefined) => Promise<any></code> | Get field list by providing an index patttern (or spec) |
|
||||
| [getFieldsForWildcard](./kibana-plugin-plugins-data-public.indexpatternsservice.getfieldsforwildcard.md) | | <code>(options: GetFieldsOptions) => Promise<any></code> | Get field list by providing { pattern } |
|
||||
| [getIds](./kibana-plugin-plugins-data-public.indexpatternsservice.getids.md) | | <code>(refresh?: boolean) => Promise<string[]></code> | Get list of index pattern ids |
|
||||
|
@ -34,7 +35,7 @@ export declare class IndexPatternsService
|
|||
| [getTitles](./kibana-plugin-plugins-data-public.indexpatternsservice.gettitles.md) | | <code>(refresh?: boolean) => Promise<string[]></code> | Get list of index pattern titles |
|
||||
| [refreshFields](./kibana-plugin-plugins-data-public.indexpatternsservice.refreshfields.md) | | <code>(indexPattern: IndexPattern) => Promise<void></code> | Refresh field list for a given index pattern |
|
||||
| [savedObjectToSpec](./kibana-plugin-plugins-data-public.indexpatternsservice.savedobjecttospec.md) | | <code>(savedObject: SavedObject<IndexPatternAttributes>) => IndexPatternSpec</code> | Converts index pattern saved object to index pattern spec |
|
||||
| [setDefault](./kibana-plugin-plugins-data-public.indexpatternsservice.setdefault.md) | | <code>(id: string, force?: boolean) => Promise<void></code> | Optionally set default index pattern, unless force = true |
|
||||
| [setDefault](./kibana-plugin-plugins-data-public.indexpatternsservice.setdefault.md) | | <code>(id: string | null, force?: boolean) => Promise<void></code> | Optionally set default index pattern, unless force = true |
|
||||
|
||||
## Methods
|
||||
|
||||
|
|
|
@ -9,5 +9,5 @@ Optionally set default index pattern, unless force = true
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
setDefault: (id: string, force?: boolean) => Promise<void>;
|
||||
setDefault: (id: string | null, force?: boolean) => Promise<void>;
|
||||
```
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [IndexPatternsService](./kibana-plugin-plugins-data-server.indexpatternsservice.md) > [getDefaultId](./kibana-plugin-plugins-data-server.indexpatternsservice.getdefaultid.md)
|
||||
|
||||
## IndexPatternsService.getDefaultId property
|
||||
|
||||
Get default index pattern id
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
getDefaultId: () => Promise<string | null>;
|
||||
```
|
|
@ -27,6 +27,7 @@ export declare class IndexPatternsService
|
|||
| [get](./kibana-plugin-plugins-data-server.indexpatternsservice.get.md) | | <code>(id: string) => Promise<IndexPattern></code> | Get an index pattern by id. Cache optimized |
|
||||
| [getCache](./kibana-plugin-plugins-data-server.indexpatternsservice.getcache.md) | | <code>() => Promise<SavedObject<IndexPatternSavedObjectAttrs>[] | null | undefined></code> | |
|
||||
| [getDefault](./kibana-plugin-plugins-data-server.indexpatternsservice.getdefault.md) | | <code>() => Promise<IndexPattern | null></code> | Get default index pattern |
|
||||
| [getDefaultId](./kibana-plugin-plugins-data-server.indexpatternsservice.getdefaultid.md) | | <code>() => Promise<string | null></code> | Get default index pattern id |
|
||||
| [getFieldsForIndexPattern](./kibana-plugin-plugins-data-server.indexpatternsservice.getfieldsforindexpattern.md) | | <code>(indexPattern: IndexPattern | IndexPatternSpec, options?: GetFieldsOptions | undefined) => Promise<any></code> | Get field list by providing an index patttern (or spec) |
|
||||
| [getFieldsForWildcard](./kibana-plugin-plugins-data-server.indexpatternsservice.getfieldsforwildcard.md) | | <code>(options: GetFieldsOptions) => Promise<any></code> | Get field list by providing { pattern } |
|
||||
| [getIds](./kibana-plugin-plugins-data-server.indexpatternsservice.getids.md) | | <code>(refresh?: boolean) => Promise<string[]></code> | Get list of index pattern ids |
|
||||
|
@ -34,7 +35,7 @@ export declare class IndexPatternsService
|
|||
| [getTitles](./kibana-plugin-plugins-data-server.indexpatternsservice.gettitles.md) | | <code>(refresh?: boolean) => Promise<string[]></code> | Get list of index pattern titles |
|
||||
| [refreshFields](./kibana-plugin-plugins-data-server.indexpatternsservice.refreshfields.md) | | <code>(indexPattern: IndexPattern) => Promise<void></code> | Refresh field list for a given index pattern |
|
||||
| [savedObjectToSpec](./kibana-plugin-plugins-data-server.indexpatternsservice.savedobjecttospec.md) | | <code>(savedObject: SavedObject<IndexPatternAttributes>) => IndexPatternSpec</code> | Converts index pattern saved object to index pattern spec |
|
||||
| [setDefault](./kibana-plugin-plugins-data-server.indexpatternsservice.setdefault.md) | | <code>(id: string, force?: boolean) => Promise<void></code> | Optionally set default index pattern, unless force = true |
|
||||
| [setDefault](./kibana-plugin-plugins-data-server.indexpatternsservice.setdefault.md) | | <code>(id: string | null, force?: boolean) => Promise<void></code> | Optionally set default index pattern, unless force = true |
|
||||
|
||||
## Methods
|
||||
|
||||
|
|
|
@ -9,5 +9,5 @@ Optionally set default index pattern, unless force = true
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
setDefault: (id: string, force?: boolean) => Promise<void>;
|
||||
setDefault: (id: string | null, force?: boolean) => Promise<void>;
|
||||
```
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [SearchStrategyDependencies](./kibana-plugin-plugins-data-server.searchstrategydependencies.md) > [request](./kibana-plugin-plugins-data-server.searchstrategydependencies.request.md)
|
||||
|
||||
## SearchStrategyDependencies.request property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
request: KibanaRequest;
|
||||
```
|
|
@ -196,7 +196,7 @@ export class IndexPatternsService {
|
|||
* Get default index pattern
|
||||
*/
|
||||
getDefault = async () => {
|
||||
const defaultIndexPatternId = await this.config.get('defaultIndex');
|
||||
const defaultIndexPatternId = await this.getDefaultId();
|
||||
if (defaultIndexPatternId) {
|
||||
return await this.get(defaultIndexPatternId);
|
||||
}
|
||||
|
@ -204,12 +204,20 @@ export class IndexPatternsService {
|
|||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get default index pattern id
|
||||
*/
|
||||
getDefaultId = async (): Promise<string | null> => {
|
||||
const defaultIndexPatternId = await this.config.get('defaultIndex');
|
||||
return defaultIndexPatternId ?? null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Optionally set default index pattern, unless force = true
|
||||
* @param id
|
||||
* @param force
|
||||
*/
|
||||
setDefault = async (id: string, force = false) => {
|
||||
setDefault = async (id: string | null, force = false) => {
|
||||
if (force || !this.config.get('defaultIndex')) {
|
||||
await this.config.set('defaultIndex', id);
|
||||
}
|
||||
|
|
|
@ -1632,6 +1632,7 @@ export class IndexPatternsService {
|
|||
// (undocumented)
|
||||
getCache: () => Promise<SavedObject<IndexPatternSavedObjectAttrs>[] | null | undefined>;
|
||||
getDefault: () => Promise<IndexPattern | null>;
|
||||
getDefaultId: () => Promise<string | null>;
|
||||
getFieldsForIndexPattern: (indexPattern: IndexPattern | IndexPatternSpec, options?: GetFieldsOptions | undefined) => Promise<any>;
|
||||
// Warning: (ae-forgotten-export) The symbol "GetFieldsOptions" needs to be exported by the entry point index.d.ts
|
||||
getFieldsForWildcard: (options: GetFieldsOptions) => Promise<any>;
|
||||
|
@ -1645,7 +1646,7 @@ export class IndexPatternsService {
|
|||
migrate(indexPattern: IndexPattern, newTitle: string): Promise<this>;
|
||||
refreshFields: (indexPattern: IndexPattern) => Promise<void>;
|
||||
savedObjectToSpec: (savedObject: SavedObject<IndexPatternAttributes>) => IndexPatternSpec;
|
||||
setDefault: (id: string, force?: boolean) => Promise<void>;
|
||||
setDefault: (id: string | null, force?: boolean) => Promise<void>;
|
||||
updateSavedObject(indexPattern: IndexPattern, saveAttempts?: number, ignoreErrors?: boolean): Promise<void | Error>;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import { registerGetScriptedFieldRoute } from './routes/scripted_fields/get_scri
|
|||
import { registerDeleteScriptedFieldRoute } from './routes/scripted_fields/delete_scripted_field';
|
||||
import { registerUpdateScriptedFieldRoute } from './routes/scripted_fields/update_scripted_field';
|
||||
import type { DataPluginStart, DataPluginStartDependencies } from '../plugin';
|
||||
import { registerManageDefaultIndexPatternRoutes } from './routes/default_index_pattern';
|
||||
|
||||
export function registerRoutes(
|
||||
http: HttpServiceSetup,
|
||||
|
@ -42,6 +43,7 @@ export function registerRoutes(
|
|||
registerGetIndexPatternRoute(router, getStartServices);
|
||||
registerDeleteIndexPatternRoute(router, getStartServices);
|
||||
registerUpdateIndexPatternRoute(router, getStartServices);
|
||||
registerManageDefaultIndexPatternRoutes(router, getStartServices);
|
||||
|
||||
// Fields API
|
||||
registerUpdateFieldsRoute(router, getStartServices);
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
||||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import { IRouter, StartServicesAccessor } from '../../../../../core/server';
|
||||
import type { DataPluginStart, DataPluginStartDependencies } from '../../plugin';
|
||||
import { handleErrors } from './util/handle_errors';
|
||||
|
||||
export const registerManageDefaultIndexPatternRoutes = (
|
||||
router: IRouter,
|
||||
getStartServices: StartServicesAccessor<DataPluginStartDependencies, DataPluginStart>
|
||||
) => {
|
||||
router.get(
|
||||
{
|
||||
path: '/api/index_patterns/default',
|
||||
validate: {},
|
||||
},
|
||||
handleErrors(async (ctx, req, res) => {
|
||||
const savedObjectsClient = ctx.core.savedObjects.client;
|
||||
const elasticsearchClient = ctx.core.elasticsearch.client.asCurrentUser;
|
||||
const [, , { indexPatterns }] = await getStartServices();
|
||||
const indexPatternsService = await indexPatterns.indexPatternsServiceFactory(
|
||||
savedObjectsClient,
|
||||
elasticsearchClient
|
||||
);
|
||||
|
||||
const defaultIndexPatternId = await indexPatternsService.getDefaultId();
|
||||
|
||||
return res.ok({
|
||||
body: {
|
||||
index_pattern_id: defaultIndexPatternId,
|
||||
},
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
router.post(
|
||||
{
|
||||
path: '/api/index_patterns/default',
|
||||
validate: {
|
||||
body: schema.object({
|
||||
index_pattern_id: schema.nullable(
|
||||
schema.string({
|
||||
minLength: 1,
|
||||
maxLength: 1_000,
|
||||
})
|
||||
),
|
||||
force: schema.boolean({ defaultValue: false }),
|
||||
}),
|
||||
},
|
||||
},
|
||||
handleErrors(async (ctx, req, res) => {
|
||||
const savedObjectsClient = ctx.core.savedObjects.client;
|
||||
const elasticsearchClient = ctx.core.elasticsearch.client.asCurrentUser;
|
||||
const [, , { indexPatterns }] = await getStartServices();
|
||||
const indexPatternsService = await indexPatterns.indexPatternsServiceFactory(
|
||||
savedObjectsClient,
|
||||
elasticsearchClient
|
||||
);
|
||||
|
||||
const newDefaultId = req.body.index_pattern_id;
|
||||
const force = req.body.force;
|
||||
|
||||
await indexPatternsService.setDefault(newDefaultId, force);
|
||||
|
||||
return res.ok({
|
||||
body: {
|
||||
acknowledged: true,
|
||||
},
|
||||
});
|
||||
})
|
||||
);
|
||||
};
|
|
@ -968,6 +968,7 @@ class IndexPatternsService {
|
|||
// (undocumented)
|
||||
getCache: () => Promise<SavedObject_2<IndexPatternSavedObjectAttrs>[] | null | undefined>;
|
||||
getDefault: () => Promise<IndexPattern | null>;
|
||||
getDefaultId: () => Promise<string | null>;
|
||||
getFieldsForIndexPattern: (indexPattern: IndexPattern | IndexPatternSpec, options?: GetFieldsOptions | undefined) => Promise<any>;
|
||||
// Warning: (ae-forgotten-export) The symbol "GetFieldsOptions" needs to be exported by the entry point index.d.ts
|
||||
getFieldsForWildcard: (options: GetFieldsOptions) => Promise<any>;
|
||||
|
@ -981,7 +982,7 @@ class IndexPatternsService {
|
|||
migrate(indexPattern: IndexPattern, newTitle: string): Promise<this>;
|
||||
refreshFields: (indexPattern: IndexPattern) => Promise<void>;
|
||||
savedObjectToSpec: (savedObject: SavedObject_2<IndexPatternAttributes>) => IndexPatternSpec;
|
||||
setDefault: (id: string, force?: boolean) => Promise<void>;
|
||||
setDefault: (id: string | null, force?: boolean) => Promise<void>;
|
||||
updateSavedObject(indexPattern: IndexPattern, saveAttempts?: number, ignoreErrors?: boolean): Promise<void | Error>;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
||||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import expect from '@kbn/expect';
|
||||
import { FtrProviderContext } from '../../../ftr_provider_context';
|
||||
|
||||
export default function ({ getService }: FtrProviderContext) {
|
||||
const supertest = getService('supertest');
|
||||
|
||||
describe('default index pattern api', () => {
|
||||
const newId = () => `default-id-${Date.now()}-${Math.random()}`;
|
||||
it('can set default index pattern', async () => {
|
||||
const defaultId = newId();
|
||||
const response1 = await supertest.post('/api/index_patterns/default').send({
|
||||
index_pattern_id: defaultId,
|
||||
force: true,
|
||||
});
|
||||
expect(response1.status).to.be(200);
|
||||
expect(response1.body.acknowledged).to.be(true);
|
||||
|
||||
const response2 = await supertest.get('/api/index_patterns/default');
|
||||
expect(response2.status).to.be(200);
|
||||
expect(response2.body.index_pattern_id).to.be(defaultId);
|
||||
|
||||
const response3 = await supertest.post('/api/index_patterns/default').send({
|
||||
index_pattern_id: newId(),
|
||||
// no force this time, so this new default shouldn't be set
|
||||
});
|
||||
|
||||
expect(response3.status).to.be(200);
|
||||
const response4 = await supertest.get('/api/index_patterns/default');
|
||||
expect(response4.body.index_pattern_id).to.be(defaultId); // original default id is used
|
||||
|
||||
const response5 = await supertest.post('/api/index_patterns/default').send({
|
||||
index_pattern_id: null,
|
||||
force: true,
|
||||
});
|
||||
expect(response5.status).to.be(200);
|
||||
|
||||
const response6 = await supertest.get('/api/index_patterns/default');
|
||||
expect(response6.body.index_pattern_id).to.be(null);
|
||||
});
|
||||
});
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
||||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { FtrProviderContext } from '../../../ftr_provider_context';
|
||||
|
||||
export default function ({ loadTestFile }: FtrProviderContext) {
|
||||
describe('default index pattern', () => {
|
||||
loadTestFile(require.resolve('./default_index_pattern'));
|
||||
});
|
||||
}
|
|
@ -14,5 +14,6 @@ export default function ({ loadTestFile }) {
|
|||
loadTestFile(require.resolve('./index_pattern_crud'));
|
||||
loadTestFile(require.resolve('./scripted_fields_crud'));
|
||||
loadTestFile(require.resolve('./fields_api'));
|
||||
loadTestFile(require.resolve('./default_index_pattern'));
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue