{-# 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.TrailProperties
-- 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.TrailProperties where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains details about the CloudTrail trail being analyzed to generate a
-- policy.
--
-- /See:/ 'newTrailProperties' smart constructor.
data TrailProperties = TrailProperties'
  { -- | A list of regions to get CloudTrail data from and analyze to generate a
    -- policy.
    TrailProperties -> Maybe [Text]
regions :: Prelude.Maybe [Prelude.Text],
    -- | Possible values are @true@ or @false@. If set to @true@, IAM Access
    -- Analyzer retrieves CloudTrail data from all regions to analyze and
    -- generate a policy.
    TrailProperties -> Maybe Bool
allRegions :: Prelude.Maybe Prelude.Bool,
    -- | Specifies the ARN of the trail. The format of a trail ARN is
    -- @arn:aws:cloudtrail:us-east-2:123456789012:trail\/MyTrail@.
    TrailProperties -> Text
cloudTrailArn :: Prelude.Text
  }
  deriving (TrailProperties -> TrailProperties -> Bool
(TrailProperties -> TrailProperties -> Bool)
-> (TrailProperties -> TrailProperties -> Bool)
-> Eq TrailProperties
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TrailProperties -> TrailProperties -> Bool
$c/= :: TrailProperties -> TrailProperties -> Bool
== :: TrailProperties -> TrailProperties -> Bool
$c== :: TrailProperties -> TrailProperties -> Bool
Prelude.Eq, ReadPrec [TrailProperties]
ReadPrec TrailProperties
Int -> ReadS TrailProperties
ReadS [TrailProperties]
(Int -> ReadS TrailProperties)
-> ReadS [TrailProperties]
-> ReadPrec TrailProperties
-> ReadPrec [TrailProperties]
-> Read TrailProperties
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TrailProperties]
$creadListPrec :: ReadPrec [TrailProperties]
readPrec :: ReadPrec TrailProperties
$creadPrec :: ReadPrec TrailProperties
readList :: ReadS [TrailProperties]
$creadList :: ReadS [TrailProperties]
readsPrec :: Int -> ReadS TrailProperties
$creadsPrec :: Int -> ReadS TrailProperties
Prelude.Read, Int -> TrailProperties -> ShowS
[TrailProperties] -> ShowS
TrailProperties -> String
(Int -> TrailProperties -> ShowS)
-> (TrailProperties -> String)
-> ([TrailProperties] -> ShowS)
-> Show TrailProperties
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TrailProperties] -> ShowS
$cshowList :: [TrailProperties] -> ShowS
show :: TrailProperties -> String
$cshow :: TrailProperties -> String
showsPrec :: Int -> TrailProperties -> ShowS
$cshowsPrec :: Int -> TrailProperties -> ShowS
Prelude.Show, (forall x. TrailProperties -> Rep TrailProperties x)
-> (forall x. Rep TrailProperties x -> TrailProperties)
-> Generic TrailProperties
forall x. Rep TrailProperties x -> TrailProperties
forall x. TrailProperties -> Rep TrailProperties x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TrailProperties x -> TrailProperties
$cfrom :: forall x. TrailProperties -> Rep TrailProperties x
Prelude.Generic)

-- |
-- Create a value of 'TrailProperties' 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:
--
-- 'regions', 'trailProperties_regions' - A list of regions to get CloudTrail data from and analyze to generate a
-- policy.
--
-- 'allRegions', 'trailProperties_allRegions' - Possible values are @true@ or @false@. If set to @true@, IAM Access
-- Analyzer retrieves CloudTrail data from all regions to analyze and
-- generate a policy.
--
-- 'cloudTrailArn', 'trailProperties_cloudTrailArn' - Specifies the ARN of the trail. The format of a trail ARN is
-- @arn:aws:cloudtrail:us-east-2:123456789012:trail\/MyTrail@.
newTrailProperties ::
  -- | 'cloudTrailArn'
  Prelude.Text ->
  TrailProperties
newTrailProperties :: Text -> TrailProperties
newTrailProperties Text
pCloudTrailArn_ =
  TrailProperties' :: Maybe [Text] -> Maybe Bool -> Text -> TrailProperties
TrailProperties'
    { $sel:regions:TrailProperties' :: Maybe [Text]
regions = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:allRegions:TrailProperties' :: Maybe Bool
allRegions = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:cloudTrailArn:TrailProperties' :: Text
cloudTrailArn = Text
pCloudTrailArn_
    }

-- | A list of regions to get CloudTrail data from and analyze to generate a
-- policy.
trailProperties_regions :: Lens.Lens' TrailProperties (Prelude.Maybe [Prelude.Text])
trailProperties_regions :: (Maybe [Text] -> f (Maybe [Text]))
-> TrailProperties -> f TrailProperties
trailProperties_regions = (TrailProperties -> Maybe [Text])
-> (TrailProperties -> Maybe [Text] -> TrailProperties)
-> Lens
     TrailProperties TrailProperties (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TrailProperties' {Maybe [Text]
regions :: Maybe [Text]
$sel:regions:TrailProperties' :: TrailProperties -> Maybe [Text]
regions} -> Maybe [Text]
regions) (\s :: TrailProperties
s@TrailProperties' {} Maybe [Text]
a -> TrailProperties
s {$sel:regions:TrailProperties' :: Maybe [Text]
regions = Maybe [Text]
a} :: TrailProperties) ((Maybe [Text] -> f (Maybe [Text]))
 -> TrailProperties -> f TrailProperties)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> TrailProperties
-> f TrailProperties
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Possible values are @true@ or @false@. If set to @true@, IAM Access
-- Analyzer retrieves CloudTrail data from all regions to analyze and
-- generate a policy.
trailProperties_allRegions :: Lens.Lens' TrailProperties (Prelude.Maybe Prelude.Bool)
trailProperties_allRegions :: (Maybe Bool -> f (Maybe Bool))
-> TrailProperties -> f TrailProperties
trailProperties_allRegions = (TrailProperties -> Maybe Bool)
-> (TrailProperties -> Maybe Bool -> TrailProperties)
-> Lens TrailProperties TrailProperties (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TrailProperties' {Maybe Bool
allRegions :: Maybe Bool
$sel:allRegions:TrailProperties' :: TrailProperties -> Maybe Bool
allRegions} -> Maybe Bool
allRegions) (\s :: TrailProperties
s@TrailProperties' {} Maybe Bool
a -> TrailProperties
s {$sel:allRegions:TrailProperties' :: Maybe Bool
allRegions = Maybe Bool
a} :: TrailProperties)

-- | Specifies the ARN of the trail. The format of a trail ARN is
-- @arn:aws:cloudtrail:us-east-2:123456789012:trail\/MyTrail@.
trailProperties_cloudTrailArn :: Lens.Lens' TrailProperties Prelude.Text
trailProperties_cloudTrailArn :: (Text -> f Text) -> TrailProperties -> f TrailProperties
trailProperties_cloudTrailArn = (TrailProperties -> Text)
-> (TrailProperties -> Text -> TrailProperties)
-> Lens TrailProperties TrailProperties Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TrailProperties' {Text
cloudTrailArn :: Text
$sel:cloudTrailArn:TrailProperties' :: TrailProperties -> Text
cloudTrailArn} -> Text
cloudTrailArn) (\s :: TrailProperties
s@TrailProperties' {} Text
a -> TrailProperties
s {$sel:cloudTrailArn:TrailProperties' :: Text
cloudTrailArn = Text
a} :: TrailProperties)

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

instance Prelude.Hashable TrailProperties

instance Prelude.NFData TrailProperties