mirror of
https://github.com/elastic/kibana.git
synced 2025-06-28 11:05:39 -04:00
## Summary
Resolves https://github.com/elastic/security-docs-internal/issues/32 by
improving the Lists API docs content. Adds missing and improves existing
operation summaries and operation descriptions to adhere to our [OAS
standards](450494532/API+reference+docs
).
Note: Couldn’t add description for the GET /api/lists/privileges
operation, since it's not documented in [ESS API
docs](https://www.elastic.co/guide/en/security/8.15/security-apis.html).
---------
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
430 lines
13 KiB
TypeScript
430 lines
13 KiB
TypeScript
/*
|
|
* 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", the "GNU Affero General Public License v3.0 only", 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", the "GNU Affero General Public
|
|
* License v3.0 only", or the "Server Side Public License, v 1".
|
|
*/
|
|
|
|
/*
|
|
* NOTICE: Do not edit this file manually.
|
|
* This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator.
|
|
*
|
|
* info:
|
|
* title: Lists API client for quickstart
|
|
* version: Bundle (no version)
|
|
*/
|
|
|
|
import type { KbnClient } from '@kbn/test';
|
|
import { ToolingLog } from '@kbn/tooling-log';
|
|
import { ELASTIC_HTTP_VERSION_HEADER } from '@kbn/core-http-common';
|
|
import { catchAxiosErrorFormatAndThrow } from '@kbn/securitysolution-utils';
|
|
|
|
import type { CreateListIndexResponse } from './create_list_index/create_list_index.gen';
|
|
import type {
|
|
CreateListItemRequestBodyInput,
|
|
CreateListItemResponse,
|
|
} from './create_list_item/create_list_item.gen';
|
|
import type { CreateListRequestBodyInput, CreateListResponse } from './create_list/create_list.gen';
|
|
import type { DeleteListIndexResponse } from './delete_list_index/delete_list_index.gen';
|
|
import type {
|
|
DeleteListItemRequestQueryInput,
|
|
DeleteListItemResponse,
|
|
} from './delete_list_item/delete_list_item.gen';
|
|
import type {
|
|
DeleteListRequestQueryInput,
|
|
DeleteListResponse,
|
|
} from './delete_list/delete_list.gen';
|
|
import type { ExportListItemsRequestQueryInput } from './export_list_items/export_list_items.gen';
|
|
import type {
|
|
FindListItemsRequestQueryInput,
|
|
FindListItemsResponse,
|
|
} from './find_list_items/find_list_items.gen';
|
|
import type { FindListsRequestQueryInput, FindListsResponse } from './find_lists/find_lists.gen';
|
|
import type {
|
|
ImportListItemsRequestQueryInput,
|
|
ImportListItemsResponse,
|
|
} from './import_list_items/import_list_items.gen';
|
|
import type {
|
|
PatchListItemRequestBodyInput,
|
|
PatchListItemResponse,
|
|
} from './patch_list_item/patch_list_item.gen';
|
|
import type { PatchListRequestBodyInput, PatchListResponse } from './patch_list/patch_list.gen';
|
|
import type { ReadListIndexResponse } from './read_list_index/read_list_index.gen';
|
|
import type {
|
|
ReadListItemRequestQueryInput,
|
|
ReadListItemResponse,
|
|
} from './read_list_item/read_list_item.gen';
|
|
import type { ReadListPrivilegesResponse } from './read_list_privileges/read_list_privileges.gen';
|
|
import type { ReadListRequestQueryInput, ReadListResponse } from './read_list/read_list.gen';
|
|
import type {
|
|
UpdateListItemRequestBodyInput,
|
|
UpdateListItemResponse,
|
|
} from './update_list_item/update_list_item.gen';
|
|
import type { UpdateListRequestBodyInput, UpdateListResponse } from './update_list/update_list.gen';
|
|
|
|
export interface ClientOptions {
|
|
kbnClient: KbnClient;
|
|
log: ToolingLog;
|
|
}
|
|
|
|
export class Client {
|
|
readonly kbnClient: KbnClient;
|
|
readonly log: ToolingLog;
|
|
|
|
constructor(options: ClientOptions) {
|
|
this.kbnClient = options.kbnClient;
|
|
this.log = options.log;
|
|
}
|
|
/**
|
|
* Create a new list.
|
|
*/
|
|
async createList(props: CreateListProps) {
|
|
this.log.info(`${new Date().toISOString()} Calling API CreateList`);
|
|
return this.kbnClient
|
|
.request<CreateListResponse>({
|
|
path: '/api/lists',
|
|
headers: {
|
|
[ELASTIC_HTTP_VERSION_HEADER]: '2023-10-31',
|
|
},
|
|
method: 'POST',
|
|
body: props.body,
|
|
})
|
|
.catch(catchAxiosErrorFormatAndThrow);
|
|
}
|
|
/**
|
|
* Create `.lists` and `.items` data streams in the relevant space.
|
|
*/
|
|
async createListIndex() {
|
|
this.log.info(`${new Date().toISOString()} Calling API CreateListIndex`);
|
|
return this.kbnClient
|
|
.request<CreateListIndexResponse>({
|
|
path: '/api/lists/index',
|
|
headers: {
|
|
[ELASTIC_HTTP_VERSION_HEADER]: '2023-10-31',
|
|
},
|
|
method: 'POST',
|
|
})
|
|
.catch(catchAxiosErrorFormatAndThrow);
|
|
}
|
|
/**
|
|
* Create a list item and associate it with the specified list.
|
|
|
|
All list items in the same list must be the same type. For example, each list item in an `ip` list must define a specific IP address.
|
|
> info
|
|
> Before creating a list item, you must create a list.
|
|
|
|
*/
|
|
async createListItem(props: CreateListItemProps) {
|
|
this.log.info(`${new Date().toISOString()} Calling API CreateListItem`);
|
|
return this.kbnClient
|
|
.request<CreateListItemResponse>({
|
|
path: '/api/lists/items',
|
|
headers: {
|
|
[ELASTIC_HTTP_VERSION_HEADER]: '2023-10-31',
|
|
},
|
|
method: 'POST',
|
|
body: props.body,
|
|
})
|
|
.catch(catchAxiosErrorFormatAndThrow);
|
|
}
|
|
/**
|
|
* Delete a list using the list ID.
|
|
> info
|
|
> When you delete a list, all of its list items are also deleted.
|
|
|
|
*/
|
|
async deleteList(props: DeleteListProps) {
|
|
this.log.info(`${new Date().toISOString()} Calling API DeleteList`);
|
|
return this.kbnClient
|
|
.request<DeleteListResponse>({
|
|
path: '/api/lists',
|
|
headers: {
|
|
[ELASTIC_HTTP_VERSION_HEADER]: '2023-10-31',
|
|
},
|
|
method: 'DELETE',
|
|
|
|
query: props.query,
|
|
})
|
|
.catch(catchAxiosErrorFormatAndThrow);
|
|
}
|
|
/**
|
|
* Delete the `.lists` and `.items` data streams.
|
|
*/
|
|
async deleteListIndex() {
|
|
this.log.info(`${new Date().toISOString()} Calling API DeleteListIndex`);
|
|
return this.kbnClient
|
|
.request<DeleteListIndexResponse>({
|
|
path: '/api/lists/index',
|
|
headers: {
|
|
[ELASTIC_HTTP_VERSION_HEADER]: '2023-10-31',
|
|
},
|
|
method: 'DELETE',
|
|
})
|
|
.catch(catchAxiosErrorFormatAndThrow);
|
|
}
|
|
/**
|
|
* Delete a list item using its `id`, or its `list_id` and `value` fields.
|
|
*/
|
|
async deleteListItem(props: DeleteListItemProps) {
|
|
this.log.info(`${new Date().toISOString()} Calling API DeleteListItem`);
|
|
return this.kbnClient
|
|
.request<DeleteListItemResponse>({
|
|
path: '/api/lists/items',
|
|
headers: {
|
|
[ELASTIC_HTTP_VERSION_HEADER]: '2023-10-31',
|
|
},
|
|
method: 'DELETE',
|
|
|
|
query: props.query,
|
|
})
|
|
.catch(catchAxiosErrorFormatAndThrow);
|
|
}
|
|
/**
|
|
* Export list item values from the specified list.
|
|
*/
|
|
async exportListItems(props: ExportListItemsProps) {
|
|
this.log.info(`${new Date().toISOString()} Calling API ExportListItems`);
|
|
return this.kbnClient
|
|
.request({
|
|
path: '/api/lists/items/_export',
|
|
headers: {
|
|
[ELASTIC_HTTP_VERSION_HEADER]: '2023-10-31',
|
|
},
|
|
method: 'POST',
|
|
|
|
query: props.query,
|
|
})
|
|
.catch(catchAxiosErrorFormatAndThrow);
|
|
}
|
|
/**
|
|
* Get all list items in the specified list.
|
|
*/
|
|
async findListItems(props: FindListItemsProps) {
|
|
this.log.info(`${new Date().toISOString()} Calling API FindListItems`);
|
|
return this.kbnClient
|
|
.request<FindListItemsResponse>({
|
|
path: '/api/lists/items/_find',
|
|
headers: {
|
|
[ELASTIC_HTTP_VERSION_HEADER]: '2023-10-31',
|
|
},
|
|
method: 'GET',
|
|
|
|
query: props.query,
|
|
})
|
|
.catch(catchAxiosErrorFormatAndThrow);
|
|
}
|
|
/**
|
|
* Get a paginated subset of lists. By default, the first page is returned, with 20 results per page.
|
|
*/
|
|
async findLists(props: FindListsProps) {
|
|
this.log.info(`${new Date().toISOString()} Calling API FindLists`);
|
|
return this.kbnClient
|
|
.request<FindListsResponse>({
|
|
path: '/api/lists/_find',
|
|
headers: {
|
|
[ELASTIC_HTTP_VERSION_HEADER]: '2023-10-31',
|
|
},
|
|
method: 'GET',
|
|
|
|
query: props.query,
|
|
})
|
|
.catch(catchAxiosErrorFormatAndThrow);
|
|
}
|
|
/**
|
|
* Import list items from a TXT or CSV file. The maximum file size is 9 million bytes.
|
|
|
|
You can import items to a new or existing list.
|
|
|
|
*/
|
|
async importListItems(props: ImportListItemsProps) {
|
|
this.log.info(`${new Date().toISOString()} Calling API ImportListItems`);
|
|
return this.kbnClient
|
|
.request<ImportListItemsResponse>({
|
|
path: '/api/lists/items/_import',
|
|
headers: {
|
|
[ELASTIC_HTTP_VERSION_HEADER]: '2023-10-31',
|
|
},
|
|
method: 'POST',
|
|
body: props.attachment,
|
|
query: props.query,
|
|
})
|
|
.catch(catchAxiosErrorFormatAndThrow);
|
|
}
|
|
/**
|
|
* Update specific fields of an existing list using the list ID.
|
|
*/
|
|
async patchList(props: PatchListProps) {
|
|
this.log.info(`${new Date().toISOString()} Calling API PatchList`);
|
|
return this.kbnClient
|
|
.request<PatchListResponse>({
|
|
path: '/api/lists',
|
|
headers: {
|
|
[ELASTIC_HTTP_VERSION_HEADER]: '2023-10-31',
|
|
},
|
|
method: 'PATCH',
|
|
body: props.body,
|
|
})
|
|
.catch(catchAxiosErrorFormatAndThrow);
|
|
}
|
|
/**
|
|
* Update specific fields of an existing list item using the list item ID.
|
|
*/
|
|
async patchListItem(props: PatchListItemProps) {
|
|
this.log.info(`${new Date().toISOString()} Calling API PatchListItem`);
|
|
return this.kbnClient
|
|
.request<PatchListItemResponse>({
|
|
path: '/api/lists/items',
|
|
headers: {
|
|
[ELASTIC_HTTP_VERSION_HEADER]: '2023-10-31',
|
|
},
|
|
method: 'PATCH',
|
|
body: props.body,
|
|
})
|
|
.catch(catchAxiosErrorFormatAndThrow);
|
|
}
|
|
/**
|
|
* Get the details of a list using the list ID.
|
|
*/
|
|
async readList(props: ReadListProps) {
|
|
this.log.info(`${new Date().toISOString()} Calling API ReadList`);
|
|
return this.kbnClient
|
|
.request<ReadListResponse>({
|
|
path: '/api/lists',
|
|
headers: {
|
|
[ELASTIC_HTTP_VERSION_HEADER]: '2023-10-31',
|
|
},
|
|
method: 'GET',
|
|
|
|
query: props.query,
|
|
})
|
|
.catch(catchAxiosErrorFormatAndThrow);
|
|
}
|
|
/**
|
|
* Verify that `.lists` and `.items` data streams exist.
|
|
*/
|
|
async readListIndex() {
|
|
this.log.info(`${new Date().toISOString()} Calling API ReadListIndex`);
|
|
return this.kbnClient
|
|
.request<ReadListIndexResponse>({
|
|
path: '/api/lists/index',
|
|
headers: {
|
|
[ELASTIC_HTTP_VERSION_HEADER]: '2023-10-31',
|
|
},
|
|
method: 'GET',
|
|
})
|
|
.catch(catchAxiosErrorFormatAndThrow);
|
|
}
|
|
/**
|
|
* Get the details of a list item.
|
|
*/
|
|
async readListItem(props: ReadListItemProps) {
|
|
this.log.info(`${new Date().toISOString()} Calling API ReadListItem`);
|
|
return this.kbnClient
|
|
.request<ReadListItemResponse>({
|
|
path: '/api/lists/items',
|
|
headers: {
|
|
[ELASTIC_HTTP_VERSION_HEADER]: '2023-10-31',
|
|
},
|
|
method: 'GET',
|
|
|
|
query: props.query,
|
|
})
|
|
.catch(catchAxiosErrorFormatAndThrow);
|
|
}
|
|
async readListPrivileges() {
|
|
this.log.info(`${new Date().toISOString()} Calling API ReadListPrivileges`);
|
|
return this.kbnClient
|
|
.request<ReadListPrivilegesResponse>({
|
|
path: '/api/lists/privileges',
|
|
headers: {
|
|
[ELASTIC_HTTP_VERSION_HEADER]: '2023-10-31',
|
|
},
|
|
method: 'GET',
|
|
})
|
|
.catch(catchAxiosErrorFormatAndThrow);
|
|
}
|
|
/**
|
|
* Update a list using the list ID. The original list is replaced, and all unspecified fields are deleted.
|
|
> info
|
|
> You cannot modify the `id` value.
|
|
|
|
*/
|
|
async updateList(props: UpdateListProps) {
|
|
this.log.info(`${new Date().toISOString()} Calling API UpdateList`);
|
|
return this.kbnClient
|
|
.request<UpdateListResponse>({
|
|
path: '/api/lists',
|
|
headers: {
|
|
[ELASTIC_HTTP_VERSION_HEADER]: '2023-10-31',
|
|
},
|
|
method: 'PUT',
|
|
body: props.body,
|
|
})
|
|
.catch(catchAxiosErrorFormatAndThrow);
|
|
}
|
|
/**
|
|
* Update a list item using the list item ID. The original list item is replaced, and all unspecified fields are deleted.
|
|
> info
|
|
> You cannot modify the `id` value.
|
|
|
|
*/
|
|
async updateListItem(props: UpdateListItemProps) {
|
|
this.log.info(`${new Date().toISOString()} Calling API UpdateListItem`);
|
|
return this.kbnClient
|
|
.request<UpdateListItemResponse>({
|
|
path: '/api/lists/items',
|
|
headers: {
|
|
[ELASTIC_HTTP_VERSION_HEADER]: '2023-10-31',
|
|
},
|
|
method: 'PUT',
|
|
body: props.body,
|
|
})
|
|
.catch(catchAxiosErrorFormatAndThrow);
|
|
}
|
|
}
|
|
|
|
export interface CreateListProps {
|
|
body: CreateListRequestBodyInput;
|
|
}
|
|
export interface CreateListItemProps {
|
|
body: CreateListItemRequestBodyInput;
|
|
}
|
|
export interface DeleteListProps {
|
|
query: DeleteListRequestQueryInput;
|
|
}
|
|
export interface DeleteListItemProps {
|
|
query: DeleteListItemRequestQueryInput;
|
|
}
|
|
export interface ExportListItemsProps {
|
|
query: ExportListItemsRequestQueryInput;
|
|
}
|
|
export interface FindListItemsProps {
|
|
query: FindListItemsRequestQueryInput;
|
|
}
|
|
export interface FindListsProps {
|
|
query: FindListsRequestQueryInput;
|
|
}
|
|
export interface ImportListItemsProps {
|
|
query: ImportListItemsRequestQueryInput;
|
|
attachment: FormData;
|
|
}
|
|
export interface PatchListProps {
|
|
body: PatchListRequestBodyInput;
|
|
}
|
|
export interface PatchListItemProps {
|
|
body: PatchListItemRequestBodyInput;
|
|
}
|
|
export interface ReadListProps {
|
|
query: ReadListRequestQueryInput;
|
|
}
|
|
export interface ReadListItemProps {
|
|
query: ReadListItemRequestQueryInput;
|
|
}
|
|
export interface UpdateListProps {
|
|
body: UpdateListRequestBodyInput;
|
|
}
|
|
export interface UpdateListItemProps {
|
|
body: UpdateListItemRequestBodyInput;
|
|
}
|