{-# 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.LexV2Models.Types.CloudWatchLogGroupLogDestination
-- 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.LexV2Models.Types.CloudWatchLogGroupLogDestination 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

-- | The Amazon CloudWatch Logs log group where the text and metadata logs
-- are delivered. The log group must exist before you enable logging.
--
-- /See:/ 'newCloudWatchLogGroupLogDestination' smart constructor.
data CloudWatchLogGroupLogDestination = CloudWatchLogGroupLogDestination'
  { -- | The Amazon Resource Name (ARN) of the log group where text and metadata
    -- logs are delivered.
    CloudWatchLogGroupLogDestination -> Text
cloudWatchLogGroupArn :: Prelude.Text,
    -- | The prefix of the log stream name within the log group that you
    -- specified
    CloudWatchLogGroupLogDestination -> Text
logPrefix :: Prelude.Text
  }
  deriving (CloudWatchLogGroupLogDestination
-> CloudWatchLogGroupLogDestination -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CloudWatchLogGroupLogDestination
-> CloudWatchLogGroupLogDestination -> Bool
$c/= :: CloudWatchLogGroupLogDestination
-> CloudWatchLogGroupLogDestination -> Bool
== :: CloudWatchLogGroupLogDestination
-> CloudWatchLogGroupLogDestination -> Bool
$c== :: CloudWatchLogGroupLogDestination
-> CloudWatchLogGroupLogDestination -> Bool
Prelude.Eq, ReadPrec [CloudWatchLogGroupLogDestination]
ReadPrec CloudWatchLogGroupLogDestination
Int -> ReadS CloudWatchLogGroupLogDestination
ReadS [CloudWatchLogGroupLogDestination]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CloudWatchLogGroupLogDestination]
$creadListPrec :: ReadPrec [CloudWatchLogGroupLogDestination]
readPrec :: ReadPrec CloudWatchLogGroupLogDestination
$creadPrec :: ReadPrec CloudWatchLogGroupLogDestination
readList :: ReadS [CloudWatchLogGroupLogDestination]
$creadList :: ReadS [CloudWatchLogGroupLogDestination]
readsPrec :: Int -> ReadS CloudWatchLogGroupLogDestination
$creadsPrec :: Int -> ReadS CloudWatchLogGroupLogDestination
Prelude.Read, Int -> CloudWatchLogGroupLogDestination -> ShowS
[CloudWatchLogGroupLogDestination] -> ShowS
CloudWatchLogGroupLogDestination -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CloudWatchLogGroupLogDestination] -> ShowS
$cshowList :: [CloudWatchLogGroupLogDestination] -> ShowS
show :: CloudWatchLogGroupLogDestination -> String
$cshow :: CloudWatchLogGroupLogDestination -> String
showsPrec :: Int -> CloudWatchLogGroupLogDestination -> ShowS
$cshowsPrec :: Int -> CloudWatchLogGroupLogDestination -> ShowS
Prelude.Show, forall x.
Rep CloudWatchLogGroupLogDestination x
-> CloudWatchLogGroupLogDestination
forall x.
CloudWatchLogGroupLogDestination
-> Rep CloudWatchLogGroupLogDestination x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CloudWatchLogGroupLogDestination x
-> CloudWatchLogGroupLogDestination
$cfrom :: forall x.
CloudWatchLogGroupLogDestination
-> Rep CloudWatchLogGroupLogDestination x
Prelude.Generic)

-- |
-- Create a value of 'CloudWatchLogGroupLogDestination' 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:
--
-- 'cloudWatchLogGroupArn', 'cloudWatchLogGroupLogDestination_cloudWatchLogGroupArn' - The Amazon Resource Name (ARN) of the log group where text and metadata
-- logs are delivered.
--
-- 'logPrefix', 'cloudWatchLogGroupLogDestination_logPrefix' - The prefix of the log stream name within the log group that you
-- specified
newCloudWatchLogGroupLogDestination ::
  -- | 'cloudWatchLogGroupArn'
  Prelude.Text ->
  -- | 'logPrefix'
  Prelude.Text ->
  CloudWatchLogGroupLogDestination
newCloudWatchLogGroupLogDestination :: Text -> Text -> CloudWatchLogGroupLogDestination
newCloudWatchLogGroupLogDestination
  Text
pCloudWatchLogGroupArn_
  Text
pLogPrefix_ =
    CloudWatchLogGroupLogDestination'
      { $sel:cloudWatchLogGroupArn:CloudWatchLogGroupLogDestination' :: Text
cloudWatchLogGroupArn =
          Text
pCloudWatchLogGroupArn_,
        $sel:logPrefix:CloudWatchLogGroupLogDestination' :: Text
logPrefix = Text
pLogPrefix_
      }

