{-# 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.HoneyCode.Types.ResultRow
-- 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.HoneyCode.Types.ResultRow where

import qualified Amazonka.Core as Core
import Amazonka.HoneyCode.Types.DataItem
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A single row in the ResultSet.
--
-- /See:/ 'newResultRow' smart constructor.
data ResultRow = ResultRow'
  { -- | The ID for a particular row.
    ResultRow -> Maybe Text
rowId :: Prelude.Maybe Prelude.Text,
    -- | List of all the data cells in a row.
    ResultRow -> [Sensitive DataItem]
dataItems :: [Core.Sensitive DataItem]
  }
  deriving (ResultRow -> ResultRow -> Bool
(ResultRow -> ResultRow -> Bool)
-> (ResultRow -> ResultRow -> Bool) -> Eq ResultRow
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResultRow -> ResultRow -> Bool
$c/= :: ResultRow -> ResultRow -> Bool
== :: ResultRow -> ResultRow -> Bool
$c== :: ResultRow -> ResultRow -> Bool
Prelude.Eq, Int -> ResultRow -> ShowS
[ResultRow] -> ShowS
ResultRow -> String
(Int -> ResultRow -> ShowS)
-> (ResultRow -> String)
-> ([ResultRow] -> ShowS)
-> Show ResultRow
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResultRow] -> ShowS
$cshowList :: [ResultRow] -> ShowS
show :: ResultRow -> String
$cshow :: ResultRow -> String
showsPrec :: Int -> ResultRow -> ShowS
$cshowsPrec :: Int -> ResultRow -> ShowS
Prelude.Show, (forall x. ResultRow -> Rep ResultRow x)
-> (forall x. Rep ResultRow x -> ResultRow) -> Generic ResultRow
forall x. Rep ResultRow x -> ResultRow
forall x. ResultRow -> Rep ResultRow x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResultRow x -> ResultRow
$cfrom :: forall x. ResultRow -> Rep ResultRow x
Prelude.Generic)

-- |
-- Create a value of 'ResultRow' 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:
--
-- 'rowId', 'resultRow_rowId' - The ID for a particular row.
--
-- 'dataItems', 'resultRow_dataItems' - List of all the data cells in a row.
newResultRow ::
  ResultRow
newResultRow :: ResultRow
newResultRow =
  ResultRow' :: Maybe Text -> [Sensitive DataItem] -> ResultRow
ResultRow'
    { $sel:rowId:ResultRow' :: Maybe Text
rowId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:dataItems:ResultRow' :: [Sensitive DataItem]
dataItems = [Sensitive DataItem]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The ID for a particular row.
resultRow_rowId :: Lens.Lens' ResultRow (Prelude.Maybe Prelude.Text)
resultRow_rowId :: (Maybe Text -> f (Maybe Text)) -> ResultRow -> f ResultRow
resultRow_rowId = (ResultRow -> Maybe Text)
-> (ResultRow -> Maybe Text -> ResultRow)
-> Lens ResultRow ResultRow (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResultRow' {Maybe Text
rowId :: Maybe Text
$sel:rowId:ResultRow' :: ResultRow -> Maybe Text
rowId} -> Maybe Text
rowId) (\s :: ResultRow
s@ResultRow' {} Maybe Text
a -> ResultRow
s {$sel:rowId:ResultRow' :: Maybe Text
rowId = Maybe Text
a} :: ResultRow)

-- | List of all the data cells in a row.
resultRow_dataItems :: Lens.Lens' ResultRow [DataItem]
resultRow_dataItems :: ([DataItem] -> f [DataItem]) -> ResultRow -> f ResultRow
resultRow_dataItems = (ResultRow -> [Sensitive DataItem])
-> (ResultRow -> [Sensitive DataItem] -> ResultRow)
-> Lens
     ResultRow ResultRow [Sensitive DataItem] [Sensitive DataItem]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResultRow' {[Sensitive DataItem]
dataItems :: [Sensitive DataItem]
$sel:dataItems:ResultRow' :: ResultRow -> [Sensitive DataItem]
dataItems} -> [Sensitive DataItem]
dataItems) (\s :: ResultRow
s@ResultRow' {} [Sensitive DataItem]
a -> ResultRow
s {$sel:dataItems:ResultRow' :: [Sensitive DataItem]
dataItems = [Sensitive DataItem]
a} :: ResultRow) (([Sensitive DataItem] -> f [Sensitive DataItem])
 -> ResultRow -> f ResultRow)
-> (([DataItem] -> f [DataItem])
    -> [Sensitive DataItem] -> f [Sensitive DataItem])
-> ([DataItem] -> f [DataItem])
-> ResultRow
-> f ResultRow
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([DataItem] -> f [DataItem])
-> [Sensitive DataItem] -> f [Sensitive DataItem]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON ResultRow where
  parseJSON :: Value -> Parser ResultRow
parseJSON =
    String -> (Object -> Parser ResultRow) -> Value -> Parser ResultRow
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ResultRow"
      ( \Object
x ->
          Maybe Text -> [Sensitive DataItem] -> ResultRow
ResultRow'
            (Maybe Text -> [Sensitive DataItem] -> ResultRow)
-> Parser (Maybe Text)
-> Parser ([Sensitive DataItem] -> ResultRow)
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
"rowId")
            Parser ([Sensitive DataItem] -> ResultRow)
-> Parser [Sensitive DataItem] -> Parser ResultRow
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe [Sensitive DataItem])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"dataItems" Parser (Maybe [Sensitive DataItem])
-> [Sensitive DataItem] -> Parser [Sensitive DataItem]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [Sensitive DataItem]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ResultRow

instance Prelude.NFData ResultRow