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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Rekognition.Types.Asset

-- | The dataset used for training.
--
-- /See:/ 'newTrainingData' smart constructor.
data TrainingData = TrainingData'
  { -- | A Sagemaker GroundTruth manifest file that contains the training images
    -- (assets).
    TrainingData -> Maybe [Asset]
assets :: Prelude.Maybe [Asset]
  }
  deriving (TrainingData -> TrainingData -> Bool
(TrainingData -> TrainingData -> Bool)
-> (TrainingData -> TrainingData -> Bool) -> Eq TrainingData
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TrainingData -> TrainingData -> Bool
$c/= :: TrainingData -> TrainingData -> Bool
== :: TrainingData -> TrainingData -> Bool
$c== :: TrainingData -> TrainingData -> Bool
Prelude.Eq, ReadPrec [TrainingData]
ReadPrec TrainingData
Int -> ReadS TrainingData
ReadS [TrainingData]
(Int -> ReadS TrainingData)
-> ReadS [TrainingData]
-> ReadPrec TrainingData
-> ReadPrec [TrainingData]
-> Read TrainingData
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TrainingData]
$creadListPrec :: ReadPrec [TrainingData]
readPrec :: ReadPrec TrainingData
$creadPrec :: ReadPrec TrainingData
readList :: ReadS [TrainingData]
$creadList :: ReadS [TrainingData]
readsPrec :: Int -> ReadS TrainingData
$creadsPrec :: Int -> ReadS TrainingData
Prelude.Read, Int -> TrainingData -> ShowS
[TrainingData] -> ShowS
TrainingData -> String
(Int -> TrainingData -> ShowS)
-> (TrainingData -> String)
-> ([TrainingData] -> ShowS)
-> Show TrainingData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TrainingData] -> ShowS
$cshowList :: [TrainingData] -> ShowS
show :: TrainingData -> String
$cshow :: TrainingData -> String
showsPrec :: Int -> TrainingData -> ShowS
$cshowsPrec :: Int -> TrainingData -> ShowS
Prelude.Show, (forall x. TrainingData -> Rep TrainingData x)
-> (forall x. Rep TrainingData x -> TrainingData)
-> Generic TrainingData
forall x. Rep TrainingData x -> TrainingData
forall x. TrainingData -> Rep TrainingData x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TrainingData x -> TrainingData
$cfrom :: forall x. TrainingData -> Rep TrainingData x
Prelude.Generic)

-- |
-- Create a value of 'TrainingData' 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:
--
-- 'assets', 'trainingData_assets' - A Sagemaker GroundTruth manifest file that contains the training images
-- (assets).
newTrainingData ::
  TrainingData
newTrainingData :: TrainingData
newTrainingData =
  TrainingData' :: Maybe [Asset] -> TrainingData
TrainingData' {$sel:assets:TrainingData' :: Maybe [Asset]
assets = Maybe [Asset]
forall a. Maybe a
Prelude.Nothing}

-- | A Sagemaker GroundTruth manifest file that contains the training images
-- (assets).
trainingData_assets :: Lens.Lens' TrainingData (Prelude.Maybe [Asset])
trainingData_assets :: (Maybe [Asset] -> f (Maybe [Asset]))
-> TrainingData -> f TrainingData
trainingData_assets = (TrainingData -> Maybe [Asset])
-> (TrainingData -> Maybe [Asset] -> TrainingData)
-> Lens TrainingData TrainingData (Maybe [Asset]) (Maybe [Asset])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TrainingData' {Maybe [Asset]
assets :: Maybe [Asset]
$sel:assets:TrainingData' :: TrainingData -> Maybe [Asset]
assets} -> Maybe [Asset]
assets) (\s :: TrainingData
s@TrainingData' {} Maybe [Asset]
a -> TrainingData
s {$sel:assets:TrainingData' :: Maybe [Asset]
assets = Maybe [Asset]
a} :: TrainingData) ((Maybe [Asset] -> f (Maybe [Asset]))
 -> TrainingData -> f TrainingData)
-> ((Maybe [Asset] -> f (Maybe [Asset]))
    -> Maybe [Asset] -> f (Maybe [Asset]))
-> (Maybe [Asset] -> f (Maybe [Asset]))
-> TrainingData
-> f TrainingData
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Asset] [Asset] [Asset] [Asset]
-> Iso
     (Maybe [Asset]) (Maybe [Asset]) (Maybe [Asset]) (Maybe [Asset])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Asset] [Asset] [Asset] [Asset]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON TrainingData where
  parseJSON :: Value -> Parser TrainingData
parseJSON =
    String
-> (Object -> Parser TrainingData) -> Value -> Parser TrainingData
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TrainingData"
      ( \Object
x ->
          Maybe [Asset] -> TrainingData
TrainingData'
            (Maybe [Asset] -> TrainingData)
-> Parser (Maybe [Asset]) -> Parser TrainingData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Asset]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Assets" Parser (Maybe (Maybe [Asset]))
-> Maybe [Asset] -> Parser (Maybe [Asset])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Asset]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable TrainingData

instance Prelude.NFData TrainingData

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