import { schema } from '@kbn/config-schema' ; import { SavedObjectsErrorHelpers } from '../../../../../../../src/core/server' ; import { wrapError } from '../../../lib/errors' ; import { createLicensedRouteHandler } from '../../lib' ; import type { ExternalRouteDeps } from './' ; export function initGetSpaceApi ( deps ) { const { externalRouter , getSpacesService } = deps ; externalRouter . get ( { path : '/api/spaces/space/{id}' , validate : { params : schema . object ( { id : schema . string ( ) , } ) , } , } , createLicensedRouteHandler ( async ( context , request , response ) => { const spaceId = request . params . id ; const spacesClient = getSpacesService ( ) . createSpacesClient ( request ) ; try { const space = await spacesClient . get ( spaceId ) ; return response . ok ( { body : space } ) ; } catch ( error ) { if ( SavedObjectsErrorHelpers . isNotFoundError ( error ) ) { return response . notFound ( ) ; } return response . customError ( wrapError ( error ) ) ; } } ) ) ; }