{-# 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.S3LogsConfig
-- 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.S3LogsConfig where

import Amazonka.CodeBuild.Types.BucketOwnerAccess
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 S3 logs for a build project.
--
-- /See:/ 'newS3LogsConfig' smart constructor.
data S3LogsConfig = S3LogsConfig'
  { -- | The ARN of an S3 bucket and the path prefix for S3 logs. If your Amazon
    -- S3 bucket name is @my-bucket@, and your path prefix is @build-log@, then
    -- acceptable formats are @my-bucket\/build-log@ or
    -- @arn:aws:s3:::my-bucket\/build-log@.
    S3LogsConfig -> Maybe Text
location :: Prelude.Maybe Prelude.Text,
    -- | Set to true if you do not want your S3 build log output encrypted. By
    -- default S3 build logs are encrypted.
    S3LogsConfig -> Maybe Bool
encryptionDisabled :: Prelude.Maybe Prelude.Bool,
    S3LogsConfig -> Maybe BucketOwnerAccess
bucketOwnerAccess :: Prelude.Maybe BucketOwnerAccess,
    -- | The current status of the S3 build logs. Valid values are:
    --
    -- -   @ENABLED@: S3 build logs are enabled for this build project.
    --
    -- -   @DISABLED@: S3 build logs are not enabled for this build project.
    S3LogsConfig -> LogsConfigStatusType
status :: LogsConfigStatusType
  }
  deriving (S3LogsConfig -> S3LogsConfig -> Bool
(S3LogsConfig -> S3LogsConfig -> Bool)
-> (S3LogsConfig -> S3LogsConfig -> Bool) -> Eq S3LogsConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3LogsConfig -> S3LogsConfig -> Bool
$c/= :: S3LogsConfig -> S3LogsConfig -> Bool
== :: S3LogsConfig -> S3LogsConfig -> Bool
$c== :: S3LogsConfig -> S3LogsConfig -> Bool
Prelude.Eq, ReadPrec [S3LogsConfig]
ReadPrec S3LogsConfig
Int -> ReadS S3LogsConfig
ReadS [S3LogsConfig]
(Int -> ReadS S3LogsConfig)
-> ReadS [S3LogsConfig]
-> ReadPrec S3LogsConfig
-> ReadPrec [S3LogsConfig]
-> Read S3LogsConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3LogsConfig]
$creadListPrec :: ReadPrec [S3LogsConfig]
readPrec :: ReadPrec S3LogsConfig
$creadPrec :: ReadPrec S3LogsConfig
readList :: ReadS [S3LogsConfig]
$creadList :: ReadS [S3LogsConfig]
readsPrec :: Int -> ReadS S3LogsConfig
$creadsPrec :: Int -> ReadS S3LogsConfig
Prelude.Read, Int -> S3LogsConfig -> ShowS
[S3LogsConfig] -> ShowS
S3LogsConfig -> String
(Int -> S3LogsConfig -> ShowS)
-> (S3LogsConfig -> String)
-> ([S3LogsConfig] -> ShowS)
-> Show S3LogsConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3LogsConfig] -> ShowS
$cshowList :: [S3LogsConfig] -> ShowS
show :: S3LogsConfig -> String
$cshow :: S3LogsConfig -> String
showsPrec :: Int -> S3LogsConfig -> ShowS
$cshowsPrec :: Int -> S3LogsConfig -> ShowS
Prelude.Show, (forall x. S3LogsConfig -> Rep S3LogsConfig x)
-> (forall x. Rep S3LogsConfig x -> S3LogsConfig)
-> Generic S3LogsConfig
forall x. Rep S3LogsConfig x -> S3LogsConfig
forall x. S3LogsConfig -> Rep S3LogsConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3LogsConfig x -> S3LogsConfig
$cfrom :: forall x. S3LogsConfig -> Rep S3LogsConfig x
Prelude.Generic)

