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

import Amazonka.CodeBuild.Types.ReportExportConfigType
import Amazonka.CodeBuild.Types.S3ReportExportConfig
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about the location where the run of a report is exported.
--
-- /See:/ 'newReportExportConfig' smart constructor.
data ReportExportConfig = ReportExportConfig'
  { -- | The export configuration type. Valid values are:
    --
    -- -   @S3@: The report results are exported to an S3 bucket.
    --
    -- -   @NO_EXPORT@: The report results are not exported.
    ReportExportConfig -> Maybe ReportExportConfigType
exportConfigType :: Prelude.Maybe ReportExportConfigType,
    -- | A @S3ReportExportConfig@ object that contains information about the S3
    -- bucket where the run of a report is exported.
    ReportExportConfig -> Maybe S3ReportExportConfig
s3Destination :: Prelude.Maybe S3ReportExportConfig
  }
  deriving (ReportExportConfig -> ReportExportConfig -> Bool
(ReportExportConfig -> ReportExportConfig -> Bool)
-> (ReportExportConfig -> ReportExportConfig -> Bool)
-> Eq ReportExportConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ReportExportConfig -> ReportExportConfig -> Bool
$c/= :: ReportExportConfig -> ReportExportConfig -> Bool
== :: ReportExportConfig -> ReportExportConfig -> Bool
$c== :: ReportExportConfig -> ReportExportConfig -> Bool
Prelude.Eq, ReadPrec [ReportExportConfig]
ReadPrec ReportExportConfig
Int -> ReadS ReportExportConfig
ReadS [ReportExportConfig]
(Int -> ReadS ReportExportConfig)
-> ReadS [ReportExportConfig]
-> ReadPrec ReportExportConfig
-> ReadPrec [ReportExportConfig]
-> Read ReportExportConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ReportExportConfig]
$creadListPrec :: ReadPrec [ReportExportConfig]
readPrec :: ReadPrec ReportExportConfig
$creadPrec :: ReadPrec ReportExportConfig
readList :: ReadS [ReportExportConfig]
$creadList :: ReadS [ReportExportConfig]
readsPrec :: Int -> ReadS ReportExportConfig
$creadsPrec :: Int -> ReadS ReportExportConfig
Prelude.Read, Int -> ReportExportConfig -> ShowS
[ReportExportConfig] -> ShowS
ReportExportConfig -> String
(Int -> ReportExportConfig -> ShowS)
-> (ReportExportConfig -> String)
-> ([ReportExportConfig] -> ShowS)
-> Show ReportExportConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReportExportConfig] -> ShowS
$cshowList :: [ReportExportConfig] -> ShowS
show :: ReportExportConfig -> String
$cshow :: ReportExportConfig -> String
showsPrec :: Int -> ReportExportConfig -> ShowS
$cshowsPrec :: Int -> ReportExportConfig -> ShowS
Prelude.Show, (forall x. ReportExportConfig -> Rep ReportExportConfig x)
-> (forall x. Rep ReportExportConfig x -> ReportExportConfig)
-> Generic ReportExportConfig
forall x. Rep ReportExportConfig x -> ReportExportConfig
forall x. ReportExportConfig -> Rep ReportExportConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ReportExportConfig x -> ReportExportConfig
$cfrom :: forall x. ReportExportConfig -> Rep ReportExportConfig x
Prelude.Generic)

-- |
-- Create a value of 'ReportExportConfig' 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:
--
-- 'exportConfigType', 'reportExportConfig_exportConfigType' - The export configuration type. Valid values are:
--
-- -   @S3@: The report results are exported to an S3 bucket.
--
-- -   @NO_EXPORT@: The report results are not exported.
--
-- 's3Destination', 'reportExportConfig_s3Destination' - A @S3ReportExportConfig@ object that contains information about the S3
-- bucket where the run of a report is exported.
newReportExportConfig ::
  ReportExportConfig
newReportExportConfig :: ReportExportConfig
newReportExportConfig =
  ReportExportConfig' :: Maybe ReportExportConfigType
-> Maybe S3ReportExportConfig -> ReportExportConfig
ReportExportConfig'
    { $sel:exportConfigType:ReportExportConfig' :: Maybe ReportExportConfigType
exportConfigType =
        Maybe ReportExportConfigType
forall a. Maybe a
Prelude.Nothing,
      $sel:s3Destination:ReportExportConfig' :: Maybe S3ReportExportConfig
s3Destination = Maybe S3ReportExportConfig
forall a. Maybe a
Prelude.Nothing
    }

