Skip to content

Commit

Permalink
[Reporting] Add warning logs about CSV export type being deprecated (#…
Browse files Browse the repository at this point in the history
…104025) (#104528)

* add deprecation logging to csv export type

* fix payload.isDeprecated

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
tsullivan and kibanamachine authored Jul 6, 2021
1 parent 3daceaf commit 137581f
Show file tree
Hide file tree
Showing 8 changed files with 476 additions and 122 deletions.
2 changes: 2 additions & 0 deletions x-pack/plugins/reporting/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export interface ReportSource {
objectType: string;
title: string;
layout?: LayoutParams;
isDeprecated?: boolean;
};
meta: { objectType: string; layout?: string };
browser_type: string;
Expand Down Expand Up @@ -130,6 +131,7 @@ export interface ReportApiJSON {
layout?: LayoutParams;
title: string;
browserTimezone?: string;
isDeprecated?: boolean;
};
meta: {
layout?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ export const createJobFnFactory: CreateJobFnFactory<
const crypto = cryptoFactory(config.get('encryptionKey'));

return async function createJob(jobParams, context, request) {
logger.warn(
`The "/generate/csv" endpoint is deprecated and will be removed in Kibana 8.0. Please recreate the POST URL used to automate this CSV export.`
);
const serializedEncryptedHeaders = await crypto.encrypt(request.headers);

const savedObjectsClient = context.core.savedObjects.client;
Expand All @@ -29,6 +32,7 @@ export const createJobFnFactory: CreateJobFnFactory<
)) as unknown) as IndexPatternSavedObjectDeprecatedCSV;

return {
isDeprecated: true,
headers: serializedEncryptedHeaders,
spaceId: reporting.getSpaceId(request, logger),
indexPatternSavedObject,
Expand Down
6 changes: 4 additions & 2 deletions x-pack/plugins/reporting/server/routes/lib/jobs_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
* 2.0.
*/

import { UnwrapPromise } from '@kbn/utility-types';
import { i18n } from '@kbn/i18n';
import { ResponseError } from '@elastic/elasticsearch/lib/errors';
import { i18n } from '@kbn/i18n';
import { UnwrapPromise } from '@kbn/utility-types';
import { ElasticsearchClient } from 'src/core/server';
import { ReportingCore } from '../../';
import { ReportDocument } from '../../lib/store';
Expand Down Expand Up @@ -87,6 +87,7 @@ export function jobsQueryFactory(reportingCore: ReportingCore) {
elasticsearchClient.search({ body, index: getIndex() })
);

// FIXME: return the info in ReportApiJSON format;
return response?.body.hits?.hits ?? [];
},

Expand Down Expand Up @@ -139,6 +140,7 @@ export function jobsQueryFactory(reportingCore: ReportingCore) {
return;
}

// FIXME: return the info in ReportApiJSON format;
return response.body.hits.hits[0] as ReportDocument;
},

Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/reporting/server/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export { BaseParams };
export interface BasePayload extends BaseParams {
headers: string;
spaceId?: string;
isDeprecated?: boolean;
}

// default fn type for CreateJobFnFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import { FtrProviderContext } from '../ftr_provider_context';
export default function ({ loadTestFile }: FtrProviderContext) {
describe('Reporting API Integration Tests with Security disabled', function () {
this.tags('ciGroup13');
loadTestFile(require.resolve('./job_apis'));
loadTestFile(require.resolve('./job_apis_csv'));
loadTestFile(require.resolve('./job_apis_csv_deprecated'));
loadTestFile(require.resolve('./ilm_migration_apis'));
});
}

This file was deleted.

Loading

0 comments on commit 137581f

Please sign in to comment.