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

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 details about the CloudTrail trail being analyzed to generate a
-- policy.
--
-- /See:/ 'newTrailProperties' smart constructor.
data TrailProperties = TrailProperties'
  { -- | 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,
    -- | A list of regions to get CloudTrail data from and analyze to generate a
    -- policy.
    TrailProperties -> Maybe [Text]
regions :: Prelude.Maybe [Prelude.Text],
    -- | 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
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]
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
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. 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:
--
-- '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.
--
-- 'regions', 'trailProperties_regions' - A list of regions to get CloudTrail data from and analyze to 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'
    { $sel:allRegions:TrailProperties' :: Maybe Bool
allRegions = forall a. Maybe a
Prelude.Nothing,
      $sel:regions:TrailProperties' :: Maybe [Text]
regions = forall a. Maybe a
Prelude.Nothing,
      $sel:cloudTrailArn:TrailProperties' :: Text
cloudTrailArn = Text
pCloudTrailArn_
    }

-- | 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 :: Lens' TrailProperties (Maybe Bool)
trailProperties_allRegions = 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)

-- | 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 :: Lens' TrailProperties (Maybe [Text])
trailProperties_regions = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | 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 :: Lens' TrailProperties Text
trailProperties_cloudTrailArn = 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 Data.FromJSON TrailProperties where
  parseJSON :: Value -> Parser TrailProperties
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"TrailProperties"
      ( \Object
x ->
          Maybe Bool -> Maybe [Text] -> Text -> TrailProperties
TrailProperties'
            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
"allRegions")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"regions" 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
"cloudTrailArn")
      )

instance Prelude.Hashable TrailProperties where
  hashWithSalt :: Int -> TrailProperties -> Int
hashWithSalt Int
_salt TrailProperties' {Maybe Bool
Maybe [Text]
Text
cloudTrailArn :: Text
regions :: Maybe [Text]
allRegions :: Maybe Bool
$sel:cloudTrailArn:TrailProperties' :: TrailProperties -> Text
$sel:regions:TrailProperties' :: TrailProperties -> Maybe [Text]
$sel:allRegions:TrailProperties' :: TrailProperties -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
allRegions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
regions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
cloudTrailArn

instance Prelude.NFData TrailProperties where
  rnf :: TrailProperties -> ()
rnf TrailProperties' {Maybe Bool
Maybe [Text]
Text
cloudTrailArn :: Text
regions :: Maybe [Text]
allRegions :: Maybe Bool
$sel:cloudTrailArn:TrailProperties' :: TrailProperties -> Text
$sel:regions:TrailProperties' :: TrailProperties -> Maybe [Text]
$sel:allRegions:TrailProperties' :: TrailProperties -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
allRegions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
regions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
cloudTrailArn