@Override protected Account buildAccount(String accountName) { AwsAccount account = (AwsAccount) new AwsAccount().setName(accountName); account.setDefaultKeyPair(defaultKeyPair) .setEdda(edda) .setDiscovery(discovery) .setAccountId(accountId) .setRegions(regions .stream() .map(r -> new AwsProvider.AwsRegion().setName(r)) .collect(Collectors.toList()) ) .setAssumeRole(assumeRole); return account; }
@Override protected Account buildAccount(String accountName) { AwsAccount account = (AwsAccount) new AwsAccount().setName(accountName); account.setDefaultKeyPair(defaultKeyPair) .setEdda(edda) .setDiscovery(discovery) .setAccountId(accountId) .setRegions(regions .stream() .map(r -> new AwsProvider.AwsRegion().setName(r)) .collect(Collectors.toList()) ) .setAssumeRole(assumeRole); return account; }
@Override protected Account editAccount(AwsAccount account) { account.setDefaultKeyPair(isSet(defaultKeyPair) ? defaultKeyPair : account.getDefaultKeyPair()); account.setEdda(isSet(edda) ? edda : account.getEdda()); account.setDiscovery(isSet(discovery) ? discovery : account.getDiscovery()); account.setAccountId(isSet(accountId) ? accountId : account.getAccountId()); account.setAssumeRole(isSet(assumeRole) ? assumeRole : account.getAssumeRole()); try { List<String> existingRegions = account .getRegions() .stream() .map(AwsProvider.AwsRegion::getName).collect(Collectors.toList()); regions = updateStringList(existingRegions, regions, addRegion, removeRegion); account.setRegions(regions .stream() .map(r -> new AwsProvider.AwsRegion().setName(r)) .collect(Collectors.toList()) ); } catch (IllegalArgumentException e) { throw new IllegalArgumentException("Set either --regions or --[add/remove]-region"); } return account; } }
@Override protected Account editAccount(AwsAccount account) { account.setDefaultKeyPair(isSet(defaultKeyPair) ? defaultKeyPair : account.getDefaultKeyPair()); account.setEdda(isSet(edda) ? edda : account.getEdda()); account.setDiscovery(isSet(discovery) ? discovery : account.getDiscovery()); account.setAccountId(isSet(accountId) ? accountId : account.getAccountId()); account.setAssumeRole(isSet(assumeRole) ? assumeRole : account.getAssumeRole()); try { List<String> existingRegions = account .getRegions() .stream() .map(AwsProvider.AwsRegion::getName).collect(Collectors.toList()); regions = updateStringList(existingRegions, regions, addRegion, removeRegion); account.setRegions(regions .stream() .map(r -> new AwsProvider.AwsRegion().setName(r)) .collect(Collectors.toList()) ); } catch (IllegalArgumentException e) { throw new IllegalArgumentException("Set either --regions or --[add/remove]-region"); } return account; } }