Skip to content

Commit

Permalink
make enablement apis public
Browse files Browse the repository at this point in the history
  • Loading branch information
klacabane committed Oct 29, 2024
1 parent 3c7268d commit 533dc3b
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class EntitiesSynthtraceKibanaClient {
this.logger.debug('Entity definitions are already defined');
} else {
this.logger.debug('Installing Entity definitions');
const entityEnablementUrl = `${this.target}/internal/entities/managed/enablement?installOnly=true`;
const entityEnablementUrl = `${this.target}/api/entities/managed/enablement?installOnly=true`;
await fetch(entityEnablementUrl, {
method: 'PUT',
headers: kibanaHeaders(),
Expand All @@ -52,7 +52,7 @@ export class EntitiesSynthtraceKibanaClient {
}

async uninstallEntityIndexPatterns() {
const url = `${this.target}/internal/entities/managed/enablement`;
const url = `${this.target}/api/entities/managed/enablement`;
await fetch(url, {
method: 'DELETE',
headers: kibanaHeaders(),
Expand Down
10 changes: 5 additions & 5 deletions x-pack/plugins/entity_manager/public/lib/entity_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ type QueryParamOf<T extends { params?: any }> = Exclude<T['params'], undefined>[
type DeleteEntityDefinitionQuery = QueryParamOf<
ClientRequestParamsOf<
EntityManagerRouteRepository,
'DELETE /internal/entities/managed/enablement'
'DELETE /api/entities/managed/enablement'
>
>;

type CreateEntityDefinitionQuery = QueryParamOf<
ClientRequestParamsOf<EntityManagerRouteRepository, 'PUT /internal/entities/managed/enablement'>
ClientRequestParamsOf<EntityManagerRouteRepository, 'PUT /api/entities/managed/enablement'>
>;

export class EntityClient {
Expand All @@ -43,14 +43,14 @@ export class EntityClient {
}

async isManagedEntityDiscoveryEnabled(): Promise<ManagedEntityEnabledResponse> {
return await this.repositoryClient('GET /internal/entities/managed/enablement');
return await this.repositoryClient('GET /api/entities/managed/enablement');
}

async enableManagedEntityDiscovery(
query?: CreateEntityDefinitionQuery
): Promise<EnableManagedEntityResponse> {
try {
return await this.repositoryClient('PUT /internal/entities/managed/enablement', {
return await this.repositoryClient('PUT /api/entities/managed/enablement', {
params: {
query: {
installOnly: query?.installOnly,
Expand All @@ -69,7 +69,7 @@ export class EntityClient {
query?: DeleteEntityDefinitionQuery
): Promise<DisableManagedEntityResponse> {
try {
return await this.repositoryClient('DELETE /internal/entities/managed/enablement', {
return await this.repositoryClient('DELETE /api/entities/managed/enablement', {
params: {
query: {
deleteData: query?.deleteData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { createEntityManagerServerRoute } from '../create_entity_manager_server_

/**
* @openapi
* /internal/entities/managed/enablement:
* /api/entities/managed/enablement:
* get:
* description: Check if managed (built-in) entity discovery is enabled. Enabled entity discovery requires a valid api key and the latest version of the builtin definitions installed and running.
* tags:
Expand All @@ -44,7 +44,7 @@ import { createEntityManagerServerRoute } from '../create_entity_manager_server_
* example: api_key_not_found
*/
export const checkEntityDiscoveryEnabledRoute = createEntityManagerServerRoute({
endpoint: 'GET /internal/entities/managed/enablement',
endpoint: 'GET /api/entities/managed/enablement',
handler: async ({ response, logger, server }) => {
try {
logger.debug('reading entity discovery API key from saved object');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { createEntityManagerServerRoute } from '../create_entity_manager_server_

/**
* @openapi
* /internal/entities/managed/enablement:
* /api/entities/managed/enablement:
* delete:
* description: Disable managed (built-in) entity discovery. This stops and deletes the transforms, ingest pipelines, definitions saved objects, and index templates for this entity definition, as well as the stored API key for entity discovery management.
* tags:
Expand Down Expand Up @@ -43,7 +43,7 @@ import { createEntityManagerServerRoute } from '../create_entity_manager_server_
* description: The current user does not have the required permissions to disable entity discovery
*/
export const disableEntityDiscoveryRoute = createEntityManagerServerRoute({
endpoint: 'DELETE /internal/entities/managed/enablement',
endpoint: 'DELETE /api/entities/managed/enablement',
params: z.object({
query: z.object({
deleteData: z.optional(BooleanFromString).default(false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { startTransforms } from '../../lib/entities/start_transforms';

/**
* @openapi
* /internal/entities/managed/enablement:
* /api/entities/managed/enablement:
* put:
* description: Enable managed (built-in) entity discovery.
* tags:
Expand Down Expand Up @@ -62,7 +62,7 @@ import { startTransforms } from '../../lib/entities/start_transforms';
* description: The current user does not have the required permissions to enable entity discovery
*/
export const enableEntityDiscoveryRoute = createEntityManagerServerRoute({
endpoint: 'PUT /internal/entities/managed/enablement',
endpoint: 'PUT /api/entities/managed/enablement',
params: z.object({
query: createEntityDefinitionQuerySchema,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('Home page', () => {
describe('When EEM is enabled', () => {
describe('When there is no entities', () => {
it('Shows inventory page with empty message', () => {
cy.intercept('GET', '/internal/entities/managed/enablement', {
cy.intercept('GET', '/api/entities/managed/enablement', {
fixture: 'eem_enabled.json',
}).as('getEEMStatus');
cy.visitKibana('/app/inventory');
Expand Down Expand Up @@ -60,7 +60,7 @@ describe('Home page', () => {
});

it('Shows inventory page with entities', () => {
cy.intercept('GET', '/internal/entities/managed/enablement', {
cy.intercept('GET', '/api/entities/managed/enablement', {
fixture: 'eem_enabled.json',
}).as('getEEMStatus');
cy.visitKibana('/app/inventory');
Expand All @@ -74,7 +74,7 @@ describe('Home page', () => {
});

it('Navigates to apm when clicking on a service type entity', () => {
cy.intercept('GET', '/internal/entities/managed/enablement', {
cy.intercept('GET', '/api/entities/managed/enablement', {
fixture: 'eem_enabled.json',
}).as('getEEMStatus');
cy.visitKibana('/app/inventory');
Expand All @@ -84,7 +84,7 @@ describe('Home page', () => {
});

it('Navigates to hosts when clicking on a host type entity', () => {
cy.intercept('GET', '/internal/entities/managed/enablement', {
cy.intercept('GET', '/api/entities/managed/enablement', {
fixture: 'eem_enabled.json',
}).as('getEEMStatus');
cy.visitKibana('/app/inventory');
Expand All @@ -94,7 +94,7 @@ describe('Home page', () => {
});

it('Navigates to infra when clicking on a container type entity', () => {
cy.intercept('GET', '/internal/entities/managed/enablement', {
cy.intercept('GET', '/api/entities/managed/enablement', {
fixture: 'eem_enabled.json',
}).as('getEEMStatus');
cy.visitKibana('/app/inventory');
Expand All @@ -104,7 +104,7 @@ describe('Home page', () => {
});

it('Filters entities by service type', () => {
cy.intercept('GET', '/internal/entities/managed/enablement', {
cy.intercept('GET', '/api/entities/managed/enablement', {
fixture: 'eem_enabled.json',
}).as('getEEMStatus');
cy.intercept('GET', '/internal/inventory/entities*').as('getEntitites');
Expand All @@ -121,7 +121,7 @@ describe('Home page', () => {
});

it('Filters entities by host type', () => {
cy.intercept('GET', '/internal/entities/managed/enablement', {
cy.intercept('GET', '/api/entities/managed/enablement', {
fixture: 'eem_enabled.json',
}).as('getEEMStatus');
cy.intercept('GET', '/internal/inventory/entities*').as('getEntitites');
Expand All @@ -138,7 +138,7 @@ describe('Home page', () => {
});

it('Filters entities by container type', () => {
cy.intercept('GET', '/internal/entities/managed/enablement', {
cy.intercept('GET', '/api/entities/managed/enablement', {
fixture: 'eem_enabled.json',
}).as('getEEMStatus');
cy.intercept('GET', '/internal/inventory/entities*').as('getEntitites');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function ({ getService }: FtrProviderContext) {
const enablementRequest =
(method: 'get' | 'put' | 'delete') =>
async (auth: Auth, expectedCode: number, query: { [key: string]: any } = {}) => {
const response = await supertestWithoutAuth[method]('/internal/entities/managed/enablement')
const response = await supertestWithoutAuth[method]('/api/entities/managed/enablement')
.auth(auth.username, auth.password)
.query(query)
.set('kbn-xsrf', 'xxx')
Expand Down

0 comments on commit 533dc3b

Please sign in to comment.