{-# 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.CloudWatchLogs.Types.LogGroup
-- 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.CloudWatchLogs.Types.LogGroup where

import Amazonka.CloudWatchLogs.Types.DataProtectionStatus
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

-- | Represents a log group.
--
-- /See:/ 'newLogGroup' smart constructor.
data LogGroup = LogGroup'
  { -- | The Amazon Resource Name (ARN) of the log group.
    LogGroup -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The creation time of the log group, expressed as the number of
    -- milliseconds after Jan 1, 1970 00:00:00 UTC.
    LogGroup -> Maybe Natural
creationTime :: Prelude.Maybe Prelude.Natural,
    -- | Displays whether this log group has a protection policy, or whether it
    -- had one in the past. For more information, see
    -- <https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutDataProtectionPolicy.html PutDataProtectionPolicy>.
    LogGroup -> Maybe DataProtectionStatus
dataProtectionStatus :: Prelude.Maybe DataProtectionStatus,
    -- | The Amazon Resource Name (ARN) of the KMS key to use when encrypting log
    -- data.
    LogGroup -> Maybe Text
kmsKeyId :: Prelude.Maybe Prelude.Text,
    -- | The name of the log group.
    LogGroup -> Maybe Text
logGroupName :: Prelude.Maybe Prelude.Text,
    -- | The number of metric filters.
    LogGroup -> Maybe Int
metricFilterCount :: Prelude.Maybe Prelude.Int,
    LogGroup -> Maybe Int
retentionInDays :: Prelude.Maybe Prelude.Int,
    -- | The number of bytes stored.
    LogGroup -> Maybe Natural
storedBytes :: Prelude.Maybe Prelude.Natural
  }
  deriving (LogGroup -> LogGroup -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LogGroup -> LogGroup -> Bool
$c/= :: LogGroup -> LogGroup -> Bool
== :: LogGroup -> LogGroup -> Bool
$c== :: LogGroup -> LogGroup -> Bool
Prelude.Eq, ReadPrec [LogGroup]
ReadPrec LogGroup
Int -> ReadS LogGroup
ReadS [LogGroup]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LogGroup]
$creadListPrec :: ReadPrec [LogGroup]
readPrec :: ReadPrec LogGroup
$creadPrec :: ReadPrec LogGroup
readList :: ReadS [LogGroup]
$creadList :: ReadS [LogGroup]
readsPrec :: Int -> ReadS LogGroup
$creadsPrec :: Int -> ReadS LogGroup
Prelude.Read, Int -> LogGroup -> ShowS
[LogGroup] -> ShowS
LogGroup -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LogGroup] -> ShowS
$cshowList :: [LogGroup] -> ShowS
show :: LogGroup -> String
$cshow :: LogGroup -> String
showsPrec :: Int -> LogGroup -> ShowS
$cshowsPrec :: Int -> LogGroup -> ShowS
Prelude.Show, forall x. Rep LogGroup x -> LogGroup
forall x. LogGroup -> Rep LogGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LogGroup x -> LogGroup
$cfrom :: forall x. LogGroup -> Rep LogGroup x
Prelude.Generic)

-- |
-- Create a value of 'LogGroup' 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:
--
-- 'arn', 'logGroup_arn' - The Amazon Resource Name (ARN) of the log group.
--
-- 'creationTime', 'logGroup_creationTime' - The creation time of the log group, expressed as the number of
-- milliseconds after Jan 1, 1970 00:00:00 UTC.
--
-- 'dataProtectionStatus', 'logGroup_dataProtectionStatus' - Displays whether this log group has a protection policy, or whether it
-- had one in the past. For more information, see
-- <https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutDataProtectionPolicy.html PutDataProtectionPolicy>.
--
-- 'kmsKeyId', 'logGroup_kmsKeyId' - The Amazon Resource Name (ARN) of the KMS key to use when encrypting log
-- data.
--
-- 'logGroupName', 'logGroup_logGroupName' - The name of the log group.
--
-- 'metricFilterCount', 'logGroup_metricFilterCount' - The number of metric filters.
--
-- 'retentionInDays', 'logGroup_retentionInDays' - Undocumented member.
--
-- 'storedBytes', 'logGroup_storedBytes' - The number of bytes stored.
newLogGroup ::
  LogGroup
