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

import Amazonka.CodeBuild.Types.ReportPackagingType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about the S3 bucket where the raw data of a report are
-- exported.
--
-- /See:/ 'newS3ReportExportConfig' smart constructor.
data S3ReportExportConfig = S3ReportExportConfig'
  { -- | The type of build output artifact to create. Valid values include:
    --
    -- -   @NONE@: CodeBuild creates the raw data in the output bucket. This is
    --     the default if packaging is not specified.
    --
    -- -   @ZIP@: CodeBuild creates a ZIP file with the raw data in the output
    --     bucket.
    S3ReportExportConfig -> Maybe ReportPackagingType
packaging :: Prelude.Maybe ReportPackagingType,
    -- | The path to the exported report\'s raw data results.
    S3ReportExportConfig -> Maybe Text
path :: Prelude.Maybe Prelude.Text,
    -- | The name of the S3 bucket where the raw data of a report are exported.
    S3ReportExportConfig -> Maybe Text
bucket :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Web Services account identifier of the owner of the Amazon S3
    -- bucket. This allows report data to be exported to an Amazon S3 bucket
    -- that is owned by an account other than the account running the build.
    S3ReportExportConfig -> Maybe Text
bucketOwner :: Prelude.Maybe Prelude.Text,
    -- | A boolean value that specifies if the results of a report are encrypted.
    S3ReportExportConfig -> Maybe Bool
encryptionDisabled :: Prelude.Maybe Prelude.Bool,
    -- | The encryption key for the report\'s encrypted raw data.
    S3ReportExportConfig -> Maybe Text
encryptionKey :: Prelude.Maybe Prelude.Text
  }
  deriving (S3ReportExportConfig -> S3ReportExportConfig -> Bool
(S3ReportExportConfig -> S3ReportExportConfig -> Bool)
-> (S3ReportExportConfig -> S3ReportExportConfig -> Bool)
-> Eq S3ReportExportConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3ReportExportConfig -> S3ReportExportConfig -> Bool
$c/= :: S3ReportExportConfig -> S3ReportExportConfig -> Bool
== :: S3ReportExportConfig -> S3ReportExportConfig -> Bool
$c== :: S3ReportExportConfig -> S3ReportExportConfig -> Bool
Prelude.Eq, ReadPrec [S3ReportExportConfig]
ReadPrec S3ReportExportConfig
Int -> ReadS S3ReportExportConfig
ReadS [S3ReportExportConfig]
(Int -> ReadS S3ReportExportConfig)
-> ReadS [S3ReportExportConfig]
-> ReadPrec S3ReportExportConfig
-> ReadPrec [S3ReportExportConfig]
-> Read S3ReportExportConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3ReportExportConfig]
$creadListPrec :: ReadPrec [S3ReportExportConfig]
readPrec :: ReadPrec S3ReportExportConfig
$creadPrec :: ReadPrec S3ReportExportConfig
readList :: ReadS [S3ReportExportConfig]
$creadList :: ReadS [S3ReportExportConfig]
readsPrec :: Int -> ReadS S3ReportExportConfig
$creadsPrec :: Int -> ReadS S3ReportExportConfig
Prelude.Read, Int -> S3ReportExportConfig -> ShowS
[S3ReportExportConfig] -> ShowS
S3ReportExportConfig -> String
(Int -> S3ReportExportConfig -> ShowS)
-> (S3ReportExportConfig -> String)
-> ([S3ReportExportConfig] -> ShowS)
-> Show S3ReportExportConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3ReportExportConfig] -> ShowS
$cshowList :: [S3ReportExportConfig] -> ShowS
show :: S3ReportExportConfig -> String
$cshow :: S3ReportExportConfig -> String
showsPrec :: Int -> S3ReportExportConfig -> ShowS
$cshowsPrec :: Int -> S3ReportExportConfig -> ShowS
Prelude.Show, (forall x. S3ReportExportConfig -> Rep S3ReportExportConfig x)
-> (forall x. Rep S3ReportExportConfig x -> S3ReportExportConfig)
-> Generic S3ReportExportConfig
forall x. Rep S3ReportExportConfig x -> S3ReportExportConfig
forall x. S3ReportExportConfig -> Rep S3ReportExportConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3ReportExportConfig x -> S3ReportExportConfig
$cfrom :: forall x. S3ReportExportConfig -> Rep S3ReportExportConfig x
Prelude.Generic)

