Skip to content

Commit 3d45d60

Browse files
committed
Update and re-gen
1 parent 47e9f13 commit 3d45d60

12 files changed

Lines changed: 33 additions & 36 deletions

File tree

src/platform/packages/shared/kbn-openapi-generator/src/template_service/templates/api_client_supertest.handlebars

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ import type {
1919
{{/each}}
2020

2121
import 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

2724
export function SecuritySolutionApiProvider({ getService }: FtrProviderContext) {
2825
const supertest = getService('supertest');
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
}

x-pack/platform/plugins/shared/spaces/common/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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';
1617
export { addSpaceIdToPath, getSpaceIdFromPath } from './lib/spaces_url_parser';
1718
export type {
1819
Space,

x-pack/solutions/security/packages/test-api-clients/supertest/detections.gen.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,7 @@ import type { SuggestUserProfilesRequestQueryInput } from '@kbn/security-solutio
5858
import type { UpdateRuleRequestBodyInput } from '@kbn/security-solution-plugin/common/api/detection_engine/rule_management/crud/update_rule/update_rule_route.gen';
5959

6060
import 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

6663
export function SecuritySolutionApiProvider({ getService }: FtrProviderContext) {
6764
const supertest = getService('supertest');

x-pack/solutions/security/packages/test-api-clients/supertest/endpoint_exceptions.gen.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ import type { ReadEndpointListItemRequestQueryInput } from '@kbn/securitysolutio
2626
import type { UpdateEndpointListItemRequestBodyInput } from '@kbn/securitysolution-endpoint-exceptions-common/api/update_endpoint_list_item/update_endpoint_list_item.gen';
2727

2828
import 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

3431
export function SecuritySolutionApiProvider({ getService }: FtrProviderContext) {
3532
const supertest = getService('supertest');

x-pack/solutions/security/packages/test-api-clients/supertest/endpoint_management.gen.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,7 @@ import type {
5252
import type { RunScriptActionRequestBodyInput } from '@kbn/security-solution-plugin/common/api/endpoint/actions/response_actions/run_script/run_script.gen';
5353

5454
import 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

6057
export function SecuritySolutionApiProvider({ getService }: FtrProviderContext) {
6158
const supertest = getService('supertest');

x-pack/solutions/security/packages/test-api-clients/supertest/entity_analytics.gen.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,7 @@ import type { StartEntityEngineRequestParamsInput } from '@kbn/security-solution
4747
import type { StopEntityEngineRequestParamsInput } from '@kbn/security-solution-plugin/common/api/entity_analytics/entity_store/engine/stop.gen';
4848

4949
import 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

5552
export function SecuritySolutionApiProvider({ getService }: FtrProviderContext) {
5653
const supertest = getService('supertest');

x-pack/solutions/security/packages/test-api-clients/supertest/exceptions.gen.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,7 @@ import type { UpdateExceptionListRequestBodyInput } from '@kbn/securitysolution-
4141
import type { UpdateExceptionListItemRequestBodyInput } from '@kbn/securitysolution-exceptions-common/api/update_exception_list_item/update_exception_list_item.gen';
4242

4343
import 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

4946
export function SecuritySolutionApiProvider({ getService }: FtrProviderContext) {
5047
const supertest = getService('supertest');

x-pack/solutions/security/packages/test-api-clients/supertest/lists.gen.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@ import type { UpdateListRequestBodyInput } from '@kbn/securitysolution-lists-com
3535
import type { UpdateListItemRequestBodyInput } from '@kbn/securitysolution-lists-common/api/update_list_item/update_list_item.gen';
3636

3737
import 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

4340
export function SecuritySolutionApiProvider({ getService }: FtrProviderContext) {
4441
const supertest = getService('supertest');

x-pack/solutions/security/packages/test-api-clients/supertest/osquery.gen.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,7 @@ import type {
5454
} from '@kbn/osquery-plugin/common/api/asset/assets.gen';
5555

5656
import 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

6259
export function SecuritySolutionApiProvider({ getService }: FtrProviderContext) {
6360
const supertest = getService('supertest');

0 commit comments

Comments
 (0)