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

import Amazonka.CodeBuild.Types.BucketOwnerAccess
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 S3 logs for a build project.
--
-- /See:/ 'newS3LogsConfig' smart constructor.
data S3LogsConfig = S3LogsConfig'
  { S3LogsConfig -> Maybe BucketOwnerAccess
bucketOwnerAccess :: Prelude.Maybe BucketOwnerAccess,
    -- | 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,
    -- | 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,
    -- | 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
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]
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
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. 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:
--
-- 'bucketOwnerAccess', 's3LogsConfig_bucketOwnerAccess' - Undocumented member.
--
-- 'encryptionDisabled', 's3LogsConfig_encryptionDisabled' - Set to true if you do not want your S3 build log output encrypted. By
-- default S3 build logs are encrypted.
--
-- '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@.
--
-- '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'
    { $sel:bucketOwnerAccess:S3LogsConfig' :: Maybe BucketOwnerAccess
bucketOwnerAccess = forall a. Maybe a
Prelude.Nothing,
      $sel:encryptionDisabled:S3LogsConfig' :: Maybe Bool
encryptionDisabled = forall a. Maybe a
Prelude.Nothing,
      $sel:location:S3LogsConfig' :: Maybe Text
location = forall a. Maybe a
Prelude.Nothing,
      $sel:status:S3LogsConfig' :: LogsConfigStatusType
status = LogsConfigStatusType
pStatus_
    }

-- | Undocumented member.
s3LogsConfig_bucketOwnerAccess :: Lens.Lens' S3LogsConfig (Prelude.Maybe BucketOwnerAccess)
s3LogsConfig_bucketOwnerAccess :: Lens' S3LogsConfig (Maybe BucketOwnerAccess)
s3LogsConfig_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)

-- | 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 :: Lens' S3LogsConfig (Maybe Bool)
s3LogsConfig_encryptionDisabled = 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)

-- | 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 :: Lens' S3LogsConfig (Maybe Text)
s3LogsConfig_location = 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)

-- | 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 :: Lens' S3LogsConfig LogsConfigStatusType
s3LogsConfig_status = 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 Data.FromJSON S3LogsConfig where
  parseJSON :: Value -> Parser S3LogsConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"S3LogsConfig"
      ( \Object
x ->
          Maybe BucketOwnerAccess
-> Maybe Bool -> Maybe Text -> LogsConfigStatusType -> S3LogsConfig
S3LogsConfig'
            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
"bucketOwnerAccess")
            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
"encryptionDisabled")
            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
"location")
            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 S3LogsConfig where
  hashWithSalt :: Int -> S3LogsConfig -> Int
hashWithSalt Int
_salt S3LogsConfig' {Maybe Bool
Maybe Text
Maybe BucketOwnerAccess
LogsConfigStatusType
status :: LogsConfigStatusType
location :: Maybe Text
encryptionDisabled :: Maybe Bool
bucketOwnerAccess :: Maybe BucketOwnerAccess
$sel:status:S3LogsConfig' :: S3LogsConfig -> LogsConfigStatusType
$sel:location:S3LogsConfig' :: S3LogsConfig -> Maybe Text
$sel:encryptionDisabled:S3LogsConfig' :: S3LogsConfig -> Maybe Bool
$sel:bucketOwnerAccess:S3LogsConfig' :: S3LogsConfig -> Maybe BucketOwnerAccess
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe BucketOwnerAccess
bucketOwnerAccess
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
encryptionDisabled
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
location
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` LogsConfigStatusType
status

instance Prelude.NFData S3LogsConfig where
  rnf :: S3LogsConfig -> ()
rnf S3LogsConfig' {Maybe Bool
Maybe Text
Maybe BucketOwnerAccess
LogsConfigStatusType
status :: LogsConfigStatusType
location :: Maybe Text
encryptionDisabled :: Maybe Bool
bucketOwnerAccess :: Maybe BucketOwnerAccess
$sel:status:S3LogsConfig' :: S3LogsConfig -> LogsConfigStatusType
$sel:location:S3LogsConfig' :: S3LogsConfig -> Maybe Text
$sel:encryptionDisabled:S3LogsConfig' :: S3LogsConfig -> Maybe Bool
$sel:bucketOwnerAccess:S3LogsConfig' :: S3LogsConfig -> Maybe BucketOwnerAccess
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe BucketOwnerAccess
bucketOwnerAccess
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
encryptionDisabled
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
location
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf LogsConfigStatusType
status

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