Skip to content

Commit

Permalink
remove old commented routes from route files
Browse files Browse the repository at this point in the history
  • Loading branch information
pgayvallet committed Aug 17, 2020
1 parent f9ed333 commit 9a71840
Show file tree
Hide file tree
Showing 17 changed files with 0 additions and 725 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,62 +10,6 @@ import { ConfigurationBlock } from '../../../common/domain_types';
import { ReturnTypeList } from '../../../common/return_types';
import { wrapRouteWithSecurity } from '../wrap_route_with_security';

/*
import Joi from 'joi';
import { FrameworkRequest } from '../../lib/adapters/framework/adapter_types';
import { CMServerLibs } from '../../lib/types';
export const createGetBeatConfigurationRoute = (libs: CMServerLibs) => ({
method: 'GET',
path: '/api/beats/agent/{beatId}/configuration',
config: {
validate: {
headers: Joi.object({
'kbn-beats-access-token': Joi.string().required(),
}).options({ allowUnknown: true }),
},
auth: false,
},
handler: async (
request: FrameworkRequest
): Promise<BaseReturnType | ReturnTypeList<ConfigurationBlock>> => {
const beatId = request.params.beatId;
const accessToken = request.headers['kbn-beats-access-token'];
let configurationBlocks: ConfigurationBlock[];
const beat = await libs.beats.getById(libs.framework.internalUser, beatId);
if (beat === null) {
return { error: { message: `Beat "${beatId}" not found`, code: 404 }, success: false };
}
const isAccessTokenValid = beat.access_token === accessToken;
if (!isAccessTokenValid) {
return { error: { message: 'Invalid access token', code: 401 }, success: false };
}
await libs.beats.update(libs.framework.internalUser, beat.id, {
last_checkin: new Date(),
});
if (beat.tags) {
const result = await libs.configurationBlocks.getForTags(
libs.framework.internalUser,
beat.tags,
-1
);
configurationBlocks = result.blocks;
} else {
configurationBlocks = [];
}
return {
list: configurationBlocks,
success: true,
};
},
});
*/

