class HmsLocalRestServiceMgmt {

    @RequestMapping( value = "/debug/switch/{switch_id}", method = RequestMethod.PUT )
    @ResponseBody
    public BaseResponse performLogArchivingForSwitch( @PathVariable
    final String switch_id, @RequestBody( required = false )
    final String body, HttpMethod method )
        throws HMSRestException
    {
        BaseResponse response = new BaseResponse();
        if ( !InventoryLoader.getInstance().getSwitchNodeMap().containsKey( switch_id ) )
        {
            throw new HMSRestException( Status.NOT_FOUND.getStatusCode(), "Invalid Request",
                                        "Can't find switch with id " + switch_id );
        }

        int noOfLines = hmsLogLineExtractLimit;

        if ( body != null )
        {
            ObjectMapper mapper = new ObjectMapper();
            try
            {
                HmsLogExtractOptions options = mapper.readValue( body, HmsLogExtractOptions.class );
                noOfLines = options.getNoOfLines();
            }
            catch ( Exception e )
            {
                logger.warn( "Cannot find number of lines to read from node [ " + switch_id
                    + " ] IB and OOB logs, in request body. So using default value [ " + noOfLines + " ]" );
            }
        }
        if ( noOfLines <= 500 )
        {
            noOfLines = hmsLogLineExtractLimit;
        }
        try
        {
            String targetArchive =
                debuggerUtil.archiveHmsDebugLogs( switch_id, hmsIpAddr, hmsOobUsername, hmsLogArchiverScript,
                                                  hmsLogArchiveLocation, hmsOobLogLocation, hmsIbLogLocation, noOfLines,
                                                  EventComponent.SWITCH );

            response.setStatusCode( Status.OK.getStatusCode() );
            response.setStatusMessage( "Hms debug logs archive will be created shortly at " + targetArchive );
            return response;
        }
        catch ( IllegalArgumentException e )
        {
            String err = "Exception occured during Log archiving for node [ " + switch_id + " ]";
            String debugString =
                String.format( "host_id [ %s ], hmsIpAddr [ %s ], hmsOobUsername [ %s ], hmsLogArchiverScript [ %s ], hmsLogArchiveLocation [ %s ], hmsOobLogLocation [ %s ], hmsIbLogLocation [ %s ], noOfLines[ %s ]",
                               switch_id, hmsIpAddr, hmsOobUsername, hmsLogArchiverScript, hmsLogArchiveLocation,
                               hmsOobLogLocation, hmsIbLogLocation, noOfLines );
            logger.error( err + debugString );
            response.setStatusCode( Status.INTERNAL_SERVER_ERROR.getStatusCode() );
            response.setStatusMessage( err );
            return response;
        }

    }

}