Skip to content

Commit

Permalink
Merge branch 'master' into zkofiro/v2-clients
Browse files Browse the repository at this point in the history
  • Loading branch information
zkofiro committed Apr 7, 2023
2 parents 5c96250 + 369701e commit 567757d
Show file tree
Hide file tree
Showing 16 changed files with 145 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public ResponseEntity<org.springframework.core.io.Resource> getSupportFiles() th
@Operation(description = "Registers an agent instance to a job and sets it's status to ready to start", summary = "Set an agent instance status to ready to start", hidden = true)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Successfully set agent to ready"),
@ApiResponse(responseCode = "400", description = "Bad request", content = @Content)
@ApiResponse(responseCode = "400", description = "Could not register agent due to bad request", content = @Content)
})
public ResponseEntity<AgentTestStartData> agentReady(
@RequestBody @Parameter(description = "agentData object that contains agent data settings", required = true) AgentData agentData) {
Expand Down Expand Up @@ -115,10 +115,11 @@ public ResponseEntity<TankHttpClientDefinitionContainer> getClients() {
@Operation(description = "Sets the availability status for a standalone agent", summary = "Set standalone agent availability", hidden = true)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Successfully set agent availability"),
@ApiResponse(responseCode = "400", description = "Bad request", content = @Content)
@ApiResponse(responseCode = "400", description = "Could not update agent availability due to bad request", content = @Content)
})
public ResponseEntity<Void> setStandaloneAgentAvailability(
@RequestBody @Parameter(description = "Agent availability request to update standalone agent availability", required = true) AgentAvailability availability) {
agentService.setStandaloneAgentAvailability(availability);
return ResponseEntity.ok().build();
}

