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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.GamesParks.Types.Document
import qualified Amazonka.Prelude as Prelude

-- | The configuration section.
--
-- /See:/ 'newSection' smart constructor.
data Section = Section'
  { -- | The content of a configuration section.
    Section -> Maybe Document
attributes :: Prelude.Maybe Document,
    -- | The name of the section.
    Section -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The size, in bytes, of the section contents.
    Section -> Maybe Natural
size :: Prelude.Maybe Prelude.Natural
  }
  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:
--
-- 'attributes', 'section_attributes' - The content of a configuration section.
--
-- 'name', 'section_name' - The name of the section.
--
-- 'size', 'section_size' - The size, in bytes, of the section contents.
newSection ::
  Section
newSection :: Section
newSection =
  Section'
    { $sel:attributes:Section' :: Maybe Document
attributes = forall a. Maybe a
Prelude.Nothing,
      $sel:name:Section' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:size:Section' :: Maybe Natural
size = forall a. Maybe a
Prelude.Nothing
    }

-- | The content of a configuration section.
section_attributes :: Lens.Lens' Section (Prelude.Maybe Document)
section_attributes :: Lens' Section (Maybe Document)
section_attributes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Section' {Maybe Document
attributes :: Maybe Document
$sel:attributes:Section' :: Section -> Maybe Document
attributes} -> Maybe Document
attributes) (\s :: Section
s@Section' {} Maybe Document
a -> Section
s {$sel:attributes:Section' :: Maybe Document
attributes = Maybe Document
a} :: Section)

-- | The name of the section.
section_name :: Lens.Lens' Section (Prelude.Maybe Prelude.Text)
section_name :: Lens' Section (Maybe Text)
section_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Section' {Maybe Text
name :: Maybe Text
$sel:name:Section' :: Section -> Maybe Text
name} -> Maybe Text
name) (\s :: Section
s@Section' {} Maybe Text
a -> Section
s {$sel:name:Section' :: Maybe Text
name = Maybe Text
a} :: Section)

-- | The size, in bytes, of the section contents.
section_size :: Lens.Lens' Section (Prelude.Maybe Prelude.Natural)
section_size :: Lens' Section (Maybe Natural)
section_size = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Section' {Maybe Natural
size :: Maybe Natural
$sel:size:Section' :: Section -> Maybe Natural
size} -> Maybe Natural
size) (\s :: Section
s@Section' {} Maybe Natural
a -> Section
s {$sel:size:Section' :: Maybe Natural
size = Maybe Natural
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 Document -> Maybe Text -> Maybe Natural -> 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
"Attributes")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe 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 (Maybe a)
Data..:? Key
"Size")
      )

instance Prelude.Hashable Section where
  hashWithSalt :: Int -> Section -> Int
hashWithSalt Int
_salt Section' {Maybe Natural
Maybe Text
Maybe Document
size :: Maybe Natural
name :: Maybe Text
attributes :: Maybe Document
$sel:size:Section' :: Section -> Maybe Natural
$sel:name:Section' :: Section -> Maybe Text
$sel:attributes:Section' :: Section -> Maybe Document
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Document
attributes
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
size

instance Prelude.NFData Section where
  rnf :: Section -> ()
rnf Section' {Maybe Natural
Maybe Text
Maybe Document
size :: Maybe Natural
name :: Maybe Text
attributes :: Maybe Document
$sel:size:Section' :: Section -> Maybe Natural
$sel:name:Section' :: Section -> Maybe Text
$sel:attributes:Section' :: Section -> Maybe Document
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Document
attributes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
size