-- |
-- Create a value of 'S3LogsConfig' 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:
--
-- 'location', 's3LogsConfig_location' - The ARN of an S3 bucket and the path prefix for S3 logs. If your Amazon
-- S3 bucket name is @my-bucket@, and your path prefix is @build-log@, then
-- acceptable formats are @my-bucket\/build-log@ or
-- @arn:aws:s3:::my-bucket\/build-log@.
--
-- 'encryptionDisabled', 's3LogsConfig_encryptionDisabled' - Set to true if you do not want your S3 build log output encrypted. By
-- default S3 build logs are encrypted.
--
-- 'bucketOwnerAccess', 's3LogsConfig_bucketOwnerAccess' - Undocumented member.
--
-- 'status', 's3LogsConfig_status' - The current status of the S3 build logs. Valid values are:
--
-- -   @ENABLED@: S3 build logs are enabled for this build project.
--
-- -   @DISABLED@: S3 build logs are not enabled for this build project.
newS3LogsConfig ::
  -- | 'status'
  LogsConfigStatusType ->
  S3LogsConfig
newS3LogsConfig :: LogsConfigStatusType -> S3LogsConfig
newS3LogsConfig LogsConfigStatusType
pStatus_ =
  S3LogsConfig' :: Maybe Text
-> Maybe Bool
-> Maybe BucketOwnerAccess
-> LogsConfigStatusType
-> S3LogsConfig
S3LogsConfig'
    { $sel:location:S3LogsConfig' :: Maybe Text
location = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:encryptionDisabled:S3LogsConfig' :: Maybe Bool
encryptionDisabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:bucketOwnerAccess:S3LogsConfig' :: Maybe BucketOwnerAccess
bucketOwnerAccess = Maybe BucketOwnerAccess
forall a. Maybe a
Prelude.Nothing,
      $sel:status:S3LogsConfig' :: LogsConfigStatusType
status = LogsConfigStatusType
pStatus_
    }

-- | The ARN of an S3 bucket and the path prefix for S3 logs. If your Amazon
-- S3 bucket name is @my-bucket@, and your path prefix is @build-log@, then
-- acceptable formats are @my-bucket\/build-log@ or
-- @arn:aws:s3:::my-bucket\/build-log@.
s3LogsConfig_location :: Lens.Lens' S3LogsConfig (Prelude.Maybe Prelude.Text)
s3LogsConfig_location :: (Maybe Text -> f (Maybe Text)) -> S3LogsConfig -> f S3LogsConfig
s3LogsConfig_location = (S3LogsConfig -> Maybe Text)
-> (S3LogsConfig -> Maybe Text -> S3LogsConfig)
-> Lens S3LogsConfig S3LogsConfig (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3LogsConfig' {Maybe Text
location :: Maybe Text
$sel:location:S3LogsConfig' :: S3LogsConfig -> Maybe Text
location} -> Maybe Text
location) (\s :: S3LogsConfig
s@S3LogsConfig' {} Maybe Text
a -> S3LogsConfig
s {$sel:location:S3LogsConfig' :: Maybe Text
location = Maybe Text
a} :: S3LogsConfig)

-- | Set to true if you do not want your S3 build log output encrypted. By
-- default S3 build logs are encrypted.
s3LogsConfig_encryptionDisabled :: Lens.Lens' S3LogsConfig (Prelude.Maybe Prelude.Bool)
s3LogsConfig_encryptionDisabled :: (Maybe Bool -> f (Maybe Bool)) -> S3LogsConfig -> f S3LogsConfig
s3LogsConfig_encryptionDisabled = (S3LogsConfig -> Maybe Bool)
-> (S3LogsConfig -> Maybe Bool -> S3LogsConfig)
-> Lens S3LogsConfig S3LogsConfig (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3LogsConfig' {Maybe Bool
encryptionDisabled :: Maybe Bool
$sel:encryptionDisabled:S3LogsConfig' :: S3LogsConfig -> Maybe Bool
encryptionDisabled} -> Maybe Bool
encryptionDisabled) (\s :: S3LogsConfig
s@S3LogsConfig' {} Maybe Bool
a -> S3LogsConfig
s {$sel:encryptionDisabled:S3LogsConfig' :: Maybe Bool
encryptionDisabled = Maybe Bool
a} :: S3LogsConfig)