export const registerGetBeatConfigurationRoute = (router: IRouter) => {
router.get(
{
Expand Down
62 changes: 0 additions & 62 deletions x-pack/plugins/beats_management/server/routes/beats/enroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,68 +12,6 @@ import { REQUIRED_LICENSES } from '../../../common/constants/security';
import { BeatEnrollmentStatus } from '../../lib/types';
import { wrapRouteWithSecurity } from '../wrap_route_with_security';

/*
import Joi from 'joi';
import { omit } from 'lodash';
import { BaseReturnType, ReturnTypeCreate } from '../../../common/return_types';
import { FrameworkRequest } from '../../lib/adapters/framework/adapter_types';
export const createBeatEnrollmentRoute = (libs: CMServerLibs) => ({
method: 'POST',
path: '/api/beats/agent/{beatId}',
licenseRequired: REQUIRED_LICENSES,
config: {
auth: false,
validate: {
headers: Joi.object({
'kbn-beats-enrollment-token': Joi.string().required(),
}).options({
allowUnknown: true,
}),
payload: Joi.object({
host_name: Joi.string().required(),
name: Joi.string().required(),
type: Joi.string().required(),
version: Joi.string().required(),
}).required(),
},
},
handler: async (
request: FrameworkRequest
): Promise<BaseReturnType | ReturnTypeCreate<string>> => {
const { beatId } = request.params;
const enrollmentToken = request.headers['kbn-beats-enrollment-token'];
const { status, accessToken } = await libs.beats.enrollBeat(
enrollmentToken,
beatId,
request.info.remoteAddress,
omit(request.payload, 'enrollment_token')
);
switch (status) {
case BeatEnrollmentStatus.ExpiredEnrollmentToken:
return {
error: { message: BeatEnrollmentStatus.ExpiredEnrollmentToken, code: 400 },
success: false,
};
case BeatEnrollmentStatus.InvalidEnrollmentToken:
return {
error: { message: BeatEnrollmentStatus.InvalidEnrollmentToken, code: 400 },
success: false,
};
case BeatEnrollmentStatus.Success:
default:
return {
item: accessToken,
action: 'created',
success: true,
};
}
},
});
*/

export const registerBeatEnrollmentRoute = (router: IRouter) => {
// TODO: write to Kibana audit log file https://github.com/elastic/kibana/issues/26024
router.post(
Expand Down
40 changes: 0 additions & 40 deletions x-pack/plugins/beats_management/server/routes/beats/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,46 +9,6 @@ import { IRouter } from 'kibana/server';
import { ReturnTypeBulkAction } from '../../../common/return_types';
import { wrapRouteWithSecurity } from '../wrap_route_with_security';

/*
import Joi from 'joi';
import { FrameworkRequest } from '../../lib/adapters/framework/adapter_types';
import { CMServerLibs } from '../../lib/types';
export const beatEventsRoute = (libs: CMServerLibs) => ({
method: 'POST',
path: '/api/beats/{beatId}/events',
config: {
validate: {
headers: Joi.object({
'kbn-beats-access-token': Joi.string().required(),
}).options({ allowUnknown: true }),
},
auth: false,
},
handler: async (request: FrameworkRequest): Promise<BaseReturnType | ReturnTypeBulkAction> => {
const beatId = request.params.beatId;
const events = request.payload;
const accessToken = request.headers['kbn-beats-access-token'];
const beat = await libs.beats.getById(libs.framework.internalUser, beatId);
if (beat === null) {
return { error: { message: `Beat "${beatId}" not found`, code: 400 }, success: false };
}
const isAccessTokenValid = beat.access_token === accessToken;
if (!isAccessTokenValid) {
return { error: { message: `Invalid access token`, code: 401 }, success: false };
}
const results = await libs.beatEvents.log(libs.framework.internalUser, beat.id, events);
return {
results,
success: true,
};
},
});
*/

export const registerBeatEventsRoute = (router: IRouter) => {
router.post(
{
Expand Down
33 changes: 0 additions & 33 deletions x-pack/plugins/beats_management/server/routes/beats/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,6 @@ import { CMBeat } from '../../../common/domain_types';
import { ReturnTypeGet } from '../../../common/return_types';
import { wrapRouteWithSecurity } from '../wrap_route_with_security';

/*
import { FrameworkRequest } from '../../lib/adapters/framework/adapter_types';
import { CMServerLibs } from '../../lib/types';
export const createGetBeatRoute = (libs: CMServerLibs) => ({
method: 'GET',
path: '/api/beats/agent/{beatId}/{token?}',
requiredRoles: ['beats_admin'],
handler: async (request: FrameworkRequest): Promise<BaseReturnType | ReturnTypeGet<CMBeat>> => {
const beatId = request.params.beatId;
let beat: CMBeat | null;
if (beatId === 'unknown') {
beat = await libs.beats.getByEnrollmentToken(request.user, request.params.token);
if (beat === null) {
return { success: false };
}
} else {
beat = await libs.beats.getById(request.user, beatId);
if (beat === null) {
return { error: { message: 'Beat not found', code: 404 }, success: false };
}
}
delete beat.access_token;
return {
item: beat,
success: true,
};
},
});
*/

export const registerGetBeatRoute = (router: IRouter) => {
router.get(
{
Expand Down
54 changes: 0 additions & 54 deletions x-pack/plugins/beats_management/server/routes/beats/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,60 +11,6 @@ import { CMBeat } from '../../../common/domain_types';
import { ReturnTypeList } from '../../../common/return_types';
import { wrapRouteWithSecurity } from '../wrap_route_with_security';

/*
import * as Joi from 'joi';
import { FrameworkRequest } from '../../lib/adapters/framework/adapter_types';
import { CMServerLibs } from '../../lib/types';
export const createListAgentsRoute = (libs: CMServerLibs) => ({
method: 'GET',
path: '/api/beats/agents/{listByAndValue*}',
requiredRoles: ['beats_admin'],
licenseRequired: REQUIRED_LICENSES,
validate: {
headers: Joi.object({
'kbn-beats-enrollment-token': Joi.string().required(),
}).options({
allowUnknown: true,
}),
query: Joi.object({
ESQuery: Joi.string(),
}),
},
handler: async (request: FrameworkRequest): Promise<ReturnTypeList<CMBeat>> => {
const listByAndValueParts = request.params.listByAndValue
? request.params.listByAndValue.split('/')
: [];
let listBy: 'tag' | null = null;
let listByValue: string | null = null;
if (listByAndValueParts.length === 2) {
listBy = listByAndValueParts[0];
listByValue = listByAndValueParts[1];
}
let beats: CMBeat[];
switch (listBy) {
case 'tag':
beats = await libs.beats.getAllWithTag(request.user, listByValue || '');
break;
default:
beats = await libs.beats.getAll(
request.user,
request.query && request.query.ESQuery ? JSON.parse(request.query.ESQuery) : undefined
);
break;
}
return { list: beats, success: true, page: -1, total: -1 };
},
});
*/

export const registerListAgentsRoute = (router: IRouter) => {
router.get(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,55 +12,6 @@ import { ReturnTypeBulkAction } from '../../../common/return_types';
import type { BeatsTagAssignment } from '../../../public/lib/adapters/beats/adapter_types';
import { wrapRouteWithSecurity } from '../wrap_route_with_security';

/*
import Joi from 'joi';
import { FrameworkRequest } from '../../lib/adapters/framework/adapter_types';
import { CMServerLibs } from '../../lib/types';
export const createTagAssignmentsRoute = (libs: CMServerLibs) => ({
method: 'POST',
path: '/api/beats/agents_tags/assignments',
licenseRequired: REQUIRED_LICENSES,
requiredRoles: ['beats_admin'],
config: {
validate: {
payload: Joi.object({
assignments: Joi.array().items(
Joi.object({
beatId: Joi.string().required(),
tag: Joi.string().required(),
})
),
}).required(),
},
},
handler: async (request: FrameworkRequest): Promise<ReturnTypeBulkAction> => {
const { assignments }: { assignments: BeatsTagAssignment[] } = request.payload;
const response = await libs.beats.assignTagsToBeats(request.user, assignments);
return {
success: true,
results: response.assignments.map((assignment) => ({
success: assignment.status && assignment.status >= 200 && assignment.status < 300,
error:
!assignment.status || assignment.status >= 300
? {
code: assignment.status || 400,
message: assignment.result,
}
: undefined,
result:
assignment.status && assignment.status >= 200 && assignment.status < 300
? {
message: assignment.result,
}
: undefined,
})),
} as ReturnTypeBulkAction;
},
});
*/

export const registerTagAssignmentsRoute = (router: IRouter) => {
// TODO: write to Kibana audit log file https://github.com/elastic/kibana/issues/26024
router.post(
Expand Down
50 changes: 0 additions & 50 deletions x-pack/plugins/beats_management/server/routes/beats/tag_removal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,56 +10,6 @@ import { REQUIRED_LICENSES } from '../../../common/constants/security';
import { ReturnTypeBulkAction } from '../../../common/return_types';
import { wrapRouteWithSecurity } from '../wrap_route_with_security';

/*
import Joi from 'joi';
import { FrameworkRequest } from '../../lib/adapters/framework/adapter_types';
import { CMServerLibs } from '../../lib/types';
export const createTagRemovalsRoute = (libs: CMServerLibs) => ({
method: 'POST',
path: '/api/beats/agents_tags/removals',
licenseRequired: REQUIRED_LICENSES,
requiredRoles: ['beats_admin'],
config: {
validate: {
payload: Joi.object({
removals: Joi.array().items(
Joi.object({
beatId: Joi.string().required(),
tag: Joi.string().required(),
})
),
}).required(),
},
},
handler: async (request: FrameworkRequest): Promise<ReturnTypeBulkAction> => {
const { removals } = request.payload;
const response = await libs.beats.removeTagsFromBeats(request.user, removals);
return {
success: true,
results: response.removals.map((removal) => ({
success: removal.status && removal.status >= 200 && removal.status < 300,
error:
!removal.status || removal.status >= 300
? {
code: removal.status || 400,
message: removal.result,
}
: undefined,
result:
removal.status && removal.status >= 200 && removal.status < 300
? {
message: removal.result,
}
: undefined,
})),
} as ReturnTypeBulkAction;
},
});
*/

export const registerTagRemovalsRoute = (router: IRouter) => {
// TODO: write to Kibana audit log file https://github.com/elastic/kibana/issues/26024
router.post(
Expand Down
Loading

0 comments on commit 9a71840

Please sign in to comment.