[Reporting] Separate internal and public API endpoints in Reporting#162288
[Reporting] Separate internal and public API endpoints in Reporting#162288tsullivan merged 58 commits intoelastic:mainfrom
Conversation
There was a problem hiding this comment.
deleting a report is manually done by the user: not a system request
There was a problem hiding this comment.
getting report info is manually done by the user: not a system request
There was a problem hiding this comment.
using the diagnostic tool is manually done by the user: not a system request
There was a problem hiding this comment.
I can't figure out why my editor says this line uses a deprecated signature, so the comment isn't valid
There was a problem hiding this comment.
Nice I'm also not seeing any issues in my editor 👍🏻
4e7152f to
c9941b7
Compare
…-ref HEAD~1..HEAD --fix'
fffb568 to
61c611e
Compare
|
|
||
| expect(httpClient.post).toHaveBeenCalledWith( | ||
| expect.stringContaining('/diagnose/screenshot'), | ||
| expect.any(Object) |
There was a problem hiding this comment.
the options object was removed from the API calls for many of these, since they mistakenly were used to send the asSystemRequest field
4305bc8 to
5122ed6
Compare
| counters: Counters | ||
| ) { | ||
| public getJobParams(): BaseParams { | ||
| let jobParamsRison: null | string = null; |
There was a problem hiding this comment.
I've added this helper because without it, this section of code would have had to be duplicated in x-pack/plugins/reporting/server/routes/internal/generate/generate_from_jobparams.ts and x-pack/plugins/reporting/server/routes/public/generate_from_jobparams.ts
| res: KibanaResponseFactory; | ||
| } | ||
|
|
||
| export const commonJobsRouteHandlerFactory = (reporting: ReportingCore) => { |
There was a problem hiding this comment.
Added these helpers to avoid duplicated code in x-pack/plugins/reporting/server/routes/internal/management/jobs.ts and x-pack/plugins/reporting/server/routes/public/jobs.ts
| // TODO: find a way to abstract this using ExportTypeRegistry: it needs a new | ||
| // public method to return this array | ||
| // const registry = reporting.getExportTypesRegistry(); | ||
| // const kibanaAccessControlTags = registry.getAllAccessControlTags(); |
There was a problem hiding this comment.
I'm not sure if we still care about this, I just copied this comment from x-pack/plugins/reporting/server/routes/generate/generate_from_jobparams.ts
There was a problem hiding this comment.
I am also tempted to remove this comment - I don't think it's really relevant anymore
| @@ -7,29 +7,26 @@ | |||
|
|
|||
| import { schema } from '@kbn/config-schema'; | |||
| import { ROUTE_TAG_CAN_REDIRECT } from '@kbn/security-plugin/server'; | |||
| import { promisify } from 'util'; | |||
There was a problem hiding this comment.
A file was deleted and made into 2 versions, but Github shows this as a rename, so this diff makes a good outline of the goals of this PR:
- Use constants for the route path strings
- Use helpers within route handler functions to avoid duplicated code
rshen91
left a comment
There was a problem hiding this comment.
I love the constants/routes file making everything so much clearer
There was a problem hiding this comment.
Nice I'm also not seeing any issues in my editor 👍🏻
|
|
||
| const API_BASE_URL_V1 = '/api/reporting/v1'; | ||
| const API_BASE_GENERATE_V1 = `${API_BASE_URL_V1}/generate`; | ||
| const path = INTERNAL_ROUTES.DOWNLOAD_CSV; |
There was a problem hiding this comment.
I love that there's the constants/routes file in this PR to reference these vs it being spread across the plugin
| // TODO: find a way to abstract this using ExportTypeRegistry: it needs a new | ||
| // public method to return this array | ||
| // const registry = reporting.getExportTypesRegistry(); | ||
| // const kibanaAccessControlTags = registry.getAllAccessControlTags(); |
There was a problem hiding this comment.
I am also tempted to remove this comment - I don't think it's really relevant anymore
|
Pinging @elastic/appex-sharedux (Team:SharedUX) |
💚 Build Succeeded
Metrics [docs]Module Count
Async chunks
Page load bundle
History
To update your PR or re-run it, just comment with: cc @tsullivan |
…lastic#162288) ## Summary Closes elastic#160827 Closes elastic#134517 Closes elastic#149942 In this PR, the following API endpoints are moved into an internal namespace: | New endpoint path | Previous | |---|---| | `/internal/reporting/diagnose/browser` | `/api/reporting/diagnose/browser` | | `/internal/reporting/diagnose/screenshot` | `/api/reporting/diagnose/screenshot` | | `/internal/reporting/generate/immediate/csv_searchsource` | `/api/reporting/v1/generate/immediate/csv_searchsource` | | `/internal/reporting/generate/{exportTypeId}` | `/api/reporting/generate/{exportTypeId}` | | `/internal/reporting/jobs/count` | `/api/reporting/jobs/count` | | `/internal/reporting/jobs/delete/{jobId}` | `/api/reporting/jobs/delete/{jobId}` | | `/internal/reporting/jobs/info/{jobId}` | `/api/reporting/jobs/info/{jobId}` | | `/internal/reporting/jobs/list` | `/api/reporting/jobs/list` | Support for the public APIs continues: | Public endpoint path | |---| | `/api/reporting/generate/{exportTypeId}` | | `/api/reporting/jobs/delete/{jobId}` | | `/api/reporting/jobs/download/{jobId}` | ## Other changes 1. Set access options on the routes 2. Removed API Counter functional tests, which were skipped to begin with. 3. Replaced functional tests with Jest integration tests. 4. Consolidated code in the generation routes by creating the `getJobParams` method of the `RequestHandler` class. 5. Added a new test for `getJobParams` 6. Consolidated code in the job management routes 7. Added new code for shared helpers in job management routes 8. Reorganized libs used for route handlers: ``` routes/lib/request_handler.ts => routes/common/generate/request_handler.ts routes/lib/job_management_pre_routing.ts => routes/common/jobs/job_management_pre_routing.ts routes/lib/jobs_query.ts => routes/common/jobs/jobs_query.ts routes/lib/get_document_payload.ts => routes/common/jobs/get_document_payload.ts routes/lib/get_counter.ts => routes/common/get_counter.ts routes/lib/authorized_user_pre_routing.ts => routes/common/authorized_user_pre_routing.ts routes/lib/get_user.ts => routes/common/get_user.ts ``` ## Release Note Updated API endpoint paths for Reporting to clarify which routes are public and which are not. Make sure that any custom script or application that uses Reporting endpoints only uses the public endpoints. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Summary
Closes #160827
Closes #134517
Closes #149942
In this PR, the following API endpoints are moved into an internal namespace:
/internal/reporting/diagnose/browser/api/reporting/diagnose/browser/internal/reporting/diagnose/screenshot/api/reporting/diagnose/screenshot/internal/reporting/generate/immediate/csv_searchsource/api/reporting/v1/generate/immediate/csv_searchsource/internal/reporting/generate/{exportTypeId}/api/reporting/generate/{exportTypeId}/internal/reporting/jobs/count/api/reporting/jobs/count/internal/reporting/jobs/delete/{jobId}/api/reporting/jobs/delete/{jobId}/internal/reporting/jobs/info/{jobId}/api/reporting/jobs/info/{jobId}/internal/reporting/jobs/list/api/reporting/jobs/listSupport for the public APIs continues:
/api/reporting/generate/{exportTypeId}/api/reporting/jobs/delete/{jobId}/api/reporting/jobs/download/{jobId}Other changes
getJobParamsmethod of theRequestHandlerclass.getJobParamsRelease Note
Updated API endpoint paths for Reporting to clarify which routes are public and which are not. Make sure that any custom script or application that uses Reporting endpoints only uses the public endpoints.