-- | The Amazon Resource Name (ARN) of the log group where text and metadata
-- logs are delivered.
cloudWatchLogGroupLogDestination_cloudWatchLogGroupArn :: Lens.Lens' CloudWatchLogGroupLogDestination Prelude.Text
cloudWatchLogGroupLogDestination_cloudWatchLogGroupArn :: Lens' CloudWatchLogGroupLogDestination Text
cloudWatchLogGroupLogDestination_cloudWatchLogGroupArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloudWatchLogGroupLogDestination' {Text
cloudWatchLogGroupArn :: Text
$sel:cloudWatchLogGroupArn:CloudWatchLogGroupLogDestination' :: CloudWatchLogGroupLogDestination -> Text
cloudWatchLogGroupArn} -> Text
cloudWatchLogGroupArn) (\s :: CloudWatchLogGroupLogDestination
s@CloudWatchLogGroupLogDestination' {} Text
a -> CloudWatchLogGroupLogDestination
s {$sel:cloudWatchLogGroupArn:CloudWatchLogGroupLogDestination' :: Text
cloudWatchLogGroupArn = Text
a} :: CloudWatchLogGroupLogDestination)

-- | The prefix of the log stream name within the log group that you
-- specified
cloudWatchLogGroupLogDestination_logPrefix :: Lens.Lens' CloudWatchLogGroupLogDestination Prelude.Text
cloudWatchLogGroupLogDestination_logPrefix :: Lens' CloudWatchLogGroupLogDestination Text
cloudWatchLogGroupLogDestination_logPrefix = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloudWatchLogGroupLogDestination' {Text
logPrefix :: Text
$sel:logPrefix:CloudWatchLogGroupLogDestination' :: CloudWatchLogGroupLogDestination -> Text
logPrefix} -> Text
logPrefix) (\s :: CloudWatchLogGroupLogDestination
s@CloudWatchLogGroupLogDestination' {} Text
a -> CloudWatchLogGroupLogDestination
s {$sel:logPrefix:CloudWatchLogGroupLogDestination' :: Text
logPrefix = Text
a} :: CloudWatchLogGroupLogDestination)

instance
  Data.FromJSON
    CloudWatchLogGroupLogDestination
  where
  parseJSON :: Value -> Parser CloudWatchLogGroupLogDestination
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CloudWatchLogGroupLogDestination"
      ( \Object
x ->
          Text -> Text -> CloudWatchLogGroupLogDestination
CloudWatchLogGroupLogDestination'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"cloudWatchLogGroupArn")
            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
"logPrefix")
      )

instance
  Prelude.Hashable
    CloudWatchLogGroupLogDestination
  where
  hashWithSalt :: Int -> CloudWatchLogGroupLogDestination -> Int
hashWithSalt
    Int
_salt
    CloudWatchLogGroupLogDestination' {Text
logPrefix :: Text
cloudWatchLogGroupArn :: Text
$sel:logPrefix:CloudWatchLogGroupLogDestination' :: CloudWatchLogGroupLogDestination -> Text
$sel:cloudWatchLogGroupArn:CloudWatchLogGroupLogDestination' :: CloudWatchLogGroupLogDestination -> Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
cloudWatchLogGroupArn
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
logPrefix

instance
  Prelude.NFData
    CloudWatchLogGroupLogDestination
  where
  rnf :: CloudWatchLogGroupLogDestination -> ()
rnf CloudWatchLogGroupLogDestination' {Text
logPrefix :: Text
cloudWatchLogGroupArn :: Text
$sel:logPrefix:CloudWatchLogGroupLogDestination' :: CloudWatchLogGroupLogDestination -> Text
$sel:cloudWatchLogGroupArn:CloudWatchLogGroupLogDestination' :: CloudWatchLogGroupLogDestination -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
cloudWatchLogGroupArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
logPrefix

instance Data.ToJSON CloudWatchLogGroupLogDestination where
  toJSON :: CloudWatchLogGroupLogDestination -> Value
toJSON CloudWatchLogGroupLogDestination' {Text
logPrefix :: Text
cloudWatchLogGroupArn :: Text
$sel:logPrefix:CloudWatchLogGroupLogDestination' :: CloudWatchLogGroupLogDestination -> Text
$sel:cloudWatchLogGroupArn:CloudWatchLogGroupLogDestination' :: CloudWatchLogGroupLogDestination -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              ( Key
"cloudWatchLogGroupArn"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
cloudWatchLogGroupArn
              ),
            forall a. a -> Maybe a
Prelude.Just (Key
"logPrefix" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
logPrefix)
          ]
      )