o
    .&ßa  ã                   @   s   d dl Z G dd„ deƒZdS )é    Nc                   @   s<   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ ZdS )ÚIAMc                 C   s
   || _ d S )N)Ú
iam_client)Úselfr   © r   ú?/usr/lib/python3/dist-packages/awscli/customizations/dlm/iam.pyÚ__init__   s   
zIAM.__init__c                 C   ó0   z
| j j|d� W dS  | j jjy   Y dS w )z,Method to verify if a particular role exists)ÚRoleNameFT)r   Úget_roleÚ
exceptionsÚNoSuchEntityException)r   Ú	role_namer   r   r   Úcheck_if_role_exists	   ó   þÿzIAM.check_if_role_existsc                 C   r   )z.Method to verify if a particular policy exists©Ú	PolicyArnFT)r   Ú
get_policyr   r   )r   Ú
policy_arnr   r   r   Úcheck_if_policy_exists   r   zIAM.check_if_policy_existsc                 C   s   | j j||d�S )z?Method to attach LifecyclePolicy to role specified by role_name)r   r	   )r   Úattach_role_policy)r   r   r   r   r   r   Úattach_policy_to_role   s   þzIAM.attach_policy_to_rolec                 C   s   | j j|t |¡d�S )zXMethod to create role with a given role name
            and assume_role_policy
        )r	   ÚAssumeRolePolicyDocument)r   Úcreate_roleÚjsonÚdumps)r   r   Úassume_role_policyr   r   r   Úcreate_role_with_trust_policy    s   þz!IAM.create_role_with_trust_policyc                 C   sB   | j j|d�}| j j|| di ¡ dd¡d�}| di ¡ di ¡S )zvMethod to get the Policy for a particular ARN
        This is used to display the policy contents to the user
        r   ÚPolicyÚDefaultVersionIdÚ )r   Ú	VersionIdÚPolicyVersionÚDocument)r   r   Úget_policy_versionÚget)r   ÚarnÚpol_detÚpolicy_version_detailsr   r   r   r   (   s   þþzIAM.get_policyN)	Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   r   r   r   r   r      s    r   )r   Úobjectr   r   r   r   r   Ú<module>   s    