o
    rMf,5                     @   s   d dl mZ d dlmZ d dlmZ d dlm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G dd deZG dd deZG dd deZdS )    )ListElement)	ResultSet)LaunchConfiguration)Request)Instance)Tagc                   @   .   e Zd Zd
ddZdd Zdd Zdd	 ZdS )ProcessTypeNc                 C   s   || _ d | _d S N)
connectionprocess_nameselfr    r   Z/var/www/html/analyze/labelStudio/lib/python3.10/site-packages/boto/ec2/autoscale/group.py__init__   s   
zProcessType.__init__c                 C   
   d| j  S )NzProcessType(%s)r   r   r   r   r   __repr__#      
zProcessType.__repr__c                 C      d S r
   r   r   nameattrsr   r   r   r   startElement&      zProcessType.startElementc                 C   s   |dkr	|| _ d S d S )NProcessNamer   r   r   valuer   r   r   r   
endElement)   s   
zProcessType.endElementr
   __name__
__module____qualname__r   r   r   r    r   r   r   r   r	      s
    
r	   c                   @   r   )SuspendedProcessNc                 C      || _ d | _d | _d S r
   )r   r   reasonr   r   r   r   r   /      
zSuspendedProcess.__init__c                 C      d| j | jf S )NzSuspendedProcess(%s, %s)r   r'   r   r   r   r   r   4      zSuspendedProcess.__repr__c                 C   r   r
   r   r   r   r   r   r   7   r   zSuspendedProcess.startElementc                 C   (   |dkr	|| _ d S |dkr|| _d S d S )Nr   SuspensionReasonr*   r   r   r   r   r    :   
   

zSuspendedProcess.endElementr
   r!   r   r   r   r   r%   .   
    
r%   c                   @   r   )EnabledMetricNc                 C   s   || _ || _|| _d S r
   r   metricgranularity)r   r   r2   r3   r   r   r   r   B   r(   zEnabledMetric.__init__c                 C   r)   )NzEnabledMetric(%s, %s))r2   r3   r   r   r   r   r   G   r+   zEnabledMetric.__repr__c                 C   r   r
   r   r   r   r   r   r   J   r   zEnabledMetric.startElementc                 C   r,   )NGranularityMetric)r3   r2   r   r   r   r   r    M   r.   zEnabledMetric.endElement)NNNr!   r   r   r   r   r0   A   r/   r0   c                   @   s   e Zd Zdd Zdd ZdS )TerminationPoliciesc                 C   r   r
   r   r   r   r   r   r   V   r   z TerminationPolicies.startElementc                 C   s   |dkr|  | d S d S )Nmember)appendr   r   r   r   r    Y   s   zTerminationPolicies.endElementN)r"   r#   r$   r   r    r   r   r   r   r6   T   s    r6   c                   @   s   e Zd Z							d"ddZdd Zdd ZeeeZdd	 Zd
