File: //lib/python3/dist-packages/awscli/customizations/cloudtrail/__pycache__/validation.cpython-310.pyc
o
.&�aԜ � @ s� d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlmZ d dl
m
Z
mZ d dlm
Z
mZ d dlmZ d dlZd dlmZmZ d dlmZ d dlmZ d d lmZ e�e�Zd
ZdZdd
� Z dd� Z!dd� Z"dd� Z#dd� Z$dd� Z% d,dd�Z&G dd� de'�Z(G dd� de)�Z*G dd� de*�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'�Z0G d*d+� d+e�Z1dS )-� N)�error)�datetime� timedelta)�tz�parser)�PyAsn1Error)�get_trail_by_arn�get_account_id_from_arn)�BasicCommand)�ClientError)�ParameterRequiredErrorz%Y%m%dT%H%M%SZz%Y-%m-%dT%H:%M:%SZc C �
| � t�S )z;Returns a formatted date string in a CloudTrail date format)�strftime�DATE_FORMAT��date� r �M/usr/lib/python3/dist-packages/awscli/customizations/cloudtrail/validation.py�format_date( �
r c C r
)z4Returns a formatted date string meant for CLI output)r �DISPLAY_DATE_FORMATr r r r �format_display_date- r r c C s | j t�� d�S )z.Returns a normalized date using a UTC timezone)�tzinfo)�replacer �tzutcr r r r �normalize_date2 s r c C s | dd� S )z�Extract the timestamp portion of a manifest file.
Manifest file names take the following form:
AWSLogs/{account}/CloudTrail-Digest/{region}/{ymd}/{account}_CloudTrail -Digest_{region}_{name}_region_{date}.json.gz
i��i����r )�
digest_s3_keyr r r �extract_digest_key_date7 s r c C s( zt �| �W S ty td| ��w )NzUnable to parse date value: %s)r �parse�
ValueError)�date_stringr r r �
parse_dateA s
�r! c C s$ t �d�}|�| �std| ��dS )zlEnsures that the arn looks correct.
ARNs look like: arn:aws:cloudtrail:us-east-1:123456789012:trail/fooz$arn:.+:cloudtrail:.+:\d{12}:trail/.+zInvalid trail ARN provided: %sN)�re�compile�matchr )� trail_arn�patternr r r �assert_cloudtrail_arn_is_validH s
�r'