-- |
-- Create a value of 'S3ReportExportConfig' 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:
--
-- 'packaging', 's3ReportExportConfig_packaging' - The type of build output artifact to create. Valid values include:
--
-- -   @NONE@: CodeBuild creates the raw data in the output bucket. This is
--     the default if packaging is not specified.
--
-- -   @ZIP@: CodeBuild creates a ZIP file with the raw data in the output
--     bucket.
--
-- 'path', 's3ReportExportConfig_path' - The path to the exported report\'s raw data results.
--
-- 'bucket', 's3ReportExportConfig_bucket' - The name of the S3 bucket where the raw data of a report are exported.
--
-- 'bucketOwner', 's3ReportExportConfig_bucketOwner' - The Amazon Web Services account identifier of the owner of the Amazon S3
-- bucket. This allows report data to be exported to an Amazon S3 bucket
-- that is owned by an account other than the account running the build.
--
-- 'encryptionDisabled', 's3ReportExportConfig_encryptionDisabled' - A boolean value that specifies if the results of a report are encrypted.
--
-- 'encryptionKey', 's3ReportExportConfig_encryptionKey' - The encryption key for the report\'s encrypted raw data.
newS3ReportExportConfig ::
  S3ReportExportConfig
newS3ReportExportConfig :: S3ReportExportConfig
newS3ReportExportConfig =
  S3ReportExportConfig' :: Maybe ReportPackagingType
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Bool
-> Maybe Text
-> S3ReportExportConfig
S3ReportExportConfig'
    { $sel:packaging:S3ReportExportConfig' :: Maybe ReportPackagingType
packaging = Maybe ReportPackagingType
forall a. Maybe a
Prelude.Nothing,
      $sel:path:S3ReportExportConfig' :: Maybe Text
path = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:bucket:S3ReportExportConfig' :: Maybe Text
bucket = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:bucketOwner:S3ReportExportConfig' :: Maybe Text
bucketOwner = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:encryptionDisabled:S3ReportExportConfig' :: Maybe Bool
encryptionDisabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:encryptionKey:S3ReportExportConfig' :: Maybe Text
encryptionKey = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The type of build output artifact to create. Valid values include:
--
-- -   @NONE@: CodeBuild creates the raw data in the output bucket. This is
--     the default if packaging is not specified.
--
-- -   @ZIP@: CodeBuild creates a ZIP file with the raw data in the output
--     bucket.
s3ReportExportConfig_packaging :: Lens.Lens' S3ReportExportConfig (Prelude.Maybe ReportPackagingType)
s3ReportExportConfig_packaging :: (Maybe ReportPackagingType -> f (Maybe ReportPackagingType))
-> S3ReportExportConfig -> f S3ReportExportConfig
s3ReportExportConfig_packaging = (S3ReportExportConfig -> Maybe ReportPackagingType)
-> (S3ReportExportConfig
    -> Maybe ReportPackagingType -> S3ReportExportConfig)
-> Lens
     S3ReportExportConfig
     S3ReportExportConfig
     (Maybe ReportPackagingType)
     (Maybe ReportPackagingType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3ReportExportConfig' {Maybe ReportPackagingType
packaging :: Maybe ReportPackagingType
$sel:packaging:S3ReportExportConfig' :: S3ReportExportConfig -> Maybe ReportPackagingType
packaging} -> Maybe ReportPackagingType
packaging) (\s :: S3ReportExportConfig
s@S3ReportExportConfig' {} Maybe ReportPackagingType
a -> S3ReportExportConfig
s {$sel:packaging:S3ReportExportConfig' :: Maybe ReportPackagingType
packaging = Maybe ReportPackagingType
a} :: S3ReportExportConfig)

