{-# 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.CodeBuild.Types.CloudWatchLogsConfig
-- 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.CodeBuild.Types.CloudWatchLogsConfig where

import Amazonka.CodeBuild.Types.LogsConfigStatusType
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

-- | Information about CloudWatch Logs for a build project.
--
-- /See:/ 'newCloudWatchLogsConfig' smart constructor.
data CloudWatchLogsConfig = CloudWatchLogsConfig'
  { -- | The group name of the logs in CloudWatch Logs. For more information, see
    -- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/Working-with-log-groups-and-streams.html Working with Log Groups and Log Streams>.
    CloudWatchLogsConfig -> Maybe Text
groupName :: Prelude.Maybe Prelude.Text,
    -- | The prefix of the stream name of the CloudWatch Logs. For more
    -- information, see
    -- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/Working-with-log-groups-and-streams.html Working with Log Groups and Log Streams>.
    CloudWatchLogsConfig -> Maybe Text
streamName :: Prelude.Maybe Prelude.Text,
    -- | The current status of the logs in CloudWatch Logs for a build project.
    -- Valid values are:
    --
    -- -   @ENABLED@: CloudWatch Logs are enabled for this build project.
    --
    -- -   @DISABLED@: CloudWatch Logs are not enabled for this build project.
    CloudWatchLogsConfig -> LogsConfigStatusType
status :: LogsConfigStatusType
  }
  deriving (CloudWatchLogsConfig -> CloudWatchLogsConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CloudWatchLogsConfig -> CloudWatchLogsConfig -> Bool
$c/= :: CloudWatchLogsConfig -> CloudWatchLogsConfig -> Bool
== :: CloudWatchLogsConfig -> CloudWatchLogsConfig -> Bool
$c== :: CloudWatchLogsConfig -> CloudWatchLogsConfig -> Bool
Prelude.Eq, ReadPrec [CloudWatchLogsConfig]
ReadPrec CloudWatchLogsConfig
Int -> ReadS CloudWatchLogsConfig
ReadS [CloudWatchLogsConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CloudWatchLogsConfig]
$creadListPrec :: ReadPrec [CloudWatchLogsConfig]
readPrec :: ReadPrec CloudWatchLogsConfig
$creadPrec :: ReadPrec CloudWatchLogsConfig
readList :: ReadS [CloudWatchLogsConfig]
$creadList :: ReadS [CloudWatchLogsConfig]
readsPrec :: Int -> ReadS CloudWatchLogsConfig
$creadsPrec :: Int -> ReadS CloudWatchLogsConfig
Prelude.Read, Int -> CloudWatchLogsConfig -> ShowS
[CloudWatchLogsConfig] -> ShowS
CloudWatchLogsConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CloudWatchLogsConfig] -> ShowS
$cshowList :: [CloudWatchLogsConfig] -> ShowS
show :: CloudWatchLogsConfig -> String
$cshow :: CloudWatchLogsConfig -> String
showsPrec :: Int -> CloudWatchLogsConfig -> ShowS
$cshowsPrec :: Int -> CloudWatchLogsConfig -> ShowS
Prelude.Show, forall x. Rep CloudWatchLogsConfig x -> CloudWatchLogsConfig
forall x. CloudWatchLogsConfig -> Rep CloudWatchLogsConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CloudWatchLogsConfig x -> CloudWatchLogsConfig
$cfrom :: forall x. CloudWatchLogsConfig -> Rep CloudWatchLogsConfig x
Prelude.Generic)

-- |
-- Create a value of 'CloudWatchLogsConfig' 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:
--
-- 'groupName', 'cloudWatchLogsConfig_groupName' - The group name of the logs in CloudWatch Logs. For more information, see
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/Working-with-log-groups-and-streams.html Working with Log Groups and Log Streams>.
--
-- 'streamName', 'cloudWatchLogsConfig_streamName' - The prefix of the stream name of the CloudWatch Logs. For more
-- information, see
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/Working-with-log-groups-and-streams.html Working with Log Groups and Log Streams>.
--
-- 'status', 'cloudWatchLogsConfig_status' - The current status of the logs in CloudWatch Logs for a build project.
-- Valid values are:
--
-- -   @ENABLED@: CloudWatch Logs are enabled for this build project.
--
-- -   @DISABLED@: CloudWatch Logs are not enabled for this build project.
newCloudWatchLogsConfig ::
  -- | 'status'
  LogsConfigStatusType ->
  CloudWatchLogsConfig
newCloudWatchLogsConfig :: LogsConfigStatusType -> CloudWatchLogsConfig
newCloudWatchLogsConfig LogsConfigStatusType
pStatus_ =
  CloudWatchLogsConfig'
    { $sel:groupName:CloudWatchLogsConfig' :: Maybe Text
groupName = forall a. Maybe a
Prelude.Nothing,
      $sel:streamName:CloudWatchLogsConfig' :: Maybe Text
streamName = forall a. Maybe a
Prelude.Nothing,
      $sel:status:CloudWatchLogsConfig' :: LogsConfigStatusType
status = LogsConfigStatusType
pStatus_
    }

