1 package org.kuali.common.devops.aws.sysadmin; 2 3 import org.kuali.common.aws.model.AwsAccount; 4 import org.kuali.common.aws.model.AwsContext; 5 import org.kuali.common.util.Assert; 6 import org.kuali.common.util.execute.Executable; 7 import org.slf4j.Logger; 8 import org.slf4j.LoggerFactory; 9 10 public class ShowAwsContext implements Executable { 11 12 private static final Logger logger = LoggerFactory.getLogger(ShowAwsContext.class); 13 14 private final AwsContext context; 15 private final boolean skip; 16 17 public ShowAwsContext(AwsContext context) { 18 this(context, false); 19 } 20 21 public ShowAwsContext(AwsContext context, boolean skip) { 22 Assert.noNulls(context); 23 this.context = context; 24 this.skip = skip; 25 } 26 27 @Override 28 public void execute() { 29 30 if (skip) { 31 return; 32 } 33 34 AwsAccount account = context.getAccount(); 35 logger.info("---------- AWS Context ----------"); 36 logger.info("Account Name: {}", account.getName()); 37 logger.info("Account Number: {}", account.getAccountNumber()); 38 if (account.getDescription().isPresent()) { 39 logger.info("Description: {}", account.getDescription().get()); 40 } 41 logger.info("---------------------------------"); 42 } 43 44 public AwsContext getContext() { 45 return context; 46 } 47 48 public boolean isSkip() { 49 return skip; 50 } 51 52 }