Commit 5a48336a authored by Spiros Koulouzis's avatar Spiros Koulouzis

added get all ids

parent 4290235d
......@@ -21,6 +21,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.validation.Valid;
import javax.validation.constraints.*;
import java.util.List;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-10T17:15:46.465Z")
@Api(value = "tosca_template", description = "the tosca_template API")
......@@ -28,66 +29,96 @@ public interface ToscaTemplateApi {
@ApiOperation(value = "Deletes a tosca topolog template", nickname = "deleteToscaTemplateByID", notes = "", response = String.class, authorizations = {
@Authorization(value = "drip_auth", scopes = {
@AuthorizationScope(scope = "read:ToscaTemplate", description = "read your topolog template"),
@AuthorizationScope(scope = "read:ToscaTemplate", description = "read your topolog template")
,
@AuthorizationScope(scope = "write:ToscaTemplate", description = "modify topolog template in your account")
})
}, tags={ })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = String.class),
@ApiResponse(code = 400, message = "Invalid ID supplied"),
@ApiResponse(code = 404, message = "ToscaTemplate not found") })
})
}, tags = {})
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = String.class)
,
@ApiResponse(code = 400, message = "Invalid ID supplied")
,
@ApiResponse(code = 404, message = "ToscaTemplate not found")})
@RequestMapping(value = "/tosca_template/{id}",
method = RequestMethod.DELETE)
ResponseEntity<String> deleteToscaTemplateByID(@ApiParam(value = "ID of topolog template to return",required=true) @PathVariable("id") String id);
method = RequestMethod.DELETE)
ResponseEntity<String> deleteToscaTemplateByID(@ApiParam(value = "ID of topolog template to return", required = true) @PathVariable("id") String id);
@ApiOperation(value = "Find topolog template by ID", nickname = "getToscaTemplateByID", notes = "Returns a single topolog template", response = String.class, authorizations = {
@Authorization(value = "drip_auth", scopes = {
@AuthorizationScope(scope = "read:ToscaTemplate", description = "read your topolog template"),
@AuthorizationScope(scope = "read:ToscaTemplate", description = "read your topolog template")
,
@AuthorizationScope(scope = "write:ToscaTemplate", description = "modify topolog template in your account")
})
}, tags={ })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = String.class),
@ApiResponse(code = 400, message = "Invalid ID supplied"),
@ApiResponse(code = 404, message = "ToscaTemplate not found"),
@ApiResponse(code = 405, message = "Invalid input") })
})
}, tags = {})
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = String.class)
,
@ApiResponse(code = 400, message = "Invalid ID supplied")
,
@ApiResponse(code = 404, message = "ToscaTemplate not found")
,
@ApiResponse(code = 405, message = "Invalid input")})
@RequestMapping(value = "/tosca_template/{id}",
produces = { "text/plain" },
method = RequestMethod.GET)
ResponseEntity<String> getToscaTemplateByID(@ApiParam(value = "ID of topolog template to return",required=true) @PathVariable("id") String id);
produces = {"text/plain"},
method = RequestMethod.GET)
ResponseEntity<String> getToscaTemplateByID(@ApiParam(value = "ID of topolog template to return", required = true) @PathVariable("id") String id);
@ApiOperation(value = "Updates exisintg topolog template", nickname = "updateToscaTemplateByID", notes = "", response = String.class, authorizations = {
@Authorization(value = "drip_auth", scopes = {
@AuthorizationScope(scope = "read:ToscaTemplate", description = "read your topolog template"),
@AuthorizationScope(scope = "read:ToscaTemplate", description = "read your topolog template")
,
@AuthorizationScope(scope = "write:ToscaTemplate", description = "modify topolog template in your account")
})
}, tags={ })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = String.class),
@ApiResponse(code = 400, message = "Invalid ID supplied"),
@ApiResponse(code = 404, message = "ToscaTemplate not found"),
@ApiResponse(code = 405, message = "Invalid input") })
})
}, tags = {})
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = String.class)
,
@ApiResponse(code = 400, message = "Invalid ID supplied")
,
@ApiResponse(code = 404, message = "ToscaTemplate not found")
,
@ApiResponse(code = 405, message = "Invalid input")})
@RequestMapping(value = "/tosca_template/{id}",
produces = { "text/plain" },
consumes = { "multipart/form-data" },
method = RequestMethod.PUT)
ResponseEntity<String> updateToscaTemplateByID(@ApiParam(value = "ID of topolog template to return",required=true) @PathVariable("id") String id,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file);
produces = {"text/plain"},
consumes = {"multipart/form-data"},
method = RequestMethod.PUT)
ResponseEntity<String> updateToscaTemplateByID(@ApiParam(value = "ID of topolog template to return", required = true) @PathVariable("id") String id, @ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file);
@ApiOperation(value = "upload a tosca template description file", nickname = "uploadToscaTemplate", notes = "", response = String.class, authorizations = {
@Authorization(value = "drip_auth", scopes = {
@AuthorizationScope(scope = "read:ToscaTemplate", description = "read your topolog template"),
@AuthorizationScope(scope = "read:ToscaTemplate", description = "read your topolog template")
,
@AuthorizationScope(scope = "write:ToscaTemplate", description = "modify topolog template in your account")
})
}, tags={ })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = String.class),
@ApiResponse(code = 405, message = "Invalid input") })
})
}, tags = {})
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = String.class)
,
@ApiResponse(code = 405, message = "Invalid input")})
@RequestMapping(value = "/tosca_template",
consumes = { "multipart/form-data" },
method = RequestMethod.POST)
consumes = {"multipart/form-data"},
method = RequestMethod.POST)
ResponseEntity<String> uploadToscaTemplate(@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file);
@ApiOperation(value = "Get all topolog template IDs", nickname = "getToscaTemplateIDs", notes = "Returns all IDss ", response = String.class, responseContainer = "List", authorizations = {
@Authorization(value = "drip_auth", scopes = {
@AuthorizationScope(scope = "read:ToscaTemplate", description = "read your topolog template")
,
@AuthorizationScope(scope = "write:ToscaTemplate", description = "modify topolog template in your account")
})
}, tags = {})
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = String.class, responseContainer = "List")
,
@ApiResponse(code = 400, message = "Invalid ID supplied")
,
@ApiResponse(code = 404, message = "ToscaTemplate not found")
,
@ApiResponse(code = 405, message = "Invalid input")})
@RequestMapping(value = "/tosca_template/ids",
produces = {"application/json"},
method = RequestMethod.GET)
ResponseEntity<List<String>> getToscaTemplateIDs();
}
......@@ -117,4 +117,14 @@ public class ToscaTemplateApiController implements ToscaTemplateApi {
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
public ResponseEntity<List<String>> getToscaTemplateIDs() {
String accept = request.getHeader("Accept");
if (accept != null && accept.contains("application/json")) {
List<String> ids = toscaTemplateService.getAllIds();
return new ResponseEntity<>(ids, HttpStatus.NOT_IMPLEMENTED);
}
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
}
......@@ -13,6 +13,8 @@ import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator.Feature;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import nl.uva.sne.drip.api.ApiException;
......@@ -79,4 +81,13 @@ public class ToscaTemplateService {
public void deleteByID(String id) {
dao.deleteById(id);
}
public List<String> getAllIds() {
List<String> allIds = new ArrayList<>();
List<ToscaTemplate> all = dao.findAll();
for(ToscaTemplate tt : all){
allIds.add(tt.getId());
}
return allIds;
}
}
......@@ -148,12 +148,12 @@ public class ToscaTemplateServiceTest {
/**
* Test of updateToscaTemplateByID method, of class ToscaTemplateService.
*
* @throws java.io.FileNotFoundException
*/
@Test
public void testUpdateToscaTemplateByID_Exception_MultipartFile() throws FileNotFoundException, IOException {
FileInputStream in = null;
in = new FileInputStream(testUpdatedApplicationExampleToscaFilePath);
FileInputStream in = new FileInputStream(testUpdatedApplicationExampleToscaFilePath);
MultipartFile file = new MockMultipartFile("file", in);
try {
String result = instance.updateToscaTemplateByID("0", file);
......
......@@ -37,6 +37,30 @@ paths:
- drip_auth:
- "write:ToscaTemplate"
- "read:ToscaTemplate"
/tosca_template/ids:
get:
summary: "Get all topolog template IDs"
description: "Returns all IDss "
operationId: "getToscaTemplateIDs"
produces:
- "application/json"
responses:
200:
description: "successful operation"
schema:
type: array
items:
type: string
400:
description: "Invalid ID supplied"
404:
description: "ToscaTemplate not found"
405:
description: "Invalid input"
security:
- drip_auth:
- "write:ToscaTemplate"
- "read:ToscaTemplate"
/tosca_template/{id}:
get:
summary: "Find topolog template by ID"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment