{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.AccessAnalyzer.Types.CloudTrailProperties
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.AccessAnalyzer.Types.CloudTrailProperties where

import Amazonka.AccessAnalyzer.Types.TrailProperties
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about CloudTrail access.
--
-- /See:/ 'newCloudTrailProperties' smart constructor.
data CloudTrailProperties = CloudTrailProperties'
  { -- | The end of the time range for which IAM Access Analyzer reviews your
    -- CloudTrail events. Events with a timestamp after this time are not
    -- considered to generate a policy. If this is not included in the request,
    -- the default value is the current time.
    CloudTrailProperties -> POSIX
endTime :: Core.POSIX,
    -- | The start of the time range for which IAM Access Analyzer reviews your
    -- CloudTrail events. Events with a timestamp before this time are not
    -- considered to generate a policy.
    CloudTrailProperties -> POSIX
startTime :: Core.POSIX,
    -- | A @TrailProperties@ object that contains settings for trail properties.
    CloudTrailProperties -> [TrailProperties]
trailProperties :: [TrailProperties]
  }
  deriving (CloudTrailProperties -> CloudTrailProperties -> Bool
(CloudTrailProperties -> CloudTrailProperties -> Bool)
-> (CloudTrailProperties -> CloudTrailProperties -> Bool)
-> Eq CloudTrailProperties
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CloudTrailProperties -> CloudTrailProperties -> Bool
$c/= :: CloudTrailProperties -> CloudTrailProperties -> Bool
== :: CloudTrailProperties -> CloudTrailProperties -> Bool
$c== :: CloudTrailProperties -> CloudTrailProperties -> Bool
Prelude.Eq, ReadPrec [CloudTrailProperties]
ReadPrec CloudTrailProperties
Int -> ReadS CloudTrailProperties
ReadS [CloudTrailProperties]
(Int -> ReadS CloudTrailProperties)
-> ReadS [CloudTrailProperties]
-> ReadPrec CloudTrailProperties
-> ReadPrec [CloudTrailProperties]
-> Read CloudTrailProperties
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CloudTrailProperties]
$creadListPrec :: ReadPrec [CloudTrailProperties]
readPrec :: ReadPrec CloudTrailProperties
$creadPrec :: ReadPrec CloudTrailProperties
readList :: ReadS [CloudTrailProperties]
$creadList :: ReadS [CloudTrailProperties]
readsPrec :: Int -> ReadS CloudTrailProperties
$creadsPrec :: Int -> ReadS CloudTrailProperties
Prelude.Read, Int -> CloudTrailProperties -> ShowS
[CloudTrailProperties] -> ShowS
CloudTrailProperties -> String
(Int -> CloudTrailProperties -> ShowS)
-> (CloudTrailProperties -> String)
-> ([CloudTrailProperties] -> ShowS)
-> Show CloudTrailProperties
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CloudTrailProperties] -> ShowS
$cshowList :: [CloudTrailProperties] -> ShowS
show :: CloudTrailProperties -> String
$cshow :: CloudTrailProperties -> String
showsPrec :: Int -> CloudTrailProperties -> ShowS
$cshowsPrec :: Int -> CloudTrailProperties -> ShowS
Prelude.Show, (forall x. CloudTrailProperties -> Rep CloudTrailProperties x)
-> (forall x. Rep CloudTrailProperties x -> CloudTrailProperties)
-> Generic CloudTrailProperties
forall x. Rep CloudTrailProperties x -> CloudTrailProperties
forall x. CloudTrailProperties -> Rep CloudTrailProperties x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CloudTrailProperties x -> CloudTrailProperties
$cfrom :: forall x. CloudTrailProperties -> Rep CloudTrailProperties x
Prelude.Generic)

-- |
-- Create a value of 'CloudTrailProperties' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'endTime', 'cloudTrailProperties_endTime' - The end of the time range for which IAM Access Analyzer reviews your
-- CloudTrail events. Events with a timestamp after this time are not
-- considered to generate a policy. If this is not included in the request,
-- the default value is the current time.
--
-- 'startTime', 'cloudTrailProperties_startTime' - The start of the time range for which IAM Access Analyzer reviews your
-- CloudTrail events. Events with a timestamp before this time are not
-- considered to generate a policy.
--
-- 'trailProperties', 'cloudTrailProperties_trailProperties' - A @TrailProperties@ object that contains settings for trail properties.
newCloudTrailProperties ::
  -- | 'endTime'
  Prelude.UTCTime ->
  -- | 'startTime'
  Prelude.UTCTime ->
  CloudTrailProperties
newCloudTrailProperties :: UTCTime -> UTCTime -> CloudTrailProperties
newCloudTrailProperties UTCTime
pEndTime_ UTCTime
pStartTime_ =
  CloudTrailProperties' :: POSIX -> POSIX -> [TrailProperties] -> CloudTrailProperties
