Skip to content

Commit

Permalink
Merge pull request #39 from sw-maestro-kumofactory/feature/#25-deploy…
Browse files Browse the repository at this point in the history
…-aws-cdk

Feature/#25 deploy aws cdk
  • Loading branch information
nookcoder authored Aug 9, 2023
2 parents ab842a2 + bcfb11a commit 0a60364
Show file tree
Hide file tree
Showing 13 changed files with 275 additions and 94 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/Build-Deploy-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
shell: bash

- name: Build Project
run: gradle build
run: ./gradlew clean build

############################################
### Start Pushing container image on ECR ###
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
package com.kumofactory.cloud.blueprint;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.kumofactory.cloud.blueprint.domain.BluePrintScope;
import com.kumofactory.cloud.blueprint.dto.aws.AwsBluePrintDto;
import com.kumofactory.cloud.blueprint.dto.aws.AwsBluePrintListDto;
import com.kumofactory.cloud.blueprint.service.AwsBlueprintService;
import com.kumofactory.cloud.global.annotation.auth.AuthorizationFromToken;
import com.kumofactory.cloud.global.dto.ResultDto;
import com.kumofactory.cloud.global.rabbitmq.MessageProducer;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -36,6 +39,36 @@ public AwsBluePrintDto getAwsBlueprint(@PathVariable("uuid") String uuid, String
return awsBlueprintService.getAwsBlueprint(uuid);
}

@Operation(
summary = "BluePrint scope 업데이트",
description = "Requires authentication.",
security = @SecurityRequirement(name = "bearerAuth")
)
@PutMapping("/aws/{uuid}")
@AuthorizationFromToken
public ResultDto updateBluePrintScope(@PathVariable("uuid") String uuid, @RequestParam("scope") BluePrintScope scope, String userId) {
boolean result = awsBlueprintService.updateBluePrintScope(scope, uuid, userId);
return ResultDto.builder()
.result(result)
.message(!result ? "Not Found or Not Authorized" : "")
.build();
}

@Operation(
summary = "BluePrint 삭제",
description = "Requires authentication.",
security = @SecurityRequirement(name = "bearerAuth")
)
@DeleteMapping("/aws/{uuid}")
@AuthorizationFromToken
public ResultDto deleteAwsBlueprint(@PathVariable("uuid") String uuid, String userId) {
boolean result = awsBlueprintService.delete(uuid);
return ResultDto.builder()
.result(result)
.message(!result ? "Not Found " : "")
.build();
}

@ApiResponse(responseCode = "200", description = "OK")
@GetMapping("/aws/list")
@AuthorizationFromToken
Expand All @@ -49,13 +82,4 @@ public Object createAwsBlueprint(@RequestBody AwsBluePrintDto awsBluePrintDto, @
awsBlueprintService.store(awsBluePrintDto, provision, userId);
return "hello-world";
}

@DeleteMapping("/aws/{uuid}")
public ResultDto deleteAwsBlueprint(@PathVariable("uuid") String uuid) {
boolean result = awsBlueprintService.delete(uuid);
return ResultDto.builder()
.result(result)
.message(!result ? "Not Found " : "")
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.kumofactory.cloud.blueprint.domain;

public enum BluePrintScope {
PUBLIC, // 공개 ( 모든 사용자가 볼 수 있음 )
PRIVATE, //
KUMOFACTORY // kumofactory 에서 만든 template
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.kumofactory.cloud.blueprint.domain.aws;

import com.kumofactory.cloud.blueprint.domain.BluePrintScope;
import com.kumofactory.cloud.blueprint.domain.ComponentLine;
import com.kumofactory.cloud.blueprint.domain.ProvisionStatus;
import com.kumofactory.cloud.member.domain.Member;
Expand Down Expand Up @@ -34,9 +35,14 @@ public class AwsBluePrint {

private String name; // 블루프린트 이름

private String keyName; // 썸네일 이미지 파일명 (S3)

@Enumerated(EnumType.STRING)
private ProvisionStatus status; // 배포 상태

@Enumerated(EnumType.STRING)
private BluePrintScope scope; // 블루프린트 공개 범위

@ManyToOne
private Member member;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.kumofactory.cloud.blueprint.dto.aws;

import com.kumofactory.cloud.blueprint.domain.BluePrintScope;
import com.kumofactory.cloud.blueprint.domain.ComponentLine;
import com.kumofactory.cloud.blueprint.domain.ProvisionStatus;
import com.kumofactory.cloud.blueprint.domain.aws.AwsArea;
import com.kumofactory.cloud.blueprint.domain.aws.AwsBluePrint;
import com.kumofactory.cloud.blueprint.domain.aws.AwsComponent;
import com.kumofactory.cloud.blueprint.dto.ComponentLineDto;

Expand All @@ -17,10 +19,11 @@
@Data
@Schema(name = "AwsBluePrintDto", description = "AwsBluePrintDto")
public class AwsBluePrintDto {

private String uuid;
private String name;
private ProvisionStatus status;
private BluePrintScope scope;
private List<AwsAreaDto> areas;
private List<AwsComponentDto> components;
private List<ComponentLineDto> links;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.kumofactory.cloud.blueprint.dto.template;

import com.kumofactory.cloud.blueprint.domain.BluePrintScope;
import com.kumofactory.cloud.blueprint.domain.aws.AwsBluePrint;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@Builder
public class TemplatePreviewDto {
private String uuid;
private String name;
private BluePrintScope scope;
private String thumbnail_url;

public static TemplatePreviewDto mapper(AwsBluePrint bluePrint, String thumbnailUrl) {
return TemplatePreviewDto.builder()
.uuid(bluePrint.getUuid())
.name(bluePrint.getName())
.scope(bluePrint.getScope())
.thumbnail_url(thumbnailUrl)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.kumofactory.cloud.blueprint.repository.aws;

import com.kumofactory.cloud.blueprint.domain.BluePrintScope;
import com.kumofactory.cloud.blueprint.domain.aws.AwsBluePrint;
import com.kumofactory.cloud.member.domain.Member;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

Expand All @@ -17,4 +19,7 @@ public interface AwsBluePrintRepository extends JpaRepository<AwsBluePrint, Long

List<AwsBluePrint> findAwsBluePrintsByMember(Member member);

List<AwsBluePrint> findAllByScope(BluePrintScope scope, Pageable pageable);

List<AwsBluePrint> findAllByName(String name, Pageable pageable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


import com.fasterxml.jackson.core.JsonProcessingException;
import com.kumofactory.cloud.blueprint.domain.BluePrintScope;
import com.kumofactory.cloud.blueprint.domain.aws.AwsBluePrint;
import com.kumofactory.cloud.blueprint.dto.aws.AwsBluePrintDto;
import com.kumofactory.cloud.blueprint.dto.aws.AwsBluePrintListDto;
Expand All @@ -17,4 +18,6 @@ public interface AwsBlueprintService {
void store(AwsBluePrintDto awsBluePrintDto, String provision, String userId) throws JsonProcessingException;

boolean delete(String uuid); // blueprint uuid 로 모든 정보 삭세

boolean updateBluePrintScope(BluePrintScope scope, String uuid, String userId);
}
Loading

0 comments on commit 0a60364

Please sign in to comment.