{-# 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.ConnectCases.Types.FieldOption
-- 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.ConnectCases.Types.FieldOption 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

-- | Object for field Options information.
--
-- /See:/ 'newFieldOption' smart constructor.
data FieldOption = FieldOption'
  { -- | Describes whether the @FieldOption@ is active (displayed) or inactive.
    FieldOption -> Bool
active :: Prelude.Bool,
    -- | @FieldOptionName@ has max length 100 and disallows trailing spaces.
    FieldOption -> Text
name :: Prelude.Text,
    -- | @FieldOptionValue@ has max length 100 and must be alphanumeric with
    -- hyphens and underscores.
    FieldOption -> Text
value :: Prelude.Text
  }
  deriving (FieldOption -> FieldOption -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FieldOption -> FieldOption -> Bool
$c/= :: FieldOption -> FieldOption -> Bool
== :: FieldOption -> FieldOption -> Bool
$c== :: FieldOption -> FieldOption -> Bool
Prelude.Eq, ReadPrec [FieldOption]
ReadPrec FieldOption
Int -> ReadS FieldOption
ReadS [FieldOption]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FieldOption]
$creadListPrec :: ReadPrec [FieldOption]
readPrec :: ReadPrec FieldOption
$creadPrec :: ReadPrec FieldOption
readList :: ReadS [FieldOption]
$creadList :: ReadS [FieldOption]
readsPrec :: Int -> ReadS FieldOption
$creadsPrec :: Int -> ReadS FieldOption
Prelude.Read, Int -> FieldOption -> ShowS
[FieldOption] -> ShowS
FieldOption -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FieldOption] -> ShowS
$cshowList :: [FieldOption] -> ShowS
show :: FieldOption -> String
$cshow :: FieldOption -> String
showsPrec :: Int -> FieldOption -> ShowS
$cshowsPrec :: Int -> FieldOption -> ShowS
Prelude.Show, forall x. Rep FieldOption x -> FieldOption
forall x. FieldOption -> Rep FieldOption x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FieldOption x -> FieldOption
$cfrom :: forall x. FieldOption -> Rep FieldOption x
Prelude.Generic)

-- |
-- Create a value of 'FieldOption' 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:
--
-- 'active', 'fieldOption_active' - Describes whether the @FieldOption@ is active (displayed) or inactive.
--
-- 'name', 'fieldOption_name' - @FieldOptionName@ has max length 100 and disallows trailing spaces.
--
-- 'value', 'fieldOption_value' - @FieldOptionValue@ has max length 100 and must be alphanumeric with
-- hyphens and underscores.
newFieldOption ::
  -- | 'active'
  Prelude.Bool ->
  -- | 'name'
  Prelude.Text ->
  -- | 'value'
  Prelude.Text ->
  FieldOption
newFieldOption :: Bool -> Text -> Text -> FieldOption
newFieldOption Bool
pActive_ Text
pName_ Text
pValue_ =
  FieldOption'
    { $sel:active:FieldOption' :: Bool
active = Bool
pActive_,
      $sel:name:FieldOption' :: Text
name = Text
pName_,
      $sel:value:FieldOption' :: Text
value = Text
pValue_
    }

-- | Describes whether the @FieldOption@ is active (displayed) or inactive.
fieldOption_active :: Lens.Lens' FieldOption Prelude.Bool
fieldOption_active :: Lens' FieldOption Bool
fieldOption_active = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FieldOption' {Bool
active :: Bool
$sel:active:FieldOption' :: FieldOption -> Bool
active} -> Bool
active) (\s :: FieldOption
s@FieldOption' {} Bool
a -> FieldOption
s {$sel:active:FieldOption' :: Bool
active = Bool
a} :: FieldOption)

-- | @FieldOptionName@ has max length 100 and disallows trailing spaces.
fieldOption_name :: Lens.Lens' FieldOption Prelude.Text
fieldOption_name :: Lens' FieldOption Text
fieldOption_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FieldOption' {Text
name :: Text
$sel:name:FieldOption' :: FieldOption -> Text
name} -> Text
name) (\s :: FieldOption
s@FieldOption' {} Text
a -> FieldOption
s {$sel:name:FieldOption' :: Text
name = Text
a} :: FieldOption)

-- | @FieldOptionValue@ has max length 100 and must be alphanumeric with
-- hyphens and underscores.
fieldOption_value :: Lens.Lens' FieldOption Prelude.Text
fieldOption_value :: Lens' FieldOption Text
fieldOption_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FieldOption' {Text
value :: Text
$sel:value:FieldOption' :: FieldOption -> Text
value} -> Text
value) (\s :: FieldOption
s@FieldOption' {} Text
a -> FieldOption
s {$sel:value:FieldOption' :: Text
value = Text
a} :: FieldOption)

instance Data.FromJSON FieldOption where
  parseJSON :: Value -> Parser FieldOption
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FieldOption"
      ( \Object
x ->
          Bool -> Text -> Text -> FieldOption
FieldOption'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"active")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"name")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"value")
      )

instance Prelude.Hashable FieldOption where
  hashWithSalt :: Int -> FieldOption -> Int
hashWithSalt Int
_salt FieldOption' {Bool
Text
value :: Text
name :: Text
active :: Bool
$sel:value:FieldOption' :: FieldOption -> Text
$sel:name:FieldOption' :: FieldOption -> Text
$sel:active:FieldOption' :: FieldOption -> Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Bool
active
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
value

instance Prelude.NFData FieldOption where
  rnf :: FieldOption -> ()
rnf FieldOption' {Bool
Text
value :: Text
name :: Text
active :: Bool
$sel:value:FieldOption' :: FieldOption -> Text
$sel:name:FieldOption' :: FieldOption -> Text
$sel:active:FieldOption' :: FieldOption -> Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Bool
active
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
value

instance Data.ToJSON FieldOption where
  toJSON :: FieldOption -> Value
toJSON FieldOption' {Bool
Text
value :: Text
name :: Text
active :: Bool
$sel:value:FieldOption' :: FieldOption -> Text
$sel:name:FieldOption' :: FieldOption -> Text
$sel:active:FieldOption' :: FieldOption -> Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"active" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Bool
active),
            forall a. a -> Maybe a
Prelude.Just (Key
"name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"value" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
value)
          ]
      )