package Orchard::AWS::EMR::Cluster;

use strict;
use warnings;

use Orchard::Session;

sub new {
	my $class   = shift;
	my $name    = shift || die __PACKAGE__."::new requires a cluster name";
	my $profile = shift || die __PACKAGE__."::new requires a credential profile";
	my $self = {};
	bless $self, $class;
	$self->_init_($name,$profile);
	$self;
}



sub _init_ {
	my $self    = shift;
	my $name    = shift;
	my $profile = shift;

	
	$self->_get_cluster_($name);


sub cli {
	my $self = shift;
	"aws emr --profile " . $self->cred->profile;
}

sub _get_cluster_ {
	my $self = shift;
	my $name = shift;
    my $clusters = awscmd("$emr list-clusters --active");
    my $clusterId;
    foreach my $c ( @{ $clusters->{'Clusters'} } ) { 
        $clusterId = $c->{'Id'} if ( $c->{'Name'} = $opt->cluster );
        last if $clusterId;
    }
