Commit c0a478f8 authored by Spiros Koulouzis's avatar Spiros Koulouzis

manager as spring/swagger

parent 8d9282a9
<?xml version="1.0" encoding="UTF-8"?>
<project-shared-configuration>
<!--
This file contains additional configuration written by modules in the NetBeans IDE.
The configuration is intended to be shared among all the users of project and
therefore it is assumed to be part of version control checkout.
Without this configuration present, some functionality in the IDE may be limited or fail altogether.
-->
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
<!--
Properties that influence various parts of the IDE, especially code formatting and the like.
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
That way multiple projects can share the same settings (useful for formatting rules for example).
Any value defined here will override the pom.xml file value but is only applicable to the current project.
-->
<org-netbeans-modules-whitelist.whitelist-oracle>false</org-netbeans-modules-whitelist.whitelist-oracle>
</properties>
</project-shared-configuration>
<?xml version="1.0" encoding="UTF-8"?>
<actions>
<action>
<actionName>run</actionName>
<packagings>
<packaging>jar</packaging>
</packagings>
<goals>
<goal>process-classes</goal>
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
</goals>
<properties>
<exec.args>-classpath %classpath nl.uva.sne.drip.Swagger2SpringBoot</exec.args>
<exec.executable>java</exec.executable>
</properties>
</action>
<action>
<actionName>debug</actionName>
<packagings>
<packaging>jar</packaging>
</packagings>
<goals>
<goal>process-classes</goal>
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
</goals>
<properties>
<exec.args>-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath nl.uva.sne.drip.Swagger2SpringBoot</exec.args>
<exec.executable>java</exec.executable>
<jpda.listen>true</jpda.listen>
</properties>
</action>
<action>
<actionName>profile</actionName>
<packagings>
<packaging>jar</packaging>
</packagings>
<goals>
<goal>process-classes</goal>
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
</goals>
<properties>
<exec.args>-classpath %classpath nl.uva.sne.drip.Swagger2SpringBoot</exec.args>
<exec.executable>java</exec.executable>
</properties>
</action>
</actions>
This diff is collapsed.
...@@ -4,10 +4,11 @@ ...@@ -4,10 +4,11 @@
<artifactId>drip-manager</artifactId> <artifactId>drip-manager</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>drip-manager</name> <name>drip-manager</name>
<version>1.0.0</version> <version>3.0.0</version>
<properties> <properties>
<maven.compiler.source>1.8</maven.compiler.source> <java.version>1.8</java.version>
<maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<springfox-version>2.9.2</springfox-version> <springfox-version>2.9.2</springfox-version>
</properties> </properties>
<parent> <parent>
...@@ -53,11 +54,27 @@ ...@@ -53,11 +54,27 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.github.joschi.jackson</groupId> <groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-datatype-threetenbp</artifactId> <artifactId>jackson-dataformat-yaml</artifactId>
<version>2.6.4</version> </dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<type>jar</type>
</dependency> </dependency>
<!-- Bean Validation API support --> <dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<type>jar</type>
</dependency>
<!-- Bean Validation API support -->
<dependency> <dependency>
<groupId>javax.validation</groupId> <groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId> <artifactId>validation-api</artifactId>
...@@ -68,14 +85,15 @@ ...@@ -68,14 +85,15 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.data</groupId> <groupId>com.github.joschi.jackson</groupId>
<artifactId>spring-data-mongodb</artifactId> <artifactId>jackson-datatype-threetenbp</artifactId>
<version>2.6.4</version>
<type>jar</type> <type>jar</type>
</dependency> </dependency>
<dependency> <dependency>
<groupId>io.swagger</groupId> <groupId>nl.uva.sne.drip</groupId>
<artifactId>swagger-annotations</artifactId> <artifactId>drip-commons</artifactId>
<version>1.5.20</version> <version>1.0-SNAPSHOT</version>
<type>jar</type> <type>jar</type>
</dependency> </dependency>
</dependencies> </dependencies>
......
package nl.uva.sne.drip; package nl.uva.sne.drip;
import nl.uva.sne.drip.dao.TopologTemplateDAO; import nl.uva.sne.drip.dao.ToscaTemplateDAO;
import org.springframework.boot.CommandLineRunner; import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.ExitCodeGenerator; import org.springframework.boot.ExitCodeGenerator;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
...@@ -12,7 +12,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2; ...@@ -12,7 +12,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
@SpringBootApplication @SpringBootApplication
@EnableSwagger2 @EnableSwagger2
@EnableMongoRepositories(basePackageClasses = {TopologTemplateDAO.class}) @EnableMongoRepositories(basePackageClasses = {ToscaTemplateDAO.class})
@ComponentScan(basePackages = {"nl.uva.sne.drip", "nl.uva.sne.drip.api", "nl.uva.sne.drip.configuration", "nl.uva.sne.drip.dao", "nl.uva.sne.drip.model", "nl.uva.sne.drip.service"}) @ComponentScan(basePackages = {"nl.uva.sne.drip", "nl.uva.sne.drip.api", "nl.uva.sne.drip.configuration", "nl.uva.sne.drip.dao", "nl.uva.sne.drip.model", "nl.uva.sne.drip.service"})
public class Swagger2SpringBoot implements CommandLineRunner { public class Swagger2SpringBoot implements CommandLineRunner {
...@@ -28,7 +28,6 @@ public class Swagger2SpringBoot implements CommandLineRunner { ...@@ -28,7 +28,6 @@ public class Swagger2SpringBoot implements CommandLineRunner {
} }
class ExitException extends RuntimeException implements ExitCodeGenerator { class ExitException extends RuntimeException implements ExitCodeGenerator {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Override @Override
......
package nl.uva.sne.drip.api; package nl.uva.sne.drip.api;
@javax.annotation.Generated(value = "nl.uva.sne.drip.codegen.languages.SpringCodegen", date = "2019-10-09T14:00:37.436Z") @javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-10T17:15:46.465Z")
public class ApiException extends Exception{ public class ApiException extends Exception{
private int code; private int code;
......
...@@ -5,7 +5,7 @@ import java.io.IOException; ...@@ -5,7 +5,7 @@ import java.io.IOException;
import javax.servlet.*; import javax.servlet.*;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@javax.annotation.Generated(value = "nl.uva.sne.drip.codegen.languages.SpringCodegen", date = "2019-10-09T14:00:37.436Z") @javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-10T17:15:46.465Z")
public class ApiOriginFilter implements javax.servlet.Filter { public class ApiOriginFilter implements javax.servlet.Filter {
@Override @Override
......
...@@ -2,7 +2,7 @@ package nl.uva.sne.drip.api; ...@@ -2,7 +2,7 @@ package nl.uva.sne.drip.api;
import javax.xml.bind.annotation.XmlTransient; import javax.xml.bind.annotation.XmlTransient;
@javax.annotation.Generated(value = "nl.uva.sne.drip.codegen.languages.SpringCodegen", date = "2019-10-09T14:00:37.436Z") @javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-10T17:15:46.465Z")
@javax.xml.bind.annotation.XmlRootElement @javax.xml.bind.annotation.XmlRootElement
public class ApiResponseMessage { public class ApiResponseMessage {
......
/**
* NOTE: This class is auto generated by the swagger code generator program (2.4.8).
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
*/
package nl.uva.sne.drip.api;
import nl.uva.sne.drip.model.Credentials;
import io.swagger.annotations.*;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
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 = "credential", description = "the credential API")
public interface CredentialApi {
@ApiOperation(value = "Create credentials", nickname = "createCredentials", notes = "Creates credentials", response = String.class, authorizations = {
@Authorization(value = "drip_auth", scopes = {
@AuthorizationScope(scope = "read:Credentials", description = "read your cloud credentials"),
@AuthorizationScope(scope = "write:Credentials", description = "modify cloud credentials 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") })
@RequestMapping(value = "/credential",
produces = { "application/json" },
consumes = { "application/json" },
method = RequestMethod.POST)
ResponseEntity<String> createCredentials(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody Credentials body);
}
package nl.uva.sne.drip.api;
import nl.uva.sne.drip.model.Credentials;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.annotations.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
import javax.validation.constraints.*;
import javax.validation.Valid;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.List;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-10T17:15:46.465Z")
@Controller
public class CredentialApiController implements CredentialApi {
private static final Logger log = LoggerFactory.getLogger(CredentialApiController.class);
private final ObjectMapper objectMapper;
private final HttpServletRequest request;
@org.springframework.beans.factory.annotation.Autowired
public CredentialApiController(ObjectMapper objectMapper, HttpServletRequest request) {
this.objectMapper = objectMapper;
this.request = request;
}
public ResponseEntity<String> createCredentials(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody Credentials body) {
String accept = request.getHeader("Accept");
if (accept != null && accept.contains("application/json")) {
try {
return new ResponseEntity<String>(objectMapper.readValue("\"\"", String.class), HttpStatus.NOT_IMPLEMENTED);
} catch (IOException e) {
log.error("Couldn't serialize response for content type application/json", e);
return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
return new ResponseEntity<String>(HttpStatus.NOT_IMPLEMENTED);
}
}
/**
* NOTE: This class is auto generated by the swagger code generator program (2.4.8).
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
*/
package nl.uva.sne.drip.api;
import io.swagger.annotations.*;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
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 = "deployer", description = "the deployer API")
public interface DeployerApi {
@ApiOperation(value = "deploy the software tosca template", nickname = "deployProvisionToscaTemplateByID", notes = "Returns the deployment ID", response = String.class, 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),
@ApiResponse(code = 400, message = "Invalid ID supplied"),
@ApiResponse(code = 404, message = "ToscaTemplate not found"),
@ApiResponse(code = 405, message = "Invalid input") })
@RequestMapping(value = "/deployer/deploy/{id}",
produces = { "text/plain" },
method = RequestMethod.GET)
ResponseEntity<String> deployProvisionToscaTemplateByID(@ApiParam(value = "ID of topolog template to deploy",required=true) @PathVariable("id") String id);
@ApiOperation(value = "get the deployment topolog template", nickname = "getDeployToscaTemplateByID", notes = "Returns the deployment topolog template", response = String.class, 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),
@ApiResponse(code = 400, message = "Invalid ID supplied"),
@ApiResponse(code = 404, message = "ToscaTemplate not found"),
@ApiResponse(code = 405, message = "Invalid input") })
@RequestMapping(value = "/deployer/{id}",
produces = { "text/plain" },
method = RequestMethod.GET)
ResponseEntity<String> getDeployToscaTemplateByID(@ApiParam(value = "ID of topolog template to deploy",required=true) @PathVariable("id") String id);
}
package nl.uva.sne.drip.api;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.annotations.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
import javax.validation.constraints.*;
import javax.validation.Valid;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.List;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-10T17:15:46.465Z")
@Controller
public class DeployerApiController implements DeployerApi {
private static final Logger log = LoggerFactory.getLogger(DeployerApiController.class);
private final ObjectMapper objectMapper;
private final HttpServletRequest request;
@org.springframework.beans.factory.annotation.Autowired
public DeployerApiController(ObjectMapper objectMapper, HttpServletRequest request) {
this.objectMapper = objectMapper;
this.request = request;
}
public ResponseEntity<String> deployProvisionToscaTemplateByID(@ApiParam(value = "ID of topolog template to deploy",required=true) @PathVariable("id") String id) {
String accept = request.getHeader("Accept");
if (accept != null && accept.contains("")) {
try {
return new ResponseEntity<String>(objectMapper.readValue("", String.class), HttpStatus.NOT_IMPLEMENTED);
} catch (IOException e) {
log.error("Couldn't serialize response for content type ", e);
return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
return new ResponseEntity<String>(HttpStatus.NOT_IMPLEMENTED);
}
public ResponseEntity<String> getDeployToscaTemplateByID(@ApiParam(value = "ID of topolog template to deploy",required=true) @PathVariable("id") String id) {
String accept = request.getHeader("Accept");
if (accept != null && accept.contains("")) {
try {
return new ResponseEntity<String>(objectMapper.readValue("", String.class), HttpStatus.NOT_IMPLEMENTED);
} catch (IOException e) {
log.error("Couldn't serialize response for content type ", e);
return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
return new ResponseEntity<String>(HttpStatus.NOT_IMPLEMENTED);
}
}
package nl.uva.sne.drip.api; package nl.uva.sne.drip.api;
@javax.annotation.Generated(value = "nl.uva.sne.drip.codegen.languages.SpringCodegen", date = "2019-10-09T14:00:37.436Z") @javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-10T17:15:46.465Z")
public class NotFoundException extends ApiException { public class NotFoundException extends ApiException {
private int code; private int code;
......
/**
* NOTE: This class is auto generated by the swagger code generator program (2.4.8).
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
*/
package nl.uva.sne.drip.api;
import io.swagger.annotations.*;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
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 = "planner", description = "the planner API")
public interface PlannerApi {
@ApiOperation(value = "get the plan tosca template", nickname = "getPlanToscaTemplateByID", notes = "Returns the plan topolog template", response = String.class, 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),
@ApiResponse(code = 400, message = "Invalid ID supplied"),
@ApiResponse(code = 404, message = "ToscaTemplate not found"),
@ApiResponse(code = 405, message = "Invalid input") })
@RequestMapping(value = "/planner/{id}",
produces = { "text/plain" },
method = RequestMethod.GET)
ResponseEntity<String> getPlanToscaTemplateByID(@ApiParam(value = "ID of topolog template plan",required=true) @PathVariable("id") String id);
@ApiOperation(value = "plan tosca template", nickname = "planToscaTemplateByID", notes = "Returns the ID of the planed topolog template", response = String.class, 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),
@ApiResponse(code = 400, message = "Invalid ID supplied"),
@ApiResponse(code = 404, message = "ToscaTemplate not found"),
@ApiResponse(code = 405, message = "Invalid input") })
@RequestMapping(value = "/planner/plan/{id}",
produces = { "text/plain" },
method = RequestMethod.GET)
ResponseEntity<String> planToscaTemplateByID(@ApiParam(value = "ID of topolog template to plan",required=true) @PathVariable("id") String id);
}
...@@ -2,59 +2,66 @@ package nl.uva.sne.drip.api; ...@@ -2,59 +2,66 @@ package nl.uva.sne.drip.api;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import nl.uva.sne.drip.service.TopologTemplateService;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.validation.constraints.*;
import javax.validation.Valid; import javax.validation.Valid;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired; import java.io.IOException;
import java.util.List;
@javax.annotation.Generated(value = "nl.uva.sne.drip.codegen.languages.SpringCodegen", date = "2019-10-09T14:00:37.436Z") @javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-10T17:15:46.465Z")
@Controller @Controller
public class TopologTemplateApiController implements TopologTemplateApi { public class PlannerApiController implements PlannerApi {
private static final Logger log = LoggerFactory.getLogger(TopologTemplateApiController.class); private static final Logger log = LoggerFactory.getLogger(PlannerApiController.class);
private final ObjectMapper objectMapper; private final ObjectMapper objectMapper;
private final HttpServletRequest request; private final HttpServletRequest request;
@Autowired
private TopologTemplateService topologTemplateService;
@org.springframework.beans.factory.annotation.Autowired @org.springframework.beans.factory.annotation.Autowired
public TopologTemplateApiController(ObjectMapper objectMapper, HttpServletRequest request) { public PlannerApiController(ObjectMapper objectMapper, HttpServletRequest request) {
this.objectMapper = objectMapper; this.objectMapper = objectMapper;
this.request = request; this.request = request;
} }
public ResponseEntity<Void> addTopologTemplate(@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file) { public ResponseEntity<String> getPlanToscaTemplateByID(@ApiParam(value = "ID of topolog template plan",required=true) @PathVariable("id") String id) {
String accept = request.getHeader("Accept"); String accept = request.getHeader("Accept");
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED); if (accept != null && accept.contains("")) {
} try {
return new ResponseEntity<String>(objectMapper.readValue("", String.class), HttpStatus.NOT_IMPLEMENTED);
} catch (IOException e) {
log.error("Couldn't serialize response for content type ", e);
return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
public ResponseEntity<Void> getTopologTemplateById(@ApiParam(value = "ID of topolog template to return", required = true) @PathVariable("TopologTemplateId") Long topologTemplateId) { return new ResponseEntity<String>(HttpStatus.NOT_IMPLEMENTED);
String accept = request.getHeader("Accept");
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
} }
public ResponseEntity<Void> topologTemplate(@ApiParam(value = "ID of topolog template to return", required = true) @PathVariable("TopologTemplateId") Long topologTemplateId, @ApiParam(value = "") @RequestHeader(value = "api_key", required = false) String apiKey) { public ResponseEntity<String> planToscaTemplateByID(@ApiParam(value = "ID of topolog template to plan",required=true) @PathVariable("id") String id) {
String accept = request.getHeader("Accept"); String accept = request.getHeader("Accept");
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED); if (accept != null && accept.contains("")) {
} try {
return new ResponseEntity<String>(objectMapper.readValue("", String.class), HttpStatus.NOT_IMPLEMENTED);
} catch (IOException e) {
log.error("Couldn't serialize response for content type ", e);
return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
public ResponseEntity<Void> updateTopologTemplate(@ApiParam(value = "ID of topolog template to return", required = true) @PathVariable("TopologTemplateId") Long topologTemplateId, @ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file) { return new ResponseEntity<String>(HttpStatus.NOT_IMPLEMENTED);
String accept = request.getHeader("Accept");
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
} }
} }
/**
* NOTE: This class is auto generated by the swagger code generator program (2.4.8).
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
*/
package nl.uva.sne.drip.api;
import io.swagger.annotations.*;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
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 = "provisioner", description = "the provisioner API")
public interface ProvisionerApi {
@ApiOperation(value = "the provisioned tosca template", nickname = "getProvisionToscaTemplateByID", notes = "Returns the provisioned tosca template", response = String.class, 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),
@ApiResponse(code = 400, message = "Invalid ID supplied"),
@ApiResponse(code = 404, message = "ToscaTemplate not found"),
@ApiResponse(code = 405, message = "Invalid input") })
@RequestMapping(value = "/provisioner/{id}",
produces = { "text/plain" },
method = RequestMethod.GET)
ResponseEntity<String> getProvisionToscaTemplateByID(@ApiParam(value = "ID of topolog template to plan",required=true) @PathVariable("id") String id);
@ApiOperation(value = "provision tosca template", nickname = "provisionPlanToscaTemplateByID", notes = "provosions the operationId: Plan Tosca Template Returns the provision ID", response = String.class, 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),
@ApiResponse(code = 400, message = "Invalid ID supplied"),
@ApiResponse(code = 404, message = "ToscaTemplate not found"),
@ApiResponse(code = 405, message = "Invalid input") })
@RequestMapping(value = "/provisioner/provision/{id}",
produces = { "text/plain" },
method = RequestMethod.GET)
ResponseEntity<String> provisionPlanToscaTemplateByID(@ApiParam(value = "ID of topolog template to plan",required=true) @PathVariable("id") String id);
}
package nl.uva.sne.drip.api;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.annotations.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
import javax.validation.constraints.*;
import javax.validation.Valid;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.List;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-10T17:15:46.465Z")
@Controller
public class ProvisionerApiController implements ProvisionerApi {
private static final Logger log = LoggerFactory.getLogger(ProvisionerApiController.class);
private final ObjectMapper objectMapper;
private final HttpServletRequest request;
@org.springframework.beans.factory.annotation.Autowired
public ProvisionerApiController(ObjectMapper objectMapper, HttpServletRequest request) {
this.objectMapper = objectMapper;
this.request = request;
}
public ResponseEntity<String> getProvisionToscaTemplateByID(@ApiParam(value = "ID of topolog template to plan",required=true) @PathVariable("id") String id) {
String accept = request.getHeader("Accept");
if (accept != null && accept.contains("")) {
try {
return new ResponseEntity<String>(objectMapper.readValue("", String.class), HttpStatus.NOT_IMPLEMENTED);
} catch (IOException e) {
log.error("Couldn't serialize response for content type ", e);
return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
return new ResponseEntity<String>(HttpStatus.NOT_IMPLEMENTED);
}
public ResponseEntity<String> provisionPlanToscaTemplateByID(@ApiParam(value = "ID of topolog template to plan",required=true) @PathVariable("id") String id) {
String accept = request.getHeader("Accept");
if (accept != null && accept.contains("")) {
try {
return new ResponseEntity<String>(objectMapper.readValue("", String.class), HttpStatus.NOT_IMPLEMENTED);
} catch (IOException e) {
log.error("Couldn't serialize response for content type ", e);
return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
return new ResponseEntity<String>(HttpStatus.NOT_IMPLEMENTED);
}
}
...@@ -21,72 +21,73 @@ import org.springframework.web.multipart.MultipartFile; ...@@ -21,72 +21,73 @@ import org.springframework.web.multipart.MultipartFile;
import javax.validation.Valid; import javax.validation.Valid;
import javax.validation.constraints.*; import javax.validation.constraints.*;
import java.util.List; import java.util.List;
@javax.annotation.Generated(value = "nl.uva.sne.drip.codegen.languages.SpringCodegen", date = "2019-10-09T14:00:37.436Z") @javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-10T17:15:46.465Z")
@Api(value = "topolog_template", description = "the topolog_template API") @Api(value = "tosca_template", description = "the tosca_template API")
public interface TopologTemplateApi { public interface ToscaTemplateApi {
@ApiOperation(value = "upload a topolog template description file", nickname = "addTopologTemplate", notes = "", authorizations = { @ApiOperation(value = "Deletes a tosca topolog template", nickname = "deleteToscaTemplateByID", notes = "", response = String.class, authorizations = {
@Authorization(value = "drip_auth", scopes = { @Authorization(value = "drip_auth", scopes = {
@AuthorizationScope(scope = "write:TopologTemplate", description = "modify topolog template in your account"), @AuthorizationScope(scope = "read:ToscaTemplate", description = "read your topolog template"),
@AuthorizationScope(scope = "read:TopologTemplate", description = "read your topolog template") @AuthorizationScope(scope = "write:ToscaTemplate", description = "modify topolog template in your account")
}) })
}, tags={ }) }, tags={ })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 405, message = "Invalid input") }) @ApiResponse(code = 200, message = "successful operation", response = String.class),
@RequestMapping(value = "/topolog_template", @ApiResponse(code = 400, message = "Invalid ID supplied"),
consumes = { "multipart/form-data" }, @ApiResponse(code = 404, message = "ToscaTemplate not found") })
method = RequestMethod.POST) @RequestMapping(value = "/tosca_template/{id}",
ResponseEntity<Void> addTopologTemplate(@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file); 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 = "getTopologTemplateById", notes = "Returns a single topolog template", authorizations = { @ApiOperation(value = "Find topolog template by ID", nickname = "getToscaTemplateByID", notes = "Returns a single topolog template", response = String.class, authorizations = {
@Authorization(value = "drip_auth", scopes = { @Authorization(value = "drip_auth", scopes = {
@AuthorizationScope(scope = "write:TopologTemplate", description = "modify topolog template in your account"), @AuthorizationScope(scope = "read:ToscaTemplate", description = "read your topolog template"),
@AuthorizationScope(scope = "read:TopologTemplate", description = "read your topolog template") @AuthorizationScope(scope = "write:ToscaTemplate", description = "modify topolog template in your account")
}) })
}, tags={ }) }, tags={ })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation"), @ApiResponse(code = 200, message = "successful operation", response = String.class),
@ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 400, message = "Invalid ID supplied"),
@ApiResponse(code = 404, message = "TopologTemplate not found"), @ApiResponse(code = 404, message = "ToscaTemplate not found"),
@ApiResponse(code = 405, message = "Invalid input") }) @ApiResponse(code = 405, message = "Invalid input") })
@RequestMapping(value = "/topolog_template/{TopologTemplateId}", @RequestMapping(value = "/tosca_template/{id}",
produces = { "text/plain" }, produces = { "text/plain" },
method = RequestMethod.GET) method = RequestMethod.GET)
ResponseEntity<Void> getTopologTemplateById(@ApiParam(value = "ID of topolog template to return",required=true) @PathVariable("TopologTemplateId") Long topologTemplateId); ResponseEntity<String> getToscaTemplateByID(@ApiParam(value = "ID of topolog template to return",required=true) @PathVariable("id") String id);
@ApiOperation(value = "Deletes a topolog template", nickname = "topologTemplate", notes = "", authorizations = { @ApiOperation(value = "Updates exisintg topolog template", nickname = "updateToscaTemplateByID", notes = "", response = String.class, authorizations = {
@Authorization(value = "drip_auth", scopes = { @Authorization(value = "drip_auth", scopes = {
@AuthorizationScope(scope = "write:TopologTemplate", description = "modify topolog template in your account"), @AuthorizationScope(scope = "read:ToscaTemplate", description = "read your topolog template"),
@AuthorizationScope(scope = "read:TopologTemplate", description = "read your topolog template") @AuthorizationScope(scope = "write:ToscaTemplate", description = "modify topolog template in your account")
}) })
}, tags={ }) }, tags={ })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation"), @ApiResponse(code = 200, message = "successful operation", response = String.class),
@ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 400, message = "Invalid ID supplied"),
@ApiResponse(code = 404, message = "TopologTemplate not found") }) @ApiResponse(code = 404, message = "ToscaTemplate not found"),
@RequestMapping(value = "/topolog_template/{TopologTemplateId}", @ApiResponse(code = 405, message = "Invalid input") })
method = RequestMethod.DELETE) @RequestMapping(value = "/tosca_template/{id}",
ResponseEntity<Void> topologTemplate(@ApiParam(value = "ID of topolog template to return",required=true) @PathVariable("TopologTemplateId") Long topologTemplateId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey); 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 = "Updates exisintg topolog template in the store", nickname = "updateTopologTemplate", notes = "", authorizations = { @ApiOperation(value = "upload a tosca template description file", nickname = "uploadToscaTemplate", notes = "", response = String.class, authorizations = {
@Authorization(value = "drip_auth", scopes = { @Authorization(value = "drip_auth", scopes = {
@AuthorizationScope(scope = "write:TopologTemplate", description = "modify topolog template in your account"), @AuthorizationScope(scope = "read:ToscaTemplate", description = "read your topolog template"),
@AuthorizationScope(scope = "read:TopologTemplate", description = "read your topolog template") @AuthorizationScope(scope = "write:ToscaTemplate", description = "modify topolog template in your account")
}) })
}, tags={ }) }, tags={ })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation"), @ApiResponse(code = 200, message = "successful operation", response = String.class),
@ApiResponse(code = 400, message = "Invalid ID supplied"),
@ApiResponse(code = 404, message = "TopologTemplate not found"),
@ApiResponse(code = 405, message = "Invalid input") }) @ApiResponse(code = 405, message = "Invalid input") })
@RequestMapping(value = "/topolog_template/{TopologTemplateId}", @RequestMapping(value = "/tosca_template",
produces = { "application/json" },
consumes = { "multipart/form-data" }, consumes = { "multipart/form-data" },
method = RequestMethod.POST) method = RequestMethod.POST)
ResponseEntity<Void> updateTopologTemplate(@ApiParam(value = "ID of topolog template to return",required=true) @PathVariable("TopologTemplateId") Long topologTemplateId,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file); ResponseEntity<String> uploadToscaTemplate(@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file);
} }
package nl.uva.sne.drip.api;
import org.springframework.core.io.Resource;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.annotations.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
import javax.validation.constraints.*;
import javax.validation.Valid;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.List;
import java.util.logging.Level;
import nl.uva.sne.drip.dao.ToscaTemplateDAO;
import nl.uva.sne.drip.model.ToscaTemplate;
import nl.uva.sne.drip.service.ToscaTemplateService;
import org.springframework.beans.factory.annotation.Autowired;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-10T17:15:46.465Z")
@Controller
public class ToscaTemplateApiController implements ToscaTemplateApi {
private static final Logger log = LoggerFactory.getLogger(ToscaTemplateApiController.class);
private final ObjectMapper objectMapper;
private final HttpServletRequest request;
@Autowired
private ToscaTemplateService toscaTemplateService;
@org.springframework.beans.factory.annotation.Autowired
public ToscaTemplateApiController(ObjectMapper objectMapper, HttpServletRequest request) {
this.objectMapper = objectMapper;
this.request = request;
}
@Override
public ResponseEntity<String> deleteToscaTemplateByID(@ApiParam(value = "ID of topolog template to return", required = true) @PathVariable("id") String id) {
String accept = request.getHeader("Accept");
if (accept != null && accept.contains("application/json")) {
try {
toscaTemplateService.deleteByID(id);
return new ResponseEntity<>(objectMapper.readValue("\"\"", String.class), HttpStatus.OK);
} catch (IOException e) {
log.error("Couldn't serialize response for content type application/json", e);
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
@Override
public ResponseEntity<String> getToscaTemplateByID(@ApiParam(value = "ID of topolog template to return", required = true) @PathVariable("id") String id) {
String accept = request.getHeader("Accept");
if (accept != null && accept.contains("text/plain")) {
try {
String ymlStr = toscaTemplateService.findByID(id);
return new ResponseEntity<>(objectMapper.readValue(ymlStr, String.class), HttpStatus.OK);
} catch (IOException e) {
log.error("Couldn't serialize response for content type ", e);
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
@Override
public 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) {
String accept = request.getHeader("Accept");
if (accept != null && accept.contains("")) {
try {
id = toscaTemplateService.updateToscaTemplateByID(id);
return new ResponseEntity<>(objectMapper.readValue(String.valueOf(id), String.class), HttpStatus.OK);
} catch (IOException e) {
log.error("Couldn't serialize response for content type ", e);
return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
}
public ResponseEntity<String> uploadToscaTemplate(@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file) {
String accept = request.getHeader("Accept");
if (accept != null && accept.contains("*/*")) {
try {
String id = toscaTemplateService.saveFile(file);
return new ResponseEntity<>(String.valueOf(id), HttpStatus.OK);
} catch (IOException e) {
log.error("Couldn't serialize response for content type application/json", e);
return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
} catch (ApiException ex) {
return new ResponseEntity<String>(HttpStatus.CONFLICT);
}
}
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
...@@ -21,39 +21,59 @@ import org.springframework.web.multipart.MultipartFile; ...@@ -21,39 +21,59 @@ import org.springframework.web.multipart.MultipartFile;
import javax.validation.Valid; import javax.validation.Valid;
import javax.validation.constraints.*; import javax.validation.constraints.*;
import java.util.List; import java.util.List;
@javax.annotation.Generated(value = "nl.uva.sne.drip.codegen.languages.SpringCodegen", date = "2019-10-09T14:00:37.436Z") @javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-10T17:15:46.465Z")
@Api(value = "user", description = "the user API") @Api(value = "user", description = "the user API")
public interface UserApi { public interface UserApi {
@ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by the logged in user.", authorizations = { @ApiOperation(value = "Create user", nickname = "createUser", notes = "This can only be done by admin.", response = String.class, authorizations = {
@Authorization(value = "drip_auth", scopes = { @Authorization(value = "drip_auth", scopes = {
@AuthorizationScope(scope = "admin:User", description = "Grants access to admin operations") @AuthorizationScope(scope = "admin:User", description = "Grants access to admin operations")
}) })
}, tags={ }) }, tags={ })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation") }) @ApiResponse(code = 200, message = "successful operation", response = String.class),
@ApiResponse(code = 409, message = "already exists") })
@RequestMapping(value = "/user", @RequestMapping(value = "/user",
produces = { "application/json" }, produces = { "application/json" },
method = RequestMethod.POST) method = RequestMethod.POST)
ResponseEntity<Void> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body); ResponseEntity<String> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body);
@ApiOperation(value = "Logs user into the system", nickname = "userLoginGet", notes = "", response = String.class, tags={ "user", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = String.class),
@ApiResponse(code = 400, message = "Invalid username/password supplied") })
@RequestMapping(value = "/user/login",
produces = { "application/json" },
method = RequestMethod.GET)
ResponseEntity<String> userLoginGet(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password);
@ApiOperation(value = "Logs out current logged in user session", nickname = "userLogoutGet", notes = "", tags={ })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation") })
@RequestMapping(value = "/user/logout",
produces = { "application/json" },
method = RequestMethod.GET)
ResponseEntity<Void> userLogoutGet();
@ApiOperation(value = "Delete user", nickname = "deleteUser", notes = "This can only be done by the logged in user.", authorizations = { @ApiOperation(value = "Delete user", nickname = "userUsernameDelete", notes = "This can only be done by the logged in user.", authorizations = {
@Authorization(value = "drip_auth", scopes = { @Authorization(value = "drip_auth", scopes = {
@AuthorizationScope(scope = "admin:User", description = "Grants access to admin operations") @AuthorizationScope(scope = "admin:User", description = "Grants access to admin operations")
}) })
}, tags={ "user", }) }, tags={ })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 400, message = "Invalid username supplied"), @ApiResponse(code = 400, message = "Invalid username supplied"),
@ApiResponse(code = 404, message = "User not found") }) @ApiResponse(code = 404, message = "User not found") })
@RequestMapping(value = "/user/{username}", @RequestMapping(value = "/user/{username}",
produces = { "application/json" }, produces = { "application/json" },
method = RequestMethod.DELETE) method = RequestMethod.DELETE)
ResponseEntity<Void> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username); ResponseEntity<Void> userUsernameDelete(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username);
@ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, authorizations = { @ApiOperation(value = "Get user by user name", nickname = "userUsernameGet", notes = "", response = User.class, authorizations = {
@Authorization(value = "drip_auth", scopes = { @Authorization(value = "drip_auth", scopes = {
@AuthorizationScope(scope = "admin:User", description = "Grants access to admin operations") @AuthorizationScope(scope = "admin:User", description = "Grants access to admin operations")
}) })
...@@ -65,29 +85,10 @@ public interface UserApi { ...@@ -65,29 +85,10 @@ public interface UserApi {
@RequestMapping(value = "/user/{username}", @RequestMapping(value = "/user/{username}",
produces = { "application/json" }, produces = { "application/json" },
method = RequestMethod.GET) method = RequestMethod.GET)
ResponseEntity<User> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username); ResponseEntity<User> userUsernameGet(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username);
@ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = String.class),
@ApiResponse(code = 400, message = "Invalid username/password supplied") })
@RequestMapping(value = "/user/login",
produces = { "application/json" },
method = RequestMethod.GET)
ResponseEntity<String> loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password);
@ApiOperation(value = "Logs out current logged in user session", nickname = "logoutUser", notes = "", tags={ "user", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation") })
@RequestMapping(value = "/user/logout",
produces = { "application/json" },
method = RequestMethod.GET)
ResponseEntity<Void> logoutUser();
@ApiOperation(value = "Updated user", nickname = "updateUser", notes = "This can only be done by the logged in user.", authorizations = { @ApiOperation(value = "Updated user", nickname = "userUsernamePut", notes = "This can only be done by the logged in user.", authorizations = {
@Authorization(value = "drip_auth", scopes = { @Authorization(value = "drip_auth", scopes = {
@AuthorizationScope(scope = "admin:User", description = "Grants access to admin operations") @AuthorizationScope(scope = "admin:User", description = "Grants access to admin operations")
}) })
...@@ -98,6 +99,6 @@ public interface UserApi { ...@@ -98,6 +99,6 @@ public interface UserApi {
@RequestMapping(value = "/user/{username}", @RequestMapping(value = "/user/{username}",
produces = { "application/json" }, produces = { "application/json" },
method = RequestMethod.PUT) method = RequestMethod.PUT)
ResponseEntity<Void> updateUser(@ApiParam(value = "name that need to be updated",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body); ResponseEntity<Void> userUsernamePut(@ApiParam(value = "name that need to be updated",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body);
} }
...@@ -20,7 +20,7 @@ import javax.validation.Valid; ...@@ -20,7 +20,7 @@ import javax.validation.Valid;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
@javax.annotation.Generated(value = "nl.uva.sne.drip.codegen.languages.SpringCodegen", date = "2019-10-09T14:00:37.436Z") @javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-10T17:15:46.465Z")
@Controller @Controller
public class UserApiController implements UserApi { public class UserApiController implements UserApi {
...@@ -37,31 +37,21 @@ public class UserApiController implements UserApi { ...@@ -37,31 +37,21 @@ public class UserApiController implements UserApi {
this.request = request; this.request = request;
} }
public ResponseEntity<Void> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body) { public ResponseEntity<String> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body) {
String accept = request.getHeader("Accept");
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
}
public ResponseEntity<Void> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username) {
String accept = request.getHeader("Accept");
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
}
public ResponseEntity<User> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username) {
String accept = request.getHeader("Accept"); String accept = request.getHeader("Accept");
if (accept != null && accept.contains("application/json")) { if (accept != null && accept.contains("application/json")) {
try { try {
return new ResponseEntity<User>(objectMapper.readValue("{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\"}", User.class), HttpStatus.NOT_IMPLEMENTED); return new ResponseEntity<String>(objectMapper.readValue("\"\"", String.class), HttpStatus.NOT_IMPLEMENTED);
} catch (IOException e) { } catch (IOException e) {
log.error("Couldn't serialize response for content type application/json", e); log.error("Couldn't serialize response for content type application/json", e);
return new ResponseEntity<User>(HttpStatus.INTERNAL_SERVER_ERROR); return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
} }
} }
return new ResponseEntity<User>(HttpStatus.NOT_IMPLEMENTED); return new ResponseEntity<String>(HttpStatus.NOT_IMPLEMENTED);
} }
public ResponseEntity<String> loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password) { public ResponseEntity<String> userLoginGet(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password) {
String accept = request.getHeader("Accept"); String accept = request.getHeader("Accept");
if (accept != null && accept.contains("application/json")) { if (accept != null && accept.contains("application/json")) {
try { try {
...@@ -75,12 +65,31 @@ public class UserApiController implements UserApi { ...@@ -75,12 +65,31 @@ public class UserApiController implements UserApi {
return new ResponseEntity<String>(HttpStatus.NOT_IMPLEMENTED); return new ResponseEntity<String>(HttpStatus.NOT_IMPLEMENTED);
} }
public ResponseEntity<Void> logoutUser() { public ResponseEntity<Void> userLogoutGet() {
String accept = request.getHeader("Accept"); String accept = request.getHeader("Accept");
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED); return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
} }
public ResponseEntity<Void> updateUser(@ApiParam(value = "name that need to be updated",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body) { public ResponseEntity<Void> userUsernameDelete(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username) {
String accept = request.getHeader("Accept");
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
}
public ResponseEntity<User> userUsernameGet(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username) {
String accept = request.getHeader("Accept");
if (accept != null && accept.contains("application/json")) {
try {
return new ResponseEntity<User>(objectMapper.readValue("{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\"}", User.class), HttpStatus.NOT_IMPLEMENTED);
} catch (IOException e) {
log.error("Couldn't serialize response for content type application/json", e);
return new ResponseEntity<User>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
return new ResponseEntity<User>(HttpStatus.NOT_IMPLEMENTED);
}
public ResponseEntity<Void> userUsernamePut(@ApiParam(value = "name that need to be updated",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body) {
String accept = request.getHeader("Accept"); String accept = request.getHeader("Accept");
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED); return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
} }
......
...@@ -27,6 +27,7 @@ import java.math.BigDecimal; ...@@ -27,6 +27,7 @@ import java.math.BigDecimal;
* Adapted from the jackson threetenbp InstantDeserializer to add support for deserializing rfc822 format. * Adapted from the jackson threetenbp InstantDeserializer to add support for deserializing rfc822 format.
* *
* @author Nick Williams * @author Nick Williams
* @param <T>
*/ */
public class CustomInstantDeserializer<T extends Temporal> public class CustomInstantDeserializer<T extends Temporal>
extends ThreeTenDateTimeDeserializerBase<T> { extends ThreeTenDateTimeDeserializerBase<T> {
......
...@@ -32,9 +32,9 @@ import org.springframework.data.mongodb.repository.config.EnableMongoRepositorie ...@@ -32,9 +32,9 @@ import org.springframework.data.mongodb.repository.config.EnableMongoRepositorie
@Configuration @Configuration
@EnableMongoRepositories(basePackages = "nl.uva.sne.drip.api") @EnableMongoRepositories(basePackages = "nl.uva.sne.drip.api")
@PropertySources({ @PropertySources({
@PropertySource(value = "classpath:drip.properties", ignoreResourceNotFound = true) @PropertySource(value = "classpath:application.properties", ignoreResourceNotFound = true)
, ,
@PropertySource(value = "file:etc/drip.properties", ignoreResourceNotFound = true) @PropertySource(value = "file:etc/application.properties", ignoreResourceNotFound = true)
}) })
@ComponentScan(basePackages = {"nl.uva.sne.drip", "nl.uva.sne.drip.api", "nl.uva.sne.drip.configuration", "nl.uva.sne.drip.dao", "nl.uva.sne.drip.model", "nl.uva.sne.drip.service"}) @ComponentScan(basePackages = {"nl.uva.sne.drip", "nl.uva.sne.drip.api", "nl.uva.sne.drip.configuration", "nl.uva.sne.drip.dao", "nl.uva.sne.drip.model", "nl.uva.sne.drip.service"})
public class MongoConfig extends AbstractMongoConfiguration { public class MongoConfig extends AbstractMongoConfiguration {
......
...@@ -10,8 +10,6 @@ import springfox.documentation.service.Contact; ...@@ -10,8 +10,6 @@ import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType; import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket; import springfox.documentation.spring.web.plugins.Docket;
@javax.annotation.Generated(value = "nl.uva.sne.drip.codegen.languages.SpringCodegen", date = "2019-10-09T14:00:37.436Z")
@Configuration @Configuration
public class SwaggerDocumentationConfig { public class SwaggerDocumentationConfig {
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
*/ */
package nl.uva.sne.drip.dao; package nl.uva.sne.drip.dao;
import nl.uva.sne.drip.model.ToscaTemplate;
import nl.uva.sne.drip.model.User; import nl.uva.sne.drip.model.User;
import org.springframework.data.mongodb.repository.MongoRepository; import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
...@@ -14,6 +15,6 @@ import org.springframework.stereotype.Repository; ...@@ -14,6 +15,6 @@ import org.springframework.stereotype.Repository;
* @author S. Koulouzis * @author S. Koulouzis
*/ */
@Repository @Repository
public interface TopologTemplateDAO extends MongoRepository<User, String> { public interface ToscaTemplateDAO extends MongoRepository<ToscaTemplate, String> {
} }
package nl.uva.sne.drip.model;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.validation.annotation.Validated;
import javax.validation.Valid;
import javax.validation.constraints.*;
/**
* Credentials
*/
@Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-10T17:15:46.465Z")
public class Credentials {
@JsonProperty("protocol")
private String protocol = null;
@JsonProperty("token_type")
private String tokenType = null;
@JsonProperty("token")
private String token = null;
@JsonProperty("keys")
@Valid
private Map<String, String> keys = null;
@JsonProperty("user")
private String user = null;
@JsonProperty("cloud_provider_name")
private String cloudProviderName = null;
public Credentials protocol(String protocol) {
this.protocol = protocol;
return this;
}
/**
* Get protocol
* @return protocol
**/
@ApiModelProperty(value = "")
public String getProtocol() {
return protocol;
}
public void setProtocol(String protocol) {
this.protocol = protocol;
}
public Credentials tokenType(String tokenType) {
this.tokenType = tokenType;
return this;
}
/**
* Get tokenType
* @return tokenType
**/
@ApiModelProperty(value = "")
public String getTokenType() {
return tokenType;
}
public void setTokenType(String tokenType) {
this.tokenType = tokenType;
}
public Credentials token(String token) {
this.token = token;
return this;
}
/**
* Get token
* @return token
**/
@ApiModelProperty(value = "")
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public Credentials keys(Map<String, String> keys) {
this.keys = keys;
return this;
}
public Credentials putKeysItem(String key, String keysItem) {
if (this.keys == null) {
this.keys = new HashMap<String, String>();
}
this.keys.put(key, keysItem);
return this;
}
/**
* Get keys
* @return keys
**/
@ApiModelProperty(value = "")
public Map<String, String> getKeys() {
return keys;
}
public void setKeys(Map<String, String> keys) {
this.keys = keys;
}
public Credentials user(String user) {
this.user = user;
return this;
}
/**
* Get user
* @return user
**/
@ApiModelProperty(value = "")
public String getUser() {
return user;
}
public void setUser(String user) {
this.user = user;
}
public Credentials cloudProviderName(String cloudProviderName) {
this.cloudProviderName = cloudProviderName;
return this;
}
/**
* Get cloudProviderName
* @return cloudProviderName
**/
@ApiModelProperty(value = "")
public String getCloudProviderName() {
return cloudProviderName;
}
public void setCloudProviderName(String cloudProviderName) {
this.cloudProviderName = cloudProviderName;
}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Credentials credentials = (Credentials) o;
return Objects.equals(this.protocol, credentials.protocol) &&
Objects.equals(this.tokenType, credentials.tokenType) &&
Objects.equals(this.token, credentials.token) &&
Objects.equals(this.keys, credentials.keys) &&
Objects.equals(this.user, credentials.user) &&
Objects.equals(this.cloudProviderName, credentials.cloudProviderName);
}
@Override
public int hashCode() {
return Objects.hash(protocol, tokenType, token, keys, user, cloudProviderName);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class Credentials {\n");
sb.append(" protocol: ").append(toIndentedString(protocol)).append("\n");
sb.append(" tokenType: ").append(toIndentedString(tokenType)).append("\n");
sb.append(" token: ").append(toIndentedString(token)).append("\n");
sb.append(" keys: ").append(toIndentedString(keys)).append("\n");
sb.append(" user: ").append(toIndentedString(user)).append("\n");
sb.append(" cloudProviderName: ").append(toIndentedString(cloudProviderName)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}
...@@ -17,7 +17,7 @@ import javax.validation.constraints.*; ...@@ -17,7 +17,7 @@ import javax.validation.constraints.*;
* NodeTemplate * NodeTemplate
*/ */
@Validated @Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-09T16:44:17.416Z") @javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-10T17:15:46.465Z")
public class NodeTemplate { public class NodeTemplate {
@JsonProperty("name") @JsonProperty("name")
...@@ -28,27 +28,27 @@ public class NodeTemplate { ...@@ -28,27 +28,27 @@ public class NodeTemplate {
@JsonProperty("requirements") @JsonProperty("requirements")
@Valid @Valid
private List<Map<String, String>> requirements = null; private List<Map<String, Object>> requirements = null;
@JsonProperty("artifacts") @JsonProperty("artifacts")
@Valid @Valid
private Map<String, String> artifacts = null; private Map<String, Object> artifacts = null;
@JsonProperty("properties") @JsonProperty("properties")
@Valid @Valid
private Map<String, String> properties = null; private Map<String, Object> properties = null;
@JsonProperty("interfaces") @JsonProperty("interfaces")
@Valid @Valid
private Map<String, String> interfaces = null; private Map<String, Object> interfaces = null;
@JsonProperty("capabilities") @JsonProperty("capabilities")
@Valid @Valid
private Map<String, String> capabilities = null; private Map<String, Object> capabilities = null;
@JsonProperty("workflows") @JsonProperty("workflows")
@Valid @Valid
private Map<String, String> workflows = null; private Map<String, Object> workflows = null;
public NodeTemplate name(String name) { public NodeTemplate name(String name) {
this.name = name; this.name = name;
...@@ -90,14 +90,14 @@ public class NodeTemplate { ...@@ -90,14 +90,14 @@ public class NodeTemplate {
this.type = type; this.type = type;
} }
public NodeTemplate requirements(List<Map<String, String>> requirements) { public NodeTemplate requirements(List<Map<String, Object>> requirements) {
this.requirements = requirements; this.requirements = requirements;
return this; return this;
} }
public NodeTemplate addRequirementsItem(Map<String, String> requirementsItem) { public NodeTemplate addRequirementsItem(Map<String, Object> requirementsItem) {
if (this.requirements == null) { if (this.requirements == null) {
this.requirements = new ArrayList<Map<String, String>>(); this.requirements = new ArrayList<Map<String, Object>>();
} }
this.requirements.add(requirementsItem); this.requirements.add(requirementsItem);
return this; return this;
...@@ -111,22 +111,22 @@ public class NodeTemplate { ...@@ -111,22 +111,22 @@ public class NodeTemplate {
@Valid @Valid
public List<Map<String, String>> getRequirements() { public List<Map<String, Object>> getRequirements() {
return requirements; return requirements;
} }
public void setRequirements(List<Map<String, String>> requirements) { public void setRequirements(List<Map<String, Object>> requirements) {
this.requirements = requirements; this.requirements = requirements;
} }
public NodeTemplate artifacts(Map<String, String> artifacts) { public NodeTemplate artifacts(Map<String, Object> artifacts) {
this.artifacts = artifacts; this.artifacts = artifacts;
return this; return this;
} }
public NodeTemplate putArtifactsItem(String key, String artifactsItem) { public NodeTemplate putArtifactsItem(String key, Object artifactsItem) {
if (this.artifacts == null) { if (this.artifacts == null) {
this.artifacts = new HashMap<String, String>(); this.artifacts = new HashMap<String, Object>();
} }
this.artifacts.put(key, artifactsItem); this.artifacts.put(key, artifactsItem);
return this; return this;
...@@ -139,22 +139,22 @@ public class NodeTemplate { ...@@ -139,22 +139,22 @@ public class NodeTemplate {
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
public Map<String, String> getArtifacts() { public Map<String, Object> getArtifacts() {
return artifacts; return artifacts;
} }
public void setArtifacts(Map<String, String> artifacts) { public void setArtifacts(Map<String, Object> artifacts) {
this.artifacts = artifacts; this.artifacts = artifacts;
} }
public NodeTemplate properties(Map<String, String> properties) { public NodeTemplate properties(Map<String, Object> properties) {
this.properties = properties; this.properties = properties;
return this; return this;
} }
public NodeTemplate putPropertiesItem(String key, String propertiesItem) { public NodeTemplate putPropertiesItem(String key, Object propertiesItem) {
if (this.properties == null) { if (this.properties == null) {
this.properties = new HashMap<String, String>(); this.properties = new HashMap<String, Object>();
} }
this.properties.put(key, propertiesItem); this.properties.put(key, propertiesItem);
return this; return this;
...@@ -167,22 +167,22 @@ public class NodeTemplate { ...@@ -167,22 +167,22 @@ public class NodeTemplate {
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
public Map<String, String> getProperties() { public Map<String, Object> getProperties() {
return properties; return properties;
} }
public void setProperties(Map<String, String> properties) { public void setProperties(Map<String, Object> properties) {
this.properties = properties; this.properties = properties;
} }
public NodeTemplate interfaces(Map<String, String> interfaces) { public NodeTemplate interfaces(Map<String, Object> interfaces) {
this.interfaces = interfaces; this.interfaces = interfaces;
return this; return this;
} }
public NodeTemplate putInterfacesItem(String key, String interfacesItem) { public NodeTemplate putInterfacesItem(String key, Object interfacesItem) {
if (this.interfaces == null) { if (this.interfaces == null) {
this.interfaces = new HashMap<String, String>(); this.interfaces = new HashMap<String, Object>();
} }
this.interfaces.put(key, interfacesItem); this.interfaces.put(key, interfacesItem);
return this; return this;
...@@ -195,22 +195,22 @@ public class NodeTemplate { ...@@ -195,22 +195,22 @@ public class NodeTemplate {
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
public Map<String, String> getInterfaces() { public Map<String, Object> getInterfaces() {
return interfaces; return interfaces;
} }
public void setInterfaces(Map<String, String> interfaces) { public void setInterfaces(Map<String, Object> interfaces) {
this.interfaces = interfaces; this.interfaces = interfaces;
} }
public NodeTemplate capabilities(Map<String, String> capabilities) { public NodeTemplate capabilities(Map<String, Object> capabilities) {
this.capabilities = capabilities; this.capabilities = capabilities;
return this; return this;
} }
public NodeTemplate putCapabilitiesItem(String key, String capabilitiesItem) { public NodeTemplate putCapabilitiesItem(String key, Object capabilitiesItem) {
if (this.capabilities == null) { if (this.capabilities == null) {
this.capabilities = new HashMap<String, String>(); this.capabilities = new HashMap<String, Object>();
} }
this.capabilities.put(key, capabilitiesItem); this.capabilities.put(key, capabilitiesItem);
return this; return this;
...@@ -223,22 +223,22 @@ public class NodeTemplate { ...@@ -223,22 +223,22 @@ public class NodeTemplate {
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
public Map<String, String> getCapabilities() { public Map<String, Object> getCapabilities() {
return capabilities; return capabilities;
} }
public void setCapabilities(Map<String, String> capabilities) { public void setCapabilities(Map<String, Object> capabilities) {
this.capabilities = capabilities; this.capabilities = capabilities;
} }
public NodeTemplate workflows(Map<String, String> workflows) { public NodeTemplate workflows(Map<String, Object> workflows) {
this.workflows = workflows; this.workflows = workflows;
return this; return this;
} }
public NodeTemplate putWorkflowsItem(String key, String workflowsItem) { public NodeTemplate putWorkflowsItem(String key, Object workflowsItem) {
if (this.workflows == null) { if (this.workflows == null) {
this.workflows = new HashMap<String, String>(); this.workflows = new HashMap<String, Object>();
} }
this.workflows.put(key, workflowsItem); this.workflows.put(key, workflowsItem);
return this; return this;
...@@ -251,11 +251,11 @@ public class NodeTemplate { ...@@ -251,11 +251,11 @@ public class NodeTemplate {
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
public Map<String, String> getWorkflows() { public Map<String, Object> getWorkflows() {
return workflows; return workflows;
} }
public void setWorkflows(Map<String, String> workflows) { public void setWorkflows(Map<String, Object> workflows) {
this.workflows = workflows; this.workflows = workflows;
} }
......
...@@ -17,7 +17,7 @@ import javax.validation.constraints.*; ...@@ -17,7 +17,7 @@ import javax.validation.constraints.*;
* TopologyTemplate * TopologyTemplate
*/ */
@Validated @Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-09T16:44:17.416Z") @javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-10T17:15:46.465Z")
public class TopologyTemplate { public class TopologyTemplate {
@JsonProperty("description") @JsonProperty("description")
...@@ -25,30 +25,31 @@ public class TopologyTemplate { ...@@ -25,30 +25,31 @@ public class TopologyTemplate {
@JsonProperty("inputs") @JsonProperty("inputs")
@Valid @Valid
private List<Map<String, String>> inputs = null; private List<Map<String, Object>> inputs = null;
@JsonProperty("policies") @JsonProperty("policies")
@Valid @Valid
private List<Map<String, String>> policies = null; private List<Map<String, Object>> policies = null;
@JsonProperty("outputs") @JsonProperty("outputs")
@Valid @Valid
private List<Map<String, String>> outputs = null; private List<Map<String, Object>> outputs = null;
@JsonProperty("node_templates") @JsonProperty("node_templates")
private NodeTemplate nodeTemplates = null; @Valid
private Map<String, Object> nodeTemplates = null;
@JsonProperty("relationship_templates") @JsonProperty("relationship_templates")
@Valid @Valid
private Map<String, String> relationshipTemplates = null; private Map<String, Object> relationshipTemplates = null;
@JsonProperty("groups") @JsonProperty("groups")
@Valid @Valid
private Map<String, String> groups = null; private Map<String, Object> groups = null;
@JsonProperty("substitution_mappings") @JsonProperty("substitution_mappings")
@Valid @Valid
private Map<String, String> substitutionMappings = null; private Map<String, Object> substitutionMappings = null;
public TopologyTemplate description(String description) { public TopologyTemplate description(String description) {
this.description = description; this.description = description;
...@@ -70,14 +71,14 @@ public class TopologyTemplate { ...@@ -70,14 +71,14 @@ public class TopologyTemplate {
this.description = description; this.description = description;
} }
public TopologyTemplate inputs(List<Map<String, String>> inputs) { public TopologyTemplate inputs(List<Map<String, Object>> inputs) {
this.inputs = inputs; this.inputs = inputs;
return this; return this;
} }
public TopologyTemplate addInputsItem(Map<String, String> inputsItem) { public TopologyTemplate addInputsItem(Map<String, Object> inputsItem) {
if (this.inputs == null) { if (this.inputs == null) {
this.inputs = new ArrayList<Map<String, String>>(); this.inputs = new ArrayList<Map<String, Object>>();
} }
this.inputs.add(inputsItem); this.inputs.add(inputsItem);
return this; return this;
...@@ -91,22 +92,22 @@ public class TopologyTemplate { ...@@ -91,22 +92,22 @@ public class TopologyTemplate {
@Valid @Valid
public List<Map<String, String>> getInputs() { public List<Map<String, Object>> getInputs() {
return inputs; return inputs;
} }
public void setInputs(List<Map<String, String>> inputs) { public void setInputs(List<Map<String, Object>> inputs) {
this.inputs = inputs; this.inputs = inputs;
} }
public TopologyTemplate policies(List<Map<String, String>> policies) { public TopologyTemplate policies(List<Map<String, Object>> policies) {
this.policies = policies; this.policies = policies;
return this; return this;
} }
public TopologyTemplate addPoliciesItem(Map<String, String> policiesItem) { public TopologyTemplate addPoliciesItem(Map<String, Object> policiesItem) {
if (this.policies == null) { if (this.policies == null) {
this.policies = new ArrayList<Map<String, String>>(); this.policies = new ArrayList<Map<String, Object>>();
} }
this.policies.add(policiesItem); this.policies.add(policiesItem);
return this; return this;
...@@ -120,22 +121,22 @@ public class TopologyTemplate { ...@@ -120,22 +121,22 @@ public class TopologyTemplate {
@Valid @Valid
public List<Map<String, String>> getPolicies() { public List<Map<String, Object>> getPolicies() {
return policies; return policies;
} }
public void setPolicies(List<Map<String, String>> policies) { public void setPolicies(List<Map<String, Object>> policies) {
this.policies = policies; this.policies = policies;
} }
public TopologyTemplate outputs(List<Map<String, String>> outputs) { public TopologyTemplate outputs(List<Map<String, Object>> outputs) {
this.outputs = outputs; this.outputs = outputs;
return this; return this;
} }
public TopologyTemplate addOutputsItem(Map<String, String> outputsItem) { public TopologyTemplate addOutputsItem(Map<String, Object> outputsItem) {
if (this.outputs == null) { if (this.outputs == null) {
this.outputs = new ArrayList<Map<String, String>>(); this.outputs = new ArrayList<Map<String, Object>>();
} }
this.outputs.add(outputsItem); this.outputs.add(outputsItem);
return this; return this;
...@@ -149,43 +150,50 @@ public class TopologyTemplate { ...@@ -149,43 +150,50 @@ public class TopologyTemplate {
@Valid @Valid
public List<Map<String, String>> getOutputs() { public List<Map<String, Object>> getOutputs() {
return outputs; return outputs;
} }
public void setOutputs(List<Map<String, String>> outputs) { public void setOutputs(List<Map<String, Object>> outputs) {
this.outputs = outputs; this.outputs = outputs;
} }
public TopologyTemplate nodeTemplates(NodeTemplate nodeTemplates) { public TopologyTemplate nodeTemplates(Map<String, Object> nodeTemplates) {
this.nodeTemplates = nodeTemplates; this.nodeTemplates = nodeTemplates;
return this; return this;
} }
public TopologyTemplate putNodeTemplatesItem(String key, Object nodeTemplatesItem) {
if (this.nodeTemplates == null) {
this.nodeTemplates = new HashMap<String, Object>();
}
this.nodeTemplates.put(key, nodeTemplatesItem);
return this;
}
/** /**
* Get nodeTemplates * Get nodeTemplates
* @return nodeTemplates * @return nodeTemplates
**/ **/
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
@Valid
public NodeTemplate getNodeTemplates() { public Map<String, Object> getNodeTemplates() {
return nodeTemplates; return nodeTemplates;
} }
public void setNodeTemplates(NodeTemplate nodeTemplates) { public void setNodeTemplates(Map<String, Object> nodeTemplates) {
this.nodeTemplates = nodeTemplates; this.nodeTemplates = nodeTemplates;
} }
public TopologyTemplate relationshipTemplates(Map<String, String> relationshipTemplates) { public TopologyTemplate relationshipTemplates(Map<String, Object> relationshipTemplates) {
this.relationshipTemplates = relationshipTemplates; this.relationshipTemplates = relationshipTemplates;
return this; return this;
} }
public TopologyTemplate putRelationshipTemplatesItem(String key, String relationshipTemplatesItem) { public TopologyTemplate putRelationshipTemplatesItem(String key, Object relationshipTemplatesItem) {
if (this.relationshipTemplates == null) { if (this.relationshipTemplates == null) {
this.relationshipTemplates = new HashMap<String, String>(); this.relationshipTemplates = new HashMap<String, Object>();
} }
this.relationshipTemplates.put(key, relationshipTemplatesItem); this.relationshipTemplates.put(key, relationshipTemplatesItem);
return this; return this;
...@@ -198,22 +206,22 @@ public class TopologyTemplate { ...@@ -198,22 +206,22 @@ public class TopologyTemplate {
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
public Map<String, String> getRelationshipTemplates() { public Map<String, Object> getRelationshipTemplates() {
return relationshipTemplates; return relationshipTemplates;
} }
public void setRelationshipTemplates(Map<String, String> relationshipTemplates) { public void setRelationshipTemplates(Map<String, Object> relationshipTemplates) {
this.relationshipTemplates = relationshipTemplates; this.relationshipTemplates = relationshipTemplates;
} }
public TopologyTemplate groups(Map<String, String> groups) { public TopologyTemplate groups(Map<String, Object> groups) {
this.groups = groups; this.groups = groups;
return this; return this;
} }
public TopologyTemplate putGroupsItem(String key, String groupsItem) { public TopologyTemplate putGroupsItem(String key, Object groupsItem) {
if (this.groups == null) { if (this.groups == null) {
this.groups = new HashMap<String, String>(); this.groups = new HashMap<String, Object>();
} }
this.groups.put(key, groupsItem); this.groups.put(key, groupsItem);
return this; return this;
...@@ -226,22 +234,22 @@ public class TopologyTemplate { ...@@ -226,22 +234,22 @@ public class TopologyTemplate {
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
public Map<String, String> getGroups() { public Map<String, Object> getGroups() {
return groups; return groups;
} }
public void setGroups(Map<String, String> groups) { public void setGroups(Map<String, Object> groups) {
this.groups = groups; this.groups = groups;
} }
public TopologyTemplate substitutionMappings(Map<String, String> substitutionMappings) { public TopologyTemplate substitutionMappings(Map<String, Object> substitutionMappings) {
this.substitutionMappings = substitutionMappings; this.substitutionMappings = substitutionMappings;
return this; return this;
} }
public TopologyTemplate putSubstitutionMappingsItem(String key, String substitutionMappingsItem) { public TopologyTemplate putSubstitutionMappingsItem(String key, Object substitutionMappingsItem) {
if (this.substitutionMappings == null) { if (this.substitutionMappings == null) {
this.substitutionMappings = new HashMap<String, String>(); this.substitutionMappings = new HashMap<String, Object>();
} }
this.substitutionMappings.put(key, substitutionMappingsItem); this.substitutionMappings.put(key, substitutionMappingsItem);
return this; return this;
...@@ -254,11 +262,11 @@ public class TopologyTemplate { ...@@ -254,11 +262,11 @@ public class TopologyTemplate {
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
public Map<String, String> getSubstitutionMappings() { public Map<String, Object> getSubstitutionMappings() {
return substitutionMappings; return substitutionMappings;
} }
public void setSubstitutionMappings(Map<String, String> substitutionMappings) { public void setSubstitutionMappings(Map<String, Object> substitutionMappings) {
this.substitutionMappings = substitutionMappings; this.substitutionMappings = substitutionMappings;
} }
......
...@@ -13,7 +13,7 @@ import javax.validation.constraints.*; ...@@ -13,7 +13,7 @@ import javax.validation.constraints.*;
* User * User
*/ */
@Validated @Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-09T16:44:17.416Z") @javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-10T17:15:46.465Z")
public class User { public class User {
@JsonProperty("id") @JsonProperty("id")
......
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package nl.uva.sne.drip.service;
import nl.uva.sne.drip.dao.TopologTemplateDAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
*
* @author S. Koulouzis
*/
@Service
public class TopologTemplateService {
@Autowired
private TopologTemplateDAO dao;
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package nl.uva.sne.drip.service;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectReader;
import com.fasterxml.jackson.databind.SerializationConfig;
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.Map;
import java.util.Optional;
import nl.uva.sne.drip.api.ApiException;
import nl.uva.sne.drip.dao.ToscaTemplateDAO;
import nl.uva.sne.drip.model.ToscaTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import nl.uva.sne.drip.commons.utils.Converter;
import org.springframework.data.domain.Example;
/**
*
* @author S. Koulouzis
*/
@Service
public class ToscaTemplateService {
private final ObjectMapper objectMapper;
@org.springframework.beans.factory.annotation.Autowired
public ToscaTemplateService() {
this.objectMapper = new ObjectMapper(new YAMLFactory().disable(Feature.WRITE_DOC_START_MARKER));
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
}
@Autowired
private ToscaTemplateDAO dao;
public String save(ToscaTemplate tt) {
dao.save(tt);
return tt.getId();
}
public String saveFile(MultipartFile file) throws IOException, ApiException {
String originalFileName = file.getOriginalFilename();
String name = System.currentTimeMillis() + "_" + originalFileName;
byte[] bytes = file.getBytes();
String ymlStr = new String(bytes, "UTF-8");
ToscaTemplate tt = objectMapper.readValue(ymlStr, ToscaTemplate.class);
Example<ToscaTemplate> templateExample = Example.of(tt);
Optional<ToscaTemplate> result = dao.findOne(templateExample);
if (result.equals(tt)) {
throw new ApiException(409, "Tosca Template already exists");
}
save(tt);
return tt.getId();
}
public String updateToscaTemplateByID(String id, MultipartFile file) throws IOException {
ToscaTemplate tt = dao.findById(id).get();
if (tt == null) {
throw new NullPointerException();
}
byte[] bytes = file.getBytes();
String ymlStr = new String(bytes, "UTF-8");
tt = objectMapper.readValue(ymlStr, ToscaTemplate.class);
tt.setID(id);
return save(tt);
}
public String updateToscaTemplateByID(String id) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
public String findByID(String id) throws JsonProcessingException {
ToscaTemplate tt = dao.findById(id).get();
return objectMapper.writeValueAsString(tt);
}
public void deleteByID(String id) {
dao.deleteById(id);
}
}
...@@ -8,4 +8,7 @@ message.broker.host=127.0.0.1 ...@@ -8,4 +8,7 @@ message.broker.host=127.0.0.1
db.host=127.0.0.1 db.host=127.0.0.1
db.name=drip db.name=drip
db.username=drip-user db.username=drip-user
db.password=drip-pass db.password=drip-pass
\ No newline at end of file
spring.jackson.deserialization.UNWRAP_ROOT_VALUE=true
\ No newline at end of file
This diff is collapsed.
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