Expand All @@ -134,14 +135,14 @@ public ResponseEntity<CloudVmStatus> getInstanceStatus(@PathVariable @Parameter(
if (status != null) {
return new ResponseEntity<CloudVmStatus>(status, HttpStatus.OK);
}
return new ResponseEntity<CloudVmStatus>(status, HttpStatus.NOT_FOUND);
return ResponseEntity.notFound().build();
}

@RequestMapping(value = "/instance/status/{instanceId}", method = RequestMethod.PUT, consumes = { MediaType.APPLICATION_JSON_VALUE })
@Operation(description = "Sets the agent instance status via instanceID and CloudVMStatus payload", summary = "Set the agent instance status", hidden = true)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Successfully set agent instance status"),
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content)
@ApiResponse(responseCode = "400", description = "Could not update agent instance status due to bad request", content = @Content)
})
public ResponseEntity<Void> setInstanceStatus(@PathVariable @Parameter(description = "The instance ID associated with the instance", required = true) String instanceId,
@RequestBody @Parameter(description = "CloudVmStatus object that contains updated content", required = true) CloudVmStatus status) {
Expand All @@ -152,8 +153,8 @@ public ResponseEntity<Void> setInstanceStatus(@PathVariable @Parameter(descripti
@RequestMapping(value = "/instance/stop/{instanceId}", method = RequestMethod.GET, produces = { MediaType.TEXT_PLAIN_VALUE } )
@Operation(description = "Stops specific agent instance by instance ID", summary = "Stop an agent instance")
@ApiResponses(value = {
@ApiResponse(responseCode = "204", description = "Successfully stopped agent instance"),
@ApiResponse(responseCode = "400", description = "Bad request", content = @Content)
@ApiResponse(responseCode = "200", description = "Successfully stopped agent instance"),
@ApiResponse(responseCode = "400", description = "Could not update agent instance status due to invalid instanceId", content = @Content)
})
public ResponseEntity<String> stopInstance(@PathVariable @Parameter(description = "The instance ID associated with the instance", required = true) String instanceId) {
String status = agentService.stopInstance(instanceId);
Expand All @@ -163,8 +164,8 @@ public ResponseEntity<String> stopInstance(@PathVariable @Parameter(description
@RequestMapping(value = "/instance/pause/{instanceId}", method = RequestMethod.GET, produces = { MediaType.TEXT_PLAIN_VALUE } )
@Operation(description = "Pauses a specific running agent instance by instance ID", summary = "Pause a running agent instance")
@ApiResponses(value = {
@ApiResponse(responseCode = "204", description = "Successfully paused agent instance"),
@ApiResponse(responseCode = "400", description = "Bad request", content = @Content)
@ApiResponse(responseCode = "200", description = "Successfully paused agent instance"),
@ApiResponse(responseCode = "400", description = "Could not update agent instance status due to invalid instanceId", content = @Content)
})
public ResponseEntity<String> pauseInstance(@PathVariable @Parameter(description = "The instance ID associated with the instance", required = true) String instanceId) {
String status = agentService.pauseInstance(instanceId);
Expand All @@ -174,8 +175,8 @@ public ResponseEntity<String> pauseInstance(@PathVariable @Parameter(description
@RequestMapping(value = "/instance/resume/{instanceId}", method = RequestMethod.GET, produces = { MediaType.TEXT_PLAIN_VALUE } )
@Operation(description = "Resumes a specific paused agent instance by instance ID", summary = "Resume a paused agent instance")
@ApiResponses(value = {
@ApiResponse(responseCode = "204", description = "Successfully resumed agent instance"),
@ApiResponse(responseCode = "400", description = "Bad request", content = @Content)
@ApiResponse(responseCode = "200", description = "Successfully resumed agent instance"),
@ApiResponse(responseCode = "400", description = "Could not update agent instance status due to invalid instanceId", content = @Content)
})
public ResponseEntity<String> resumeInstance(@PathVariable @Parameter(description = "The instance ID associated with the instance", required = true) String instanceId) {
String status = agentService.resumeInstance(instanceId);
Expand All @@ -185,8 +186,8 @@ public ResponseEntity<String> resumeInstance(@PathVariable @Parameter(descriptio
@RequestMapping(value = "/instance/kill/{instanceId}", method = RequestMethod.GET, produces = { MediaType.TEXT_PLAIN_VALUE } )
@Operation(description = "Terminates a specific agent instance by instance ID", summary = "Terminate an agent instance")
@ApiResponses(value = {
@ApiResponse(responseCode = "204", description = "Successfully terminated agent instance"),
@ApiResponse(responseCode = "400", description = "Bad request", content = @Content)
@ApiResponse(responseCode = "200", description = "Successfully terminated agent instance"),
@ApiResponse(responseCode = "400", description = "Could not update agent instance status due to invalid instanceId", content = @Content)
})
public ResponseEntity<String> killInstance(@PathVariable @Parameter(description = "The instance ID associated with the instance", required = true) String instanceId) {
String status = agentService.killInstance(instanceId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ public ResponseEntity<DataFileDescriptorContainer> getDatafiles() {
return new ResponseEntity<>(dataFileService.getDatafiles(), HttpStatus.OK);
}

@RequestMapping(value = "/names", method = RequestMethod.GET)
@Operation(description = "Returns all datafile names with corresponding datafile IDs", summary = "Get all datafile names with datafile IDs")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Successfully found all datafile names with IDs", content = @Content),
@ApiResponse(responseCode = "404", description = "All datafile names with IDs could not be found", content = @Content)
})
public ResponseEntity<Map<Integer, String>> getAllDatafileNames() {
return new ResponseEntity<>(dataFileService.getAllDatafileNames(), HttpStatus.OK);
}

@RequestMapping(value = "/{datafileId}", method = RequestMethod.GET)
@Operation(description = "Returns a specific datafile description by datafile ID", summary = "Get a specific datafile description")
@ApiResponses(value = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,11 @@ public ResponseEntity<JobContainer> getJobsByProject(@PathVariable @Parameter(de

@RequestMapping(method = RequestMethod.POST, consumes = { MediaType.APPLICATION_JSON_VALUE })
@Operation(description = "Given a job request payload, creates a new job under an existing project and returns new jobId and created status in response \n\n" +
"Note: Make sure projectId matches an existing project to successfully add job to project's job queue" +
"Note: Make sure projectId matches an existing project to successfully create the job for that project \n\n" +
"Parameters: \n\n" +
" - jobInstanceName is accepted as a string \n\n" +
" - jobInstanceName and projectName are accepted as strings (both optional) \n\n" +
" - jobInstanceName overrides projectName for naming jobs \n\n" +
" - passing only projectName creates jobs named: '{projectName}_{total_users}\\_users\\_{timestamp}' \n\n" +
" - rampTime and simulationTime are accepted as time strings i.e 60s, 12m, 24h \n\n" +
" - stopBehavior is matched against accepted values ( END_OF_STEP, END_OF_SCRIPT, END_OF_SCRIPT_GROUP, END_OF_TEST ) \n\n" +
" - vmInstance matches against AWS EC2 Instance Types i.e c5.large, c5.xlarge, etc \n\n"+
Expand All @@ -91,7 +93,7 @@ public ResponseEntity<JobContainer> getJobsByProject(@PathVariable @Parameter(de
" - jobRegions.users are accepted as integer strings i.e \"100\", \"4000\" \n\n", summary = "Create a new job")
@ApiResponses(value = {
@ApiResponse(responseCode = "201", description = "Successfully created job", content = @Content),
@ApiResponse(responseCode = "400", description = "Bad request", content = @Content)
@ApiResponse(responseCode = "400", description = "Could not create job due to bad request", content = @Content)
})
public ResponseEntity<Map<String, String>> createJob(
@RequestBody @Parameter(description = "request", required = true) CreateJobRequest request) {
Expand Down Expand Up @@ -149,8 +151,8 @@ public ResponseEntity<CloudVmStatusContainer> getJobVMStatuses(@PathVariable @Pa
@RequestMapping(value = "/start/{jobId}", method = RequestMethod.GET, produces = { MediaType.TEXT_PLAIN_VALUE } )
@Operation(description = "Starts a specific job by job id", summary = "Start a specific job")
@ApiResponses(value = {
@ApiResponse(responseCode = "204", description = "Successfully started job"),
@ApiResponse(responseCode = "400", description = "Bad request", content = @Content)
@ApiResponse(responseCode = "200", description = "Successfully started job"),
@ApiResponse(responseCode = "400", description = "Could not update job status due to invalid jobId", content = @Content)
})
public ResponseEntity<String> startJob(@PathVariable @Parameter(description = "The job ID associated with the job", required = true) Integer jobId) {
String status = jobService.startJob(jobId);
Expand All @@ -160,8 +162,8 @@ public ResponseEntity<String> startJob(@PathVariable @Parameter(description = "T
@RequestMapping(value = "/stop/{jobId}", method = RequestMethod.GET, produces = { MediaType.TEXT_PLAIN_VALUE } )
@Operation(description = "Stops a specific job by job id", summary = "Stop a specific job")
@ApiResponses(value = {
@ApiResponse(responseCode = "204", description = "Successfully stopped job"),
@ApiResponse(responseCode = "400", description = "Bad request", content = @Content)
@ApiResponse(responseCode = "200", description = "Successfully stopped job"),
@ApiResponse(responseCode = "400", description = "Could not update job status due to invalid jobId", content = @Content)
})
public ResponseEntity<String> stopJob(@PathVariable @Parameter(description = "The job ID associated with the job", required = true) Integer jobId) {
String status = jobService.stopJob(jobId);
Expand All @@ -171,8 +173,8 @@ public ResponseEntity<String> stopJob(@PathVariable @Parameter(description = "Th
@RequestMapping(value = "/pause/{jobId}", method = RequestMethod.GET, produces = { MediaType.TEXT_PLAIN_VALUE } )
@Operation(description = "Pauses a specific job by job id", summary = "Pause a job")
@ApiResponses(value = {
@ApiResponse(responseCode = "204", description = "Successfully paused job"),
@ApiResponse(responseCode = "400", description = "Bad request", content = @Content)
@ApiResponse(responseCode = "200", description = "Successfully paused job"),
@ApiResponse(responseCode = "400", description = "Could not update job status due to invalid jobId", content = @Content)
})
public ResponseEntity<String> pauseJob(@PathVariable @Parameter(description = "The job ID associated with the job", required = true) Integer jobId) {
String status = jobService.pauseJob(jobId);
Expand All @@ -182,8 +184,8 @@ public ResponseEntity<String> pauseJob(@PathVariable @Parameter(description = "T
@RequestMapping(value = "/resume/{jobId}", method = RequestMethod.GET, produces = { MediaType.TEXT_PLAIN_VALUE } )
@Operation(description = "Resumes a specific job by job id", summary = "Resume a paused job")
@ApiResponses(value = {
@ApiResponse(responseCode = "204", description = "Successfully resumed job"),
@ApiResponse(responseCode = "400", description = "Bad request", content = @Content)
@ApiResponse(responseCode = "200", description = "Successfully resumed job"),
@ApiResponse(responseCode = "400", description = "Could not update job status due to invalid jobId", content = @Content)
})
public ResponseEntity<String> resumeJob(@PathVariable @Parameter(description = "The job ID associated with the job", required = true) Integer jobId) {
String status = jobService.resumeJob(jobId);
Expand All @@ -193,8 +195,8 @@ public ResponseEntity<String> resumeJob(@PathVariable @Parameter(description = "
@RequestMapping(value = "/kill/{jobId}", method = RequestMethod.GET, produces = { MediaType.TEXT_PLAIN_VALUE } )
@Operation(description = "Terminates a specific job by job id", summary = "Terminate a specific job")
@ApiResponses(value = {
@ApiResponse(responseCode = "204", description = "Successfully terminated job"),
@ApiResponse(responseCode = "400", description = "Bad request", content = @Content)
@ApiResponse(responseCode = "200", description = "Successfully terminated job"),
@ApiResponse(responseCode = "400", description = "Could not update job status due to invalid jobId", content = @Content)
})
public ResponseEntity<String> killJob(@PathVariable @Parameter(description = "The job ID associated with the job", required = true) Integer jobId) {
String status = jobService.killJob(jobId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ public ResponseEntity<ProjectContainer> getAllProjects() {
}

@RequestMapping(value = "/names", method = RequestMethod.GET)
@Operation(description = "Returns all project name/project ID key value pairs", summary = "Get all project names with project IDs")
@Operation(description = "Returns all project names with corresponding project IDs", summary = "Get all project names with project IDs")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Successfully found all project names with IDs", content = @Content),
@ApiResponse(responseCode = "404", description = "All project name with IDs could not be found", content = @Content)
@ApiResponse(responseCode = "404", description = "All project names with IDs could not be found", content = @Content)
})
public ResponseEntity<Map<String, Integer>> getAllProjectNames() {
public ResponseEntity<Map<Integer, String>> getAllProjectNames() {
return new ResponseEntity<>(projectService.getAllProjectNames(), HttpStatus.OK);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ public ResponseEntity<ScriptDescriptionContainer> getScripts() {
return new ResponseEntity<>(scriptService.getScripts(), HttpStatus.OK);
}

@RequestMapping(value = "/names", method = RequestMethod.GET)
@Operation(description = "Returns all script names with corresponding script IDs", summary = "Get all script names with script IDs")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Successfully found all script names with IDs", content = @Content),
@ApiResponse(responseCode = "404", description = "All script names with IDs could not be found", content = @Content)
})
public ResponseEntity<Map<Integer, String>> getAllScriptNames() {
return new ResponseEntity<>(scriptService.getAllScriptNames(), HttpStatus.OK);
}

@RequestMapping(value = "/{scriptId}", method = RequestMethod.GET)
@Operation(description = "Returns a specific script description by script ID", summary = "Get a specific script description")
@ApiResponses(value = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public class CreateJobRequest implements Serializable {

private static final long serialVersionUID = 1L;

@JsonProperty(access = JsonProperty.Access.READ_ONLY)
@XmlElement(name="projectName")
private String projectName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@ public interface DataFileServiceV2 {
*/
public DataFileDescriptorContainer getDatafiles();

/**
* Gets all datafile names along with datafileId
*
* @throws GenericServiceResourceNotFoundException
* if there is an error returning all datafile names
*
* @return map of datafile < datafileName, datafileId > JSON response
*/
public Map<Integer, String> getAllDatafileNames();

/**
* Upload datafile to Tank
Expand Down
Loading

0 comments on commit 567757d

Please sign in to comment.