Skip to content

Commit

Permalink
Merge pull request #93 from AWS-Cloud-School-6/92-feat-add-subnet-inf…
Browse files Browse the repository at this point in the history
…o-to-routetable

#92 Feat: Add Subnet Info to RouteTable
  • Loading branch information
nareunhang authored Nov 1, 2024
2 parents 73613f8 + 60e4789 commit e8a5ec8
Show file tree
Hide file tree
Showing 13 changed files with 17 additions and 3 deletions.
Binary file modified .gradle/8.10.2/executionHistory/executionHistory.bin
Binary file not shown.
Binary file modified .gradle/8.10.2/executionHistory/executionHistory.lock
Binary file not shown.
Binary file modified .gradle/8.10.2/fileHashes/fileHashes.bin
Binary file not shown.
Binary file modified .gradle/8.10.2/fileHashes/fileHashes.lock
Binary file not shown.
Binary file modified .gradle/8.10.2/fileHashes/resourceHashesCache.bin
Binary file not shown.
Binary file modified .gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
Binary file modified .gradle/file-system.probe
Binary file not shown.
1 change: 0 additions & 1 deletion .idea/modules/McpBackend.test.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
Binary file modified build/tmp/compileJava/previous-compilation-data.bin
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package AIWA.McpBackend.controller.api.dto.routetable;

import AIWA.McpBackend.controller.api.dto.subnet.SubnetResponseDto;
import lombok.Getter;

import java.util.List;
Expand All @@ -11,12 +12,14 @@ public class RouteTableResponseDto {
private String vpcId;
private List<RouteDTO> routes;
private Map<String, String> tags;
private List<SubnetResponseDto> associatedSubnets;

public RouteTableResponseDto(String routeTableId, String vpcId, List<RouteDTO> routes, Map<String, String> tags) {
public RouteTableResponseDto(String routeTableId, String vpcId, List<RouteDTO> routes, Map<String, String> tags, List<SubnetResponseDto> associatedSubnets) {
this.routeTableId = routeTableId;
this.vpcId = vpcId;
this.routes = routes;
this.tags = tags;
this.associatedSubnets = associatedSubnets;
}

// Getters and Setters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,28 @@ public List<SubnetResponseDto> fetchSubnets(String userId) {
// Route Tables 가져오기
public List<RouteTableResponseDto> fetchRouteTables(String userId) {
initializeClient(userId);

// 서브넷 정보를 먼저 가져옵니다.
List<SubnetResponseDto> allSubnets = fetchSubnets(userId);

DescribeRouteTablesRequest request = DescribeRouteTablesRequest.builder().build();
DescribeRouteTablesResponse response = ec2Client.describeRouteTables(request);

return response.routeTables().stream()
.map(routeTable -> {
Map<String, String> tagsMap = routeTable.tags() == null ? Collections.emptyMap() :
routeTable.tags().stream().collect(Collectors.toMap(Tag::key, Tag::value));

List<RouteDTO> routes = routeTable.routes().stream()
.map(route -> new RouteDTO(route.gatewayId(), route.destinationCidrBlock()))
.collect(Collectors.toList());
return new RouteTableResponseDto(routeTable.routeTableId(), routeTable.vpcId(), routes, tagsMap);

// 각 라우팅 테이블과 연결된 서브넷을 필터링합니다.
List<SubnetResponseDto> associatedSubnets = allSubnets.stream()
.filter(subnet -> subnet.getVpcId().equals(routeTable.vpcId()))
.collect(Collectors.toList());

return new RouteTableResponseDto(routeTable.routeTableId(), routeTable.vpcId(), routes, tagsMap, associatedSubnets);
})
.collect(Collectors.toList());
}
Expand Down

0 comments on commit e8a5ec8

Please sign in to comment.