Skip to content

Commit

Permalink
docs update
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzad31 committed Aug 8, 2024
1 parent e40c095 commit 364d674
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 12 deletions.
24 changes: 22 additions & 2 deletions docs/api/synthetics/monitors/delete-monitor-api.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ Deletes one or more monitors from the Synthetics app.

=== {api-request-title}

`DELETE <kibana host>:<port>/api/synthetics/monitors`
`DELETE <kibana host>:<port>/api/synthetics/monitors/<config_id>`

`DELETE <kibana host>:<port>/s/<space_id>/api/synthetics/monitors`
`DELETE <kibana host>:<port>/s/<space_id>/api/synthetics/monitors/<config_id>`

=== {api-prereq-title}

Expand All @@ -20,6 +20,26 @@ You must have `all` privileges for the *Synthetics* feature in the *{observabili
You must have `all` privileges for the *Synthetics* feature in the *{observability}* section of the
<<kibana-feature-privileges,{kib} feature privileges>>.


[[delete-monitor-api-path-params]]
=== {api-path-parms-title}

`config_id`::
(Required, string) The ID of the monitor that you want to delete.


Here is an example of a DELETE request to delete a monitor by ID:

[source,sh]
--------------------------------------------------
DELETE /api/synthetics/monitors/monitor1-id
--------------------------------------------------

==== Bulk Delete Monitors

You can delete multiple monitors by sending a list of config ids to a DELETE request to the `/api/synthetics/monitors` endpoint.


[[monitors-delete-request-body]]
==== Request Body

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export function useMonitorListColumns({
},
{
'data-test-subj': 'syntheticsMonitorCopyAction',
isPrimary: true,
isPrimary: false,
name: (fields) => (
<NoPermissionsTooltip
canEditSynthetics={canEditSynthetics}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,36 @@ import { formatSecrets, normalizeSecrets } from '../../synthetics_service/utils/

export const deleteSyntheticsMonitorRoute: SyntheticsRestApiRouteFactory<
DeleteParamsResponse[],
Record<string, any>,
Record<string, any>,
Record<string, string>,
Record<string, string>,
{ ids: string[] }
> = () => ({
method: 'DELETE',
path: SYNTHETICS_API_URLS.SYNTHETICS_MONITORS,
path: SYNTHETICS_API_URLS.SYNTHETICS_MONITORS + '/{id?}',
validate: {},
validation: {
request: {
body: schema.object({
ids: schema.arrayOf(schema.string(), {
minSize: 1,
}),
body: schema.nullable(
schema.object({
ids: schema.arrayOf(schema.string(), {
minSize: 1,
}),
})
),
params: schema.object({
id: schema.maybe(schema.string()),
}),
},
},
handler: async (routeContext): Promise<any> => {
const { request, response } = routeContext;

const { ids } = request.body;
const { ids } = request.body || {};
const { id: queryId } = request.params;

const result: Array<{ id: string; deleted: boolean; error?: string }> = [];

await pMap(ids, async (id) => {
await pMap([...(ids ?? []), ...(queryId ? [queryId] : [])], async (id) => {
try {
const { errors, res } = await deleteMonitor({
routeContext,
Expand Down

0 comments on commit 364d674

Please sign in to comment.