Skip to content

Commit

Permalink
Use versioned router
Browse files Browse the repository at this point in the history
  • Loading branch information
sphilipse committed Sep 18, 2024
1 parent 42453a8 commit 81429a4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
2 changes: 1 addition & 1 deletion x-pack/plugins/cloud/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ export const ELASTIC_SUPPORT_LINK = 'https://support.elastic.co/';
*/
export const CLOUD_SNAPSHOTS_PATH = 'elasticsearch/snapshots/';

export const ELASTICSEARCH_CONFIG_ROUTE = '/api/internal/elasticsearch_config';
export const ELASTICSEARCH_CONFIG_ROUTE = '/api/internal/cloud/elasticsearch_config';
6 changes: 4 additions & 2 deletions x-pack/plugins/cloud/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { CoreSetup, CoreStart, Plugin, PluginInitializerContext } from '@kb
import { registerCloudDeploymentMetadataAnalyticsContext } from '../common/register_cloud_deployment_id_analytics_context';
import { getIsCloudEnabled } from '../common/is_cloud_enabled';
import { parseDeploymentIdFromDeploymentUrl } from '../common/parse_deployment_id_from_deployment_url';
import { CLOUD_SNAPSHOTS_PATH } from '../common/constants';
import { CLOUD_SNAPSHOTS_PATH, ELASTICSEARCH_CONFIG_ROUTE } from '../common/constants';
import { decodeCloudId, type DecodedCloudId } from '../common/decode_cloud_id';
import { getFullCloudUrl } from '../common/utils';
import { parseOnboardingSolution } from '../common/parse_onboarding_default_solution';
Expand Down Expand Up @@ -228,7 +228,9 @@ export class CloudPlugin implements Plugin<CloudSetup> {
return this.elasticsearchConfig;
}
try {
const result = await http.get<ElasticsearchConfigType>('/api/internal/elasticsearch_config');
const result = await http.get<ElasticsearchConfigType>(ELASTICSEARCH_CONFIG_ROUTE, {
version: '1',
});

this.elasticsearchConfig = { elasticsearchUrl: result.elasticsearch_url || undefined };
return this.elasticsearchConfig;
Expand Down
19 changes: 7 additions & 12 deletions x-pack/plugins/cloud/server/routes/elasticsearch_routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,17 @@ export function defineRoutes({
logger: Logger;
router: IRouter;
}) {
router.get(
{
router.versioned
.get({
path: ELASTICSEARCH_CONFIG_ROUTE,
validate: {},
options: {
access: 'internal',
},
},
async (context, request, response) => {
access: 'internal',
})
.addVersion({ version: '1', validate: {} }, async (context, request, response) => {
const body: ElasticsearchConfigType = {
elasticsearch_url: elasticsearchUrl || '',
elasticsearch_url: elasticsearchUrl,
};
return response.ok({
body,
headers: { 'content-type': 'application/json' },
});
}
);
});
}

0 comments on commit 81429a4

Please sign in to comment.