Skip to content

Commit

Permalink
Merge pull request #97 from Strato-YangSungHun/main
Browse files Browse the repository at this point in the history
Update API Response format
  • Loading branch information
Strato-YangSungHun authored Nov 12, 2024
2 parents 539d6b5 + 5a08229 commit ed5a05b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.List;

import kr.co.mcmp.response.ResponseWrapper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
Expand Down Expand Up @@ -29,38 +30,38 @@ public class CbtumblebugController {

@GetMapping("/ns")
@Operation(summary = "Retrieve all namespaces", description = "Fetches all registered namespaces.")
public List<NamespaceDto> getAllNamespaces() {
return cbtumblebugService.getAllNamespaces();
public ResponseWrapper<List<NamespaceDto>> getAllNamespaces() {
return new ResponseWrapper<>(cbtumblebugService.getAllNamespaces()) ;
}

@GetMapping("/ns/{nsId}/mci")
@Operation(summary = "Retrieve MCIS for a specific namespace", description = "Fetches all MCIS belonging to the specified namespace.")
public List<MciDto> getMicsByNamespace(@Parameter(description = "Namespace ID", required = true)
public ResponseWrapper<List<MciDto>> getMicsByNamespace(@Parameter(description = "Namespace ID", required = true)
@PathVariable String nsId) {
return cbtumblebugService.getMcisByNamespace(nsId);
return new ResponseWrapper<>(cbtumblebugService.getMcisByNamespace(nsId));
}

@GetMapping("/ns/{nsId}/mci/{mciId}")
@Operation(summary = "Retrieve a specific MCI", description = "Fetches the specified MCI.")
public MciDto getMicByMciId(@PathVariable String nsId, @PathVariable String mciId) {
return cbtumblebugService.getMciByMciId(nsId, mciId);
public ResponseWrapper<MciDto> getMicByMciId(@PathVariable String nsId, @PathVariable String mciId) {
return new ResponseWrapper<>(cbtumblebugService.getMciByMciId(nsId, mciId));
}

@GetMapping("/ns/{nsId}/k8scluster")
@Operation(summary = "Retrieve k8sclusters for a specific namespace", description = "Fetches all k8sclusters belonging to the specified namespace.")
public List<K8sClusterDto> getK8sCluster(@PathVariable String nsId) {
return cbtumblebugService.getAllK8sClusters(nsId);
public ResponseWrapper<List<K8sClusterDto>> getK8sCluster(@PathVariable String nsId) {
return new ResponseWrapper<>(cbtumblebugService.getAllK8sClusters(nsId));
}

@GetMapping("/ns/{nsId}/k8scluster/{clusterName}")
@Operation(summary = "Retrieve a specific k8scluster", description = "Fetches the specified k8scluster.")
public K8sClusterDto getK8sClusterByName(@PathVariable String nsId, @PathVariable String clusterName) {
return cbtumblebugService.getK8sClusterByName(nsId, clusterName);
public ResponseWrapper<K8sClusterDto> getK8sClusterByName(@PathVariable String nsId, @PathVariable String clusterName) {
return new ResponseWrapper<>(cbtumblebugService.getK8sClusterByName(nsId, clusterName));
}

@GetMapping("/ns/{nsId}/resources/spec/{specId}")
public Spec getMethodName(@PathVariable String nsId, @PathVariable String specId) {
return cbtumblebugService.getSpecBySpecId(nsId, specId);
public ResponseWrapper<Spec> getMethodName(@PathVariable String nsId, @PathVariable String specId) {
return new ResponseWrapper<>(cbtumblebugService.getSpecBySpecId(nsId, specId));
}


Expand Down
23 changes: 12 additions & 11 deletions src/main/java/kr/co/mcmp/catalog/CatalogController.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.List;

import kr.co.mcmp.response.ResponseWrapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
Expand Down Expand Up @@ -42,36 +43,36 @@ public class CatalogController {
@ApiOperation(value="software catalog list(all)", notes="software catalog 리스트 불러오기")
@Operation(summary = "get software catalog list")
@GetMapping
public List<CatalogDTO> getCatalogList(@RequestParam(required = false) String title){
public ResponseWrapper<List<CatalogDTO>> getCatalogList(@RequestParam(required = false) String title){
if(StringUtils.isEmpty(title)){
return catalogService.getCatalogList();
return new ResponseWrapper<>(catalogService.getCatalogList());
}else {
return catalogService.getCatalogListSearch(title);
return new ResponseWrapper<>(catalogService.getCatalogListSearch(title));
}
}

@Operation(summary = "software catalogd detail(and reference)")
@ApiOperation(value="software catalog detail", notes="software catalog 내용 확인(연결된 정보들까지)")
@GetMapping("/{catalogIdx}")
public CatalogDTO getCatalog(@PathVariable Integer catalogIdx){
return catalogService.getCatalog(catalogIdx);
public ResponseWrapper<CatalogDTO> getCatalog(@PathVariable Integer catalogIdx){
return new ResponseWrapper<>(catalogService.getCatalog(catalogIdx));
}

@Operation(summary = "create software catalog", description = "Insert a software catalog with an optional icon file.")
@ApiOperation(value="software catalog insert", notes="software catalog 등록")
@PostMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public CatalogDTO createCatalog(
public ResponseWrapper<CatalogDTO> createCatalog(
@RequestPart(value = "catalogDto") CatalogDTO catalogDto,
@RequestPart(value ="iconFile", required = false) MultipartFile iconFile)
{
return catalogService.createCatalog(catalogDto, iconFile);
return new ResponseWrapper<>(catalogService.createCatalog(catalogDto, iconFile));
}

@Operation(summary = "delete software catalog")
@ApiOperation(value="software catalog delete", notes="software catalog 삭제")
@DeleteMapping("/{catalogIdx}")
public boolean deleteCatalog(@PathVariable Integer catalogIdx){
return catalogService.deleteCatalog(catalogIdx);
public ResponseWrapper<Boolean> deleteCatalog(@PathVariable Integer catalogIdx){
return new ResponseWrapper<Boolean>(catalogService.deleteCatalog(catalogIdx));
}

// @Operation(summary = "update software catalog")
Expand All @@ -84,10 +85,10 @@ public boolean deleteCatalog(@PathVariable Integer catalogIdx){
@Operation(summary = "update software catalog")
@ApiOperation(value="software catalog update", notes="software catalog 수정")
@PutMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public boolean updateCatalog(
public ResponseWrapper<Boolean> updateCatalog(
@RequestPart("catalogDto") CatalogDTO catalogDto,
@RequestPart(value = "iconFile", required = false) MultipartFile iconFile) {
return catalogService.updateCatalog(catalogDto, iconFile);
return new ResponseWrapper<>(catalogService.updateCatalog(catalogDto, iconFile));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;

import kr.co.mcmp.response.ResponseWrapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -30,14 +31,14 @@ public class CatalogRefController {

@Operation(summary = "execute catalog reference workflow")
@PostMapping("/workflow")
public String execWorkflow(){
public ResponseWrapper<String> execWorkflow(){
return null;
}

@Operation(summary = "delete catalog reference workflow")
@DeleteMapping("/{catalogIdx}/{catalogRefIdx}")
public boolean deleteCatalogRefWorkflow(@PathVariable Integer catalogIdx, @PathVariable Integer catalogRefIdx){
return false;
public ResponseWrapper<Boolean> deleteCatalogRefWorkflow(@PathVariable Integer catalogIdx, @PathVariable Integer catalogRefIdx){
return new ResponseWrapper<>(false);
}

@Operation(summary = "get catalog reference")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.List;

import kr.co.mcmp.response.ResponseWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
Expand Down Expand Up @@ -53,18 +54,18 @@ public ResponseEntity<List<K8sApplicationHistoryDTO>> getActiveK8sApplications(
}

@GetMapping("/vm/check/application")
public boolean canInstallApplicationForVM(@RequestParam String namespace,
@RequestParam String mciName,
@RequestParam String vmName,
@RequestParam Integer catalogId) {
return applicationService.canInstallApplicationOnVm(namespace, mciName, vmName, catalogId);
public ResponseWrapper<Boolean> canInstallApplicationForVM(@RequestParam String namespace,
@RequestParam String mciName,
@RequestParam String vmName,
@RequestParam Integer catalogId) {
return new ResponseWrapper<>(applicationService.canInstallApplicationOnVm(namespace, mciName, vmName, catalogId));
}

@GetMapping("/k8s/check/application")
public boolean canInstallApplicationForK8s(@RequestParam String namespace,
public ResponseWrapper<Boolean> canInstallApplicationForK8s(@RequestParam String namespace,
@RequestParam String clusterName,
@RequestParam Integer catalogId) {
return applicationService.canInstallApplicationOnK8s(namespace, clusterName, catalogId);
return new ResponseWrapper<>(applicationService.canInstallApplicationOnK8s(namespace, clusterName, catalogId));
}


Expand Down

0 comments on commit ed5a05b

Please sign in to comment.