Commit c2b58e88 authored by wutu's avatar wutu

新增Swagger文档

parent 5fc70d0b
......@@ -63,6 +63,15 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!--自动生成文档-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
</dependency>
</dependencies>
<build>
......
package top.ninwoo.cloudcenter.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.pathMapping("/")
.select()
.apis(RequestHandlerSelectors.basePackage("top.ninwoo.cloudcenter.controller"))
.paths(PathSelectors.any())
.build().apiInfo(new ApiInfoBuilder().title("CNF云平台Swagger文档")
.description("由Swagger自动生成,仅限测试环境使用")
.version("1.0")
.contact(new Contact("joliu", "opengn.org", "ljo0412@live.com"))
.license("The Apache License")
.licenseUrl("http://git.opensource5g.org/xidiancos/cnf/-/blob/master/LICENSE")
.build());
}
}
package top.ninwoo.cloudcenter.controller;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*;
import top.ninwoo.cloudcenter.service.CloudService;
import top.ninwoo.common.entity.NetworkTopology;
......@@ -9,19 +10,24 @@ import javax.annotation.Resource;
import java.util.List;
@RestController
@Api(tags = "容器集群管理相关接口")
@RequestMapping("/cluster")
public class ClusterController {
@Resource
CloudService cloudService;
@RequestMapping(value = "/sendClusterConfigToEdgeNode", method = RequestMethod.POST)
@ApiOperation("下发集群配置")
@ApiImplicitParam(name = "clusterConfigs", value = "集群配置类", defaultValue = "", dataType = "List" ,required = true)
@PostMapping(value = "/sendClusterConfigToEdgeNode")
public List<SeparatedClusterConfig> sendClusterConfigToEdgeNode(@RequestBody List<SeparatedClusterConfig> clusterConfigs) {
// return cloudService.sendClusterConfigToEdgeNode(clusterConfigs);
return cloudService.sendClusterConfigToEdgeNodeByThreads(clusterConfigs);
}
@RequestMapping(value = "/removeClusterFromEdgeNode")
@ApiOperation("删除集群")
@ApiImplicitParam(name = "clusterId", value = "容器集群ID", defaultValue = "11111", required = true)
@GetMapping(value = "/removeClusterFromEdgeNode")
public String removeClusterFromEdgeNode(Long clusterId) {
boolean res = cloudService.deleteClusterFromEdgeNode(clusterId);
if(res) {
......@@ -30,22 +36,29 @@ public class ClusterController {
return "fail";
}
@RequestMapping(value = "/getEdgeNodeIds")
@ApiOperation("获取边缘节点")
@GetMapping(value = "/getEdgeNodeIds")
public List<String> getEdgeNodeIds() {
return cloudService.getEdgeNodeIds();
}
@RequestMapping(value = "/adjustCluster", method = RequestMethod.POST)
@ApiOperation("调整容器集群")
@ApiImplicitParam(name = "clusterConfigs", value = "集群配置类", defaultValue = "", required = true)
@PostMapping(value = "/adjustCluster")
public Boolean adjustClusterToEdgeNode(@RequestBody List<SeparatedClusterConfig> clusterConfigs) {
return cloudService.adjustCluster(clusterConfigs);
}
@RequestMapping(value = "/sendLogicTopo", method = RequestMethod.POST)
@ApiOperation("下发容器逻辑拓扑")
@ApiImplicitParam(name = "clusterConfigs", value = "集群配置类", defaultValue = "", required = true)
@PostMapping(value = "/sendLogicTopo")
public Boolean sendLogicTopoToEdgeNode(@RequestBody List<SeparatedClusterConfig> clusterConfigs) {
return cloudService.sendLogicTopo(clusterConfigs);
}
@RequestMapping(value = "/adjustLogicTopo", method = RequestMethod.POST)
@ApiOperation("调整容器逻辑拓扑")
@ApiImplicitParam(name = "clusterConfigs", value = "集群配置类", defaultValue = "", required = true)
@PostMapping(value = "/adjustLogicTopo")
public Boolean adjustLogicTopoToEdgeNode(@RequestBody List<SeparatedClusterConfig> clusterConfigs) {
return cloudService.adjustLogicTopo(clusterConfigs);
}
......
......@@ -2,10 +2,10 @@ server:
port: 9091
zookeeper:
url: 192.168.31.156:2181
url: 127.0.0.1:2181
bs:
cloudcenter:
name: my-bs-cloud-center
ipservice:
url: 192.168.31.156:23333
\ No newline at end of file
url: 127.0.0.1:23333
\ No newline at end of file
......@@ -19,5 +19,9 @@
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package top.ninwoo.common.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class SeparatedClusterConfig {
@ApiModelProperty
private ClusterConfig clusterConfig;
@ApiModelProperty
private String edgeNodeId;
}
......@@ -26,9 +26,9 @@ bs:
name: random
ip-prefix: 192.168.31
ipservice:
ip: 192.168.31.238:23333
ip: 192.168.31.198:23333
sdn-controller:
host: 127.0.0.1
port: 6653
zookeeper:
url: 192.168.31.238:2181
url: 192.168.31.198:2181
......@@ -145,6 +145,16 @@
<artifactId>influxdb-java</artifactId>
<version>2.9</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
</dependencies>
</dependencyManagement>
......
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