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

-- | CellInput object contains the data needed to create or update cells in a
-- table.
--
-- CellInput object has only a facts field or a fact field, but not both. A
-- 400 bad request will be thrown if both fact and facts field are present.
--
-- /See:/ 'newCellInput' smart constructor.
data CellInput = CellInput'
  { -- | Fact represents the data that is entered into a cell. This data can be
    -- free text or a formula. Formulas need to start with the equals (=) sign.
    CellInput -> Maybe (Sensitive Text)
fact :: Prelude.Maybe (Data.Sensitive Prelude.Text),
    -- | A list representing the values that are entered into a ROWSET cell.
    -- Facts list can have either only values or rowIDs, and rowIDs should from
    -- the same table.
    CellInput -> Maybe [Sensitive Text]
facts :: Prelude.Maybe [Data.Sensitive Prelude.Text]
  }
  deriving (CellInput -> CellInput -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CellInput -> CellInput -> Bool
$c/= :: CellInput -> CellInput -> Bool
== :: CellInput -> CellInput -> Bool
$c== :: CellInput -> CellInput -> Bool
Prelude.Eq, Int -> CellInput -> ShowS
[CellInput] -> ShowS
CellInput -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CellInput] -> ShowS
$cshowList :: [CellInput] -> ShowS
show :: CellInput -> String
$cshow :: CellInput -> String
showsPrec :: Int -> CellInput -> ShowS
$cshowsPrec :: Int -> CellInput -> ShowS
Prelude.Show, forall x. Rep CellInput x -> CellInput
forall x. CellInput -> Rep CellInput x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CellInput x -> CellInput
$cfrom :: forall x. CellInput -> Rep CellInput x
Prelude.Generic)

-- |
-- Create a value of 'CellInput' 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:
--
-- 'fact', 'cellInput_fact' - Fact represents the data that is entered into a cell. This data can be
-- free text or a formula. Formulas need to start with the equals (=) sign.
--
-- 'facts', 'cellInput_facts' - A list representing the values that are entered into a ROWSET cell.
-- Facts list can have either only values or rowIDs, and rowIDs should from
-- the same table.
newCellInput ::
  CellInput
newCellInput :: CellInput
newCellInput =
  CellInput'
    { $sel:fact:CellInput' :: Maybe (Sensitive Text)
fact = forall a. Maybe a
Prelude.Nothing,
      $sel:facts:CellInput' :: Maybe [Sensitive Text]
facts = forall a. Maybe a
Prelude.Nothing
    }

-- | Fact represents the data that is entered into a cell. This data can be
-- free text or a formula. Formulas need to start with the equals (=) sign.
cellInput_fact :: Lens.Lens' CellInput (Prelude.Maybe Prelude.Text)
cellInput_fact :: Lens' CellInput (Maybe Text)
cellInput_fact = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CellInput' {Maybe (Sensitive Text)
fact :: Maybe (Sensitive Text)
$sel:fact:CellInput' :: CellInput -> Maybe (Sensitive Text)
fact} -> Maybe (Sensitive Text)
fact) (\s :: CellInput
s@CellInput' {} Maybe (Sensitive Text)
a -> CellInput
s {$sel:fact:CellInput' :: Maybe (Sensitive Text)
fact = Maybe (Sensitive Text)
a} :: CellInput) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall a. Iso' (Sensitive a) a
Data._Sensitive

-- | A list representing the values that are entered into a ROWSET cell.
-- Facts list can have either only values or rowIDs, and rowIDs should from
-- the same table.
cellInput_facts :: Lens.Lens' CellInput (Prelude.Maybe [Prelude.Text])
cellInput_facts :: Lens' CellInput (Maybe [Text])
cellInput_facts = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CellInput' {Maybe [Sensitive Text]
facts :: Maybe [Sensitive Text]
$sel:facts:CellInput' :: CellInput -> Maybe [Sensitive Text]
facts} -> Maybe [Sensitive Text]
facts) (\s :: CellInput
s@CellInput' {} Maybe [Sensitive Text]
a -> CellInput
s {$sel:facts:CellInput' :: Maybe [Sensitive Text]
facts = Maybe [Sensitive Text]
a} :: CellInput) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable CellInput where
  hashWithSalt :: Int -> CellInput -> Int
hashWithSalt Int
_salt CellInput' {Maybe [Sensitive Text]
Maybe (Sensitive Text)
facts :: Maybe [Sensitive Text]
fact :: Maybe (Sensitive Text)
$sel:facts:CellInput' :: CellInput -> Maybe [Sensitive Text]
$sel:fact:CellInput' :: CellInput -> Maybe (Sensitive Text)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Text)
fact
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Sensitive Text]
facts

instance Prelude.NFData CellInput where
  rnf :: CellInput -> ()
rnf CellInput' {Maybe [Sensitive Text]
Maybe (Sensitive Text)
facts :: Maybe [Sensitive Text]
fact :: Maybe (Sensitive Text)
$sel:facts:CellInput' :: CellInput -> Maybe [Sensitive Text]
$sel:fact:CellInput' :: CellInput -> Maybe (Sensitive Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
fact seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Sensitive Text]
facts

instance Data.ToJSON CellInput where
  toJSON :: CellInput -> Value
toJSON CellInput' {Maybe [Sensitive Text]
Maybe (Sensitive Text)
facts :: Maybe [Sensitive Text]
fact :: Maybe (Sensitive Text)
$sel:facts:CellInput' :: CellInput -> Maybe [Sensitive Text]
$sel:fact:CellInput' :: CellInput -> Maybe (Sensitive Text)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"fact" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (Sensitive Text)
fact,
            (Key
"facts" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Sensitive Text]
facts
          ]
      )