From 20a652c857995211827fcef4d6de6eefe28e3772 Mon Sep 17 00:00:00 2001 From: Russsnizza <134000942+Russsnizza@users.noreply.github.com> Date: Mon, 23 Sep 2024 16:17:08 -0500 Subject: [PATCH 1/3] Update DbSubnetGroupResource.java --- .../gyro/aws/rds/DbSubnetGroupResource.java | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/main/java/gyro/aws/rds/DbSubnetGroupResource.java b/src/main/java/gyro/aws/rds/DbSubnetGroupResource.java index 5e5e7fbf3..f0d6e0521 100644 --- a/src/main/java/gyro/aws/rds/DbSubnetGroupResource.java +++ b/src/main/java/gyro/aws/rds/DbSubnetGroupResource.java @@ -36,6 +36,9 @@ import java.util.HashSet; import java.util.Set; import java.util.stream.Collectors; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; /** * Create a db subnet group. @@ -63,7 +66,7 @@ public class DbSubnetGroupResource extends RdsTaggableResource implements Copyab private String description; private String name; - private Set subnets; + private List subnets; /** * The description for the DB subnet group. @@ -96,23 +99,25 @@ public void setName(String name) { */ @Required @Updatable - public Set getSubnets() { + public List getSubnets() { if (subnets == null) { - return new HashSet<>(); + return new ArrayList<>(); } - return subnets; + return subnets.stream() + .sorted(Comparator.comparing(SubnetResource::getId)) + .collect(Collectors.toList()); } - public void setSubnets(Set subnets) { - this.subnets = subnets; + public void setSubnets(List subnets) { + this.subnets = new ArrayList<>(subnets); } @Override public void copyFrom(DBSubnetGroup group) { setDescription(group.dbSubnetGroupDescription()); setName(group.dbSubnetGroupName()); - setSubnets(group.subnets().stream().map(s -> findById(SubnetResource.class, s.subnetIdentifier())).collect(Collectors.toSet())); + setSubnets(group.subnets().stream().map(s -> findById(SubnetResource.class, s.subnetIdentifier())).collect(Collectors.toList())); setArn(group.dbSubnetGroupArn()); } @@ -143,8 +148,8 @@ public void doCreate(GyroUI ui, State state) { RdsClient client = createClient(RdsClient.class); CreateDbSubnetGroupResponse response = client.createDBSubnetGroup( r -> r.dbSubnetGroupDescription(getDescription()) - .dbSubnetGroupName(getName()) - .subnetIds(getSubnets().stream().map(SubnetResource::getId).collect(Collectors.toSet())) + .dbSubnetGroupName(getName()) + .subnetIds(getSubnets().stream().map(SubnetResource::getId).collect(Collectors.toList())) ); setArn(response.dbSubnetGroup().dbSubnetGroupArn()); @@ -155,8 +160,8 @@ public void doUpdate(Resource current, Set changedProperties) { RdsClient client = createClient(RdsClient.class); client.modifyDBSubnetGroup( r -> r.dbSubnetGroupName(getName()) - .dbSubnetGroupDescription(getDescription()) - .subnetIds(getSubnets().stream().map(SubnetResource::getId).collect(Collectors.toSet())) + .dbSubnetGroupDescription(getDescription()) + .subnetIds(getSubnets().stream().map(SubnetResource::getId).collect(Collectors.toList())) ); } @@ -167,4 +172,4 @@ public void delete(GyroUI ui, State state) { r -> r.dbSubnetGroupName(getName()) ); } -} +} \ No newline at end of file From 0ce98a61dbd27c1b588982097fedc9e8ea8dca79 Mon Sep 17 00:00:00 2001 From: Russsnizza <134000942+Russsnizza@users.noreply.github.com> Date: Tue, 24 Sep 2024 08:37:08 -0500 Subject: [PATCH 2/3] Sort by name --- src/main/java/gyro/aws/rds/DbSubnetGroupResource.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/gyro/aws/rds/DbSubnetGroupResource.java b/src/main/java/gyro/aws/rds/DbSubnetGroupResource.java index f0d6e0521..6af17e3d5 100644 --- a/src/main/java/gyro/aws/rds/DbSubnetGroupResource.java +++ b/src/main/java/gyro/aws/rds/DbSubnetGroupResource.java @@ -105,7 +105,7 @@ public List getSubnets() { } return subnets.stream() - .sorted(Comparator.comparing(SubnetResource::getId)) + .sorted(Comparator.comparing(SubnetResource::getName)) .collect(Collectors.toList()); } @@ -117,7 +117,8 @@ public void setSubnets(List subnets) { public void copyFrom(DBSubnetGroup group) { setDescription(group.dbSubnetGroupDescription()); setName(group.dbSubnetGroupName()); - setSubnets(group.subnets().stream().map(s -> findById(SubnetResource.class, s.subnetIdentifier())).collect(Collectors.toList())); + setSubnets(group.subnets().stream().map(s -> findById(SubnetResource.class, s.subnetIdentifier())) + .collect(Collectors.toList())); setArn(group.dbSubnetGroupArn()); } From 84f116f8cf8fe6af85b7eaf22fdfc87310294fe4 Mon Sep 17 00:00:00 2001 From: Russsnizza <134000942+Russsnizza@users.noreply.github.com> Date: Wed, 25 Sep 2024 14:27:35 -0500 Subject: [PATCH 3/3] Add newline at the EOF --- src/main/java/gyro/aws/rds/DbSubnetGroupResource.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/gyro/aws/rds/DbSubnetGroupResource.java b/src/main/java/gyro/aws/rds/DbSubnetGroupResource.java index 6af17e3d5..47cbd30ef 100644 --- a/src/main/java/gyro/aws/rds/DbSubnetGroupResource.java +++ b/src/main/java/gyro/aws/rds/DbSubnetGroupResource.java @@ -173,4 +173,4 @@ public void delete(GyroUI ui, State state) { r -> r.dbSubnetGroupName(getName()) ); } -} \ No newline at end of file +}