{-# 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.Section
-- 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.Section where

import Amazonka.ConnectCases.Types.FieldGroup
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

-- | This represents a sections within a panel or tab of the page layout.
--
-- /See:/ 'newSection' smart constructor.
data Section = Section'
  { -- | Consists of a group of fields and associated properties.
    Section -> Maybe FieldGroup
fieldGroup :: Prelude.Maybe FieldGroup
  }
  deriving (Section -> Section -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Section -> Section -> Bool
$c/= :: Section -> Section -> Bool
== :: Section -> Section -> Bool
$c== :: Section -> Section -> Bool
Prelude.Eq, ReadPrec [Section]
ReadPrec Section
Int -> ReadS Section
ReadS [Section]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Section]
$creadListPrec :: ReadPrec [Section]
readPrec :: ReadPrec Section
$creadPrec :: ReadPrec Section
readList :: ReadS [Section]
$creadList :: ReadS [Section]
readsPrec :: Int -> ReadS Section
$creadsPrec :: Int -> ReadS Section
Prelude.Read, Int -> Section -> ShowS
[Section] -> ShowS
Section -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Section] -> ShowS
$cshowList :: [Section] -> ShowS
show :: Section -> String
$cshow :: Section -> String
showsPrec :: Int -> Section -> ShowS
$cshowsPrec :: Int -> Section -> ShowS
Prelude.Show, forall x. Rep Section x -> Section
forall x. Section -> Rep Section x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Section x -> Section
$cfrom :: forall x. Section -> Rep Section x
Prelude.Generic)

-- |
-- Create a value of 'Section' 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:
--
-- 'fieldGroup', 'section_fieldGroup' - Consists of a group of fields and associated properties.
newSection ::
  Section
newSection :: Section
newSection = Section' {$sel:fieldGroup:Section' :: Maybe FieldGroup
fieldGroup = forall a. Maybe a
Prelude.Nothing}

-- | Consists of a group of fields and associated properties.
section_fieldGroup :: Lens.Lens' Section (Prelude.Maybe FieldGroup)
section_fieldGroup :: Lens' Section (Maybe FieldGroup)
section_fieldGroup = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Section' {Maybe FieldGroup
fieldGroup :: Maybe FieldGroup
$sel:fieldGroup:Section' :: Section -> Maybe FieldGroup
fieldGroup} -> Maybe FieldGroup
fieldGroup) (\s :: Section
s@Section' {} Maybe FieldGroup
a -> Section
s {$sel:fieldGroup:Section' :: Maybe FieldGroup
fieldGroup = Maybe FieldGroup
a} :: Section)

instance Data.FromJSON Section where
  parseJSON :: Value -> Parser Section
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Section"
      ( \Object
x ->
          Maybe FieldGroup -> Section
Section' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"fieldGroup")
      )

instance Prelude.Hashable Section where
  hashWithSalt :: Int -> Section -> Int
hashWithSalt Int
_salt Section' {Maybe FieldGroup
fieldGroup :: Maybe FieldGroup
$sel:fieldGroup:Section' :: Section -> Maybe FieldGroup
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FieldGroup
fieldGroup

instance Prelude.NFData Section where
  rnf :: Section -> ()
rnf Section' {Maybe FieldGroup
fieldGroup :: Maybe FieldGroup
$sel:fieldGroup:Section' :: Section -> Maybe FieldGroup
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe FieldGroup
fieldGroup

instance Data.ToJSON Section where
  toJSON :: Section -> Value
toJSON Section' {Maybe FieldGroup
fieldGroup :: Maybe FieldGroup
$sel:fieldGroup:Section' :: Section -> Maybe FieldGroup
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"fieldGroup" 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 FieldGroup
fieldGroup]
      )