{-# 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.DatasetChanges
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Rekognition.Types.DatasetChanges where

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

-- | Describes updates or additions to a dataset. A Single update or addition
-- is an entry (JSON Line) that provides information about a single image.
-- To update an existing entry, you match the @source-ref@ field of the
-- update entry with the @source-ref@ filed of the entry that you want to
-- update. If the @source-ref@ field doesn\'t match an existing entry, the
-- entry is added to dataset as a new entry.
--
-- /See:/ 'newDatasetChanges' smart constructor.
data DatasetChanges = DatasetChanges'
  { -- | A Base64-encoded binary data object containing one or JSON lines that
    -- either update the dataset or are additions to the dataset. You change a
    -- dataset by calling UpdateDatasetEntries. If you are using an AWS SDK to
    -- call @UpdateDatasetEntries@, you don\'t need to encode @Changes@ as the
    -- SDK encodes the data for you.
    --
    -- For example JSON lines, see Image-Level labels in manifest files and and
    -- Object localization in manifest files in the /Amazon Rekognition Custom
    -- Labels Developer Guide/.
    DatasetChanges -> Base64
groundTruth :: Data.Base64
  }
  deriving (DatasetChanges -> DatasetChanges -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DatasetChanges -> DatasetChanges -> Bool
$c/= :: DatasetChanges -> DatasetChanges -> Bool
== :: DatasetChanges -> DatasetChanges -> Bool
$c== :: DatasetChanges -> DatasetChanges -> Bool
Prelude.Eq, ReadPrec [DatasetChanges]
ReadPrec DatasetChanges
Int -> ReadS DatasetChanges
ReadS [DatasetChanges]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DatasetChanges]
$creadListPrec :: ReadPrec [DatasetChanges]
readPrec :: ReadPrec DatasetChanges
$creadPrec :: ReadPrec DatasetChanges
readList :: ReadS [DatasetChanges]
$creadList :: ReadS [DatasetChanges]
readsPrec :: Int -> ReadS DatasetChanges
$creadsPrec :: Int -> ReadS DatasetChanges
Prelude.Read, Int -> DatasetChanges -> ShowS
[DatasetChanges] -> ShowS
DatasetChanges -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DatasetChanges] -> ShowS
$cshowList :: [DatasetChanges] -> ShowS
show :: DatasetChanges -> String
$cshow :: DatasetChanges -> String
showsPrec :: Int -> DatasetChanges -> ShowS
$cshowsPrec :: Int -> DatasetChanges -> ShowS
Prelude.Show, forall x. Rep DatasetChanges x -> DatasetChanges
forall x. DatasetChanges -> Rep DatasetChanges x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DatasetChanges x -> DatasetChanges
$cfrom :: forall x. DatasetChanges -> Rep DatasetChanges x
Prelude.Generic)

-- |
-- Create a value of 'DatasetChanges' 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:
--
-- 'groundTruth', 'datasetChanges_groundTruth' - A Base64-encoded binary data object containing one or JSON lines that
-- either update the dataset or are additions to the dataset. You change a
-- dataset by calling UpdateDatasetEntries. If you are using an AWS SDK to
-- call @UpdateDatasetEntries@, you don\'t need to encode @Changes@ as the
-- SDK encodes the data for you.
--
-- For example JSON lines, see Image-Level labels in manifest files and and
-- Object localization in manifest files in the /Amazon Rekognition Custom
-- Labels Developer Guide/.--
-- -- /Note:/ This 'Lens' automatically encodes and decodes Base64 data.
-- -- The underlying isomorphism will encode to Base64 representation during
-- -- serialisation, and decode from Base64 representation during deserialisation.
-- -- This 'Lens' accepts and returns only raw unencoded data.
newDatasetChanges ::
  -- | 'groundTruth'
  Prelude.ByteString ->
  DatasetChanges
newDatasetChanges :: ByteString -> DatasetChanges
newDatasetChanges ByteString
pGroundTruth_ =
  DatasetChanges'
    { $sel:groundTruth:DatasetChanges' :: Base64
groundTruth =
        Iso' Base64 ByteString
Data._Base64 forall t b. AReview t b -> b -> t
Lens.# ByteString
pGroundTruth_
    }

-- | A Base64-encoded binary data object containing one or JSON lines that
-- either update the dataset or are additions to the dataset. You change a
-- dataset by calling UpdateDatasetEntries. If you are using an AWS SDK to
-- call @UpdateDatasetEntries@, you don\'t need to encode @Changes@ as the
-- SDK encodes the data for you.
--
-- For example JSON lines, see Image-Level labels in manifest files and and
-- Object localization in manifest files in the /Amazon Rekognition Custom
-- Labels Developer Guide/.--
-- -- /Note:/ This 'Lens' automatically encodes and decodes Base64 data.
-- -- The underlying isomorphism will encode to Base64 representation during
-- -- serialisation, and decode from Base64 representation during deserialisation.
-- -- This 'Lens' accepts and returns only raw unencoded data.
datasetChanges_groundTruth :: Lens.Lens' DatasetChanges Prelude.ByteString
datasetChanges_groundTruth :: Lens' DatasetChanges ByteString
datasetChanges_groundTruth = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DatasetChanges' {Base64
groundTruth :: Base64
$sel:groundTruth:DatasetChanges' :: DatasetChanges -> Base64
groundTruth} -> Base64
groundTruth) (\s :: DatasetChanges
s@DatasetChanges' {} Base64
a -> DatasetChanges
s {$sel:groundTruth:DatasetChanges' :: Base64
groundTruth = Base64
a} :: DatasetChanges) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Iso' Base64 ByteString
Data._Base64

instance Prelude.Hashable DatasetChanges where
  hashWithSalt :: Int -> DatasetChanges -> Int
hashWithSalt Int
_salt DatasetChanges' {Base64
groundTruth :: Base64
$sel:groundTruth:DatasetChanges' :: DatasetChanges -> Base64
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Base64
groundTruth

instance Prelude.NFData DatasetChanges where
  rnf :: DatasetChanges -> ()
rnf DatasetChanges' {Base64
groundTruth :: Base64
$sel:groundTruth:DatasetChanges' :: DatasetChanges -> Base64
..} = forall a. NFData a => a -> ()
Prelude.rnf Base64
groundTruth

instance Data.ToJSON DatasetChanges where
  toJSON :: DatasetChanges -> Value
toJSON DatasetChanges' {Base64
groundTruth :: Base64
$sel:groundTruth:DatasetChanges' :: DatasetChanges -> Base64
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"GroundTruth" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Base64
groundTruth)]
      )