-- | The group name of the logs in CloudWatch Logs. For more information, see
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/Working-with-log-groups-and-streams.html Working with Log Groups and Log Streams>.
cloudWatchLogsConfig_groupName :: Lens.Lens' CloudWatchLogsConfig (Prelude.Maybe Prelude.Text)
cloudWatchLogsConfig_groupName :: Lens' CloudWatchLogsConfig (Maybe Text)
cloudWatchLogsConfig_groupName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloudWatchLogsConfig' {Maybe Text
groupName :: Maybe Text
$sel:groupName:CloudWatchLogsConfig' :: CloudWatchLogsConfig -> Maybe Text
groupName} -> Maybe Text
groupName) (\s :: CloudWatchLogsConfig
s@CloudWatchLogsConfig' {} Maybe Text
a -> CloudWatchLogsConfig
s {$sel:groupName:CloudWatchLogsConfig' :: Maybe Text
groupName = Maybe Text
a} :: CloudWatchLogsConfig)

-- | The prefix of the stream name of the CloudWatch Logs. For more
-- information, see
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/Working-with-log-groups-and-streams.html Working with Log Groups and Log Streams>.
cloudWatchLogsConfig_streamName :: Lens.Lens' CloudWatchLogsConfig (Prelude.Maybe Prelude.Text)
cloudWatchLogsConfig_streamName :: Lens' CloudWatchLogsConfig (Maybe Text)
cloudWatchLogsConfig_streamName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloudWatchLogsConfig' {Maybe Text
streamName :: Maybe Text
$sel:streamName:CloudWatchLogsConfig' :: CloudWatchLogsConfig -> Maybe Text
streamName} -> Maybe Text
streamName) (\s :: CloudWatchLogsConfig
s@CloudWatchLogsConfig' {} Maybe Text
a -> CloudWatchLogsConfig
s {$sel:streamName:CloudWatchLogsConfig' :: Maybe Text
streamName = Maybe Text
a} :: CloudWatchLogsConfig)

-- | The current status of the logs in CloudWatch Logs for a build project.
-- Valid values are:
--
-- -   @ENABLED@: CloudWatch Logs are enabled for this build project.
--
-- -   @DISABLED@: CloudWatch Logs are not enabled for this build project.
cloudWatchLogsConfig_status :: Lens.Lens' CloudWatchLogsConfig LogsConfigStatusType
cloudWatchLogsConfig_status :: Lens' CloudWatchLogsConfig LogsConfigStatusType
cloudWatchLogsConfig_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloudWatchLogsConfig' {LogsConfigStatusType
status :: LogsConfigStatusType
$sel:status:CloudWatchLogsConfig' :: CloudWatchLogsConfig -> LogsConfigStatusType
status} -> LogsConfigStatusType
status) (\s :: CloudWatchLogsConfig
s@CloudWatchLogsConfig' {} LogsConfigStatusType
a -> CloudWatchLogsConfig
s {$sel:status:CloudWatchLogsConfig' :: LogsConfigStatusType
status = LogsConfigStatusType
a} :: CloudWatchLogsConfig)

instance Data.FromJSON CloudWatchLogsConfig where
  parseJSON :: Value -> Parser CloudWatchLogsConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CloudWatchLogsConfig"
      ( \Object
x ->
          Maybe Text
-> Maybe Text -> LogsConfigStatusType -> CloudWatchLogsConfig
CloudWatchLogsConfig'
            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
"groupName")
            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
"streamName")
            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
"status")
      )

instance Prelude.Hashable CloudWatchLogsConfig where
  hashWithSalt :: Int -> CloudWatchLogsConfig -> Int
hashWithSalt Int
_salt CloudWatchLogsConfig' {Maybe Text
LogsConfigStatusType
status :: LogsConfigStatusType
streamName :: Maybe Text
groupName :: Maybe Text
$sel:status:CloudWatchLogsConfig' :: CloudWatchLogsConfig -> LogsConfigStatusType
$sel:streamName:CloudWatchLogsConfig' :: CloudWatchLogsConfig -> Maybe Text
$sel:groupName:CloudWatchLogsConfig' :: CloudWatchLogsConfig -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
groupName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
streamName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` LogsConfigStatusType
status

instance Prelude.NFData CloudWatchLogsConfig where
  rnf :: CloudWatchLogsConfig -> ()
rnf CloudWatchLogsConfig' {Maybe Text
LogsConfigStatusType
status :: LogsConfigStatusType
streamName :: Maybe Text
groupName :: Maybe Text
$sel:status:CloudWatchLogsConfig' :: CloudWatchLogsConfig -> LogsConfigStatusType
$sel:streamName:CloudWatchLogsConfig' :: CloudWatchLogsConfig -> Maybe Text
$sel:groupName:CloudWatchLogsConfig' :: CloudWatchLogsConfig -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
groupName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
streamName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf LogsConfigStatusType
status

instance Data.ToJSON CloudWatchLogsConfig where
  toJSON :: CloudWatchLogsConfig -> Value
toJSON CloudWatchLogsConfig' {Maybe Text
LogsConfigStatusType
status :: LogsConfigStatusType
streamName :: Maybe Text
groupName :: Maybe Text
$sel:status:CloudWatchLogsConfig' :: CloudWatchLogsConfig -> LogsConfigStatusType
$sel:streamName:CloudWatchLogsConfig' :: CloudWatchLogsConfig -> Maybe Text
$sel:groupName:CloudWatchLogsConfig' :: CloudWatchLogsConfig -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"groupName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
groupName,
            (Key
"streamName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
streamName,
            forall a. a -> Maybe a
Prelude.Just (Key
"status" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= LogsConfigStatusType
status)
          ]
      )