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

import Amazonka.CodeBuild.Types.LogsConfigStatusType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(CloudWatchLogsConfig -> CloudWatchLogsConfig -> Bool)
-> (CloudWatchLogsConfig -> CloudWatchLogsConfig -> Bool)
-> Eq CloudWatchLogsConfig
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]
(Int -> ReadS CloudWatchLogsConfig)
-> ReadS [CloudWatchLogsConfig]
-> ReadPrec CloudWatchLogsConfig
-> ReadPrec [CloudWatchLogsConfig]
-> Read 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
(Int -> CloudWatchLogsConfig -> ShowS)
-> (CloudWatchLogsConfig -> String)
-> ([CloudWatchLogsConfig] -> ShowS)
-> Show CloudWatchLogsConfig
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. CloudWatchLogsConfig -> Rep CloudWatchLogsConfig x)
-> (forall x. Rep CloudWatchLogsConfig x -> CloudWatchLogsConfig)
-> Generic CloudWatchLogsConfig
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' :: Maybe Text
-> Maybe Text -> LogsConfigStatusType -> CloudWatchLogsConfig
CloudWatchLogsConfig'
    { $sel:groupName:CloudWatchLogsConfig' :: Maybe Text
groupName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:streamName:CloudWatchLogsConfig' :: Maybe Text
streamName = Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> CloudWatchLogsConfig -> f CloudWatchLogsConfig
cloudWatchLogsConfig_groupName = (CloudWatchLogsConfig -> Maybe Text)
-> (CloudWatchLogsConfig -> Maybe Text -> CloudWatchLogsConfig)
-> Lens
     CloudWatchLogsConfig CloudWatchLogsConfig (Maybe Text) (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text))
-> CloudWatchLogsConfig -> f CloudWatchLogsConfig
cloudWatchLogsConfig_streamName = (CloudWatchLogsConfig -> Maybe Text)
-> (CloudWatchLogsConfig -> Maybe Text -> CloudWatchLogsConfig)
-> Lens
     CloudWatchLogsConfig CloudWatchLogsConfig (Maybe Text) (Maybe Text)
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 :: (LogsConfigStatusType -> f LogsConfigStatusType)
-> CloudWatchLogsConfig -> f CloudWatchLogsConfig
cloudWatchLogsConfig_status = (CloudWatchLogsConfig -> LogsConfigStatusType)
-> (CloudWatchLogsConfig
    -> LogsConfigStatusType -> CloudWatchLogsConfig)
-> Lens
     CloudWatchLogsConfig
     CloudWatchLogsConfig
     LogsConfigStatusType
     LogsConfigStatusType
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 Core.FromJSON CloudWatchLogsConfig where
  parseJSON :: Value -> Parser CloudWatchLogsConfig
parseJSON =
    String
-> (Object -> Parser CloudWatchLogsConfig)
-> Value
-> Parser CloudWatchLogsConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CloudWatchLogsConfig"
      ( \Object
x ->
          Maybe Text
-> Maybe Text -> LogsConfigStatusType -> CloudWatchLogsConfig
CloudWatchLogsConfig'
            (Maybe Text
 -> Maybe Text -> LogsConfigStatusType -> CloudWatchLogsConfig)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> LogsConfigStatusType -> CloudWatchLogsConfig)
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
"groupName")
            Parser (Maybe Text -> LogsConfigStatusType -> CloudWatchLogsConfig)
-> Parser (Maybe Text)
-> Parser (LogsConfigStatusType -> CloudWatchLogsConfig)
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
"streamName")
            Parser (LogsConfigStatusType -> CloudWatchLogsConfig)
-> Parser LogsConfigStatusType -> Parser CloudWatchLogsConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser LogsConfigStatusType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"status")
      )

instance Prelude.Hashable CloudWatchLogsConfig

instance Prelude.NFData CloudWatchLogsConfig

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"groupName" 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
groupName,
            (Text
"streamName" 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
streamName,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"status" Text -> LogsConfigStatusType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= LogsConfigStatusType
status)
          ]
      )