d Z	dd Z
dd Zdd Zdd Zd#ddZd$ddZdd Zdd Zd%ddZd%d d!ZdS )&AutoScalingGroupNc                 K   s  |p| d| _|| _|durt|nd| _|durt|nd| _d| _|p*| d}|dur3t|}|| _|| _|rDt	|t
rD|j| _|| _|pJg }t|| _|pSg }t|| _|| _|| _|	| _d| _t|
tu rpd|
}
|
| _d| _|pyd| _|p~g }t|| _|| _dS )a.
  
        Creates a new AutoScalingGroup with the specified name.

        You must not have already used up your entire quota of
        AutoScalingGroups in order for this call to be successful. Once the
        creation request is completed, the AutoScalingGroup is ready to be
        used in other calls.

        :type name: str
        :param name: Name of autoscaling group (required).

        :type availability_zones: list
        :param availability_zones: List of availability zones (required).

        :type default_cooldown: int
        :param default_cooldown: Number of seconds after a Scaling Activity
            completes before any further scaling activities can start.

        :type desired_capacity: int
        :param desired_capacity: The desired capacity for the group.

        :type health_check_period: str
        :param health_check_period: Length of time in seconds after a new
            EC2 instance comes into service that Auto Scaling starts
            checking its health.

        :type health_check_type: str
        :param health_check_type: The service you want the health status from,
            Amazon EC2 or Elastic Load Balancer.

        :type launch_config: str or LaunchConfiguration
        :param launch_config: Name of launch configuration (required).

        :type load_balancers: list
        :param load_balancers: List of load balancers.

        :type max_size: int
        :param max_size: Maximum size of group (required).

        :type min_size: int
        :param min_size: Minimum size of group (required).

        :type placement_group: str
        :param placement_group: Physical location of your cluster placement
            group created in Amazon EC2.

        :type vpc_zone_identifier: str or list
        :param vpc_zone_identifier: A comma-separated string or python list of
            the subnet identifiers of the Virtual Private Cloud.

        :type tags: list
        :param tags: List of :class:`boto.ec2.autoscale.tag.Tag`s

        :type termination_policies: list
        :param termination_policies: A list of termination policies. Valid values
            are: "OldestInstance", "NewestInstance", "OldestLaunchConfiguration",
            "ClosestToNextInstanceHour", "Default".  If no value is specified,
            the "Default" value is used.

        :type instance_id: str
        :param instance_id: The ID of the Amazon EC2 instance you want to use
            to create the Auto Scaling group.

        :rtype: :class:`boto.ec2.autoscale.group.AutoScalingGroup`
        :return: An autoscale group.
        
group_nameNcooldown,)getr   r   intmin_sizemax_sizecreated_timedefault_cooldownlaunch_config_name
isinstancer   desired_capacityr   load_balancersavailability_zoneshealth_check_periodhealth_check_typeplacement_groupautoscaling_group_arntypelistjoinvpc_zone_identifier	instancestagstermination_policiesinstance_id)r   r   r   launch_configrG   rF   rB   rI   rH   rJ   rO   rE   r?   r@   rQ   rR   rS   kwargslbszonesr   r   r   r   _   s:   J





zAutoScalingGroup.__init__c                 C   s   | j S r
   rB   r   r   r   r   _get_cooldown   s   zAutoScalingGroup._get_cooldownc                 C   s
   || _ d S r
   rX   )r   valr   r   r   _set_cooldown   r   zAutoScalingGroup._set_cooldownc                 C   r   )NzAutoScaleGroup<%s>)r   r   r   r   r   r      r   zAutoScalingGroup.__repr__c                 C   s   |dkrt dtfg| _| jS |dkr| jS |dkr| jS |dkr,t dtfg| _| jS |dkr;t dtfg| _| jS |dkrJt dt	fg| _
| j
S |dkrQ| jS d S )	N	Instancesr7   LoadBalancerNamesAvailabilityZonesEnabledMetricsSuspendedProcessesTagsr6   )r   r   rP   rF   rG   r0   enabled_metricsr%   suspended_processesr   rQ   rR   r   r   r   r   r      s&   zAutoScalingGroup.startElementc                 C   s,  |dkrt || _d S |dkr|| _d S |dkr|| _d S |dkr(t || _d S |dkr1|| _d S |dkr<t || _d S |dkrGt || _d S |dkrP|| _d S |d	krY|| _	d S |d
krszt || _
W d S  tyr   d | _
Y d S w |dkr||| _d S |dkr|| _d S |dkr|| _d S t| || d S )NMinSizeAutoScalingGroupARNCreatedTimeDefaultCooldownLaunchConfigurationNameDesiredCapacityMaxSizeAutoScalingGroupNamePlacementGroupHealthCheckGracePeriodHealthCheckTypeVPCZoneIdentifier
InstanceId)r>   r?   rK   rA   rB   rC   rE   r@   r   rJ   rH   
ValueErrorrI   rO   rS   setattrr   r   r   r   r       s>   







