o ckF[jB@sXddlZddlmZddlmZddlmZddlmZddl m Z GdddeZ dS) N)AWSQueryConnection) RegionInfo)JSONResponseError) exceptions)jsoncs0eZdZdZdZdZdZdZdZe Z ide j de j d e jd e jd e jd e jd e jde jde jde jde jde jde jde jde jde jde jZfddZddZ    d/ddZ dd Z!d0d!d"Z"d#d$Z#  d/d%d&Z$d'd(Z%d)d*Z&    d1d+d,Z'd-d.Z(Z)S)2CloudTrailConnectiona AWS CloudTrail This is the CloudTrail API Reference. It provides descriptions of actions, data types, common parameters, and common errors for CloudTrail. CloudTrail is a web service that records AWS API calls for your AWS account and delivers log files to an Amazon S3 bucket. The recorded information includes the identity of the user, the start time of the AWS API call, the source IP address, the request parameters, and the response elements returned by the service. As an alternative to using the API, you can use one of the AWS SDKs, which consist of libraries and sample code for various programming languages and platforms (Java, Ruby, .NET, iOS, Android, etc.). The SDKs provide a convenient way to create programmatic access to AWSCloudTrail. For example, the SDKs take care of cryptographically signing requests, managing errors, and retrying requests automatically. For information about the AWS SDKs, including how to download and install them, see the `Tools for Amazon Web Services page`_. See the CloudTrail User Guide for information about the data that is included with each AWS API call listed in the log files. z 2013-11-01z us-east-1z"cloudtrail.us-east-1.amazonaws.com CloudTrailz6com.amazonaws.cloudtrail.v20131101.CloudTrail_20131101InvalidMaxResultsExceptionInvalidSnsTopicNameExceptionInvalidS3BucketNameExceptionTrailAlreadyExistsExceptionInvalidTimeRangeException InvalidLookupAttributesException#InsufficientSnsTopicPolicyException)InvalidCloudWatchLogsLogGroupArnException%InvalidCloudWatchLogsRoleArnExceptionInvalidTrailNameException*CloudWatchLogsDeliveryUnavailableExceptionTrailNotFoundExceptionS3BucketDoesNotExistExceptionInvalidNextTokenExceptionInvalidS3PrefixException&MaximumNumberOfTrailsExceededException#InsufficientS3BucketPolicyExceptionc s^|dd}|st||j|j}d|vs|ddur|j|d<tt|jdi|||_dS)Nregionhost) poprDefaultRegionNameDefaultRegionEndpointendpointsuperr__init__r)selfkwargsr __class__r8/usr/lib/python3/dist-packages/boto/cloudtrail/layer1.pyr"Us   zCloudTrailConnection.__init__cCsdgS)Nzhmac-v4r)r#rrr'_required_auth_capabilityasz.CloudTrailConnection._required_auth_capabilityNc Csn||d}|dur ||d<|dur||d<|dur||d<|dur%||d<|dur-||d<|jdt|d S) a From the command line, use `create-subscription`. Creates a trail that specifies the settings for delivery of log data to an Amazon S3 bucket. :type name: string :param name: Specifies the name of the trail. :type s3_bucket_name: string :param s3_bucket_name: Specifies the name of the Amazon S3 bucket designated for publishing log files. :type s3_key_prefix: string :param s3_key_prefix: Specifies the Amazon S3 key prefix that precedes the name of the bucket you have designated for log file delivery. :type sns_topic_name: string :param sns_topic_name: Specifies the name of the Amazon SNS topic defined for notification of log file delivery. :type include_global_service_events: boolean :param include_global_service_events: Specifies whether the trail is publishing events from global services such as IAM to the log files. :type cloud_watch_logs_log_group_arn: string :param cloud_watch_logs_log_group_arn: Specifies a log group name using an Amazon Resource Name (ARN), a unique identifier that represents the log group to which CloudTrail logs will be delivered. Not required unless you specify CloudWatchLogsRoleArn. :type cloud_watch_logs_role_arn: string :param cloud_watch_logs_role_arn: Specifies the role for the CloudWatch Logs endpoint to assume to write to a users log group. )Name S3BucketNameN S3KeyPrefix SnsTopicNameIncludeGlobalServiceEventsCloudWatchLogsLogGroupArnCloudWatchLogsRoleArn CreateTrailactionbody make_requestrdumps r#names3_bucket_name s3_key_prefixsns_topic_nameinclude_global_service_eventscloud_watch_logs_log_group_arncloud_watch_logs_role_arnparamsrrr' create_trailds )z!CloudTrailConnection.create_trailcCd|i}|jdt|dS)zw Deletes a trail. :type name: string :param name: The name of a trail to be deleted. r) DeleteTrailr1r4r#r8r?rrr' delete_trailsz!CloudTrailConnection.delete_trailcCs(i}|dur ||d<|jdt|dS)z Retrieves settings for the trail associated with the current region for your account. :type trail_name_list: list :param trail_name_list: The trail returned. N trailNameListDescribeTrailsr1r4)r#trail_name_listr?rrr'describe_trailss  z$CloudTrailConnection.describe_trailscCrA)aw Returns a JSON-formatted list of information about the specified trail. Fields include information on delivery errors, Amazon SNS and Amazon S3 errors, and start and stop logging times for each trail. :type name: string :param name: The name of the trail for which you are requesting the current status. r)GetTrailStatusr1r4rCrrr'get_trail_statuss z%CloudTrailConnection.get_trail_statuscCshi}|dur ||d<|dur||d<|dur||d<|dur"||d<|dur*||d<|jdt|dS) al Looks up API activity events captured by CloudTrail that create, update, or delete resources in your account. Events for a region can be looked up for the times in which you had CloudTrail turned on in that region during the last seven days. Lookup supports five different attributes: time range (defined by a start time and end time), user name, event name, resource type, and resource name. All attributes are optional. The maximum number of attributes that can be specified in any one lookup request are time range and one other attribute. The default number of results returned is 10, with a maximum of 50 possible. The response includes a token that you can use to get the next page of results. The rate of lookup requests is limited to one per second per account. If this limit is exceeded, a throttling error occurs. Events that occurred during the selected time range will not be available for lookup if CloudTrail logging was not enabled when the events occurred. :type lookup_attributes: list :param lookup_attributes: Contains a list of lookup attributes. Currently the list can contain only one item. :type start_time: timestamp :param start_time: Specifies that only events that occur after or at the specified time are returned. If the specified start time is after the specified end time, an error is returned. :type end_time: timestamp :param end_time: Specifies that only events that occur before or at the specified time are returned. If the specified end time is before the specified start time, an error is returned. :type max_results: integer :param max_results: The number of events to return. Possible values are 1 through 50. The default is 10. :type next_token: string :param next_token: The token to use to get the next page of results after a previous API call. This token must be passed in with the same parameters that were specified in the the original call. For example, if the original call specified an AttributeKey of 'Username' with a value of 'root', the call with NextToken should include those same parameters. NLookupAttributes StartTimeEndTime MaxResults NextToken LookupEventsr1r4)r#lookup_attributes start_timeend_time max_results next_tokenr?rrr' lookup_eventss0z"CloudTrailConnection.lookup_eventscCrA)z Starts the recording of AWS API calls and log file delivery for a trail. :type name: string :param name: The name of the trail for which CloudTrail logs AWS API calls. r) StartLoggingr1r4rCrrr' start_loggings z"CloudTrailConnection.start_loggingcCrA)a Suspends the recording of AWS API calls and log file delivery for the specified trail. Under most circumstances, there is no need to use this action. You can update a trail without stopping it first. This action is the only way to stop recording. :type name: string :param name: Communicates to CloudTrail the name of the trail for which to stop logging AWS API calls. r) StopLoggingr1r4rCrrr' stop_loggings z!CloudTrailConnection.stop_loggingc Cs|d|i}|dur ||d<|dur||d<|dur||d<|dur$||d<|dur,||d<|dur4||d<|jd t|d S) a From the command line, use `update-subscription`. Updates the settings that specify delivery of log files. Changes to a trail do not require stopping the CloudTrail service. Use this action to designate an existing bucket for log delivery. If the existing bucket has previously been a target for CloudTrail log files, an IAM policy exists for the bucket. :type name: string :param name: Specifies the name of the trail. :type s3_bucket_name: string :param s3_bucket_name: Specifies the name of the Amazon S3 bucket designated for publishing log files. :type s3_key_prefix: string :param s3_key_prefix: Specifies the Amazon S3 key prefix that precedes the name of the bucket you have designated for log file delivery. :type sns_topic_name: string :param sns_topic_name: Specifies the name of the Amazon SNS topic defined for notification of log file delivery. :type include_global_service_events: boolean :param include_global_service_events: Specifies whether the trail is publishing events from global services such as IAM to the log files. :type cloud_watch_logs_log_group_arn: string :param cloud_watch_logs_log_group_arn: Specifies a log group name using an Amazon Resource Name (ARN), a unique identifier that represents the log group to which CloudTrail logs will be delivered. Not required unless you specify CloudWatchLogsRoleArn. :type cloud_watch_logs_role_arn: string :param cloud_watch_logs_role_arn: Specifies the role for the CloudWatch Logs endpoint to assume to write to a users log group. r)Nr*r+r,r-r.r/ UpdateTrailr1r4r7rrr' update_trail#s -z!CloudTrailConnection.update_trailc Csd|j|f|jjdtt|d}|jdddi||d}|j|ddd}|d }t j ||j d kr@|r>t |SdSt |}|d d}|j||j} | |j |j|d ) Nz%s.%szapplication/x-amz-json-1.1)z X-Amz-TargetHostz Content-TypezContent-LengthPOST/)methodpath auth_pathr?headersdata )senderoverride_num_retrieszutf-8__type)r3) TargetPrefixrr strlenbuild_base_http_request_mexereaddecodebotologdebugstatusrloadsget_faults ResponseErrorreason) r#r2r3rc http_requestresponse response_body json_body fault_nameexception_classrrr'r5`s0        z!CloudTrailConnection.make_request)NNNNN)N)NNNNNN)*__name__ __module__ __qualname____doc__ APIVersionrr ServiceNamerjrrxrr r r r r rrrrrrrrrrrrrwr"r(r@rDrHrJrVrXrZr\r5 __classcell__rrr%r'rs        7  > =r) rqboto.connectionrboto.regioninforboto.exceptionrboto.cloudtrailr boto.compatrrrrrr's