o
    ȷe                     @   sD   d 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 DBSecurityGroup
    )SecurityGroupc                   @   sR   e Zd ZdZ		dddZdd Zdd Zd	d
 Zdd ZdddZ	dddZ
dS )DBSecurityGroupa  
    Represents an RDS database security group

    Properties reference available from the AWS documentation at
    http://docs.amazonwebservices.com/AmazonRDS/latest/APIReference/API_DeleteDBSecurityGroup.html

    :ivar Status: The current status of the security group. Possible values are
        [ active, ? ]. Reference documentation lacks specifics of possibilities
    :ivar connection: :py:class:`boto.rds.RDSConnection` associated with the current object
    :ivar description: The description of the security group
    :ivar ec2_groups: List of :py:class:`EC2 Security Group
        <boto.ec2.securitygroup.SecurityGroup>` objects that this security
        group PERMITS
    :ivar ip_ranges: List of :py:class:`boto.rds.dbsecuritygroup.IPRange`
        objects (containing CIDR addresses) that this security group PERMITS
    :ivar name: Name of the security group
    :ivar owner_id: ID of the owner of the security group. Can be 'None'
    Nc                 C   s(   || _ || _|| _|| _g | _g | _d S N)
connectionowner_idnamedescription
ec2_groups	ip_ranges)selfr   r   r   r    r   O/var/www/ideatree/venv/lib/python3.10/site-packages/boto/rds/dbsecuritygroup.py__init__.   s   
zDBSecurityGroup.__init__c                 C   
   d| j  S )NzDBSecurityGroup:%sr   r   r   r   r   __repr__7      
zDBSecurityGroup.__repr__c                 C   sD   |dkrt | }| j| |S |dkr t| }| j| |S d S )NIPRangeEC2SecurityGroup)r   r
   appendr   r	   )r   r   attrsr   cidrec2_grpr   r   r   startElement:   s   zDBSecurityGroup.startElementc                 C   sR   |dkr	|| _ d S |dkr|| _d S |dkr|| _d S |dkr!d S t| || d S )NOwnerIdDBSecurityGroupNameDBSecurityGroupDescriptionIPRanges)r   r   r   setattrr   r   valuer   r   r   r   
endElementF   s   


zDBSecurityGroup.endElementc                 C   s   | j | jS r   )r   delete_dbsecurity_groupr   r   r   r   r   deleteR   s   zDBSecurityGroup.deletec                 C   s4   t |tr|j}|j}nd}d}| j| j|||S )a  
        Add a new rule to this DBSecurity group.
        You need to pass in either a CIDR block to authorize or
        and EC2 SecurityGroup.

        :type cidr_ip: string
        :param cidr_ip: A valid CIDR IP range to authorize

        :type ec2_group: :class:`boto.ec2.securitygroup.SecurityGroup`
        :param ec2_group: An EC2 security group to authorize

        :rtype: bool
        :return: True if successful.
        N)
isinstancer   r   r   r   authorize_dbsecurity_groupr   cidr_ip	ec2_group
group_namegroup_owner_idr   r   r   	authorizeU   s   

zDBSecurityGroup.authorizec                 C   s<   t |tr|j}|j}| jj| j||dS | jj| j|dS )a  
        Revoke access to a CIDR range or EC2 SecurityGroup.
        You need to pass in either a CIDR block or
        an EC2 SecurityGroup from which to revoke access.

        :type cidr_ip: string
        :param cidr_ip: A valid CIDR IP range to revoke

        :type ec2_group: :class:`boto.ec2.securitygroup.SecurityGroup`
        :param ec2_group: An EC2 security group to revoke

        :rtype: bool
        :return: True if successful.
        )ec2_security_group_nameec2_security_group_owner_idr(   )r%   r   r   r   r   revoke_dbsecurity_groupr'   r   r   r   revokeo   s   
zDBSecurityGroup.revoke)NNNN)NN)__name__
__module____qualname____doc__r   r   r   r"   r$   r,   r1   r   r   r   r   r      s    
	
r   c                   @   2   e Zd ZdZdddZdd Zdd Zd	d
 ZdS )r   zj
    Describes a CIDR address range for use in a DBSecurityGroup

    :ivar cidr_ip: IP Address range
    Nc                 C      || _ d | _d | _d S r   )parentr(   statusr   r8   r   r   r   r         
zIPRange.__init__c                 C   r   )Nz
IPRange:%sr/   r   r   r   r   r      r   zIPRange.__repr__c                 C      d S r   r   r   r   r   r   r   r   r   r         zIPRange.startElementc                 C   4   |dkr	|| _ d S |dkr|| _d S t| || d S )NCIDRIPStatus)r(   r9   r   r    r   r   r   r"      
   

zIPRange.endElementr   r2   r3   r4   r5   r   r   r   r"   r   r   r   r   r      s    
r   c                   @   r6   )r   zF
    Describes an EC2 security group for use in a DBSecurityGroup
    Nc                 C   r7   r   )r8   r   r   r:   r   r   r   r      r;   zEC2SecurityGroup.__init__c                 C   r   )NzEC2SecurityGroup:%sr   r   r   r   r   r      r   zEC2SecurityGroup.__repr__c                 C   r<   r   r   r=   r   r   r   r      r>   zEC2SecurityGroup.startElementc                 C   r?   )NEC2SecurityGroupNameEC2SecurityGroupOwnerId)r   r   r   r    r   r   r   r"      rB   zEC2SecurityGroup.endElementr   rC   r   r   r   r   r      s    
r   N)r5   boto.ec2.securitygroupr   objectr   r   r   r   r   r   r   <module>   s
   o