Skip to content

Commit

Permalink
variable rename for legacy id
Browse files Browse the repository at this point in the history
  • Loading branch information
tsullivan committed Jan 16, 2020
1 parent 25e30da commit 5378584
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ export function registerGenerateFromJobParams(
path: `${BASE_GENERATE}/{exportType}`,
method: 'POST',
options: getRouteConfig(),
handler: async (originalRequest: Legacy.Request, h: ReportingResponseToolkit) => {
const request = makeRequestFacade(originalRequest);
handler: async (legacyRequest: Legacy.Request, h: ReportingResponseToolkit) => {
const request = makeRequestFacade(legacyRequest);
let jobParamsRison: string | null;

if (request.payload) {
Expand All @@ -83,7 +83,7 @@ export function registerGenerateFromJobParams(
if (!jobParams) {
throw new Error('missing jobParams!');
}
response = await handler(exportType, jobParams, originalRequest, h);
response = await handler(exportType, jobParams, legacyRequest, h);
} catch (err) {
throw boom.badRequest(`invalid rison: ${jobParamsRison}`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export function registerGenerateCsvFromSavedObject(
path: `${API_BASE_GENERATE_V1}/csv/saved-object/{savedObjectType}:{savedObjectId}`,
method: 'POST',
options: routeOptions,
handler: async (originalRequest: Legacy.Request, h: ReportingResponseToolkit) => {
const requestFacade = makeRequestFacade(originalRequest);
handler: async (legacyRequest: Legacy.Request, h: ReportingResponseToolkit) => {
const requestFacade = makeRequestFacade(legacyRequest);

/*
* 1. Build `jobParams` object: job data that execution will need to reference in various parts of the lifecycle
Expand All @@ -44,7 +44,7 @@ export function registerGenerateCsvFromSavedObject(
let result: QueuedJobPayload<any>;
try {
const jobParams = getJobParamsFromRequest(requestFacade, { isImmediate: false });
result = await handleRoute(CSV_FROM_SAVEDOBJECT_JOB_TYPE, jobParams, originalRequest, h); // pass the original request because the handler will make the request facade on its own
result = await handleRoute(CSV_FROM_SAVEDOBJECT_JOB_TYPE, jobParams, legacyRequest, h); // pass the original request because the handler will make the request facade on its own
} catch (err) {
throw handleRouteError(CSV_FROM_SAVEDOBJECT_JOB_TYPE, err);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export function registerGenerateCsvFromSavedObjectImmediate(
path: `${API_BASE_GENERATE_V1}/immediate/csv/saved-object/{savedObjectType}:{savedObjectId}`,
method: 'POST',
options: routeOptions,
handler: async (originalRequest: Legacy.Request, h: ReportingResponseToolkit) => {
const request = makeRequestFacade(originalRequest);
handler: async (legacyRequest: Legacy.Request, h: ReportingResponseToolkit) => {
const request = makeRequestFacade(legacyRequest);
const logger = parentLogger.clone(['savedobject-csv']);
const jobParams = getJobParamsFromRequest(request, { isImmediate: true });

Expand Down
4 changes: 2 additions & 2 deletions x-pack/legacy/plugins/reporting/server/routes/generation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ export function registerJobGenerationRoutes(
async function handler(
exportTypeId: string,
jobParams: object,
originalRequest: Legacy.Request,
legacyRequest: Legacy.Request,
h: ReportingResponseToolkit
) {
const request = makeRequestFacade(originalRequest);
const request = makeRequestFacade(legacyRequest);
const user = request.pre.user;
const headers = request.headers;

Expand Down
20 changes: 10 additions & 10 deletions x-pack/legacy/plugins/reporting/server/routes/jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export function registerJobInfoRoutes(
path: `${MAIN_ENTRY}/list`,
method: 'GET',
options: getRouteConfig(),
handler: (originalRequest: Legacy.Request) => {
const request = makeRequestFacade(originalRequest);
handler: (legacyRequest: Legacy.Request) => {
const request = makeRequestFacade(legacyRequest);
const { page: queryPage, size: querySize, ids: queryIds } = request.query as ListQuery;
const page = parseInt(queryPage, 10) || 0;
const size = Math.min(100, parseInt(querySize, 10) || 10);
Expand All @@ -65,8 +65,8 @@ export function registerJobInfoRoutes(
path: `${MAIN_ENTRY}/count`,
method: 'GET',
options: getRouteConfig(),
handler: (originalRequest: Legacy.Request) => {
const request = makeRequestFacade(originalRequest);
handler: (legacyRequest: Legacy.Request) => {
const request = makeRequestFacade(legacyRequest);
const results = jobsQuery.count(request.pre.management.jobTypes, request.pre.user);
return results;
},
Expand All @@ -77,8 +77,8 @@ export function registerJobInfoRoutes(
path: `${MAIN_ENTRY}/output/{docId}`,
method: 'GET',
options: getRouteConfig(),
handler: (originalRequest: Legacy.Request) => {
const request = makeRequestFacade(originalRequest);
handler: (legacyRequest: Legacy.Request) => {
const request = makeRequestFacade(legacyRequest);
const { docId } = request.params;

return jobsQuery.get(request.pre.user, docId, { includeContent: true }).then(
Expand All @@ -103,8 +103,8 @@ export function registerJobInfoRoutes(
path: `${MAIN_ENTRY}/info/{docId}`,
method: 'GET',
options: getRouteConfig(),
handler: (originalRequest: Legacy.Request) => {
const request = makeRequestFacade(originalRequest);
handler: (legacyRequest: Legacy.Request) => {
const request = makeRequestFacade(legacyRequest);
const { docId } = request.params;

return jobsQuery
Expand Down Expand Up @@ -136,8 +136,8 @@ export function registerJobInfoRoutes(
path: `${MAIN_ENTRY}/download/{docId}`,
method: 'GET',
options: getRouteConfigDownload(),
handler: async (originalRequest: Legacy.Request, h: ReportingResponseToolkit) => {
const request = makeRequestFacade(originalRequest);
handler: async (legacyRequest: Legacy.Request, h: ReportingResponseToolkit) => {
const request = makeRequestFacade(legacyRequest);
const { docId } = request.params;

let response = await jobResponseHandler(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { makeRequestFacade } from './make_request_facade';

describe('makeRequestFacade', () => {
test('creates a default object', () => {
const originalRequest = ({
const legacyRequest = ({
getBasePath: () => 'basebase',
params: {
param1: 123,
Expand All @@ -22,7 +22,7 @@ describe('makeRequestFacade', () => {
},
} as unknown) as Legacy.Request;

expect(makeRequestFacade(originalRequest)).toMatchInlineSnapshot(`
expect(makeRequestFacade(legacyRequest)).toMatchInlineSnapshot(`
Object {
"getBasePath": [Function],
"getRawRequest": [Function],
Expand All @@ -44,7 +44,7 @@ describe('makeRequestFacade', () => {
});

test('getRawRequest', () => {
const originalRequest = ({
const legacyRequest = ({
getBasePath: () => 'basebase',
params: {
param1: 123,
Expand All @@ -57,6 +57,6 @@ describe('makeRequestFacade', () => {
},
} as unknown) as Legacy.Request;

expect(makeRequestFacade(originalRequest).getRawRequest()).toBe(originalRequest);
expect(makeRequestFacade(legacyRequest).getRawRequest()).toBe(legacyRequest);
});
});

0 comments on commit 5378584

Please sign in to comment.