newLogGroup :: LogGroup
newLogGroup =
  LogGroup'
    { $sel:arn:LogGroup' :: Maybe Text
arn = forall a. Maybe a
Prelude.Nothing,
      $sel:creationTime:LogGroup' :: Maybe Natural
creationTime = forall a. Maybe a
Prelude.Nothing,
      $sel:dataProtectionStatus:LogGroup' :: Maybe DataProtectionStatus
dataProtectionStatus = forall a. Maybe a
Prelude.Nothing,
      $sel:kmsKeyId:LogGroup' :: Maybe Text
kmsKeyId = forall a. Maybe a
Prelude.Nothing,
      $sel:logGroupName:LogGroup' :: Maybe Text
logGroupName = forall a. Maybe a
Prelude.Nothing,
      $sel:metricFilterCount:LogGroup' :: Maybe Int
metricFilterCount = forall a. Maybe a
Prelude.Nothing,
      $sel:retentionInDays:LogGroup' :: Maybe Int
retentionInDays = forall a. Maybe a
Prelude.Nothing,
      $sel:storedBytes:LogGroup' :: Maybe Natural
storedBytes = forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) of the log group.
logGroup_arn :: Lens.Lens' LogGroup (Prelude.Maybe Prelude.Text)
logGroup_arn :: Lens' LogGroup (Maybe Text)
logGroup_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogGroup' {Maybe Text
arn :: Maybe Text
$sel:arn:LogGroup' :: LogGroup -> Maybe Text
arn} -> Maybe Text
arn) (\s :: LogGroup
s@LogGroup' {} Maybe Text
a -> LogGroup
s {$sel:arn:LogGroup' :: Maybe Text
arn = Maybe Text
a} :: LogGroup)

-- | The creation time of the log group, expressed as the number of
-- milliseconds after Jan 1, 1970 00:00:00 UTC.
logGroup_creationTime :: Lens.Lens' LogGroup (Prelude.Maybe Prelude.Natural)
logGroup_creationTime :: Lens' LogGroup (Maybe Natural)
logGroup_creationTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogGroup' {Maybe Natural
creationTime :: Maybe Natural
$sel:creationTime:LogGroup' :: LogGroup -> Maybe Natural
creationTime} -> Maybe Natural
creationTime) (\s :: LogGroup
s@LogGroup' {} Maybe Natural
a -> LogGroup
s {$sel:creationTime:LogGroup' :: Maybe Natural
creationTime = Maybe Natural
a} :: LogGroup)

-- | Displays whether this log group has a protection policy, or whether it
-- had one in the past. For more information, see
-- <https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutDataProtectionPolicy.html PutDataProtectionPolicy>.
logGroup_dataProtectionStatus :: Lens.Lens' LogGroup (Prelude.Maybe DataProtectionStatus)
logGroup_dataProtectionStatus :: Lens' LogGroup (Maybe DataProtectionStatus)
logGroup_dataProtectionStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogGroup' {Maybe DataProtectionStatus
dataProtectionStatus :: Maybe DataProtectionStatus
$sel:dataProtectionStatus:LogGroup' :: LogGroup -> Maybe DataProtectionStatus
dataProtectionStatus} -> Maybe DataProtectionStatus
dataProtectionStatus) (\s :: LogGroup
s@LogGroup' {} Maybe DataProtectionStatus
a -> LogGroup
s {$sel:dataProtectionStatus:LogGroup' :: Maybe DataProtectionStatus
dataProtectionStatus = Maybe DataProtectionStatus
a} :: LogGroup)

-- | The Amazon Resource Name (ARN) of the KMS key to use when encrypting log
-- data.
logGroup_kmsKeyId :: Lens.Lens' LogGroup (Prelude.Maybe Prelude.Text)
logGroup_kmsKeyId :: Lens' LogGroup (Maybe Text)
logGroup_kmsKeyId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogGroup' {Maybe Text
kmsKeyId :: Maybe Text
$sel:kmsKeyId:LogGroup' :: LogGroup -> Maybe Text
kmsKeyId} -> Maybe Text
kmsKeyId) (\s :: LogGroup
s@LogGroup' {} Maybe Text
a -> LogGroup
s {$sel:kmsKeyId:LogGroup' :: Maybe Text
kmsKeyId = Maybe Text
a} :: LogGroup)

-- | The name of the log group.
logGroup_logGroupName :: Lens.Lens' LogGroup (Prelude.Maybe Prelude.Text)
logGroup_logGroupName :: Lens' LogGroup (Maybe Text)
logGroup_logGroupName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogGroup' {Maybe Text
logGroupName :: Maybe Text
$sel:logGroupName:LogGroup' :: LogGroup -> Maybe Text
logGroupName} -> Maybe Text
logGroupName) (\s :: LogGroup
s@LogGroup' {} Maybe Text
a -> LogGroup
s {$sel:logGroupName:LogGroup' :: Maybe Text
logGroupName = Maybe Text
a} :: LogGroup)

-- | The number of metric filters.
logGroup_metricFilterCount :: Lens.Lens' LogGroup (Prelude.Maybe Prelude.Int)
logGroup_metricFilterCount :: Lens' LogGroup (Maybe Int)
logGroup_metricFilterCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogGroup' {Maybe Int
metricFilterCount :: Maybe Int
$sel:metricFilterCount:LogGroup' :: LogGroup -> Maybe Int
metricFilterCount} -> Maybe Int
metricFilterCount) (\s :: LogGroup
s@LogGroup' {} Maybe Int
a -> LogGroup
s {$sel:metricFilterCount:LogGroup' :: Maybe Int
metricFilterCount = Maybe Int
a} :: LogGroup)

