Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/kbn-check-mappings-update-cli/current_fields.json
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,9 @@
"installCount",
"unInstallCount"
],
"scheduled_report": [
"createdBy"
],
"search": [
"description",
"title"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3032,6 +3032,14 @@
}
}
},
"scheduled_report": {
"dynamic": false,
"properties": {
"createdBy": {
"type": "keyword"
}
}
},
"search": {
"dynamic": false,
"properties": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ const previouslyRegisteredTypes = [
'query',
'rules-settings',
'sample-data-telemetry',
'scheduled_report',
'search',
'search-session',
'search-telemetry',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ export class AuthenticationExpiredError extends ReportingError {
}
}

export class MissingAuthenticationError extends ReportingError {
static code = 'missing_authentication_header_error' as const;
public get code(): string {
return MissingAuthenticationError.code;
}
}

export class QueueTimeoutError extends ReportingError {
static code = 'queue_timeout_error' as const;
public get code(): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,13 @@ export const INTERNAL_ROUTES = {
DOWNLOAD_PREFIX: prefixInternalPath + '/jobs/download', // docId is added to the final path
},
DOWNLOAD_CSV: prefixInternalPath + '/generate/immediate/csv_searchsource', // DEPRECATED
SCHEDULED: {
LIST: prefixInternalPath + '/scheduled/list',
BULK_DISABLE: prefixInternalPath + '/scheduled/bulk_disable',
},
HEALTH: prefixInternalPath + '/_health',
GENERATE_PREFIX: prefixInternalPath + '/generate', // exportTypeId is added to the final path
SCHEDULE_PREFIX: prefixInternalPath + '/schedule', // exportTypeId is added to the final path
};

const prefixPublicPath = '/api/reporting';
Expand Down
2 changes: 2 additions & 0 deletions src/platform/packages/private/kbn-reporting/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export interface BaseParams {
objectType: string;
title: string;
version: string; // to handle any state migrations
forceNow?: string;
layout?: LayoutParams; // png & pdf only
pagingStrategy?: CsvPagingStrategy; // csv only
}
Expand Down Expand Up @@ -152,6 +153,7 @@ export interface ReportSource {
created_at: string; // timestamp in UTC
'@timestamp'?: string; // creation timestamp, only used for data streams compatibility
status: JOB_STATUS;
scheduled_report_id?: string;

/*
* `output` is only populated if the report job is completed or failed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ describe('check_license', () => {
it('should set management.jobTypes to undefined', () => {
expect(checkLicense(exportTypesRegistry, undefined).management.jobTypes).toEqual(undefined);
});

it('should set scheduledReports.showLinks to true', () => {
expect(checkLicense(exportTypesRegistry, undefined).scheduledReports.showLinks).toEqual(true);
});

it('should set scheduledReports.enableLinks to false', () => {
expect(checkLicense(exportTypesRegistry, undefined).scheduledReports.enableLinks).toEqual(
false
);
});
});

describe('license information is not available', () => {
Expand Down Expand Up @@ -82,6 +92,16 @@ describe('check_license', () => {
it('should set management.jobTypes to undefined', () => {
expect(checkLicense(exportTypesRegistry, license).management.jobTypes).toEqual(undefined);
});

it('should set scheduledReports.showLinks to true', () => {
expect(checkLicense(exportTypesRegistry, license).scheduledReports.showLinks).toEqual(true);
});

it('should set scheduledReports.enableLinks to false', () => {
expect(checkLicense(exportTypesRegistry, license).scheduledReports.enableLinks).toEqual(
false
);
});
});

describe('license information is available', () => {
Expand Down Expand Up @@ -121,6 +141,18 @@ describe('check_license', () => {
'printable_pdf'
);
});

it('should set scheduledReports.showLinks to true', () => {
expect(checkLicense(exportTypesRegistry, license).scheduledReports.showLinks).toEqual(
true
);
});

it('should set scheduledReports.enableLinks to true', () => {
expect(checkLicense(exportTypesRegistry, license).scheduledReports.enableLinks).toEqual(
true
);
});
});

describe('& license is expired', () => {
Expand All @@ -147,6 +179,18 @@ describe('check_license', () => {
it('should set management.jobTypes to undefined', () => {
expect(checkLicense(exportTypesRegistry, license).management.jobTypes).toEqual(undefined);
});

it('should set scheduledReports.showLinks to true', () => {
expect(checkLicense(exportTypesRegistry, license).scheduledReports.showLinks).toEqual(
true
);
});

it('should set scheduledReports.enableLinks to false', () => {
expect(checkLicense(exportTypesRegistry, license).scheduledReports.enableLinks).toEqual(
false
);
});
});
});

Expand Down Expand Up @@ -175,6 +219,12 @@ describe('check_license', () => {
expect(checkLicense(exportTypesRegistry, license).management.jobTypes).toEqual([]);
expect(checkLicense(exportTypesRegistry, license).management.jobTypes).toHaveLength(0);
});

it('should set scheduledReports.showLinks to false', () => {
expect(checkLicense(exportTypesRegistry, license).scheduledReports.showLinks).toEqual(
false
);
});
});

describe('& license is expired', () => {
Expand All @@ -193,6 +243,12 @@ describe('check_license', () => {
it('should set management.jobTypes to undefined', () => {
expect(checkLicense(exportTypesRegistry, license).management.jobTypes).toEqual(undefined);
});

it('should set scheduledReports.showLinks to true', () => {
expect(checkLicense(exportTypesRegistry, license).scheduledReports.showLinks).toEqual(
true
);
});
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { ILicense } from '@kbn/licensing-plugin/server';
import { ILicense, LicenseType } from '@kbn/licensing-plugin/server';
import {
LICENSE_TYPE_CLOUD_STANDARD,
LICENSE_TYPE_ENTERPRISE,
LICENSE_TYPE_GOLD,
LICENSE_TYPE_PLATINUM,
LICENSE_TYPE_TRIAL,
} from '@kbn/reporting-common';
import type { ExportType } from '.';
import { ExportTypesRegistry } from './export_types_registry';

Expand All @@ -18,6 +25,14 @@ export interface LicenseCheckResult {
jobTypes?: string[];
}

const scheduledReportValidLicenses: LicenseType[] = [
LICENSE_TYPE_TRIAL,
LICENSE_TYPE_CLOUD_STANDARD,
LICENSE_TYPE_GOLD,
LICENSE_TYPE_PLATINUM,
LICENSE_TYPE_ENTERPRISE,
];

const messages = {
getUnavailable: () => {
return 'You cannot use Reporting because license information is not available at this time.';
Expand Down Expand Up @@ -60,6 +75,42 @@ const makeManagementFeature = (exportTypes: ExportType[]) => {
};
};

const makeScheduledReportsFeature = () => {
return {
id: 'scheduledReports',
checkLicense: (license?: ILicense) => {
if (!license || !license.type) {
return {
showLinks: true,
enableLinks: false,
message: messages.getUnavailable(),
};
}

if (!license.isActive) {
return {
showLinks: true,
enableLinks: false,
message: messages.getExpired(license),
};
}

if (!scheduledReportValidLicenses.includes(license.type)) {
return {
showLinks: false,
enableLinks: false,
message: `Your ${license.type} license does not support Scheduled reports. Please upgrade your license.`,
};
}

return {
showLinks: true,
enableLinks: true,
};
},
};
};

const makeExportTypeFeature = (exportType: ExportType) => {
return {
id: exportType.id,
Expand Down Expand Up @@ -104,6 +155,7 @@ export function checkLicense(
const reportingFeatures = [
...exportTypes.map(makeExportTypeFeature),
makeManagementFeature(exportTypes),
makeScheduledReportsFeature(),
];

return reportingFeatures.reduce((result, feature) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,9 @@ it(`Calls on Reporting whether to include Generate PDF as a sub-feature`, () =>
"minimumLicense": "gold",
"name": "Generate PDF reports",
"savedObject": Object {
"all": Array [],
"all": Array [
"scheduled_report",
],
"read": Array [],
},
"ui": Array [
Expand Down
2 changes: 1 addition & 1 deletion x-pack/platform/plugins/private/canvas/server/feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function getCanvasFeature(plugins: { reporting?: ReportingStart }): Kiban
includeIn: 'all',
management: { insightsAndAlerting: ['reporting'] },
minimumLicense: 'gold',
savedObject: { all: [], read: [] },
savedObject: { all: ['scheduled_report'], read: [] },
api: ['generateReport'],
ui: ['generatePdf'],
},
Expand Down
1 change: 1 addition & 0 deletions x-pack/platform/plugins/private/reporting/kibana.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"reporting"
],
"requiredPlugins": [
"actions",
"data",
"discover",
"encryptedSavedObjects",
Expand Down
Loading