-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[ReponseOps][Reporting] Allow users to schedule reports and view schedules list #224849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 16 commits
b2f9223
0eefc32
6a7880b
fccc892
d3da5c8
4bca76d
28266a7
c34cd02
adbcfd1
ede0893
505aeb0
798f2cc
edbc91c
6346bd1
8e80d58
ea44ff4
6d4c6a8
7d281d5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,5 +21,6 @@ | |
| "@kbn/i18n", | ||
| "@kbn/task-manager-plugin", | ||
| "@kbn/deeplinks-analytics", | ||
| "@kbn/licensing-plugin", | ||
| ] | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -118,6 +118,27 @@ describe('ReportingAPIClient', () => { | |
| }); | ||
| }); | ||
|
|
||
| describe('getScheduledReportInfo', () => { | ||
| beforeEach(() => { | ||
| httpClient.get.mockResolvedValueOnce({ data: [{ id: '123', title: 'Scheduled Report 1' }] }); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: Because we filter out the reports that do not match the ID, let's add another item here. |
||
| }); | ||
|
|
||
| it('should send a get request', async () => { | ||
| await apiClient.getScheduledReportInfo('123'); | ||
|
|
||
| expect(httpClient.get).toHaveBeenCalledWith( | ||
| expect.stringContaining('/internal/reporting/scheduled/list') | ||
| ); | ||
| }); | ||
|
|
||
| it('should return a report', async () => { | ||
| await expect(apiClient.getScheduledReportInfo('123')).resolves.toEqual({ | ||
| id: '123', | ||
| title: 'Scheduled Report 1', | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| describe('getError', () => { | ||
| it('should get an error message', async () => { | ||
| httpClient.get.mockResolvedValueOnce({ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,13 @@ import { | |
| buildKibanaPath, | ||
| REPORTING_REDIRECT_APP, | ||
| } from '@kbn/reporting-common'; | ||
| import { BaseParams, JobId, ManagementLinkFn, ReportApiJSON } from '@kbn/reporting-common/types'; | ||
| import { | ||
| BaseParams, | ||
| JobId, | ||
| ManagementLinkFn, | ||
| ReportApiJSON, | ||
| ScheduledReportApiJSON, | ||
| } from '@kbn/reporting-common/types'; | ||
| import rison from '@kbn/rison'; | ||
| import moment from 'moment'; | ||
| import { stringify } from 'query-string'; | ||
|
|
@@ -83,7 +89,10 @@ export class ReportingAPIClient implements IReportingAPI { | |
| } | ||
|
|
||
| public getKibanaAppHref(job: Job): string { | ||
| const searchParams = stringify({ jobId: job.id }); | ||
| const searchParams = stringify({ | ||
| jobId: job.id, | ||
| ...(job.scheduled_report_id ? { scheduledReportId: job.scheduled_report_id } : {}), | ||
| }); | ||
|
|
||
| const path = buildKibanaPath({ | ||
| basePath: this.http.basePath.serverBasePath, | ||
|
|
@@ -158,6 +167,15 @@ export class ReportingAPIClient implements IReportingAPI { | |
| return new Job(report); | ||
| } | ||
|
|
||
| public async getScheduledReportInfo(id: string) { | ||
| const { data: reportList = [] }: { data: ScheduledReportApiJSON[] } = await this.http.get( | ||
| `${INTERNAL_ROUTES.SCHEDULED.LIST}` | ||
| ); | ||
|
|
||
| const report = reportList.find((item) => item.id === id); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't we have a get by ID API?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No we don't, right @ymao1 ? |
||
| return report; | ||
| } | ||
|
|
||
| public async findForJobIds(jobIds: JobId[]) { | ||
| const reports: ReportApiJSON[] = await this.http.fetch(INTERNAL_ROUTES.JOBS.LIST, { | ||
| query: { page: 0, ids: jobIds.join(',') }, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,5 +27,6 @@ | |
| "@kbn/home-plugin", | ||
| "@kbn/management-plugin", | ||
| "@kbn/ui-actions-plugin", | ||
| "@kbn/actions-plugin", | ||
| ] | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should
space_idbe optional?