-- | Undocumented member.
logGroup_retentionInDays :: Lens.Lens' LogGroup (Prelude.Maybe Prelude.Int)
logGroup_retentionInDays :: Lens' LogGroup (Maybe Int)
logGroup_retentionInDays = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogGroup' {Maybe Int
retentionInDays :: Maybe Int
$sel:retentionInDays:LogGroup' :: LogGroup -> Maybe Int
retentionInDays} -> Maybe Int
retentionInDays) (\s :: LogGroup
s@LogGroup' {} Maybe Int
a -> LogGroup
s {$sel:retentionInDays:LogGroup' :: Maybe Int
retentionInDays = Maybe Int
a} :: LogGroup)

-- | The number of bytes stored.
logGroup_storedBytes :: Lens.Lens' LogGroup (Prelude.Maybe Prelude.Natural)
logGroup_storedBytes :: Lens' LogGroup (Maybe Natural)
logGroup_storedBytes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogGroup' {Maybe Natural
storedBytes :: Maybe Natural
$sel:storedBytes:LogGroup' :: LogGroup -> Maybe Natural
storedBytes} -> Maybe Natural
storedBytes) (\s :: LogGroup
s@LogGroup' {} Maybe Natural
a -> LogGroup
s {$sel:storedBytes:LogGroup' :: Maybe Natural
storedBytes = Maybe Natural
a} :: LogGroup)

instance Data.FromJSON LogGroup where
  parseJSON :: Value -> Parser LogGroup
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"LogGroup"
      ( \Object
x ->
          Maybe Text
-> Maybe Natural
-> Maybe DataProtectionStatus
-> Maybe Text
-> Maybe Text
-> Maybe Int
-> Maybe Int
-> Maybe Natural
-> LogGroup
LogGroup'
            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
"arn")
            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
"creationTime")
            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
"dataProtectionStatus")
            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
"kmsKeyId")
            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
"logGroupName")
            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
"metricFilterCount")
            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
"retentionInDays")
            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
"storedBytes")
      )

instance Prelude.Hashable LogGroup where
  hashWithSalt :: Int -> LogGroup -> Int
hashWithSalt Int
_salt LogGroup' {Maybe Int
Maybe Natural
Maybe Text
Maybe DataProtectionStatus
storedBytes :: Maybe Natural
retentionInDays :: Maybe Int
metricFilterCount :: Maybe Int
logGroupName :: Maybe Text
kmsKeyId :: Maybe Text
dataProtectionStatus :: Maybe DataProtectionStatus
creationTime :: Maybe Natural
arn :: Maybe Text
$sel:storedBytes:LogGroup' :: LogGroup -> Maybe Natural
$sel:retentionInDays:LogGroup' :: LogGroup -> Maybe Int
$sel:metricFilterCount:LogGroup' :: LogGroup -> Maybe Int
$sel:logGroupName:LogGroup' :: LogGroup -> Maybe Text
$sel:kmsKeyId:LogGroup' :: LogGroup -> Maybe Text
$sel:dataProtectionStatus:LogGroup' :: LogGroup -> Maybe DataProtectionStatus
$sel:creationTime:LogGroup' :: LogGroup -> Maybe Natural
$sel:arn:LogGroup' :: LogGroup -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
arn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
creationTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe DataProtectionStatus
dataProtectionStatus
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
kmsKeyId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
logGroupName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
metricFilterCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
retentionInDays
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
storedBytes

instance Prelude.NFData LogGroup where
  rnf :: LogGroup -> ()
rnf LogGroup' {Maybe Int
Maybe Natural
Maybe Text
Maybe DataProtectionStatus
storedBytes :: Maybe Natural
retentionInDays :: Maybe Int
metricFilterCount :: Maybe Int
logGroupName :: Maybe Text
kmsKeyId :: Maybe Text
dataProtectionStatus :: Maybe DataProtectionStatus
creationTime :: Maybe Natural
arn :: Maybe Text
$sel:storedBytes:LogGroup' :: LogGroup -> Maybe Natural
$sel:retentionInDays:LogGroup' :: LogGroup -> Maybe Int
$sel:metricFilterCount:LogGroup' :: LogGroup -> Maybe Int
$sel:logGroupName:LogGroup' :: LogGroup -> Maybe Text
$sel:kmsKeyId:LogGroup' :: LogGroup -> Maybe Text
$sel:dataProtectionStatus:LogGroup' :: LogGroup -> Maybe DataProtectionStatus
$sel:creationTime:LogGroup' :: LogGroup -> Maybe Natural
$sel:arn:LogGroup' :: LogGroup -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
creationTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe DataProtectionStatus
dataProtectionStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
kmsKeyId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
logGroupName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
metricFilterCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
retentionInDays
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
storedBytes