{-# 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.Rekognition.Types.OutputConfig
-- 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.Rekognition.Types.OutputConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The S3 bucket and folder location where training output is placed.
--
-- /See:/ 'newOutputConfig' smart constructor.
data OutputConfig = OutputConfig'
  { -- | The prefix applied to the training output files.
    OutputConfig -> Maybe Text
s3KeyPrefix :: Prelude.Maybe Prelude.Text,
    -- | The S3 bucket where training output is placed.
    OutputConfig -> Maybe Text
s3Bucket :: Prelude.Maybe Prelude.Text
  }
  deriving (OutputConfig -> OutputConfig -> Bool
(OutputConfig -> OutputConfig -> Bool)
-> (OutputConfig -> OutputConfig -> Bool) -> Eq OutputConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OutputConfig -> OutputConfig -> Bool
$c/= :: OutputConfig -> OutputConfig -> Bool
== :: OutputConfig -> OutputConfig -> Bool
$c== :: OutputConfig -> OutputConfig -> Bool
Prelude.Eq, ReadPrec [OutputConfig]
ReadPrec OutputConfig
Int -> ReadS OutputConfig
ReadS [OutputConfig]
(Int -> ReadS OutputConfig)
-> ReadS [OutputConfig]
-> ReadPrec OutputConfig
-> ReadPrec [OutputConfig]
-> Read OutputConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OutputConfig]
$creadListPrec :: ReadPrec [OutputConfig]
readPrec :: ReadPrec OutputConfig
$creadPrec :: ReadPrec OutputConfig
readList :: ReadS [OutputConfig]
$creadList :: ReadS [OutputConfig]
readsPrec :: Int -> ReadS OutputConfig
$creadsPrec :: Int -> ReadS OutputConfig
Prelude.Read, Int -> OutputConfig -> ShowS
[OutputConfig] -> ShowS
OutputConfig -> String
(Int -> OutputConfig -> ShowS)
-> (OutputConfig -> String)
-> ([OutputConfig] -> ShowS)
-> Show OutputConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OutputConfig] -> ShowS
$cshowList :: [OutputConfig] -> ShowS
show :: OutputConfig -> String
$cshow :: OutputConfig -> String
showsPrec :: Int -> OutputConfig -> ShowS
$cshowsPrec :: Int -> OutputConfig -> ShowS
Prelude.Show, (forall x. OutputConfig -> Rep OutputConfig x)
-> (forall x. Rep OutputConfig x -> OutputConfig)
-> Generic OutputConfig
forall x. Rep OutputConfig x -> OutputConfig
forall x. OutputConfig -> Rep OutputConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OutputConfig x -> OutputConfig
$cfrom :: forall x. OutputConfig -> Rep OutputConfig x
Prelude.Generic)

-- |
-- Create a value of 'OutputConfig' 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:
--
-- 's3KeyPrefix', 'outputConfig_s3KeyPrefix' - The prefix applied to the training output files.
--
-- 's3Bucket', 'outputConfig_s3Bucket' - The S3 bucket where training output is placed.
newOutputConfig ::
  OutputConfig
newOutputConfig :: OutputConfig
newOutputConfig =
  OutputConfig' :: Maybe Text -> Maybe Text -> OutputConfig
OutputConfig'
    { $sel:s3KeyPrefix:OutputConfig' :: Maybe Text
s3KeyPrefix = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:s3Bucket:OutputConfig' :: Maybe Text
s3Bucket = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The prefix applied to the training output files.
outputConfig_s3KeyPrefix :: Lens.Lens' OutputConfig (Prelude.Maybe Prelude.Text)
outputConfig_s3KeyPrefix :: (Maybe Text -> f (Maybe Text)) -> OutputConfig -> f OutputConfig
outputConfig_s3KeyPrefix = (OutputConfig -> Maybe Text)
-> (OutputConfig -> Maybe Text -> OutputConfig)
-> Lens OutputConfig OutputConfig (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OutputConfig' {Maybe Text
s3KeyPrefix :: Maybe Text
$sel:s3KeyPrefix:OutputConfig' :: OutputConfig -> Maybe Text
s3KeyPrefix} -> Maybe Text
s3KeyPrefix) (\s :: OutputConfig
s@OutputConfig' {} Maybe Text
a -> OutputConfig
s {$sel:s3KeyPrefix:OutputConfig' :: Maybe Text
s3KeyPrefix = Maybe Text
a} :: OutputConfig)

-- | The S3 bucket where training output is placed.
outputConfig_s3Bucket :: Lens.Lens' OutputConfig (Prelude.Maybe Prelude.Text)
outputConfig_s3Bucket :: (Maybe Text -> f (Maybe Text)) -> OutputConfig -> f OutputConfig
outputConfig_s3Bucket = (OutputConfig -> Maybe Text)
-> (OutputConfig -> Maybe Text -> OutputConfig)
-> Lens OutputConfig OutputConfig (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OutputConfig' {Maybe Text
s3Bucket :: Maybe Text
$sel:s3Bucket:OutputConfig' :: OutputConfig -> Maybe Text
s3Bucket} -> Maybe Text
s3Bucket) (\s :: OutputConfig
s@OutputConfig' {} Maybe Text
a -> OutputConfig
s {$sel:s3Bucket:OutputConfig' :: Maybe Text
s3Bucket = Maybe Text
a} :: OutputConfig)

instance Core.FromJSON OutputConfig where
  parseJSON :: Value -> Parser OutputConfig
parseJSON =
    String
-> (Object -> Parser OutputConfig) -> Value -> Parser OutputConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"OutputConfig"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> OutputConfig
OutputConfig'
            (Maybe Text -> Maybe Text -> OutputConfig)
-> Parser (Maybe Text) -> Parser (Maybe Text -> OutputConfig)
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
"S3KeyPrefix")
            Parser (Maybe Text -> OutputConfig)
-> Parser (Maybe Text) -> Parser OutputConfig
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
"S3Bucket")
      )

instance Prelude.Hashable OutputConfig

instance Prelude.NFData OutputConfig

instance Core.ToJSON OutputConfig where
  toJSON :: OutputConfig -> Value
toJSON OutputConfig' {Maybe Text
s3Bucket :: Maybe Text
s3KeyPrefix :: Maybe Text
$sel:s3Bucket:OutputConfig' :: OutputConfig -> Maybe Text
$sel:s3KeyPrefix:OutputConfig' :: OutputConfig -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"S3KeyPrefix" 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
s3KeyPrefix,
            (Text
"S3Bucket" 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
s3Bucket
          ]
      )