-- | The export configuration type. Valid values are:
--
-- -   @S3@: The report results are exported to an S3 bucket.
--
-- -   @NO_EXPORT@: The report results are not exported.
reportExportConfig_exportConfigType :: Lens.Lens' ReportExportConfig (Prelude.Maybe ReportExportConfigType)
reportExportConfig_exportConfigType :: (Maybe ReportExportConfigType -> f (Maybe ReportExportConfigType))
-> ReportExportConfig -> f ReportExportConfig
reportExportConfig_exportConfigType = (ReportExportConfig -> Maybe ReportExportConfigType)
-> (ReportExportConfig
    -> Maybe ReportExportConfigType -> ReportExportConfig)
-> Lens
     ReportExportConfig
     ReportExportConfig
     (Maybe ReportExportConfigType)
     (Maybe ReportExportConfigType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReportExportConfig' {Maybe ReportExportConfigType
exportConfigType :: Maybe ReportExportConfigType
$sel:exportConfigType:ReportExportConfig' :: ReportExportConfig -> Maybe ReportExportConfigType
exportConfigType} -> Maybe ReportExportConfigType
exportConfigType) (\s :: ReportExportConfig
s@ReportExportConfig' {} Maybe ReportExportConfigType
a -> ReportExportConfig
s {$sel:exportConfigType:ReportExportConfig' :: Maybe ReportExportConfigType
exportConfigType = Maybe ReportExportConfigType
a} :: ReportExportConfig)

-- | A @S3ReportExportConfig@ object that contains information about the S3
-- bucket where the run of a report is exported.
reportExportConfig_s3Destination :: Lens.Lens' ReportExportConfig (Prelude.Maybe S3ReportExportConfig)
reportExportConfig_s3Destination :: (Maybe S3ReportExportConfig -> f (Maybe S3ReportExportConfig))
-> ReportExportConfig -> f ReportExportConfig
reportExportConfig_s3Destination = (ReportExportConfig -> Maybe S3ReportExportConfig)
-> (ReportExportConfig
    -> Maybe S3ReportExportConfig -> ReportExportConfig)
-> Lens
     ReportExportConfig
     ReportExportConfig
     (Maybe S3ReportExportConfig)
     (Maybe S3ReportExportConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReportExportConfig' {Maybe S3ReportExportConfig
s3Destination :: Maybe S3ReportExportConfig
$sel:s3Destination:ReportExportConfig' :: ReportExportConfig -> Maybe S3ReportExportConfig
s3Destination} -> Maybe S3ReportExportConfig
s3Destination) (\s :: ReportExportConfig
s@ReportExportConfig' {} Maybe S3ReportExportConfig
a -> ReportExportConfig
s {$sel:s3Destination:ReportExportConfig' :: Maybe S3ReportExportConfig
s3Destination = Maybe S3ReportExportConfig
a} :: ReportExportConfig)

instance Core.FromJSON ReportExportConfig where
  parseJSON :: Value -> Parser ReportExportConfig
parseJSON =
    String
-> (Object -> Parser ReportExportConfig)
-> Value
-> Parser ReportExportConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ReportExportConfig"
      ( \Object
x ->
          Maybe ReportExportConfigType
-> Maybe S3ReportExportConfig -> ReportExportConfig
ReportExportConfig'
            (Maybe ReportExportConfigType
 -> Maybe S3ReportExportConfig -> ReportExportConfig)
-> Parser (Maybe ReportExportConfigType)
-> Parser (Maybe S3ReportExportConfig -> ReportExportConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ReportExportConfigType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"exportConfigType")
            Parser (Maybe S3ReportExportConfig -> ReportExportConfig)
-> Parser (Maybe S3ReportExportConfig) -> Parser ReportExportConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe S3ReportExportConfig)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"s3Destination")
      )

instance Prelude.Hashable ReportExportConfig

instance Prelude.NFData ReportExportConfig

instance Core.ToJSON ReportExportConfig where
  toJSON :: ReportExportConfig -> Value
toJSON ReportExportConfig' {Maybe ReportExportConfigType
Maybe S3ReportExportConfig
s3Destination :: Maybe S3ReportExportConfig
exportConfigType :: Maybe ReportExportConfigType
$sel:s3Destination:ReportExportConfig' :: ReportExportConfig -> Maybe S3ReportExportConfig
$sel:exportConfigType:ReportExportConfig' :: ReportExportConfig -> Maybe ReportExportConfigType
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"exportConfigType" Text -> ReportExportConfigType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ReportExportConfigType -> Pair)
-> Maybe ReportExportConfigType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ReportExportConfigType
exportConfigType,
            (Text
"s3Destination" Text -> S3ReportExportConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (S3ReportExportConfig -> Pair)
-> Maybe S3ReportExportConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe S3ReportExportConfig
s3Destination
          ]
      )