zAutoScalingGroup.endElementc                 C   s(   | j |d}| jd|t}|| j_|S )z9
        Set the desired capacity for the group.
        )rk   ri   SetDesiredCapacity)r   r   
get_objectr   last_request)r   capacityparamsreqr   r   r   set_capacity  s   
zAutoScalingGroup.set_capacityc                 C   s   | j d| S )z<
        Sync local changes with AutoScaling group.
        UpdateAutoScalingGroup)r   _update_groupr   r   r   r   update     zAutoScalingGroup.updatec                 C   s   d| _ d| _d| _|   dS )zg
        Convenience method which shuts down all instances associated with
        this group.
        r   N)r?   r@   rE   r|   r   r   r   r   shutdown_instances  s   z#AutoScalingGroup.shutdown_instancesFc                 C      | j | j|S )zw
        Delete this auto-scaling group if no instances attached or no
        scaling activities in progress.
        )r   delete_auto_scaling_groupr   )r   force_deleter   r   r   delete&  s   
zAutoScalingGroup.delete2   c                 C      | j | ||S )z2
        Get all activies for this group.
        )r   get_all_activities)r   activity_idsmax_recordsr   r   r   get_activities.  s   
zAutoScalingGroup.get_activitiesc                 C   r   )av  
        Configures an Auto Scaling group to send notifications when
        specified events take place. Valid notification types are:
        'autoscaling:EC2_INSTANCE_LAUNCH',
        'autoscaling:EC2_INSTANCE_LAUNCH_ERROR',
        'autoscaling:EC2_INSTANCE_TERMINATE',
        'autoscaling:EC2_INSTANCE_TERMINATE_ERROR',
        'autoscaling:TEST_NOTIFICATION'
        )r   put_notification_configuration)r   topicnotification_typesr   r   r   r   5  s   
z/AutoScalingGroup.put_notification_configurationc                 C   s   | j | |S )zR
        Deletes notifications created by put_notification_configuration.
        )r   !delete_notification_configuration)r   r   r   r   r   r   C  r}   z2AutoScalingGroup.delete_notification_configurationc                 C   r   )zL
        Suspends Auto Scaling processes for an Auto Scaling group.
        )r   suspend_processesr   r   scaling_processesr   r   r   r   I     z"AutoScalingGroup.suspend_processesc                 C   r   )zK
        Resumes Auto Scaling processes for an Auto Scaling group.
        )r   resume_processesr   r   r   r   r   r   O  r   z!AutoScalingGroup.resume_processes)NNNNNNNNNNNNNNNN)F)Nr   r
   )r"   r#   r$   r   rY   r[   propertyr;   r   r   r    ry   r|   r~   r   r   r   r   r   r   r   r   r   r   r9   ^   s0    
j
!



r9   c                   @   r   )AutoScalingGroupMetricNc                 C   r&   r
   r1   r   r   r   r   r   W  s   
zAutoScalingGroupMetric.__init__c                 C   r   )NzAutoScalingGroupMetric:%s)r2   r   r   r   r   r   ]  r   zAutoScalingGroupMetric.__repr__c                 C   r   r
   r   r   r   r   r   r   `  r   z#AutoScalingGroupMetric.startElementc                 C   s4   |dkr	|| _ d S |dkr|| _d S t| || d S )Nr5   r4   )r2   r3   rr   r   r   r   r   r    c  s
   

z!AutoScalingGroupMetric.endElementr
   r!   r   r   r   r   r   V  s
    
r   N)boto.ec2.elb.listelementr   boto.resultsetr   boto.ec2.autoscale.launchconfigr   boto.ec2.autoscale.requestr   boto.ec2.autoscale.instancer   boto.ec2.autoscale.tagr   objectr	   r%   r0   rM   r6   r9   r   r   r   r   r   <module>   s   
 y