{-# 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.SectionModification
-- 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.SectionModification 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 Amazonka.GamesParks.Types.Operation
import qualified Amazonka.Prelude as Prelude

-- | A single modification to the configuration section.
--
-- /See:/ 'newSectionModification' smart constructor.
data SectionModification = SectionModification'
  { -- | For add and replace operations, this is the value that will be used.
    --
    -- This field should be omitted for delete operations.
    SectionModification -> Maybe Document
value :: Prelude.Maybe Document,
    -- | The operation to be performed on a configuration section.
    --
    -- Content can be added, deleted, or replaced within a section.
    SectionModification -> Operation
operation :: Operation,
    -- | The path within the section content to be modified.
    SectionModification -> Text
path :: Prelude.Text,
    -- | The name of the section to be modified.
    SectionModification -> Text
section :: Prelude.Text
  }
  deriving (SectionModification -> SectionModification -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SectionModification -> SectionModification -> Bool
$c/= :: SectionModification -> SectionModification -> Bool
== :: SectionModification -> SectionModification -> Bool
$c== :: SectionModification -> SectionModification -> Bool
Prelude.Eq, ReadPrec [SectionModification]
ReadPrec SectionModification
Int -> ReadS SectionModification
ReadS [SectionModification]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SectionModification]
$creadListPrec :: ReadPrec [SectionModification]
readPrec :: ReadPrec SectionModification
$creadPrec :: ReadPrec SectionModification
readList :: ReadS [SectionModification]
$creadList :: ReadS [SectionModification]
readsPrec :: Int -> ReadS SectionModification
$creadsPrec :: Int -> ReadS SectionModification
Prelude.Read, Int -> SectionModification -> ShowS
[SectionModification] -> ShowS
SectionModification -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SectionModification] -> ShowS
$cshowList :: [SectionModification] -> ShowS
show :: SectionModification -> String
$cshow :: SectionModification -> String
showsPrec :: Int -> SectionModification -> ShowS
$cshowsPrec :: Int -> SectionModification -> ShowS
Prelude.Show, forall x. Rep SectionModification x -> SectionModification
forall x. SectionModification -> Rep SectionModification x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SectionModification x -> SectionModification
$cfrom :: forall x. SectionModification -> Rep SectionModification x
Prelude.Generic)

-- |
-- Create a value of 'SectionModification' 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:
--
-- 'value', 'sectionModification_value' - For add and replace operations, this is the value that will be used.
--
-- This field should be omitted for delete operations.
--
-- 'operation', 'sectionModification_operation' - The operation to be performed on a configuration section.
--
-- Content can be added, deleted, or replaced within a section.
--
-- 'path', 'sectionModification_path' - The path within the section content to be modified.
--
-- 'section', 'sectionModification_section' - The name of the section to be modified.
newSectionModification ::
  -- | 'operation'
  Operation ->
  -- | 'path'
  Prelude.Text ->
  -- | 'section'
  Prelude.Text ->
  SectionModification
newSectionModification :: Operation -> Text -> Text -> SectionModification
newSectionModification Operation
pOperation_ Text
pPath_ Text
pSection_ =
  SectionModification'
    { $sel:value:SectionModification' :: Maybe Document
value = forall a. Maybe a
Prelude.Nothing,
      $sel:operation:SectionModification' :: Operation
operation = Operation
pOperation_,
      $sel:path:SectionModification' :: Text
path = Text
pPath_,
      $sel:section:SectionModification' :: Text
section = Text
pSection_
    }

-- | For add and replace operations, this is the value that will be used.
--
-- This field should be omitted for delete operations.
sectionModification_value :: Lens.Lens' SectionModification (Prelude.Maybe Document)
sectionModification_value :: Lens' SectionModification (Maybe Document)
sectionModification_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SectionModification' {Maybe Document
value :: Maybe Document
$sel:value:SectionModification' :: SectionModification -> Maybe Document
value} -> Maybe Document
value) (\s :: SectionModification
s@SectionModification' {} Maybe Document
a -> SectionModification
s {$sel:value:SectionModification' :: Maybe Document
value = Maybe Document
a} :: SectionModification)

-- | The operation to be performed on a configuration section.
--
-- Content can be added, deleted, or replaced within a section.
sectionModification_operation :: Lens.Lens' SectionModification Operation
sectionModification_operation :: Lens' SectionModification Operation
sectionModification_operation = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SectionModification' {Operation
operation :: Operation
$sel:operation:SectionModification' :: SectionModification -> Operation
operation} -> Operation
operation) (\s :: SectionModification
s@SectionModification' {} Operation
a -> SectionModification
s {$sel:operation:SectionModification' :: Operation
operation = Operation
a} :: SectionModification)

-- | The path within the section content to be modified.
sectionModification_path :: Lens.Lens' SectionModification Prelude.Text
sectionModification_path :: Lens' SectionModification Text
sectionModification_path = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SectionModification' {Text
path :: Text
$sel:path:SectionModification' :: SectionModification -> Text
path} -> Text
path) (\s :: SectionModification
s@SectionModification' {} Text
a -> SectionModification
s {$sel:path:SectionModification' :: Text
path = Text
a} :: SectionModification)

-- | The name of the section to be modified.
sectionModification_section :: Lens.Lens' SectionModification Prelude.Text
sectionModification_section :: Lens' SectionModification Text
sectionModification_section = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SectionModification' {Text
section :: Text
$sel:section:SectionModification' :: SectionModification -> Text
section} -> Text
section) (\s :: SectionModification
s@SectionModification' {} Text
a -> SectionModification
s {$sel:section:SectionModification' :: Text
section = Text
a} :: SectionModification)

instance Prelude.Hashable SectionModification where
  hashWithSalt :: Int -> SectionModification -> Int
hashWithSalt Int
_salt SectionModification' {Maybe Document
Text
Operation
section :: Text
path :: Text
operation :: Operation
value :: Maybe Document
$sel:section:SectionModification' :: SectionModification -> Text
$sel:path:SectionModification' :: SectionModification -> Text
$sel:operation:SectionModification' :: SectionModification -> Operation
$sel:value:SectionModification' :: SectionModification -> Maybe Document
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Document
value
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Operation
operation
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
path
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
section

instance Prelude.NFData SectionModification where
  rnf :: SectionModification -> ()
rnf SectionModification' {Maybe Document
Text
Operation
section :: Text
path :: Text
operation :: Operation
value :: Maybe Document
$sel:section:SectionModification' :: SectionModification -> Text
$sel:path:SectionModification' :: SectionModification -> Text
$sel:operation:SectionModification' :: SectionModification -> Operation
$sel:value:SectionModification' :: SectionModification -> Maybe Document
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Document
value
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Operation
operation
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
path
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
section

instance Data.ToJSON SectionModification where
  toJSON :: SectionModification -> Value
toJSON SectionModification' {Maybe Document
Text
Operation
section :: Text
path :: Text
operation :: Operation
value :: Maybe Document
$sel:section:SectionModification' :: SectionModification -> Text
$sel:path:SectionModification' :: SectionModification -> Text
$sel:operation:SectionModification' :: SectionModification -> Operation
$sel:value:SectionModification' :: SectionModification -> Maybe Document
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Value" 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 Document
value,
            forall a. a -> Maybe a
Prelude.Just (Key
"Operation" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Operation
operation),
            forall a. a -> Maybe a
Prelude.Just (Key
"Path" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
path),
            forall a. a -> Maybe a
Prelude.Just (Key
"Section" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
section)
          ]
      )