{-# 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.CloudTrail.Types.TrailInfo
-- 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.CloudTrail.Types.TrailInfo where

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

-- | Information about a CloudTrail trail, including the trail\'s name, home
-- region, and Amazon Resource Name (ARN).
--
-- /See:/ 'newTrailInfo' smart constructor.
data TrailInfo = TrailInfo'
  { -- | The ARN of a trail.
    TrailInfo -> Maybe Text
trailARN :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Web Services Region in which a trail was created.
    TrailInfo -> Maybe Text
homeRegion :: Prelude.Maybe Prelude.Text,
    -- | The name of a trail.
    TrailInfo -> Maybe Text
name :: Prelude.Maybe Prelude.Text
  }
  deriving (TrailInfo -> TrailInfo -> Bool
(TrailInfo -> TrailInfo -> Bool)
-> (TrailInfo -> TrailInfo -> Bool) -> Eq TrailInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TrailInfo -> TrailInfo -> Bool
$c/= :: TrailInfo -> TrailInfo -> Bool
== :: TrailInfo -> TrailInfo -> Bool
$c== :: TrailInfo -> TrailInfo -> Bool
Prelude.Eq, ReadPrec [TrailInfo]
ReadPrec TrailInfo
Int -> ReadS TrailInfo
ReadS [TrailInfo]
(Int -> ReadS TrailInfo)
-> ReadS [TrailInfo]
-> ReadPrec TrailInfo
-> ReadPrec [TrailInfo]
-> Read TrailInfo
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TrailInfo]
$creadListPrec :: ReadPrec [TrailInfo]
readPrec :: ReadPrec TrailInfo
$creadPrec :: ReadPrec TrailInfo
readList :: ReadS [TrailInfo]
$creadList :: ReadS [TrailInfo]
readsPrec :: Int -> ReadS TrailInfo
$creadsPrec :: Int -> ReadS TrailInfo
Prelude.Read, Int -> TrailInfo -> ShowS
[TrailInfo] -> ShowS
TrailInfo -> String
(Int -> TrailInfo -> ShowS)
-> (TrailInfo -> String)
-> ([TrailInfo] -> ShowS)
-> Show TrailInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TrailInfo] -> ShowS
$cshowList :: [TrailInfo] -> ShowS
show :: TrailInfo -> String
$cshow :: TrailInfo -> String
showsPrec :: Int -> TrailInfo -> ShowS
$cshowsPrec :: Int -> TrailInfo -> ShowS
Prelude.Show, (forall x. TrailInfo -> Rep TrailInfo x)
-> (forall x. Rep TrailInfo x -> TrailInfo) -> Generic TrailInfo
forall x. Rep TrailInfo x -> TrailInfo
forall x. TrailInfo -> Rep TrailInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TrailInfo x -> TrailInfo
$cfrom :: forall x. TrailInfo -> Rep TrailInfo x
Prelude.Generic)

-- |
-- Create a value of 'TrailInfo' 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:
--
-- 'trailARN', 'trailInfo_trailARN' - The ARN of a trail.
--
-- 'homeRegion', 'trailInfo_homeRegion' - The Amazon Web Services Region in which a trail was created.
--
-- 'name', 'trailInfo_name' - The name of a trail.
newTrailInfo ::
  TrailInfo
newTrailInfo :: TrailInfo
newTrailInfo =
  TrailInfo' :: Maybe Text -> Maybe Text -> Maybe Text -> TrailInfo
TrailInfo'
    { $sel:trailARN:TrailInfo' :: Maybe Text
trailARN = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:homeRegion:TrailInfo' :: Maybe Text
homeRegion = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:TrailInfo' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The ARN of a trail.
trailInfo_trailARN :: Lens.Lens' TrailInfo (Prelude.Maybe Prelude.Text)
trailInfo_trailARN :: (Maybe Text -> f (Maybe Text)) -> TrailInfo -> f TrailInfo
trailInfo_trailARN = (TrailInfo -> Maybe Text)
-> (TrailInfo -> Maybe Text -> TrailInfo)
-> Lens TrailInfo TrailInfo (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TrailInfo' {Maybe Text
trailARN :: Maybe Text
$sel:trailARN:TrailInfo' :: TrailInfo -> Maybe Text
trailARN} -> Maybe Text
trailARN) (\s :: TrailInfo
s@TrailInfo' {} Maybe Text
a -> TrailInfo
s {$sel:trailARN:TrailInfo' :: Maybe Text
trailARN = Maybe Text
a} :: TrailInfo)

-- | The Amazon Web Services Region in which a trail was created.
trailInfo_homeRegion :: Lens.Lens' TrailInfo (Prelude.Maybe Prelude.Text)
trailInfo_homeRegion :: (Maybe Text -> f (Maybe Text)) -> TrailInfo -> f TrailInfo
trailInfo_homeRegion = (TrailInfo -> Maybe Text)
-> (TrailInfo -> Maybe Text -> TrailInfo)
-> Lens TrailInfo TrailInfo (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TrailInfo' {Maybe Text
homeRegion :: Maybe Text
$sel:homeRegion:TrailInfo' :: TrailInfo -> Maybe Text
homeRegion} -> Maybe Text
homeRegion) (\s :: TrailInfo
s@TrailInfo' {} Maybe Text
a -> TrailInfo
s {$sel:homeRegion:TrailInfo' :: Maybe Text
homeRegion = Maybe Text
a} :: TrailInfo)

-- | The name of a trail.
trailInfo_name :: Lens.Lens' TrailInfo (Prelude.Maybe Prelude.Text)
trailInfo_name :: (Maybe Text -> f (Maybe Text)) -> TrailInfo -> f TrailInfo
trailInfo_name = (TrailInfo -> Maybe Text)
-> (TrailInfo -> Maybe Text -> TrailInfo)
-> Lens TrailInfo TrailInfo (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TrailInfo' {Maybe Text
name :: Maybe Text
$sel:name:TrailInfo' :: TrailInfo -> Maybe Text
name} -> Maybe Text
name) (\s :: TrailInfo
s@TrailInfo' {} Maybe Text
a -> TrailInfo
s {$sel:name:TrailInfo' :: Maybe Text
name = Maybe Text
a} :: TrailInfo)

instance Core.FromJSON TrailInfo where
  parseJSON :: Value -> Parser TrailInfo
parseJSON =
    String -> (Object -> Parser TrailInfo) -> Value -> Parser TrailInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TrailInfo"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Text -> TrailInfo
TrailInfo'
            (Maybe Text -> Maybe Text -> Maybe Text -> TrailInfo)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> TrailInfo)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TrailARN")
            Parser (Maybe Text -> Maybe Text -> TrailInfo)
-> Parser (Maybe Text) -> Parser (Maybe Text -> TrailInfo)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"HomeRegion")
            Parser (Maybe Text -> TrailInfo)
-> Parser (Maybe Text) -> Parser TrailInfo
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Name")
      )

instance Prelude.Hashable TrailInfo

instance Prelude.NFData TrailInfo