HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/awscli/customizations/dlm/__pycache__/createdefaultrole.cpython-310.pyc
o

.&�a:�@s�ddlZddlmZddlmZddlmZddlmZddl	m
Z
mZmZm
Z
mZe�e�Zdd�Zd	d
�Zdd�Zd
d�ZGdd�de�ZdS)�N)�CLIOperationCaller)�get_policy_arn_suffix)�BasicCommand)�IAM)�	RESOURCES�$LIFECYCLE_DEFAULT_ROLE_ASSUME_POLICY�POLICY_ARN_PATTERN�RESOURCE_TYPE_SNAPSHOT�RESOURCE_TYPE_IMAGEcCs.|�dd�|�dd�d|i}|�|�|S)N�ResponseMetadata�
RolePolicy)�pop�update)�create_role_response�get_policy_response�result�r�M/usr/lib/python3/dist-packages/awscli/customizations/dlm/createdefaultrole.py�_construct_results

rcCs&|durt|�}|�|||�dSdS�N)r�_display_response)�session�operation_namer�parsed_globals�cli_operation_callerrrr�display_response's��rcCst|�}t�||�}|Sr)rr�format)�region�policy_name�
region_suffix�role_arnrrr�get_policy_arn1sr!cCs|j}|dur|�d�}|S)Nr)r�get_config_variable)rrrrrr�
get_region8s
r#cs\eZdZdZdZdddd�deeegdeeefd	�gZ�fd
d�Zdd
�Z	dd�Z
�ZS)�CreateDefaultRolezcreate-default-rolez�Creates the default IAM role  which will be used by Lifecycle service.
If the role does not exist, create-default-role will automatically create it and set its policy. If the role has been already created, create-default-role will not update its policy.
ziam-endpointTz�<p>The IAM endpoint to call for creating the roles. This is optional and should only be specified when a custom endpoint should be called for IAM operations.</p>)�name�no_paramfile�	help_textz
resource-typez�<p>The resource type for which the role needs to be created. The available options are '%s' and '%s'. This parameter defaults to '%s'.</p>)r%�default�choicesr'cstt|��|�dSr)�superr$�__init__)�selfr��	__class__rrr+\szCreateDefaultRole.__init__cCs\t|j|�|_|j|_|j|_t|jjd|j|j|j	d��|_
|�|�}t|jd||�dS)zCall to run the commands�iam)�region_name�endpoint_url�verify�create_roler)
r#�_session�_region�iam_endpoint�
_endpoint_url�
resource_type�_resource_typer�
create_client�
verify_ssl�_iam_client�"_create_default_role_if_not_existsr)r,�parsed_argsrrrrr�	_run_main_s"
�
�zCreateDefaultRole._run_maincCs�t|jd}t}|j�|�rt�d|�dSt�d|�t|j|�}|dur+t	d��t
|t|jd�}|j�|�sCt�d|�dSt�d|�|j�||�}|j�
||�|j�|�}t||�S)	zXMethod to create default lifecycle role
            if it doesn't exist already
        �default_role_namezRole %s existsNz;Role %s does not exist. Creating default role for LifecyclezYYou must specify a region. You can also configure your region by running "aws configure".�default_policy_namez!Managed Policy %s does not exist.zManaged Policy %s exists.)rr9rr<�check_if_role_exists�LOG�debugr#r4�
ValueErrorr!�check_if_policy_exists�create_role_with_trust_policy�attach_policy_to_role�
get_policyr)r,r�	role_name�assume_role_policyr�managed_policy_arnrrrrrr=ws<�����
z4CreateDefaultRole._create_default_role_if_not_exists)�__name__�
__module__�__qualname__�NAME�DESCRIPTIONr	r
�	ARG_TABLEr+r?r=�
__classcell__rrr-rr$?s(	�����r$)�logging�awscli.clidriverr�awscli.customizations.utilsr�awscli.customizations.commandsr�awscli.customizations.dlm.iamr�#awscli.customizations.dlm.constantsrrrr	r
�	getLoggerrMrCrrr!r#r$rrrr�<module>s