package Ġhello . aws Ċ Ċ import Ġcom . amazonaws . regions . Regions Ċ import Ġcom . amazonaws . services . lambda . AW SL ambda Client Ċ import Ġcom . amazonaws . services . lambda . model . Invoke Request Ċ import Ġcom . amazonaws . services . lambda . runtime . Context Ċ import Ġcom . amazonaws . services . lambda . runtime . RequestHandler Ċ import Ġcom . slack . api . bolt . aws _ lambda . request . Api Gateway Request Ċ import Ġcom . slack . api . bolt . aws _ lambda . response . Api Gateway Response Ċ Ċ class ĠW arm up Handler Ġ: ĠRequest Handler < Api Gateway Request , ĠApi Gateway Response > Ġ{ ĊĊĠ Ġprivate Ġval Ġservice Ġ= ĠSystem . getenv (" SERVER LESS _ SERVICE ") ĊĠ Ġprivate Ġval Ġstage Ġ= ĠSystem . getenv (" SERVER LESS _ STAGE ") ĊĠ Ġprivate Ġval Ġpayload Ġ= Ġ""" {" body ":" warm up = true "} """ ĊĠ Ġprivate Ġval Ġfunction Names Ġ= ĠlistOf ("$ service -$ stage - api ", Ġ"$ service -$ stage - oauth ") ĊĊĠ Ġoverride Ġfun Ġhandle Request ( req : ĠApi Gateway Request ?, Ġcontext : ĠContext ?): ĠApi Gateway Response Ġ{ ĊĠĠĠ Ġval Ġlambda Ġ= ĠAW SL ambda Client . builder (). with Region ( Regions . AP _ N ORT HE AST _ 1 ). build () ĊĠĠĠ Ġfor Ġ( function Name Ġin Ġfunction Names ) Ġ{ ĊĠĠĠĠĠ Ġval Ġinvoke Request Ġ= ĠInvoke Request (). with FunctionName ( function Name ). with Payload ( payload ) ĊĠĠĠĠĠ Ġval Ġresult Ġ= Ġlambda . invoke ( invoke Request ) ĊĠĠĠĠĠ Ġif Ġ( result . statusCode Ġ!= Ġ 2 0 0 Ġ|| Ġresult . function Error Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠ Ġthrow ĠRuntimeException (" status : Ġ${ result . statusCode } Ġfunction Ġerror : Ġ${ result . function Error }") ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠĠĠ Ġreturn ĠApi Gateway Response . builder (). statusCode ( 2 0 0 ). raw Body (" done "). build () ĊĠ Ġ} Ċ }