{-# 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.Firehose.Types.Record
-- 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.Firehose.Types.Record 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

-- | The unit of data in a delivery stream.
--
-- /See:/ 'newRecord' smart constructor.
data Record = Record'
  { -- | The data blob, which is base64-encoded when the blob is serialized. The
    -- maximum size of the data blob, before base64-encoding, is 1,000 KiB.
    Record -> Base64
data' :: Data.Base64
  }
  deriving (Record -> Record -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Record -> Record -> Bool
$c/= :: Record -> Record -> Bool
== :: Record -> Record -> Bool
$c== :: Record -> Record -> Bool
Prelude.Eq, ReadPrec [Record]
ReadPrec Record
Int -> ReadS Record
ReadS [Record]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Record]
$creadListPrec :: ReadPrec [Record]
readPrec :: ReadPrec Record
$creadPrec :: ReadPrec Record
readList :: ReadS [Record]
$creadList :: ReadS [Record]
readsPrec :: Int -> ReadS Record
$creadsPrec :: Int -> ReadS Record
Prelude.Read, Int -> Record -> ShowS
[Record] -> ShowS
Record -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Record] -> ShowS
$cshowList :: [Record] -> ShowS
show :: Record -> String
$cshow :: Record -> String
showsPrec :: Int -> Record -> ShowS
$cshowsPrec :: Int -> Record -> ShowS
Prelude.Show, forall x. Rep Record x -> Record
forall x. Record -> Rep Record x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Record x -> Record
$cfrom :: forall x. Record -> Rep Record x
Prelude.Generic)

-- |
-- Create a value of 'Record' 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:
--
-- 'data'', 'record_data' - The data blob, which is base64-encoded when the blob is serialized. The
-- maximum size of the data blob, before base64-encoding, is 1,000 KiB.--
-- -- /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.
newRecord ::
  -- | 'data''
  Prelude.ByteString ->
  Record
newRecord :: ByteString -> Record
newRecord ByteString
pData_ =
  Record' {$sel:data':Record' :: Base64
data' = Iso' Base64 ByteString
Data._Base64 forall t b. AReview t b -> b -> t
Lens.# ByteString
pData_}

-- | The data blob, which is base64-encoded when the blob is serialized. The
-- maximum size of the data blob, before base64-encoding, is 1,000 KiB.--
-- -- /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.
record_data :: Lens.Lens' Record Prelude.ByteString
record_data :: Lens' Record ByteString
record_data = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Record' {Base64
data' :: Base64
$sel:data':Record' :: Record -> Base64
data'} -> Base64
data') (\s :: Record
s@Record' {} Base64
a -> Record
s {$sel:data':Record' :: Base64
data' = Base64
a} :: Record) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Iso' Base64 ByteString
Data._Base64

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

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

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