{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Contains information about CloudTrail access.
--
-- /See:/ 'newCloudTrailProperties' smart constructor.
data CloudTrailProperties = CloudTrailProperties'
  { -- | A @TrailProperties@ object that contains settings for trail properties.
    CloudTrailProperties -> [TrailProperties]
trailProperties :: [TrailProperties],
    -- | 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 -> ISO8601
startTime :: Data.ISO8601,
    -- | 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 -> ISO8601
endTime :: Data.ISO8601
  }
  deriving (CloudTrailProperties -> CloudTrailProperties -> Bool
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]
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
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. 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:
--
-- 'trailProperties', 'cloudTrailProperties_trailProperties' - A @TrailProperties@ object that contains settings for trail properties.
--
-- '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.
--
-- '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.
newCloudTrailProperties ::
  -- | 'startTime'
  Prelude.UTCTime ->
  -- | 'endTime'
  Prelude.UTCTime ->
  CloudTrailProperties
newCloudTrailProperties :: UTCTime -> UTCTime -> CloudTrailProperties
newCloudTrailProperties UTCTime
pStartTime_ UTCTime
pEndTime_ =
  CloudTrailProperties'
    { $sel:trailProperties:CloudTrailProperties' :: [TrailProperties]
trailProperties =
        forall a. Monoid a => a
Prelude.mempty,
      $sel:startTime:CloudTrailProperties' :: ISO8601
startTime = forall (a :: Format). Iso' (Time a) UTCTime
Data._Time forall t b. AReview t b -> b -> t
Lens.# UTCTime
pStartTime_,
      $sel:endTime:CloudTrailProperties' :: ISO8601
endTime = forall (a :: Format). Iso' (Time a) UTCTime
Data._Time forall t b. AReview t b -> b -> t
Lens.# UTCTime
pEndTime_
    }

-- | A @TrailProperties@ object that contains settings for trail properties.
cloudTrailProperties_trailProperties :: Lens.Lens' CloudTrailProperties [TrailProperties]
cloudTrailProperties_trailProperties :: Lens' CloudTrailProperties [TrailProperties]
cloudTrailProperties_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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | 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 :: Lens' CloudTrailProperties UTCTime
cloudTrailProperties_startTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloudTrailProperties' {ISO8601
startTime :: ISO8601
$sel:startTime:CloudTrailProperties' :: CloudTrailProperties -> ISO8601
startTime} -> ISO8601
startTime) (\s :: CloudTrailProperties
s@CloudTrailProperties' {} ISO8601
a -> CloudTrailProperties
s {$sel:startTime:CloudTrailProperties' :: ISO8601
startTime = ISO8601
a} :: CloudTrailProperties) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | 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 :: Lens' CloudTrailProperties UTCTime
cloudTrailProperties_endTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloudTrailProperties' {ISO8601
endTime :: ISO8601
$sel:endTime:CloudTrailProperties' :: CloudTrailProperties -> ISO8601
endTime} -> ISO8601
endTime) (\s :: CloudTrailProperties
s@CloudTrailProperties' {} ISO8601
a -> CloudTrailProperties
s {$sel:endTime:CloudTrailProperties' :: ISO8601
endTime = ISO8601
a} :: CloudTrailProperties) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

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

instance Prelude.Hashable CloudTrailProperties where
  hashWithSalt :: Int -> CloudTrailProperties -> Int
hashWithSalt Int
_salt CloudTrailProperties' {[TrailProperties]
ISO8601
endTime :: ISO8601
startTime :: ISO8601
trailProperties :: [TrailProperties]
$sel:endTime:CloudTrailProperties' :: CloudTrailProperties -> ISO8601
$sel:startTime:CloudTrailProperties' :: CloudTrailProperties -> ISO8601
$sel:trailProperties:CloudTrailProperties' :: CloudTrailProperties -> [TrailProperties]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [TrailProperties]
trailProperties
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ISO8601
startTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ISO8601
endTime

instance Prelude.NFData CloudTrailProperties where
  rnf :: CloudTrailProperties -> ()
rnf CloudTrailProperties' {[TrailProperties]
ISO8601
endTime :: ISO8601
startTime :: ISO8601
trailProperties :: [TrailProperties]
$sel:endTime:CloudTrailProperties' :: CloudTrailProperties -> ISO8601
$sel:startTime:CloudTrailProperties' :: CloudTrailProperties -> ISO8601
$sel:trailProperties:CloudTrailProperties' :: CloudTrailProperties -> [TrailProperties]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf [TrailProperties]
trailProperties
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ISO8601
startTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ISO8601
endTime