{-# 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.TestingData
-- 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.TestingData 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 testing. Optionally, if @AutoCreate@ is set, Amazon
-- Rekognition Custom Labels creates a testing dataset using an 80\/20
-- split of the training dataset.
--
-- /See:/ 'newTestingData' smart constructor.
data TestingData = TestingData'
  { -- | The assets used for testing.
    TestingData -> Maybe [Asset]
assets :: Prelude.Maybe [Asset],
    -- | If specified, Amazon Rekognition Custom Labels creates a testing dataset
    -- with an 80\/20 split of the training dataset.
    TestingData -> Maybe Bool
autoCreate :: Prelude.Maybe Prelude.Bool
  }
  deriving (TestingData -> TestingData -> Bool
(TestingData -> TestingData -> Bool)
-> (TestingData -> TestingData -> Bool) -> Eq TestingData
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TestingData -> TestingData -> Bool
$c/= :: TestingData -> TestingData -> Bool
== :: TestingData -> TestingData -> Bool
$c== :: TestingData -> TestingData -> Bool
Prelude.Eq, ReadPrec [TestingData]
ReadPrec TestingData
Int -> ReadS TestingData
ReadS [TestingData]
(Int -> ReadS TestingData)
-> ReadS [TestingData]
-> ReadPrec TestingData
-> ReadPrec [TestingData]
-> Read TestingData
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TestingData]
$creadListPrec :: ReadPrec [TestingData]
readPrec :: ReadPrec TestingData
$creadPrec :: ReadPrec TestingData
readList :: ReadS [TestingData]
$creadList :: ReadS [TestingData]
readsPrec :: Int -> ReadS TestingData
$creadsPrec :: Int -> ReadS TestingData
Prelude.Read, Int -> TestingData -> ShowS
[TestingData] -> ShowS
TestingData -> String
(Int -> TestingData -> ShowS)
-> (TestingData -> String)
-> ([TestingData] -> ShowS)
-> Show TestingData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TestingData] -> ShowS
$cshowList :: [TestingData] -> ShowS
show :: TestingData -> String
$cshow :: TestingData -> String
showsPrec :: Int -> TestingData -> ShowS
$cshowsPrec :: Int -> TestingData -> ShowS
Prelude.Show, (forall x. TestingData -> Rep TestingData x)
-> (forall x. Rep TestingData x -> TestingData)
-> Generic TestingData
forall x. Rep TestingData x -> TestingData
forall x. TestingData -> Rep TestingData x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TestingData x -> TestingData
$cfrom :: forall x. TestingData -> Rep TestingData x
Prelude.Generic)

-- |
-- Create a value of 'TestingData' 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', 'testingData_assets' - The assets used for testing.
--
-- 'autoCreate', 'testingData_autoCreate' - If specified, Amazon Rekognition Custom Labels creates a testing dataset
-- with an 80\/20 split of the training dataset.
newTestingData ::
  TestingData
newTestingData :: TestingData
newTestingData =
  TestingData' :: Maybe [Asset] -> Maybe Bool -> TestingData
TestingData'
    { $sel:assets:TestingData' :: Maybe [Asset]
assets = Maybe [Asset]
forall a. Maybe a
Prelude.Nothing,
      $sel:autoCreate:TestingData' :: Maybe Bool
autoCreate = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | The assets used for testing.
testingData_assets :: Lens.Lens' TestingData (Prelude.Maybe [Asset])
testingData_assets :: (Maybe [Asset] -> f (Maybe [Asset]))
-> TestingData -> f TestingData
testingData_assets = (TestingData -> Maybe [Asset])
-> (TestingData -> Maybe [Asset] -> TestingData)
-> Lens TestingData TestingData (Maybe [Asset]) (Maybe [Asset])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestingData' {Maybe [Asset]
assets :: Maybe [Asset]
$sel:assets:TestingData' :: TestingData -> Maybe [Asset]
assets} -> Maybe [Asset]
assets) (\s :: TestingData
s@TestingData' {} Maybe [Asset]
a -> TestingData
s {$sel:assets:TestingData' :: Maybe [Asset]
assets = Maybe [Asset]
a} :: TestingData) ((Maybe [Asset] -> f (Maybe [Asset]))
 -> TestingData -> f TestingData)
-> ((Maybe [Asset] -> f (Maybe [Asset]))
    -> Maybe [Asset] -> f (Maybe [Asset]))
-> (Maybe [Asset] -> f (Maybe [Asset]))
-> TestingData
-> f TestingData
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

-- | If specified, Amazon Rekognition Custom Labels creates a testing dataset
-- with an 80\/20 split of the training dataset.
testingData_autoCreate :: Lens.Lens' TestingData (Prelude.Maybe Prelude.Bool)
testingData_autoCreate :: (Maybe Bool -> f (Maybe Bool)) -> TestingData -> f TestingData
testingData_autoCreate = (TestingData -> Maybe Bool)
-> (TestingData -> Maybe Bool -> TestingData)
-> Lens TestingData TestingData (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestingData' {Maybe Bool
autoCreate :: Maybe Bool
$sel:autoCreate:TestingData' :: TestingData -> Maybe Bool
autoCreate} -> Maybe Bool
autoCreate) (\s :: TestingData
s@TestingData' {} Maybe Bool
a -> TestingData
s {$sel:autoCreate:TestingData' :: Maybe Bool
autoCreate = Maybe Bool
a} :: TestingData)

instance Core.FromJSON TestingData where
  parseJSON :: Value -> Parser TestingData
parseJSON =
    String
-> (Object -> Parser TestingData) -> Value -> Parser TestingData
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TestingData"
      ( \Object
x ->
          Maybe [Asset] -> Maybe Bool -> TestingData
TestingData'
            (Maybe [Asset] -> Maybe Bool -> TestingData)
-> Parser (Maybe [Asset]) -> Parser (Maybe Bool -> TestingData)
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)
            Parser (Maybe Bool -> TestingData)
-> Parser (Maybe Bool) -> Parser TestingData
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
"AutoCreate")
      )

instance Prelude.Hashable TestingData

instance Prelude.NFData TestingData

instance Core.ToJSON TestingData where
  toJSON :: TestingData -> Value
toJSON TestingData' {Maybe Bool
Maybe [Asset]
autoCreate :: Maybe Bool
assets :: Maybe [Asset]
$sel:autoCreate:TestingData' :: TestingData -> Maybe Bool
$sel:assets:TestingData' :: TestingData -> 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,
            (Text
"AutoCreate" 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
autoCreate
          ]
      )