File tree Expand file tree Collapse file tree
src/platform/packages/shared/kbn-openapi-generator/src/template_service/templates
platform/plugins/shared/spaces/common
solutions/security/packages/test-api-clients Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,10 +19,7 @@ import type {
1919{{ /each }}
2020
2121import type { FtrProviderContext } from '@kbn/ftr-common-functional-services';
22-
23- function getRouteUrlForSpace(routeUrl: string, spaceId?: string): string {
24- return spaceId ? `/s/${spaceId}${routeUrl}` : routeUrl;
25- }
22+ import { getRouteUrlForSpace } from '@kbn/spaces-plugin/common';
2623
2724export function SecuritySolutionApiProvider({ getService }: FtrProviderContext) {
2825 const supertest = getService('supertest');
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+ * or more contributor license agreements. Licensed under the Elastic License
4+ * 2.0; you may not use this file except in compliance with the Elastic License
5+ * 2.0.
6+ */
7+
8+ /**
9+ * Wraps the provided Kibana route URL with the Kibana space ID.
10+ * "default" space is equivalent to an empty value and doesn't lead to adding any space aware path.
11+ *
12+ * @param routeUrl the route url string
13+ * @param spaceId [optional] the Kibana space to account for in the route url
14+ *
15+ * Examples:
16+ * - `getRouteUrlForSpace('/api/some_endpoint')` returns `/api/some_endpoint`
17+ * - `getRouteUrlForSpace('/api/some_endpoint', 'default')` returns `/api/some_endpoint`
18+ * - `getRouteUrlForSpace('/api/some_endpoint', 'my_space') returns `/s/my_space/api/some_endpoint`
19+ */
20+ export function getRouteUrlForSpace ( routeUrl : string , spaceId ?: string ) : string {
21+ return spaceId ? `/s/${ spaceId } ${ routeUrl } ` : routeUrl ;
22+ }
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ export {
1313 DEFAULT_SPACE_ID ,
1414 API_VERSIONS ,
1515} from './constants' ;
16+ export { getRouteUrlForSpace } from './get_spaced_route_url' ;
1617export { addSpaceIdToPath , getSpaceIdFromPath } from './lib/spaces_url_parser' ;
1718export type {
1819 Space ,
Original file line number Diff line number Diff line change @@ -58,10 +58,7 @@ import type { SuggestUserProfilesRequestQueryInput } from '@kbn/security-solutio
5858import type { UpdateRuleRequestBodyInput } from '@kbn/security-solution-plugin/common/api/detection_engine/rule_management/crud/update_rule/update_rule_route.gen' ;
5959
6060import type { FtrProviderContext } from '@kbn/ftr-common-functional-services' ;
61-
62- function getRouteUrlForSpace ( routeUrl : string , spaceId ?: string ) : string {
63- return spaceId ? `/s/${ spaceId } ${ routeUrl } ` : routeUrl ;
64- }
61+ import { getRouteUrlForSpace } from '@kbn/spaces-plugin/common' ;
6562
6663export function SecuritySolutionApiProvider ( { getService } : FtrProviderContext ) {
6764 const supertest = getService ( 'supertest' ) ;
Original file line number Diff line number Diff line change @@ -26,10 +26,7 @@ import type { ReadEndpointListItemRequestQueryInput } from '@kbn/securitysolutio
2626import type { UpdateEndpointListItemRequestBodyInput } from '@kbn/securitysolution-endpoint-exceptions-common/api/update_endpoint_list_item/update_endpoint_list_item.gen' ;
2727
2828import type { FtrProviderContext } from '@kbn/ftr-common-functional-services' ;
29-
30- function getRouteUrlForSpace ( routeUrl : string , spaceId ?: string ) : string {
31- return spaceId ? `/s/${ spaceId } ${ routeUrl } ` : routeUrl ;
32- }
29+ import { getRouteUrlForSpace } from '@kbn/spaces-plugin/common' ;
3330
3431export function SecuritySolutionApiProvider ( { getService } : FtrProviderContext ) {
3532 const supertest = getService ( 'supertest' ) ;
Original file line number Diff line number Diff line change @@ -52,10 +52,7 @@ import type {
5252import type { RunScriptActionRequestBodyInput } from '@kbn/security-solution-plugin/common/api/endpoint/actions/response_actions/run_script/run_script.gen' ;
5353
5454import type { FtrProviderContext } from '@kbn/ftr-common-functional-services' ;
55-
56- function getRouteUrlForSpace ( routeUrl : string , spaceId ?: string ) : string {
57- return spaceId ? `/s/${ spaceId } ${ routeUrl } ` : routeUrl ;
58- }
55+ import { getRouteUrlForSpace } from '@kbn/spaces-plugin/common' ;
5956
6057export function SecuritySolutionApiProvider ( { getService } : FtrProviderContext ) {
6158 const supertest = getService ( 'supertest' ) ;
Original file line number Diff line number Diff line change @@ -47,10 +47,7 @@ import type { StartEntityEngineRequestParamsInput } from '@kbn/security-solution
4747import type { StopEntityEngineRequestParamsInput } from '@kbn/security-solution-plugin/common/api/entity_analytics/entity_store/engine/stop.gen' ;
4848
4949import type { FtrProviderContext } from '@kbn/ftr-common-functional-services' ;
50-
51- function getRouteUrlForSpace ( routeUrl : string , spaceId ?: string ) : string {
52- return spaceId ? `/s/${ spaceId } ${ routeUrl } ` : routeUrl ;
53- }
50+ import { getRouteUrlForSpace } from '@kbn/spaces-plugin/common' ;
5451
5552export function SecuritySolutionApiProvider ( { getService } : FtrProviderContext ) {
5653 const supertest = getService ( 'supertest' ) ;
Original file line number Diff line number Diff line change @@ -41,10 +41,7 @@ import type { UpdateExceptionListRequestBodyInput } from '@kbn/securitysolution-
4141import type { UpdateExceptionListItemRequestBodyInput } from '@kbn/securitysolution-exceptions-common/api/update_exception_list_item/update_exception_list_item.gen' ;
4242
4343import type { FtrProviderContext } from '@kbn/ftr-common-functional-services' ;
44-
45- function getRouteUrlForSpace ( routeUrl : string , spaceId ?: string ) : string {
46- return spaceId ? `/s/${ spaceId } ${ routeUrl } ` : routeUrl ;
47- }
44+ import { getRouteUrlForSpace } from '@kbn/spaces-plugin/common' ;
4845
4946export function SecuritySolutionApiProvider ( { getService } : FtrProviderContext ) {
5047 const supertest = getService ( 'supertest' ) ;
Original file line number Diff line number Diff line change @@ -35,10 +35,7 @@ import type { UpdateListRequestBodyInput } from '@kbn/securitysolution-lists-com
3535import type { UpdateListItemRequestBodyInput } from '@kbn/securitysolution-lists-common/api/update_list_item/update_list_item.gen' ;
3636
3737import type { FtrProviderContext } from '@kbn/ftr-common-functional-services' ;
38-
39- function getRouteUrlForSpace ( routeUrl : string , spaceId ?: string ) : string {
40- return spaceId ? `/s/${ spaceId } ${ routeUrl } ` : routeUrl ;
41- }
38+ import { getRouteUrlForSpace } from '@kbn/spaces-plugin/common' ;
4239
4340export function SecuritySolutionApiProvider ( { getService } : FtrProviderContext ) {
4441 const supertest = getService ( 'supertest' ) ;
Original file line number Diff line number Diff line change @@ -54,10 +54,7 @@ import type {
5454} from '@kbn/osquery-plugin/common/api/asset/assets.gen' ;
5555
5656import type { FtrProviderContext } from '@kbn/ftr-common-functional-services' ;
57-
58- function getRouteUrlForSpace ( routeUrl : string , spaceId ?: string ) : string {
59- return spaceId ? `/s/${ spaceId } ${ routeUrl } ` : routeUrl ;
60- }
57+ import { getRouteUrlForSpace } from '@kbn/spaces-plugin/common' ;
6158
6259export function SecuritySolutionApiProvider ( { getService } : FtrProviderContext ) {
6360 const supertest = getService ( 'supertest' ) ;
You can’t perform that action at this time.
0 commit comments