

#import "ElasticLoadBalancingCreateLoadBalancerRequest.h"


@implementation ElasticLoadBalancingCreateLoadBalancerRequest

@synthesize loadBalancerName;
@synthesize listeners;
@synthesize availabilityZones;
@synthesize subnets;
@synthesize securityGroups;


-(id)init
{
    if (self = [super init]) {
        loadBalancerName  = nil;
        listeners         = [[NSMutableArray alloc] initWithCapacity:1];
        availabilityZones = [[NSMutableArray alloc] initWithCapacity:1];
        subnets           = [[NSMutableArray alloc] initWithCapacity:1];
        securityGroups    = [[NSMutableArray alloc] initWithCapacity:1];
    }

    return self;
}

-(id)initWithLoadBalancerName:(NSString *)theLoadBalancerName
{
    if (self = [self init]) {
        self.loadBalancerName = theLoadBalancerName;
    }

    return self;
}

-(id)initWithLoadBalancerName:(NSString *)theLoadBalancerName andListeners:(NSMutableArray *)theListeners andAvailabilityZones:(NSMutableArray *)theAvailabilityZones
{
    if (self = [self init]) {
        self.loadBalancerName  = theLoadBalancerName;
        self.listeners         = theListeners;
        self.availabilityZones = theAvailabilityZones;
    }

    return self;
}


-(void)addListener:(ElasticLoadBalancingListener *)listenerObject
{
    if (listeners == nil) {
        listeners = [[NSMutableArray alloc] initWithCapacity:1];
    }

    [listeners addObject:listenerObject];
}

-(void)addAvailabilityZone:(NSString *)availabilityZoneObject
{
    if (availabilityZones == nil) {
        availabilityZones = [[NSMutableArray alloc] initWithCapacity:1];
    }

    [availabilityZones addObject:availabilityZoneObject];
}

-(void)addSubnet:(NSString *)subnetObject
{
    if (subnets == nil) {
        subnets = [[NSMutableArray alloc] initWithCapacity:1];
    }

    [subnets addObject:subnetObject];
}

-(void)addSecurityGroup:(NSString *)securityGroupObject
{
    if (securityGroups == nil) {
        securityGroups = [[NSMutableArray alloc] initWithCapacity:1];
    }

    [securityGroups addObject:securityGroupObject];
}


-(NSString *)description
{
    NSMutableString *buffer = [[NSMutableString alloc] initWithCapacity:256];

    [buffer appendString:@"{"];
    [buffer appendString:[[[NSString alloc] initWithFormat:@"LoadBalancerName: %@,", loadBalancerName] autorelease]];
    [buffer appendString:[[[NSString alloc] initWithFormat:@"Listeners: %@,", listeners] autorelease]];
    [buffer appendString:[[[NSString alloc] initWithFormat:@"AvailabilityZones: %@,", availabilityZones] autorelease]];
    [buffer appendString:[[[NSString alloc] initWithFormat:@"Subnets: %@,", subnets] autorelease]];
    [buffer appendString:[[[NSString alloc] initWithFormat:@"SecurityGroups: %@,", securityGroups] autorelease]];
    [buffer appendString:[super description]];
    [buffer appendString:@"}"];

    return [buffer autorelease];
}



-(void)dealloc
{
    [loadBalancerName release];
    [listeners release];
    [availabilityZones release];
    [subnets release];
    [securityGroups release];

    [super dealloc];
}


@end
