Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
*/

import { z } from '@kbn/zod';
import { BooleanFromString } from '@kbn/zod-helpers';

export type MonitoringEntitySourceDescriptor = z.infer<typeof MonitoringEntitySourceDescriptor>;
export const MonitoringEntitySourceDescriptor = z.object({
export type CreateMonitoringEntitySource = z.infer<typeof CreateMonitoringEntitySource>;
export const CreateMonitoringEntitySource = z.object({
type: z.string(),
name: z.string(),
managed: z.boolean().optional(),
Expand All @@ -33,14 +34,42 @@ export const MonitoringEntitySourceDescriptor = z.object({
})
)
.optional(),
filter: z.object({}).optional(),
filter: z
.object({
kuery: z.union([z.string(), z.object({})]).optional(),
})
.optional(),
});

export type MonitoringEntitySourceResponse = z.infer<typeof MonitoringEntitySourceResponse>;
export const MonitoringEntitySourceResponse = z.object({
id: z.string().optional(),
name: z.string().optional(),
export type UpdatedMonitoringEntitySource = z.infer<typeof UpdatedMonitoringEntitySource>;
export const UpdatedMonitoringEntitySource = z.object({
type: z.string().optional(),
name: z.string().optional(),
managed: z.boolean().optional(),
indexPattern: z.string().optional(),
enabled: z.boolean().optional(),
error: z.string().optional(),
integrationName: z.string().optional(),
matchers: z
.array(
z.object({
fields: z.array(z.string()),
values: z.array(z.string()),
})
)
.optional(),
filter: z
.object({
kuery: z.union([z.string(), z.object({})]).optional(),
})
.optional(),
});

export type MonitoringEntitySource = z.infer<typeof MonitoringEntitySource>;
export const MonitoringEntitySource = z.object({
id: z.string(),
name: z.string(),
type: z.string(),
indexPattern: z.string().optional(),
integrationName: z.string().optional(),
enabled: z.boolean().optional(),
Expand All @@ -52,4 +81,54 @@ export const MonitoringEntitySourceResponse = z.object({
})
)
.optional(),
filter: z
.object({
kuery: z.union([z.string(), z.object({})]).optional(),
})
.optional(),
});

export type CreateEntitySourceRequestBody = z.infer<typeof CreateEntitySourceRequestBody>;
export const CreateEntitySourceRequestBody = CreateMonitoringEntitySource;
export type CreateEntitySourceRequestBodyInput = z.input<typeof CreateEntitySourceRequestBody>;

export type CreateEntitySourceResponse = z.infer<typeof CreateEntitySourceResponse>;
export const CreateEntitySourceResponse = UpdatedMonitoringEntitySource;

export type DeleteEntitySourceRequestParams = z.infer<typeof DeleteEntitySourceRequestParams>;
export const DeleteEntitySourceRequestParams = z.object({
id: z.string(),
});
export type DeleteEntitySourceRequestParamsInput = z.input<typeof DeleteEntitySourceRequestParams>;

export type GetEntitySourceRequestParams = z.infer<typeof GetEntitySourceRequestParams>;
export const GetEntitySourceRequestParams = z.object({
id: z.string(),
});
export type GetEntitySourceRequestParamsInput = z.input<typeof GetEntitySourceRequestParams>;

export type GetEntitySourceResponse = z.infer<typeof GetEntitySourceResponse>;
export const GetEntitySourceResponse = MonitoringEntitySource;
export type ListEntitySourcesRequestQuery = z.infer<typeof ListEntitySourcesRequestQuery>;
export const ListEntitySourcesRequestQuery = z.object({
type: z.string().optional(),
managed: BooleanFromString.optional(),
name: z.string().optional(),
});
export type ListEntitySourcesRequestQueryInput = z.input<typeof ListEntitySourcesRequestQuery>;

export type ListEntitySourcesResponse = z.infer<typeof ListEntitySourcesResponse>;
export const ListEntitySourcesResponse = z.array(MonitoringEntitySource);

export type UpdateEntitySourceRequestParams = z.infer<typeof UpdateEntitySourceRequestParams>;
export const UpdateEntitySourceRequestParams = z.object({
id: z.string(),
});
export type UpdateEntitySourceRequestParamsInput = z.input<typeof UpdateEntitySourceRequestParams>;

export type UpdateEntitySourceRequestBody = z.infer<typeof UpdateEntitySourceRequestBody>;
export const UpdateEntitySourceRequestBody = MonitoringEntitySource;
export type UpdateEntitySourceRequestBodyInput = z.input<typeof UpdateEntitySourceRequestBody>;

export type UpdateEntitySourceResponse = z.infer<typeof UpdateEntitySourceResponse>;
export const UpdateEntitySourceResponse = UpdatedMonitoringEntitySource;
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,27 @@ info:
paths:
/api/entity_analytics/monitoring/entity_source:
post:
operationId: createEntitySource
operationId: CreateEntitySource
x-codegen-enabled: true
summary: Create a new entity source configuration
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/MonitoringEntitySourceDescriptor"
$ref: "#/components/schemas/CreateMonitoringEntitySource"
responses:
"200":
description: Entity source created successfully
content:
application/json:
schema:
$ref: "#/components/schemas/MonitoringEntitySourceResponse"
$ref: "#/components/schemas/UpdatedMonitoringEntitySource"

/api/entity_analytics/monitoring/entity_source/{id}:
get:
operationId: getEntitySource
operationId: GetEntitySource
x-codegen-enabled: true
summary: Get an entity source configuration by ID
parameters:
- name: id
Expand All @@ -39,10 +41,11 @@ paths:
content:
application/json:
schema:
$ref: "#/components/schemas/MonitoringEntitySourceResponse"
$ref: "#/components/schemas/MonitoringEntitySource"

put:
operationId: updateEntitySource
operationId: UpdateEntitySource
x-codegen-enabled: true
summary: Update an entity source configuration
parameters:
- name: id
Expand All @@ -55,13 +58,18 @@ paths:
content:
application/json:
schema:
$ref: "#/components/schemas/MonitoringEntitySourceDescriptor"
$ref: "#/components/schemas/MonitoringEntitySource"
responses:
"200":
description: Entity source updated successfully
content:
application/json:
schema:
$ref: "#/components/schemas/UpdatedMonitoringEntitySource"

delete:
operationId: deleteEntitySource
operationId: DeleteEntitySource
x-codegen-enabled: true
summary: Delete an entity source configuration
parameters:
- name: id
Expand All @@ -75,8 +83,23 @@ paths:

/api/entity_analytics/monitoring/entity_source/list:
get:
operationId: listEntitySources
operationId: ListEntitySources
x-codegen-enabled: true
summary: List all entity source configurations
parameters:
- name: type
in: query
schema:
type: string
- name: managed
in: query
schema:
type: boolean
- name: name
in: query
schema:
type: string

responses:
"200":
description: List of entity sources retrieved
Expand All @@ -85,10 +108,10 @@ paths:
schema:
type: array
items:
$ref: "#/components/schemas/MonitoringEntitySourceDescriptor"
$ref: "#/components/schemas/MonitoringEntitySource"
components:
schemas:
MonitoringEntitySourceDescriptor:
CreateMonitoringEntitySource:
type: object
required: [type, name]
properties:
Expand Down Expand Up @@ -124,9 +147,56 @@ components:
type: string
filter:
type: object
properties:
kuery:
oneOf:
- type: string
- type: object

MonitoringEntitySourceResponse:
UpdatedMonitoringEntitySource:
type: object
properties:
type:
type: string
name:
type: string
managed:
type: boolean
indexPattern:
type: string
enabled:
type: boolean
error:
type: string
integrationName:
type: string
matchers:
type: array
items:
type: object
required:
- fields
- values
properties:
fields:
type: array
items:
type: string
values:
type: array
items:
type: string
filter:
type: object
properties:
kuery:
oneOf:
- type: string
- type: object

MonitoringEntitySource:
type: object
required: [type, name, id, managed]
properties:
id:
type: string
Expand Down Expand Up @@ -155,4 +225,11 @@ components:
values:
type: array
items:
type: string
type: string
filter:
type: object
properties:
kuery:
oneOf:
- type: string
- type: object
Loading