-- | Undocumented member.
s3LogsConfig_bucketOwnerAccess :: Lens.Lens' S3LogsConfig (Prelude.Maybe BucketOwnerAccess)
s3LogsConfig_bucketOwnerAccess :: (Maybe BucketOwnerAccess -> f (Maybe BucketOwnerAccess))
-> S3LogsConfig -> f S3LogsConfig
s3LogsConfig_bucketOwnerAccess = (S3LogsConfig -> Maybe BucketOwnerAccess)
-> (S3LogsConfig -> Maybe BucketOwnerAccess -> S3LogsConfig)
-> Lens
     S3LogsConfig
     S3LogsConfig
     (Maybe BucketOwnerAccess)
     (Maybe BucketOwnerAccess)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3LogsConfig' {Maybe BucketOwnerAccess
bucketOwnerAccess :: Maybe BucketOwnerAccess
$sel:bucketOwnerAccess:S3LogsConfig' :: S3LogsConfig -> Maybe BucketOwnerAccess
bucketOwnerAccess} -> Maybe BucketOwnerAccess
bucketOwnerAccess) (\s :: S3LogsConfig
s@S3LogsConfig' {} Maybe BucketOwnerAccess
a -> S3LogsConfig
s {$sel:bucketOwnerAccess:S3LogsConfig' :: Maybe BucketOwnerAccess
bucketOwnerAccess = Maybe BucketOwnerAccess
a} :: S3LogsConfig)

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

instance Core.FromJSON S3LogsConfig where
  parseJSON :: Value -> Parser S3LogsConfig
parseJSON =
    String
-> (Object -> Parser S3LogsConfig) -> Value -> Parser S3LogsConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"S3LogsConfig"
      ( \Object
x ->
          Maybe Text
-> Maybe Bool
-> Maybe BucketOwnerAccess
-> LogsConfigStatusType
-> S3LogsConfig
S3LogsConfig'
            (Maybe Text
 -> Maybe Bool
 -> Maybe BucketOwnerAccess
 -> LogsConfigStatusType
 -> S3LogsConfig)
-> Parser (Maybe Text)
-> Parser
     (Maybe Bool
      -> Maybe BucketOwnerAccess -> LogsConfigStatusType -> S3LogsConfig)
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
"location")
            Parser
  (Maybe Bool
   -> Maybe BucketOwnerAccess -> LogsConfigStatusType -> S3LogsConfig)
-> Parser (Maybe Bool)
-> Parser
     (Maybe BucketOwnerAccess -> LogsConfigStatusType -> S3LogsConfig)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"encryptionDisabled")
            Parser
  (Maybe BucketOwnerAccess -> LogsConfigStatusType -> S3LogsConfig)
-> Parser (Maybe BucketOwnerAccess)
-> Parser (LogsConfigStatusType -> S3LogsConfig)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe BucketOwnerAccess)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"bucketOwnerAccess")
            Parser (LogsConfigStatusType -> S3LogsConfig)
-> Parser LogsConfigStatusType -> Parser S3LogsConfig
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 S3LogsConfig

instance Prelude.NFData S3LogsConfig

instance Core.ToJSON S3LogsConfig where
  toJSON :: S3LogsConfig -> Value
toJSON S3LogsConfig' {Maybe Bool
Maybe Text
Maybe BucketOwnerAccess
LogsConfigStatusType
status :: LogsConfigStatusType
bucketOwnerAccess :: Maybe BucketOwnerAccess
encryptionDisabled :: Maybe Bool
location :: Maybe Text
$sel:status:S3LogsConfig' :: S3LogsConfig -> LogsConfigStatusType
$sel:bucketOwnerAccess:S3LogsConfig' :: S3LogsConfig -> Maybe BucketOwnerAccess
$sel:encryptionDisabled:S3LogsConfig' :: S3LogsConfig -> Maybe Bool
$sel:location:S3LogsConfig' :: S3LogsConfig -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"location" 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
location,
            (Text
"encryptionDisabled" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
encryptionDisabled,
            (Text
"bucketOwnerAccess" Text -> BucketOwnerAccess -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (BucketOwnerAccess -> Pair)
-> Maybe BucketOwnerAccess -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe BucketOwnerAccess
bucketOwnerAccess,
            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)
          ]
      )