CloudTrailProperties'
    { $sel:endTime:CloudTrailProperties' :: POSIX
endTime =
        Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pEndTime_,
      $sel:startTime:CloudTrailProperties' :: POSIX
startTime = Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pStartTime_,
      $sel:trailProperties:CloudTrailProperties' :: [TrailProperties]
trailProperties = [TrailProperties]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The end of the time range for which IAM Access Analyzer reviews your
-- CloudTrail events. Events with a timestamp after this time are not
-- considered to generate a policy. If this is not included in the request,
-- the default value is the current time.
cloudTrailProperties_endTime :: Lens.Lens' CloudTrailProperties Prelude.UTCTime
cloudTrailProperties_endTime :: (UTCTime -> f UTCTime)
-> CloudTrailProperties -> f CloudTrailProperties
cloudTrailProperties_endTime = (CloudTrailProperties -> POSIX)
-> (CloudTrailProperties -> POSIX -> CloudTrailProperties)
-> Lens CloudTrailProperties CloudTrailProperties POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloudTrailProperties' {POSIX
endTime :: POSIX
$sel:endTime:CloudTrailProperties' :: CloudTrailProperties -> POSIX
endTime} -> POSIX
endTime) (\s :: CloudTrailProperties
s@CloudTrailProperties' {} POSIX
a -> CloudTrailProperties
s {$sel:endTime:CloudTrailProperties' :: POSIX
endTime = POSIX
a} :: CloudTrailProperties) ((POSIX -> f POSIX)
 -> CloudTrailProperties -> f CloudTrailProperties)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> CloudTrailProperties
-> f CloudTrailProperties
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The start of the time range for which IAM Access Analyzer reviews your
-- CloudTrail events. Events with a timestamp before this time are not
-- considered to generate a policy.
cloudTrailProperties_startTime :: Lens.Lens' CloudTrailProperties Prelude.UTCTime
cloudTrailProperties_startTime :: (UTCTime -> f UTCTime)
-> CloudTrailProperties -> f CloudTrailProperties
cloudTrailProperties_startTime = (CloudTrailProperties -> POSIX)
-> (CloudTrailProperties -> POSIX -> CloudTrailProperties)
-> Lens CloudTrailProperties CloudTrailProperties POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloudTrailProperties' {POSIX
startTime :: POSIX
$sel:startTime:CloudTrailProperties' :: CloudTrailProperties -> POSIX
startTime} -> POSIX
startTime) (\s :: CloudTrailProperties
s@CloudTrailProperties' {} POSIX
a -> CloudTrailProperties
s {$sel:startTime:CloudTrailProperties' :: POSIX
startTime = POSIX
a} :: CloudTrailProperties) ((POSIX -> f POSIX)
 -> CloudTrailProperties -> f CloudTrailProperties)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> CloudTrailProperties
-> f CloudTrailProperties
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | A @TrailProperties@ object that contains settings for trail properties.
cloudTrailProperties_trailProperties :: Lens.Lens' CloudTrailProperties [TrailProperties]
cloudTrailProperties_trailProperties :: ([TrailProperties] -> f [TrailProperties])
-> CloudTrailProperties -> f CloudTrailProperties
cloudTrailProperties_trailProperties = (CloudTrailProperties -> [TrailProperties])
-> (CloudTrailProperties
    -> [TrailProperties] -> CloudTrailProperties)
-> Lens
     CloudTrailProperties
     CloudTrailProperties
     [TrailProperties]
     [TrailProperties]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloudTrailProperties' {[TrailProperties]
trailProperties :: [TrailProperties]
$sel:trailProperties:CloudTrailProperties' :: CloudTrailProperties -> [TrailProperties]
trailProperties} -> [TrailProperties]
trailProperties) (\s :: CloudTrailProperties
s@CloudTrailProperties' {} [TrailProperties]
a -> CloudTrailProperties
s {$sel:trailProperties:CloudTrailProperties' :: [TrailProperties]
trailProperties = [TrailProperties]
a} :: CloudTrailProperties) (([TrailProperties] -> f [TrailProperties])
 -> CloudTrailProperties -> f CloudTrailProperties)
-> (([TrailProperties] -> f [TrailProperties])
    -> [TrailProperties] -> f [TrailProperties])
-> ([TrailProperties] -> f [TrailProperties])
-> CloudTrailProperties
-> f CloudTrailProperties
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([TrailProperties] -> f [TrailProperties])
-> [TrailProperties] -> f [TrailProperties]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON CloudTrailProperties where
  parseJSON :: Value -> Parser CloudTrailProperties
parseJSON =
    String
-> (Object -> Parser CloudTrailProperties)
-> Value
-> Parser CloudTrailProperties
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CloudTrailProperties"
      ( \Object
x ->
          POSIX -> POSIX -> [TrailProperties] -> CloudTrailProperties
CloudTrailProperties'
            (POSIX -> POSIX -> [TrailProperties] -> CloudTrailProperties)
-> Parser POSIX
-> Parser (POSIX -> [TrailProperties] -> CloudTrailProperties)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser POSIX
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"endTime")
            Parser (POSIX -> [TrailProperties] -> CloudTrailProperties)
-> Parser POSIX
-> Parser ([TrailProperties] -> CloudTrailProperties)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser POSIX
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"startTime")
            Parser ([TrailProperties] -> CloudTrailProperties)
-> Parser [TrailProperties] -> Parser CloudTrailProperties
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe [TrailProperties])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"trailProperties"
                            Parser (Maybe [TrailProperties])
-> [TrailProperties] -> Parser [TrailProperties]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [TrailProperties]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable CloudTrailProperties

instance Prelude.NFData CloudTrailProperties