import { RequestHandlerContext , KibanaRequest , KibanaResponseFactory , IKibanaResponse , IRouter , } from 'kibana/server' ; export function initPlugin ( router , path ) { router . post ( { path : `${ path }/rest/api/2/issue` , options : { authRequired : false , } , validate : { } , } , async function ( context , req , res ) : Promise < IKibanaResponse < any > > { return jsonResponse ( res , 200 , { id : '123' , key : 'CK-1' , } ) ; } ) ; router . put ( { path : `${ path }/rest/api/2/issue/{id}` , options : { authRequired : false , } , validate : { } , } , async function ( context , req , res ) : Promise < IKibanaResponse < any > > { return jsonResponse ( res , 204 , { } ) ; } ) ; router . get ( { path : `${ path }/rest/api/2/issue/{id}` , options : { authRequired : false , } , validate : { } , } , async function ( context , req , res ) : Promise < IKibanaResponse < any > > { return jsonResponse ( res , 200 , { id : '123' , key : 'CK-1' , fields : { created : '2020-04-27T14:17:45.490Z' , updated : '2020-04-27T14:17:45.490Z' , summary : 'title' , description : 'description' , } , } ) ; } ) ; router . post ( { path : `${ path }/rest/api/2/issue/{id}/comment` , options : { authRequired : false , } , validate : { } , } , async function ( context , req , res ) : Promise < IKibanaResponse < any > > { return jsonResponse ( res , 200 , { id : '123' , created : '2020-04-27T14:17:45.490Z' , updated : '2020-04-27T14:17:45.490Z' , } ) ; } ) ; router . get ( { path : `${ path }/rest/capabilities` , options : { authRequired : false , } , validate : { } , } , async function ( context , req , res ) : Promise < IKibanaResponse < any > > { return jsonResponse ( res , 200 , { capabilities : { } , } ) ; } ) ; router . get ( { path : `${ path }/rest/api/2/issue/createmeta` , options : { authRequired : false , } , validate : { } , } , async function ( context , req , res ) : Promise < IKibanaResponse < any > > { return jsonResponse ( res , 200 , { projects : [ { issuetypes : [ { id : '10006' , name : 'Task' , } , { id : '10007' , name : 'Sub-task' , } , ] , } , ] , } ) ; } ) ; } function jsonResponse ( res , code , object = { } ) { return res . custom < Record < string , unknown > > ( { body : object , statusCode : code } ) ; }