Skip to content

Commit

Permalink
MOSIP-37959
Browse files Browse the repository at this point in the history
Signed-off-by: Jayesh Kharode <[email protected]>
  • Loading branch information
Jayesh Kharode committed Dec 2, 2024
1 parent 0af132f commit 4e8a855
Showing 1 changed file with 60 additions and 74 deletions.
Original file line number Diff line number Diff line change
@@ -1,40 +1,33 @@
package io.mosip.testrig.dslrig.packetcreator.controller;

import java.io.IOException; import java.util.Optional; import
java.util.Properties;

import org.json.JSONObject; import org.slf4j.Logger; import
org.slf4j.LoggerFactory; import
org.springframework.beans.factory.annotation.Autowired; import
org.springframework.web.bind.annotation.GetMapping; import
org.springframework.web.bind.annotation.PathVariable; import
org.springframework.web.bind.annotation.PostMapping; import
org.springframework.web.bind.annotation.PutMapping; import
org.springframework.web.bind.annotation.RequestBody; import
org.springframework.web.bind.annotation.RequestParam; import
org.springframework.web.bind.annotation.ResponseBody; import
org.springframework.web.bind.annotation.RestController; import
org.springframework.web.multipart.MultipartFile;

import io.mosip.testrig.dslrig.dataprovider.util.CommonUtil; import
io.mosip.testrig.dslrig.dataprovider.variables.VariableManager; import
io.mosip.testrig.dslrig.packetcreator.service.CommandsService; import
io.swagger.v3.oas.annotations.tags.Tag; import
io.swagger.v3.oas.annotations.Operation; import
io.swagger.v3.oas.annotations.responses.ApiResponse; import
io.swagger.v3.oas.annotations.responses.ApiResponses;

@RestController

@Tag(name = "CommandsController", description =
"REST APIs for Command Center,x Kubernetes Control") public class
CommandsController { private static final Logger logger =
LoggerFactory.getLogger(CommandsController.class);

@Autowired CommandsService commandsService;



package io.mosip.testrig.dslrig.packetcreator.controller;

import java.io.IOException;
import java.util.Properties;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import io.mosip.testrig.dslrig.packetcreator.service.CommandsService;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;

@RestController

@Tag(name = "CommandsController", description = "REST APIs for Command Center,x Kubernetes Control")
public class CommandsController {
private static final Logger logger = LoggerFactory.getLogger(CommandsController.class);

@Autowired
CommandsService commandsService;

// @GetMapping(value = "/exec/{testcaseId}/{IsSynchronous}/{contextKey}")
//
// @Operation(summary = "Executing the job")
Expand Down Expand Up @@ -109,40 +102,33 @@
// } catch (Exception e) {
//
// } return "{\"Free\"}"; }

@PostMapping("/writeFile/{offset}/{contextKey}")

@Operation(summary = "Creating the file")

@ApiResponses(value = { @ApiResponse(responseCode = "200", description =
"File created successfully") }) public @ResponseBody String writeToFile(
// @RequestParam("offset") long offset,

@PathVariable("offset") long offset, @RequestBody Properties reqestData,

@PathVariable("contextKey") String contextKey) {

try {

return commandsService.writeToFile(contextKey, reqestData, offset);

} catch (IOException e) { logger.error(e.getMessage()); } return "{Failed}";
}



@GetMapping(value = "/generatekey/{machineId}/{contextKey}")

@Operation(summary = "Generate private key based on machineId", description =
"Generate a private key based on the provided machine ID.", responses = {

@ApiResponse(responseCode = "200", description =
"Private key generated successfully") }) public String
generatekey(@PathVariable String machineId, @PathVariable("contextKey")
String contextKey) { try { return commandsService.generatekey(contextKey,
machineId); } catch (Exception e) {

logger.error(e.getMessage()); } return "{Failed}"; }

}


@PostMapping("/writeFile/{offset}/{contextKey}")
@Operation(summary = "Creating the file")
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "File created successfully") })
public @ResponseBody String writeToFile(
// @RequestParam("offset") long offset,
@PathVariable("offset") long offset, @RequestBody Properties reqestData,
@PathVariable("contextKey") String contextKey) {
try {
return commandsService.writeToFile(contextKey, reqestData, offset);
} catch (IOException e) {
logger.error(e.getMessage());
}
return "{Failed}";
}

@GetMapping(value = "/generatekey/{machineId}/{contextKey}")
@Operation(summary = "Generate private key based on machineId", description = "Generate a private key based on the provided machine ID.", responses = {
@ApiResponse(responseCode = "200", description = "Private key generated successfully") })
public String generatekey(@PathVariable String machineId, @PathVariable("contextKey") String contextKey) {
try {
return commandsService.generatekey(contextKey, machineId);
} catch (Exception e) {

logger.error(e.getMessage());
}
return "{Failed}";
}

}

0 comments on commit 4e8a855

Please sign in to comment.