{-# 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.Trail
-- 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.Trail 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:/ 'newTrail' smart constructor.
data Trail = Trail'
  { -- | A list of regions to get CloudTrail data from and analyze to generate a
    -- policy.
    Trail -> 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.
    Trail -> 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@.
    Trail -> Text
cloudTrailArn :: Prelude.Text
  }
  deriving (Trail -> Trail -> Bool
(Trail -> Trail -> Bool) -> (Trail -> Trail -> Bool) -> Eq Trail
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Trail -> Trail -> Bool
$c/= :: Trail -> Trail -> Bool
== :: Trail -> Trail -> Bool
$c== :: Trail -> Trail -> Bool
Prelude.Eq, ReadPrec [Trail]
ReadPrec Trail
Int -> ReadS Trail
ReadS [Trail]
(Int -> ReadS Trail)
-> ReadS [Trail]
-> ReadPrec Trail
-> ReadPrec [Trail]
-> Read Trail
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Trail]
$creadListPrec :: ReadPrec [Trail]
readPrec :: ReadPrec Trail
$creadPrec :: ReadPrec Trail
readList :: ReadS [Trail]
$creadList :: ReadS [Trail]
readsPrec :: Int -> ReadS Trail
$creadsPrec :: Int -> ReadS Trail
Prelude.Read, Int -> Trail -> ShowS
[Trail] -> ShowS
Trail -> String
(Int -> Trail -> ShowS)
-> (Trail -> String) -> ([Trail] -> ShowS) -> Show Trail
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Trail] -> ShowS
$cshowList :: [Trail] -> ShowS
show :: Trail -> String
$cshow :: Trail -> String
showsPrec :: Int -> Trail -> ShowS
$cshowsPrec :: Int -> Trail -> ShowS
Prelude.Show, (forall x. Trail -> Rep Trail x)
-> (forall x. Rep Trail x -> Trail) -> Generic Trail
forall x. Rep Trail x -> Trail
forall x. Trail -> Rep Trail x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Trail x -> Trail
$cfrom :: forall x. Trail -> Rep Trail x
Prelude.Generic)

-- |
-- Create a value of 'Trail' 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', 'trail_regions' - A list of regions to get CloudTrail data from and analyze to generate a
-- policy.
--
-- 'allRegions', 'trail_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', 'trail_cloudTrailArn' - Specifies the ARN of the trail. The format of a trail ARN is
-- @arn:aws:cloudtrail:us-east-2:123456789012:trail\/MyTrail@.
newTrail ::
  -- | 'cloudTrailArn'
  Prelude.Text ->
  Trail
newTrail :: Text -> Trail
newTrail Text
pCloudTrailArn_ =
  Trail' :: Maybe [Text] -> Maybe Bool -> Text -> Trail
Trail'
    { $sel:regions:Trail' :: Maybe [Text]
regions = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:allRegions:Trail' :: Maybe Bool
allRegions = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:cloudTrailArn:Trail' :: Text
cloudTrailArn = Text
pCloudTrailArn_
    }

-- | A list of regions to get CloudTrail data from and analyze to generate a
-- policy.
trail_regions :: Lens.Lens' Trail (Prelude.Maybe [Prelude.Text])
trail_regions :: (Maybe [Text] -> f (Maybe [Text])) -> Trail -> f Trail
trail_regions = (Trail -> Maybe [Text])
-> (Trail -> Maybe [Text] -> Trail)
-> Lens Trail Trail (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Trail' {Maybe [Text]
regions :: Maybe [Text]
$sel:regions:Trail' :: Trail -> Maybe [Text]
regions} -> Maybe [Text]
regions) (\s :: Trail
s@Trail' {} Maybe [Text]
a -> Trail
s {$sel:regions:Trail' :: Maybe [Text]
regions = Maybe [Text]
a} :: Trail) ((Maybe [Text] -> f (Maybe [Text])) -> Trail -> f Trail)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> Trail
-> f Trail
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.
trail_allRegions :: Lens.Lens' Trail (Prelude.Maybe Prelude.Bool)
trail_allRegions :: (Maybe Bool -> f (Maybe Bool)) -> Trail -> f Trail
trail_allRegions = (Trail -> Maybe Bool)
-> (Trail -> Maybe Bool -> Trail)
-> Lens Trail Trail (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Trail' {Maybe Bool
allRegions :: Maybe Bool
$sel:allRegions:Trail' :: Trail -> Maybe Bool
allRegions} -> Maybe Bool
allRegions) (\s :: Trail
s@Trail' {} Maybe Bool
a -> Trail
s {$sel:allRegions:Trail' :: Maybe Bool
allRegions = Maybe Bool
a} :: Trail)

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

instance Prelude.Hashable Trail

instance Prelude.NFData Trail

instance Core.ToJSON Trail where
  toJSON :: Trail -> Value
toJSON Trail' {Maybe Bool
Maybe [Text]
Text
cloudTrailArn :: Text
allRegions :: Maybe Bool
regions :: Maybe [Text]
$sel:cloudTrailArn:Trail' :: Trail -> Text
$sel:allRegions:Trail' :: Trail -> Maybe Bool
$sel:regions:Trail' :: Trail -> Maybe [Text]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"regions" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
regions,
            (Text
"allRegions" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
allRegions,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"cloudTrailArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
cloudTrailArn)
          ]
      )