import { schema } from '@kbn/config-schema' ; import { RouteDependencies } from '../../plugin' ; const tokenSchema = schema . oneOf ( [ schema . object ( { name : schema . string ( ) , type : schema . literal ( 'admin' ) , } ) , schema . object ( { name : schema . string ( ) , type : schema . literal ( 'private' ) , read : schema . boolean ( ) , write : schema . boolean ( ) , access_all_engines : schema . boolean ( ) , engines : schema . maybe ( schema . arrayOf ( schema . string ( ) ) ) , } ) , schema . object ( { name : schema . string ( ) , type : schema . literal ( 'search' ) , access_all_engines : schema . boolean ( ) , engines : schema . maybe ( schema . arrayOf ( schema . string ( ) ) ) , } ) , ] ) ; export function registerCredentialsRoutes ( { router , enterpriseSearchRequestHandler , } ) { router . get ( { path : '/internal/app_search/credentials' , validate : { query : schema . object ( { 'page[current]' : schema . number ( ) , 'page[size]' : schema . number ( ) , } ) , } , } , enterpriseSearchRequestHandler . createRequest ( { path : '/as/credentials/collection' , } ) ) ; router . post ( { path : '/internal/app_search/credentials' , validate : { body : tokenSchema , } , } , enterpriseSearchRequestHandler . createRequest ( { path : '/as/credentials/collection' , } ) ) ; router . get ( { path : '/internal/app_search/credentials/details' , validate : false , } , enterpriseSearchRequestHandler . createRequest ( { path : '/as/credentials/details' , } ) ) ; router . put ( { path : '/internal/app_search/credentials/{name}' , validate : { params : schema . object ( { name : schema . string ( ) , } ) , body : tokenSchema , } , } , enterpriseSearchRequestHandler . createRequest ( { path : '/as/credentials/:name' , } ) ) ; router . delete ( { path : '/internal/app_search/credentials/{name}' , validate : { params : schema . object ( { name : schema . string ( ) , } ) , } , } , enterpriseSearchRequestHandler . createRequest ( { path : '/as/credentials/:name' , } ) ) ; }