-- | The path to the exported report\'s raw data results.
s3ReportExportConfig_path :: Lens.Lens' S3ReportExportConfig (Prelude.Maybe Prelude.Text)
s3ReportExportConfig_path :: (Maybe Text -> f (Maybe Text))
-> S3ReportExportConfig -> f S3ReportExportConfig
s3ReportExportConfig_path = (S3ReportExportConfig -> Maybe Text)
-> (S3ReportExportConfig -> Maybe Text -> S3ReportExportConfig)
-> Lens
     S3ReportExportConfig S3ReportExportConfig (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3ReportExportConfig' {Maybe Text
path :: Maybe Text
$sel:path:S3ReportExportConfig' :: S3ReportExportConfig -> Maybe Text
path} -> Maybe Text
path) (\s :: S3ReportExportConfig
s@S3ReportExportConfig' {} Maybe Text
a -> S3ReportExportConfig
s {$sel:path:S3ReportExportConfig' :: Maybe Text
path = Maybe Text
a} :: S3ReportExportConfig)

-- | The name of the S3 bucket where the raw data of a report are exported.
s3ReportExportConfig_bucket :: Lens.Lens' S3ReportExportConfig (Prelude.Maybe Prelude.Text)
s3ReportExportConfig_bucket :: (Maybe Text -> f (Maybe Text))
-> S3ReportExportConfig -> f S3ReportExportConfig
s3ReportExportConfig_bucket = (S3ReportExportConfig -> Maybe Text)
-> (S3ReportExportConfig -> Maybe Text -> S3ReportExportConfig)
-> Lens
     S3ReportExportConfig S3ReportExportConfig (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3ReportExportConfig' {Maybe Text
bucket :: Maybe Text
$sel:bucket:S3ReportExportConfig' :: S3ReportExportConfig -> Maybe Text
bucket} -> Maybe Text
bucket) (\s :: S3ReportExportConfig
s@S3ReportExportConfig' {} Maybe Text
a -> S3ReportExportConfig
s {$sel:bucket:S3ReportExportConfig' :: Maybe Text
bucket = Maybe Text
a} :: S3ReportExportConfig)

-- | The Amazon Web Services account identifier of the owner of the Amazon S3
-- bucket. This allows report data to be exported to an Amazon S3 bucket
-- that is owned by an account other than the account running the build.
s3ReportExportConfig_bucketOwner :: Lens.Lens' S3ReportExportConfig (Prelude.Maybe Prelude.Text)
s3ReportExportConfig_bucketOwner :: (Maybe Text -> f (Maybe Text))
-> S3ReportExportConfig -> f S3ReportExportConfig
s3ReportExportConfig_bucketOwner = (S3ReportExportConfig -> Maybe Text)
-> (S3ReportExportConfig -> Maybe Text -> S3ReportExportConfig)
-> Lens
     S3ReportExportConfig S3ReportExportConfig (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3ReportExportConfig' {Maybe Text
bucketOwner :: Maybe Text
$sel:bucketOwner:S3ReportExportConfig' :: S3ReportExportConfig -> Maybe Text
bucketOwner} -> Maybe Text
bucketOwner) (\s :: S3ReportExportConfig
s@S3ReportExportConfig' {} Maybe Text
a -> S3ReportExportConfig
s {$sel:bucketOwner:S3ReportExportConfig' :: Maybe Text
bucketOwner = Maybe Text
a} :: S3ReportExportConfig)

-- | A boolean value that specifies if the results of a report are encrypted.
s3ReportExportConfig_encryptionDisabled :: Lens.Lens' S3ReportExportConfig (Prelude.Maybe Prelude.Bool)
s3ReportExportConfig_encryptionDisabled :: (Maybe Bool -> f (Maybe Bool))
-> S3ReportExportConfig -> f S3ReportExportConfig
s3ReportExportConfig_encryptionDisabled = (S3ReportExportConfig -> Maybe Bool)
-> (S3ReportExportConfig -> Maybe Bool -> S3ReportExportConfig)
-> Lens
     S3ReportExportConfig S3ReportExportConfig (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3ReportExportConfig' {Maybe Bool
encryptionDisabled :: Maybe Bool
$sel:encryptionDisabled:S3ReportExportConfig' :: S3ReportExportConfig -> Maybe Bool
encryptionDisabled} -> Maybe Bool
encryptionDisabled) (\s :: S3ReportExportConfig
s@S3ReportExportConfig' {} Maybe Bool
a -> S3ReportExportConfig
s {$sel:encryptionDisabled:S3ReportExportConfig' :: Maybe Bool
encryptionDisabled = Maybe Bool
a} :: S3ReportExportConfig)

