module Network.AWS.CloudTrail.Types
(
CloudTrail
, JSONError
, Trail
, trail
, tCloudWatchLogsLogGroupArn
, tCloudWatchLogsRoleArn
, tIncludeGlobalServiceEvents
, tName
, tS3BucketName
, tS3KeyPrefix
, tSnsTopicName
) where
import Network.AWS.Prelude
import Network.AWS.Signing
import qualified GHC.Exts
data CloudTrail
instance AWSService CloudTrail where
type Sg CloudTrail = V4
type Er CloudTrail = JSONError
service = service'
where
service' :: Service CloudTrail
service' = Service
{ _svcAbbrev = "CloudTrail"
, _svcPrefix = "cloudtrail"
, _svcVersion = "2013-11-01"
, _svcTargetPrefix = Just "com.amazonaws.cloudtrail.v20131101.CloudTrail_20131101"
, _svcJSONVersion = Just "1.1"
, _svcHandle = handle
, _svcRetry = retry
}
handle :: Status
-> Maybe (LazyByteString -> ServiceError JSONError)
handle = jsonError statusSuccess service'
retry :: Retry CloudTrail
retry = Exponential
{ _retryBase = 0.05
, _retryGrowth = 2
, _retryAttempts = 5
, _retryCheck = check
}
check :: Status
-> JSONError
-> Bool
check (statusCode -> s) (awsErrorCode -> e)
| s == 500 = True
| s == 509 = True
| s == 503 = True
| otherwise = False
data Trail = Trail
{ _tCloudWatchLogsLogGroupArn :: Maybe Text
, _tCloudWatchLogsRoleArn :: Maybe Text
, _tIncludeGlobalServiceEvents :: Maybe Bool
, _tName :: Maybe Text
, _tS3BucketName :: Maybe Text
, _tS3KeyPrefix :: Maybe Text
, _tSnsTopicName :: Maybe Text
} deriving (Eq, Ord, Show)
trail :: Trail
trail = Trail
{ _tName = Nothing
, _tS3BucketName = Nothing
, _tS3KeyPrefix = Nothing
, _tSnsTopicName = Nothing
, _tIncludeGlobalServiceEvents = Nothing
, _tCloudWatchLogsLogGroupArn = Nothing
, _tCloudWatchLogsRoleArn = Nothing
}
tCloudWatchLogsLogGroupArn :: Lens' Trail (Maybe Text)
tCloudWatchLogsLogGroupArn =
lens _tCloudWatchLogsLogGroupArn
(\s a -> s { _tCloudWatchLogsLogGroupArn = a })
tCloudWatchLogsRoleArn :: Lens' Trail (Maybe Text)
tCloudWatchLogsRoleArn =
lens _tCloudWatchLogsRoleArn (\s a -> s { _tCloudWatchLogsRoleArn = a })
tIncludeGlobalServiceEvents :: Lens' Trail (Maybe Bool)
tIncludeGlobalServiceEvents =
lens _tIncludeGlobalServiceEvents
(\s a -> s { _tIncludeGlobalServiceEvents = a })
tName :: Lens' Trail (Maybe Text)
tName = lens _tName (\s a -> s { _tName = a })
tS3BucketName :: Lens' Trail (Maybe Text)
tS3BucketName = lens _tS3BucketName (\s a -> s { _tS3BucketName = a })
tS3KeyPrefix :: Lens' Trail (Maybe Text)
tS3KeyPrefix = lens _tS3KeyPrefix (\s a -> s { _tS3KeyPrefix = a })
tSnsTopicName :: Lens' Trail (Maybe Text)
tSnsTopicName = lens _tSnsTopicName (\s a -> s { _tSnsTopicName = a })
instance FromJSON Trail where
parseJSON = withObject "Trail" $ \o -> Trail
<$> o .:? "CloudWatchLogsLogGroupArn"
<*> o .:? "CloudWatchLogsRoleArn"
<*> o .:? "IncludeGlobalServiceEvents"
<*> o .:? "Name"
<*> o .:? "S3BucketName"
<*> o .:? "S3KeyPrefix"
<*> o .:? "SnsTopicName"
instance ToJSON Trail where
toJSON Trail{..} = object
[ "Name" .= _tName
, "S3BucketName" .= _tS3BucketName
, "S3KeyPrefix" .= _tS3KeyPrefix
, "SnsTopicName" .= _tSnsTopicName
, "IncludeGlobalServiceEvents" .= _tIncludeGlobalServiceEvents
, "CloudWatchLogsLogGroupArn" .= _tCloudWatchLogsLogGroupArn
, "CloudWatchLogsRoleArn" .= _tCloudWatchLogsRoleArn
]