Skip to content

Commit 567757d

Browse files
author
zkofiro
committed
Merge branch 'master' into zkofiro/v2-clients
2 parents 5c96250 + 369701e commit 567757d

File tree

16 files changed

+145
-59
lines changed

16 files changed

+145
-59
lines changed

rest-mvc/src/main/java/com/intuit/tank/rest/mvc/rest/controllers/AgentController.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public ResponseEntity<org.springframework.core.io.Resource> getSupportFiles() th
8484
@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)
8585
@ApiResponses(value = {
8686
@ApiResponse(responseCode = "200", description = "Successfully set agent to ready"),
87-
@ApiResponse(responseCode = "400", description = "Bad request", content = @Content)
87+
@ApiResponse(responseCode = "400", description = "Could not register agent due to bad request", content = @Content)
8888
})
8989
public ResponseEntity<AgentTestStartData> agentReady(
9090
@RequestBody @Parameter(description = "agentData object that contains agent data settings", required = true) AgentData agentData) {
@@ -115,10 +115,11 @@ public ResponseEntity<TankHttpClientDefinitionContainer> getClients() {
115115
@Operation(description = "Sets the availability status for a standalone agent", summary = "Set standalone agent availability", hidden = true)
116116
@ApiResponses(value = {
117117
@ApiResponse(responseCode = "200", description = "Successfully set agent availability"),
118-
@ApiResponse(responseCode = "400", description = "Bad request", content = @Content)
118+
@ApiResponse(responseCode = "400", description = "Could not update agent availability due to bad request", content = @Content)
119119
})
120120
public ResponseEntity<Void> setStandaloneAgentAvailability(
121121
@RequestBody @Parameter(description = "Agent availability request to update standalone agent availability", required = true) AgentAvailability availability) {
122+
agentService.setStandaloneAgentAvailability(availability);
122123
return ResponseEntity.ok().build();
123124
}
124125

@@ -134,14 +135,14 @@ public ResponseEntity<CloudVmStatus> getInstanceStatus(@PathVariable @Parameter(
134135
if (status != null) {
135136
return new ResponseEntity<CloudVmStatus>(status, HttpStatus.OK);
136137
}
137-
return new ResponseEntity<CloudVmStatus>(status, HttpStatus.NOT_FOUND);
138+
return ResponseEntity.notFound().build();
138139
}
139140

140141
@RequestMapping(value = "/instance/status/{instanceId}", method = RequestMethod.PUT, consumes = { MediaType.APPLICATION_JSON_VALUE })
141142
@Operation(description = "Sets the agent instance status via instanceID and CloudVMStatus payload", summary = "Set the agent instance status", hidden = true)
142143
@ApiResponses(value = {
143144
@ApiResponse(responseCode = "200", description = "Successfully set agent instance status"),
144-
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content)
145+
@ApiResponse(responseCode = "400", description = "Could not update agent instance status due to bad request", content = @Content)
145146
})
146147
public ResponseEntity<Void> setInstanceStatus(@PathVariable @Parameter(description = "The instance ID associated with the instance", required = true) String instanceId,
147148
@RequestBody @Parameter(description = "CloudVmStatus object that contains updated content", required = true) CloudVmStatus status) {
@@ -152,8 +153,8 @@ public ResponseEntity<Void> setInstanceStatus(@PathVariable @Parameter(descripti
152153
@RequestMapping(value = "/instance/stop/{instanceId}", method = RequestMethod.GET, produces = { MediaType.TEXT_PLAIN_VALUE } )
153154
@Operation(description = "Stops specific agent instance by instance ID", summary = "Stop an agent instance")
154155
@ApiResponses(value = {
155-
@ApiResponse(responseCode = "204", description = "Successfully stopped agent instance"),
156-
@ApiResponse(responseCode = "400", description = "Bad request", content = @Content)
156+
@ApiResponse(responseCode = "200", description = "Successfully stopped agent instance"),
157+
@ApiResponse(responseCode = "400", description = "Could not update agent instance status due to invalid instanceId", content = @Content)
157158
})
158159
public ResponseEntity<String> stopInstance(@PathVariable @Parameter(description = "The instance ID associated with the instance", required = true) String instanceId) {
159160
String status = agentService.stopInstance(instanceId);
@@ -163,8 +164,8 @@ public ResponseEntity<String> stopInstance(@PathVariable @Parameter(description
163164
@RequestMapping(value = "/instance/pause/{instanceId}", method = RequestMethod.GET, produces = { MediaType.TEXT_PLAIN_VALUE } )
164165
@Operation(description = "Pauses a specific running agent instance by instance ID", summary = "Pause a running agent instance")
165166
@ApiResponses(value = {
166-
@ApiResponse(responseCode = "204", description = "Successfully paused agent instance"),
167-
@ApiResponse(responseCode = "400", description = "Bad request", content = @Content)
167+
@ApiResponse(responseCode = "200", description = "Successfully paused agent instance"),
168+
@ApiResponse(responseCode = "400", description = "Could not update agent instance status due to invalid instanceId", content = @Content)
168169
})
169170
public ResponseEntity<String> pauseInstance(@PathVariable @Parameter(description = "The instance ID associated with the instance", required = true) String instanceId) {
170171
String status = agentService.pauseInstance(instanceId);
@@ -174,8 +175,8 @@ public ResponseEntity<String> pauseInstance(@PathVariable @Parameter(description
174175
@RequestMapping(value = "/instance/resume/{instanceId}", method = RequestMethod.GET, produces = { MediaType.TEXT_PLAIN_VALUE } )
175176
@Operation(description = "Resumes a specific paused agent instance by instance ID", summary = "Resume a paused agent instance")
176177
@ApiResponses(value = {
177-
@ApiResponse(responseCode = "204", description = "Successfully resumed agent instance"),
178-
@ApiResponse(responseCode = "400", description = "Bad request", content = @Content)
178+
@ApiResponse(responseCode = "200", description = "Successfully resumed agent instance"),
179+
@ApiResponse(responseCode = "400", description = "Could not update agent instance status due to invalid instanceId", content = @Content)
179180
})
180181
public ResponseEntity<String> resumeInstance(@PathVariable @Parameter(description = "The instance ID associated with the instance", required = true) String instanceId) {
181182
String status = agentService.resumeInstance(instanceId);
@@ -185,8 +186,8 @@ public ResponseEntity<String> resumeInstance(@PathVariable @Parameter(descriptio
185186
@RequestMapping(value = "/instance/kill/{instanceId}", method = RequestMethod.GET, produces = { MediaType.TEXT_PLAIN_VALUE } )
186187
@Operation(description = "Terminates a specific agent instance by instance ID", summary = "Terminate an agent instance")
187188
@ApiResponses(value = {
188-
@ApiResponse(responseCode = "204", description = "Successfully terminated agent instance"),
189-
@ApiResponse(responseCode = "400", description = "Bad request", content = @Content)
189+
@ApiResponse(responseCode = "200", description = "Successfully terminated agent instance"),
190+
@ApiResponse(responseCode = "400", description = "Could not update agent instance status due to invalid instanceId", content = @Content)
190191
})
191192
public ResponseEntity<String> killInstance(@PathVariable @Parameter(description = "The instance ID associated with the instance", required = true) String instanceId) {
192193
String status = agentService.killInstance(instanceId);

rest-mvc/src/main/java/com/intuit/tank/rest/mvc/rest/controllers/DataFileController.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,16 @@ public ResponseEntity<DataFileDescriptorContainer> getDatafiles() {
5959
return new ResponseEntity<>(dataFileService.getDatafiles(), HttpStatus.OK);
6060
}
6161

62+
@RequestMapping(value = "/names", method = RequestMethod.GET)
63+
@Operation(description = "Returns all datafile names with corresponding datafile IDs", summary = "Get all datafile names with datafile IDs")
64+
@ApiResponses(value = {
65+
@ApiResponse(responseCode = "200", description = "Successfully found all datafile names with IDs", content = @Content),
66+
@ApiResponse(responseCode = "404", description = "All datafile names with IDs could not be found", content = @Content)
67+
})
68+
public ResponseEntity<Map<Integer, String>> getAllDatafileNames() {
69+
return new ResponseEntity<>(dataFileService.getAllDatafileNames(), HttpStatus.OK);
70+
}
71+
6272
@RequestMapping(value = "/{datafileId}", method = RequestMethod.GET)
6373
@Operation(description = "Returns a specific datafile description by datafile ID", summary = "Get a specific datafile description")
6474
@ApiResponses(value = {

rest-mvc/src/main/java/com/intuit/tank/rest/mvc/rest/controllers/JobController.java

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,11 @@ public ResponseEntity<JobContainer> getJobsByProject(@PathVariable @Parameter(de
8080

8181
@RequestMapping(method = RequestMethod.POST, consumes = { MediaType.APPLICATION_JSON_VALUE })
8282
@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" +
83-
"Note: Make sure projectId matches an existing project to successfully add job to project's job queue" +
83+
"Note: Make sure projectId matches an existing project to successfully create the job for that project \n\n" +
8484
"Parameters: \n\n" +
85-
" - jobInstanceName is accepted as a string \n\n" +
85+
" - jobInstanceName and projectName are accepted as strings (both optional) \n\n" +
86+
" - jobInstanceName overrides projectName for naming jobs \n\n" +
87+
" - passing only projectName creates jobs named: '{projectName}_{total_users}\\_users\\_{timestamp}' \n\n" +
8688
" - rampTime and simulationTime are accepted as time strings i.e 60s, 12m, 24h \n\n" +
8789
" - stopBehavior is matched against accepted values ( END_OF_STEP, END_OF_SCRIPT, END_OF_SCRIPT_GROUP, END_OF_TEST ) \n\n" +
8890
" - vmInstance matches against AWS EC2 Instance Types i.e c5.large, c5.xlarge, etc \n\n"+
@@ -91,7 +93,7 @@ public ResponseEntity<JobContainer> getJobsByProject(@PathVariable @Parameter(de
9193
" - jobRegions.users are accepted as integer strings i.e \"100\", \"4000\" \n\n", summary = "Create a new job")
9294
@ApiResponses(value = {
9395
@ApiResponse(responseCode = "201", description = "Successfully created job", content = @Content),
94-
@ApiResponse(responseCode = "400", description = "Bad request", content = @Content)
96+
@ApiResponse(responseCode = "400", description = "Could not create job due to bad request", content = @Content)
9597
})
9698
public ResponseEntity<Map<String, String>> createJob(
9799
@RequestBody @Parameter(description = "request", required = true) CreateJobRequest request) {
@@ -149,8 +151,8 @@ public ResponseEntity<CloudVmStatusContainer> getJobVMStatuses(@PathVariable @Pa
149151
@RequestMapping(value = "/start/{jobId}", method = RequestMethod.GET, produces = { MediaType.TEXT_PLAIN_VALUE } )
150152
@Operation(description = "Starts a specific job by job id", summary = "Start a specific job")
151153
@ApiResponses(value = {
152-
@ApiResponse(responseCode = "204", description = "Successfully started job"),
153-
@ApiResponse(responseCode = "400", description = "Bad request", content = @Content)
154+
@ApiResponse(responseCode = "200", description = "Successfully started job"),
155+
@ApiResponse(responseCode = "400", description = "Could not update job status due to invalid jobId", content = @Content)
154156
})
155157
public ResponseEntity<String> startJob(@PathVariable @Parameter(description = "The job ID associated with the job", required = true) Integer jobId) {
156158
String status = jobService.startJob(jobId);
@@ -160,8 +162,8 @@ public ResponseEntity<String> startJob(@PathVariable @Parameter(description = "T
160162
@RequestMapping(value = "/stop/{jobId}", method = RequestMethod.GET, produces = { MediaType.TEXT_PLAIN_VALUE } )
161163
@Operation(description = "Stops a specific job by job id", summary = "Stop a specific job")
162164
@ApiResponses(value = {
163-
@ApiResponse(responseCode = "204", description = "Successfully stopped job"),
164-
@ApiResponse(responseCode = "400", description = "Bad request", content = @Content)
165+
@ApiResponse(responseCode = "200", description = "Successfully stopped job"),
166+
@ApiResponse(responseCode = "400", description = "Could not update job status due to invalid jobId", content = @Content)
165167
})
166168
public ResponseEntity<String> stopJob(@PathVariable @Parameter(description = "The job ID associated with the job", required = true) Integer jobId) {
167169
String status = jobService.stopJob(jobId);
@@ -171,8 +173,8 @@ public ResponseEntity<String> stopJob(@PathVariable @Parameter(description = "Th
171173
@RequestMapping(value = "/pause/{jobId}", method = RequestMethod.GET, produces = { MediaType.TEXT_PLAIN_VALUE } )
172174
@Operation(description = "Pauses a specific job by job id", summary = "Pause a job")
173175
@ApiResponses(value = {
174-
@ApiResponse(responseCode = "204", description = "Successfully paused job"),
175-
@ApiResponse(responseCode = "400", description = "Bad request", content = @Content)
176+
@ApiResponse(responseCode = "200", description = "Successfully paused job"),
177+
@ApiResponse(responseCode = "400", description = "Could not update job status due to invalid jobId", content = @Content)
176178
})
177179
public ResponseEntity<String> pauseJob(@PathVariable @Parameter(description = "The job ID associated with the job", required = true) Integer jobId) {
178180
String status = jobService.pauseJob(jobId);
@@ -182,8 +184,8 @@ public ResponseEntity<String> pauseJob(@PathVariable @Parameter(description = "T
182184
@RequestMapping(value = "/resume/{jobId}", method = RequestMethod.GET, produces = { MediaType.TEXT_PLAIN_VALUE } )
183185
@Operation(description = "Resumes a specific job by job id", summary = "Resume a paused job")
184186
@ApiResponses(value = {
185-
@ApiResponse(responseCode = "204", description = "Successfully resumed job"),
186-
@ApiResponse(responseCode = "400", description = "Bad request", content = @Content)
187+
@ApiResponse(responseCode = "200", description = "Successfully resumed job"),
188+
@ApiResponse(responseCode = "400", description = "Could not update job status due to invalid jobId", content = @Content)
187189
})
188190
public ResponseEntity<String> resumeJob(@PathVariable @Parameter(description = "The job ID associated with the job", required = true) Integer jobId) {
189191
String status = jobService.resumeJob(jobId);
@@ -193,8 +195,8 @@ public ResponseEntity<String> resumeJob(@PathVariable @Parameter(description = "
193195
@RequestMapping(value = "/kill/{jobId}", method = RequestMethod.GET, produces = { MediaType.TEXT_PLAIN_VALUE } )
194196
@Operation(description = "Terminates a specific job by job id", summary = "Terminate a specific job")
195197
@ApiResponses(value = {
196-
@ApiResponse(responseCode = "204", description = "Successfully terminated job"),
197-
@ApiResponse(responseCode = "400", description = "Bad request", content = @Content)
198+
@ApiResponse(responseCode = "200", description = "Successfully terminated job"),
199+
@ApiResponse(responseCode = "400", description = "Could not update job status due to invalid jobId", content = @Content)
198200
})
199201
public ResponseEntity<String> killJob(@PathVariable @Parameter(description = "The job ID associated with the job", required = true) Integer jobId) {
200202
String status = jobService.killJob(jobId);

rest-mvc/src/main/java/com/intuit/tank/rest/mvc/rest/controllers/ProjectController.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ public ResponseEntity<ProjectContainer> getAllProjects() {
6060
}
6161

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

rest-mvc/src/main/java/com/intuit/tank/rest/mvc/rest/controllers/ScriptController.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ public ResponseEntity<ScriptDescriptionContainer> getScripts() {
6363
return new ResponseEntity<>(scriptService.getScripts(), HttpStatus.OK);
6464
}
6565

66+
@RequestMapping(value = "/names", method = RequestMethod.GET)
67+
@Operation(description = "Returns all script names with corresponding script IDs", summary = "Get all script names with script IDs")
68+
@ApiResponses(value = {
69+
@ApiResponse(responseCode = "200", description = "Successfully found all script names with IDs", content = @Content),
70+
@ApiResponse(responseCode = "404", description = "All script names with IDs could not be found", content = @Content)
71+
})
72+
public ResponseEntity<Map<Integer, String>> getAllScriptNames() {
73+
return new ResponseEntity<>(scriptService.getAllScriptNames(), HttpStatus.OK);
74+
}
75+
6676
@RequestMapping(value = "/{scriptId}", method = RequestMethod.GET)
6777
@Operation(description = "Returns a specific script description by script ID", summary = "Get a specific script description")
6878
@ApiResponses(value = {

rest-mvc/src/main/java/com/intuit/tank/rest/mvc/rest/models/jobs/CreateJobRequest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public class CreateJobRequest implements Serializable {
2323

2424
private static final long serialVersionUID = 1L;
2525

26-
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
2726
@XmlElement(name="projectName")
2827
private String projectName;
2928

rest-mvc/src/main/java/com/intuit/tank/rest/mvc/rest/services/datafiles/DataFileServiceV2.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,15 @@ public interface DataFileServiceV2 {
7575
*/
7676
public DataFileDescriptorContainer getDatafiles();
7777

78+
/**
79+
* Gets all datafile names along with datafileId
80+
*
81+
* @throws GenericServiceResourceNotFoundException
82+
* if there is an error returning all datafile names
83+
*
84+
* @return map of datafile < datafileName, datafileId > JSON response
85+
*/
86+
public Map<Integer, String> getAllDatafileNames();
7887

7988
/**
8089
* Upload datafile to Tank

0 commit comments

Comments
 (0)