-- | The encryption key for the report\'s encrypted raw data.
s3ReportExportConfig_encryptionKey :: Lens.Lens' S3ReportExportConfig (Prelude.Maybe Prelude.Text)
s3ReportExportConfig_encryptionKey :: (Maybe Text -> f (Maybe Text))
-> S3ReportExportConfig -> f S3ReportExportConfig
s3ReportExportConfig_encryptionKey = (S3ReportExportConfig -> Maybe Text)
-> (S3ReportExportConfig -> Maybe Text -> S3ReportExportConfig)
-> Lens
     S3ReportExportConfig S3ReportExportConfig (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3ReportExportConfig' {Maybe Text
encryptionKey :: Maybe Text
$sel:encryptionKey:S3ReportExportConfig' :: S3ReportExportConfig -> Maybe Text
encryptionKey} -> Maybe Text
encryptionKey) (\s :: S3ReportExportConfig
s@S3ReportExportConfig' {} Maybe Text
a -> S3ReportExportConfig
s {$sel:encryptionKey:S3ReportExportConfig' :: Maybe Text
encryptionKey = Maybe Text
a} :: S3ReportExportConfig)

instance Core.FromJSON S3ReportExportConfig where
  parseJSON :: Value -> Parser S3ReportExportConfig
parseJSON =
    String
-> (Object -> Parser S3ReportExportConfig)
-> Value
-> Parser S3ReportExportConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"S3ReportExportConfig"
      ( \Object
x ->
          Maybe ReportPackagingType
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Bool
-> Maybe Text
-> S3ReportExportConfig
S3ReportExportConfig'
            (Maybe ReportPackagingType
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Bool
 -> Maybe Text
 -> S3ReportExportConfig)
-> Parser (Maybe ReportPackagingType)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Bool
      -> Maybe Text
      -> S3ReportExportConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ReportPackagingType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"packaging")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Bool
   -> Maybe Text
   -> S3ReportExportConfig)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe Bool -> Maybe Text -> S3ReportExportConfig)
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
"path")
            Parser
  (Maybe Text
   -> Maybe Text -> Maybe Bool -> Maybe Text -> S3ReportExportConfig)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Bool -> Maybe Text -> S3ReportExportConfig)
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
"bucket")
            Parser
  (Maybe Text -> Maybe Bool -> Maybe Text -> S3ReportExportConfig)
-> Parser (Maybe Text)
-> Parser (Maybe Bool -> Maybe Text -> S3ReportExportConfig)
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
"bucketOwner")
            Parser (Maybe Bool -> Maybe Text -> S3ReportExportConfig)
-> Parser (Maybe Bool)
-> Parser (Maybe Text -> S3ReportExportConfig)
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 Text -> S3ReportExportConfig)
-> Parser (Maybe Text) -> Parser S3ReportExportConfig
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
"encryptionKey")
      )

instance Prelude.Hashable S3ReportExportConfig

instance Prelude.NFData S3ReportExportConfig

instance Core.ToJSON S3ReportExportConfig where
  toJSON :: S3ReportExportConfig -> Value
toJSON S3ReportExportConfig' {Maybe Bool
Maybe Text
Maybe ReportPackagingType
encryptionKey :: Maybe Text
encryptionDisabled :: Maybe Bool
bucketOwner :: Maybe Text
bucket :: Maybe Text
path :: Maybe Text
packaging :: Maybe ReportPackagingType
$sel:encryptionKey:S3ReportExportConfig' :: S3ReportExportConfig -> Maybe Text
$sel:encryptionDisabled:S3ReportExportConfig' :: S3ReportExportConfig -> Maybe Bool
$sel:bucketOwner:S3ReportExportConfig' :: S3ReportExportConfig -> Maybe Text
$sel:bucket:S3ReportExportConfig' :: S3ReportExportConfig -> Maybe Text
$sel:path:S3ReportExportConfig' :: S3ReportExportConfig -> Maybe Text
$sel:packaging:S3ReportExportConfig' :: S3ReportExportConfig -> Maybe ReportPackagingType
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"packaging" Text -> ReportPackagingType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ReportPackagingType -> Pair)
-> Maybe ReportPackagingType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ReportPackagingType
packaging,
            (Text
"path" 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
path,
            (Text
"bucket" 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
bucket,
            (Text
"bucketOwner" 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
bucketOwner,
            (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
"encryptionKey" 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
encryptionKey
          ]
      )