U
    W+dx                     @   sP   d Z ddlmZ ddlmZ G dd deZG dd deZG dd	 d	eZd
S )z)
Represents an EC2 Spot Instance Request
    )TaggedEC2Object)LaunchSpecificationc                   @   s2   e Zd ZdZdddZdd Zdd Zd	d
 ZdS )SpotInstanceStateFaultz
    The fault codes for the Spot Instance request, if any.

    :ivar code: The reason code for the Spot Instance state change.
    :ivar message: The message for the Spot Instance state change.
    Nc                 C   s   || _ || _d S Ncodemessage)selfr   r    r
   @/tmp/pip-unpacked-wheel-dlxw5sjy/boto/ec2/spotinstancerequest.py__init__'   s    zSpotInstanceStateFault.__init__c                 C   s   d| j | jf S )Nz(%s, %s)r   r	   r
   r
   r   __repr__+   s    zSpotInstanceStateFault.__repr__c                 C   s   d S r   r
   r	   nameattrs
connectionr
   r
   r   startElement.   s    z#SpotInstanceStateFault.startElementc                 C   s.   |dkr|| _ n|dkr|| _t| || d S )Nr   r   )r   r   setattrr	   r   valuer   r
   r
   r   
endElement1   s
    z!SpotInstanceStateFault.endElement)NN__name__
__module____qualname____doc__r   r   r   r   r
   r
   r
   r   r      s
   
r   c                   @   s2   e Zd ZdZdddZdd Zdd Zd	d
 ZdS )SpotInstanceStatusz
    Contains the status of a Spot Instance Request.

    :ivar code: Status code of the request.
    :ivar message: The description for the status code for the Spot request.
    :ivar update_time: Time the status was stated.
    Nc                 C   s   || _ || _|| _d S r   )r   update_timer   )r	   r   r   r   r
   r
   r   r   B   s    zSpotInstanceStatus.__init__c                 C   s
   d| j  S )Nz<Status: %s>)r   r   r
   r
   r   r   G   s    zSpotInstanceStatus.__repr__c                 C   s   d S r   r
   r   r
   r
   r   r   J   s    zSpotInstanceStatus.startElementc                 C   s2   |dkr|| _ n|dkr || _n|dkr.|| _d S )Nr   r   Z
updateTime)r   r   r   r   r
   r
   r   r   M   s    zSpotInstanceStatus.endElement)NNNr   r
   r
   r
   r   r   9   s
   
r   c                       sH   e Zd ZdZd fdd	Zdd Z fddZd	d
 ZdddZ  Z	S )SpotInstanceRequesta  

    :ivar id: The ID of the Spot Instance Request.
    :ivar price: The maximum hourly price for any Spot Instance launched to
        fulfill the request.
    :ivar type: The Spot Instance request type.
    :ivar state: The state of the Spot Instance request.
    :ivar fault: The fault codes for the Spot Instance request, if any.
    :ivar valid_from: The start date of the request. If this is a one-time
        request, the request becomes active at this date and time and remains
        active until all instances launch, the request expires, or the request is
        canceled. If the request is persistent, the request becomes active at this
        date and time and remains active until it expires or is canceled.
    :ivar valid_until: The end date of the request. If this is a one-time
        request, the request remains active until all instances launch, the request
        is canceled, or this date is reached. If the request is persistent, it
        remains active until it is canceled or this date is reached.
    :ivar launch_group: The instance launch group. Launch groups are Spot
        Instances that launch together and terminate together.
    :ivar launched_availability_zone: foo
    :ivar product_description: The Availability Zone in which the bid is
        launched.
    :ivar availability_zone_group: The Availability Zone group. If you specify
        the same Availability Zone group for all Spot Instance requests, all Spot
        Instances are launched in the same Availability Zone.
    :ivar create_time: The time stamp when the Spot Instance request was
        created.
    :ivar launch_specification: Additional information for launching instances.
    :ivar instance_id: The instance ID, if an instance has been launched to
        fulfill the Spot Instance request.
    :ivar status: The status code and status message describing the Spot
        Instance request.

    Nc                    sn   t t| | d | _d | _d | _d | _d | _d | _d | _	d | _
d | _d | _d | _d | _d | _d | _d | _d S r   )superr   r   idpricetypestatefault
valid_fromvalid_untillaunch_grouplaunched_availability_zoneproduct_descriptionavailability_zone_groupcreate_timelaunch_specificationinstance_idstatus)r	   r   	__class__r
   r   r   z   s     zSpotInstanceRequest.__init__c                 C   s
   d| j  S )NzSpotInstanceRequest:%s)r!   r   r
   r
   r   r      s    zSpotInstanceRequest.__repr__c                    sl   t t| |||}|d k	r |S |dkr8t|| _| jS |dkrNt | _| jS |dkrdt | _| jS d S d S )NZlaunchSpecificationr%   r/   )	r    r   r   r   r-   r   r%   r   r/   )r	   r   r   r   retvalr0   r
   r   r      s    
z SpotInstanceRequest.startElementc                 C   s   |dkr|| _ n|dkr$t|| _n|dkr4|| _n|dkrD|| _n|dkrT|| _n||dkrd|| _nl|dkrt|| _n\|dkr|| _nL|d	kr|| _	n<|d
kr|| _
n,|dkr|| _n|dkr|| _nt| || d S )NZspotInstanceRequestIdZ	spotPricer#   r$   Z	validFromZ
validUntilZlaunchGroupZavailabilityZoneGroupZlaunchedAvailabilityZoneZ
instanceIdZ
createTimeZproductDescription)r!   floatr"   r#   r$   r&   r'   r(   r+   r)   r.   r,   r*   r   r   r
   r
   r   r      s2    zSpotInstanceRequest.endElementFc                 C   s   | j j| jg|d d S )N)dry_run)r   Zcancel_spot_instance_requestsr!   )r	   r4   r
   r
   r   cancel   s    zSpotInstanceRequest.cancel)N)F)
r   r   r   r   r   r   r   r   r5   __classcell__r
   r
   r0   r   r   V   s   #r   N)	r   Zboto.ec2.ec2objectr   Zboto.ec2.launchspecificationr   objectr   r   r   r
   r
   r
   r   <module>   s
   