Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
machadoum committed Nov 21, 2024
1 parent 3cd8fc4 commit 44adc4a
Show file tree
Hide file tree
Showing 28 changed files with 697 additions and 599 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,3 @@ const PatternComponent: React.FC<Props> = ({
PatternComponent.displayName = 'PatternComponent';

export const Pattern = React.memo(PatternComponent);

// can be postponed
// TODO Task needs a sub item to show issues and other values
// TODO transform needs a sub item to show issues and other values
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,37 @@ export const EngineDescriptor = z.object({
error: z.object({}).optional(),
});

export type EngineComponentResource = z.infer<typeof EngineComponentResource>;
export const EngineComponentResource = z.enum([
'entity_engine',
'entity_definition',
'index',
'component_template',
'index_template',
'ingest_pipeline',
'enrich_policy',
'task',
'transform',
]);
export type EngineComponentResourceEnum = typeof EngineComponentResource.enum;
export const EngineComponentResourceEnum = EngineComponentResource.enum;

export type EngineComponentStatus = z.infer<typeof EngineComponentStatus>;
export const EngineComponentStatus = z.object({
id: z.string(),
installed: z.boolean(),
resource: EngineComponentResource,
health: z.enum(['green', 'yellow', 'red', 'unknown']).optional(),
errors: z
.array(
z.object({
title: z.string().optional(),
message: z.string().optional(),
})
)
.optional(),
});

export type StoreStatus = z.infer<typeof StoreStatus>;
export const StoreStatus = z.enum(['not_installed', 'installing', 'running', 'stopped', 'error']);
export type StoreStatusEnum = typeof StoreStatus.enum;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,49 @@ components:
- updating
- error

EngineComponentStatus:
type: object
required:
- id
- installed
- resource
properties:
id:
type: string
installed:
type: boolean
resource:
$ref: '#/components/schemas/EngineComponentResource'
health:
type: string
enum:
- green
- yellow
- red
- unknown
errors:
type: array
items:
type: object
properties:
title:
type: string
message:
type: string

EngineComponentResource:
type: string
enum:
- entity_engine
- entity_definition
- index
- component_template
- index_template
- ingest_pipeline
- enrich_policy
- task
- transform

StoreStatus:
type: string
enum:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@

import { z } from '@kbn/zod';

import { IndexPattern, EngineDescriptor, StoreStatus } from './common.gen';

export type GetEntityStoreStatusResponse = z.infer<typeof GetEntityStoreStatusResponse>;
export const GetEntityStoreStatusResponse = z.object({
status: StoreStatus.optional(),
engines: z.array(EngineDescriptor).optional(),
});
import { IndexPattern, EngineDescriptor } from './common.gen';

export type InitEntityStoreRequestBody = z.infer<typeof InitEntityStoreRequestBody>;
export const InitEntityStoreRequestBody = z.object({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,3 @@ paths:
type: array
items:
$ref: './common.schema.yaml#/components/schemas/EngineDescriptor'

/api/entity_store/status:
get:
x-labels: [ess, serverless]
x-codegen-enabled: true
operationId: GetEntityStoreStatus
summary: Get the status of the Entity Store
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: object
properties:
status:
$ref: './common.schema.yaml#/components/schemas/StoreStatus'
engines:
type: array
items:
$ref: './common.schema.yaml#/components/schemas/EngineDescriptor'
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,9 @@
*/

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

import { EngineDescriptor } from '../common.gen';

export type ListEntityEnginesRequestQuery = z.infer<typeof ListEntityEnginesRequestQuery>;
export const ListEntityEnginesRequestQuery = z.object({
/**
* If true returns the full status of the engine definition and its components
*/
includeStatus: BooleanFromString.optional(),
});
export type ListEntityEnginesRequestQueryInput = z.input<typeof ListEntityEnginesRequestQuery>;

export type ListEntityEnginesResponse = z.infer<typeof ListEntityEnginesResponse>;
export const ListEntityEnginesResponse = z.object({
count: z.number().int().optional(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ paths:
x-codegen-enabled: true
operationId: ListEntityEngines
summary: List the Entity Engines
parameters:
- name: includeStatus
in: query
schema:
type: boolean
description: If true returns the full status of the engine definition and its components

responses:
'200':
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

/*
* NOTICE: Do not edit this file manually.
* This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator.
*
* info:
* title: Enable Entity Store
* version: 2023-10-31
*/

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

import { StoreStatus, EngineDescriptor, EngineComponentStatus } from './common.gen';

export type GetEntityStoreStatusRequestQuery = z.infer<typeof GetEntityStoreStatusRequestQuery>;
export const GetEntityStoreStatusRequestQuery = z.object({
/**
* If true returns a detailed status of the engine including all it's components
*/
withComponents: BooleanFromString.optional(),
});
export type GetEntityStoreStatusRequestQueryInput = z.input<
typeof GetEntityStoreStatusRequestQuery
>;

export type GetEntityStoreStatusResponse = z.infer<typeof GetEntityStoreStatusResponse>;
export const GetEntityStoreStatusResponse = z.object({
status: StoreStatus,
engines: z.array(
EngineDescriptor.merge(
z.object({
components: z.array(EngineComponentStatus).optional(),
})
)
),
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
openapi: 3.0.0

info:
title: Enable Entity Store
version: '2023-10-31'
paths:
/api/entity_store/status:
get:
x-labels: [ess, serverless]
x-codegen-enabled: true
operationId: GetEntityStoreStatus
summary: Get the status of the Entity Store

parameters:
- name: withComponents
in: query
schema:
type: boolean
description: If true returns a detailed status of the engine including all it's components

responses:
'200':
description: Successful response
content:
application/json:
schema:
type: object
required:
- status
- engines
properties:
status:
$ref: './common.schema.yaml#/components/schemas/StoreStatus'
engines:
type: array
items:
allOf:
- $ref: './common.schema.yaml#/components/schemas/EngineDescriptor'
- type: object
properties:
components:
type: array
items:
$ref: './common.schema.yaml#/components/schemas/EngineComponentStatus'
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,9 @@ import type {
UploadAssetCriticalityRecordsResponse,
} from './entity_analytics/asset_criticality/upload_asset_criticality_csv.gen';
import type {
GetEntityStoreStatusResponse,
InitEntityStoreRequestBodyInput,
InitEntityStoreResponse,
} from './entity_analytics/entity_store/enablement.gen';
} from './entity_analytics/entity_store/enable.gen';
import type { ApplyEntityEngineDataviewIndicesResponse } from './entity_analytics/entity_store/engine/apply_dataview_indices.gen';
import type {
DeleteEntityEngineRequestQueryInput,
Expand All @@ -252,10 +251,7 @@ import type {
InitEntityEngineRequestBodyInput,
InitEntityEngineResponse,
} from './entity_analytics/entity_store/engine/init.gen';
import type {
ListEntityEnginesRequestQueryInput,
ListEntityEnginesResponse,
} from './entity_analytics/entity_store/engine/list.gen';
import type { ListEntityEnginesResponse } from './entity_analytics/entity_store/engine/list.gen';
import type {
StartEntityEngineRequestParamsInput,
StartEntityEngineResponse,
Expand All @@ -272,6 +268,10 @@ import type {
ListEntitiesRequestQueryInput,
ListEntitiesResponse,
} from './entity_analytics/entity_store/entities/list_entities.gen';
import type {
GetEntityStoreStatusRequestQueryInput,
GetEntityStoreStatusResponse,
} from './entity_analytics/entity_store/status.gen';
import type { CleanUpRiskEngineResponse } from './entity_analytics/risk_engine/engine_cleanup_route.gen';
import type { DisableRiskEngineResponse } from './entity_analytics/risk_engine/engine_disable_route.gen';
import type { EnableRiskEngineResponse } from './entity_analytics/risk_engine/engine_enable_route.gen';
Expand Down Expand Up @@ -1311,7 +1311,7 @@ finalize it.
})
.catch(catchAxiosErrorFormatAndThrow);
}
async getEntityStoreStatus() {
async getEntityStoreStatus(props: GetEntityStoreStatusProps) {
this.log.info(`${new Date().toISOString()} Calling API GetEntityStoreStatus`);
return this.kbnClient
.request<GetEntityStoreStatusResponse>({
Expand All @@ -1320,6 +1320,8 @@ finalize it.
[ELASTIC_HTTP_VERSION_HEADER]: '2023-10-31',
},
method: 'GET',

query: props.query,
})
.catch(catchAxiosErrorFormatAndThrow);
}
Expand Down Expand Up @@ -1640,7 +1642,7 @@ finalize it.
})
.catch(catchAxiosErrorFormatAndThrow);
}
async listEntityEngines(props: ListEntityEnginesProps) {
async listEntityEngines() {
this.log.info(`${new Date().toISOString()} Calling API ListEntityEngines`);
return this.kbnClient
.request<ListEntityEnginesResponse>({
Expand All @@ -1649,8 +1651,6 @@ finalize it.
[ELASTIC_HTTP_VERSION_HEADER]: '2023-10-31',
},
method: 'GET',

query: props.query,
})
.catch(catchAxiosErrorFormatAndThrow);
}
Expand Down Expand Up @@ -2299,6 +2299,9 @@ export interface GetEntityEngineProps {
export interface GetEntityEngineStatsProps {
params: GetEntityEngineStatsRequestParamsInput;
}
export interface GetEntityStoreStatusProps {
query: GetEntityStoreStatusRequestQueryInput;
}
export interface GetNotesProps {
query: GetNotesRequestQueryInput;
}
Expand Down Expand Up @@ -2355,9 +2358,6 @@ export interface InternalUploadAssetCriticalityRecordsProps {
export interface ListEntitiesProps {
query: ListEntitiesRequestQueryInput;
}
export interface ListEntityEnginesProps {
query: ListEntityEnginesRequestQueryInput;
}
export interface PatchRuleProps {
body: PatchRuleRequestBodyInput;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* 2.0.
*/
import { useMemo } from 'react';
import type { GetEntityStoreStatusResponse } from '../../../common/api/entity_analytics/entity_store/status.gen';
import type {
DeleteEntityEngineResponse,
EntityType,
Expand Down Expand Up @@ -43,11 +44,18 @@ export const useEntityStoreRoutes = () => {
});
};

const listEntityEngines = async (includeStatus = false) => {
const listEntityEngines = async () => {
return http.fetch<ListEntityEnginesResponse>(`/api/entity_store/engines`, {
method: 'GET',
version: API_VERSIONS.public.v1,
query: { includeStatus },
});
};

const getEntityStoreStatus = async (withComponents = false) => {
return http.fetch<GetEntityStoreStatusResponse>('/api/entity_store/status', {
method: 'GET',
version: API_VERSIONS.public.v1,
query: { withComponents },
});
};

Expand All @@ -56,6 +64,7 @@ export const useEntityStoreRoutes = () => {
stopEntityStore,
deleteEntityEngine,
listEntityEngines,
getEntityStoreStatus,
};
}, [http]);
};
Loading

0 comments on commit 44adc4a

Please sign in to comment.