{-# 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.Route53.Types.ChangeBatch
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Route53.Types.ChangeBatch where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Route53.Internal
import Amazonka.Route53.Types.Change

-- | The information for a change request.
--
-- /See:/ 'newChangeBatch' smart constructor.
data ChangeBatch = ChangeBatch'
  { -- | /Optional:/ Any comments you want to include about a change batch
    -- request.
    ChangeBatch -> Maybe Text
comment :: Prelude.Maybe Prelude.Text,
    -- | Information about the changes to make to the record sets.
    ChangeBatch -> NonEmpty Change
changes :: Prelude.NonEmpty Change
  }
  deriving (ChangeBatch -> ChangeBatch -> Bool
(ChangeBatch -> ChangeBatch -> Bool)
-> (ChangeBatch -> ChangeBatch -> Bool) -> Eq ChangeBatch
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ChangeBatch -> ChangeBatch -> Bool
$c/= :: ChangeBatch -> ChangeBatch -> Bool
== :: ChangeBatch -> ChangeBatch -> Bool
$c== :: ChangeBatch -> ChangeBatch -> Bool
Prelude.Eq, ReadPrec [ChangeBatch]
ReadPrec ChangeBatch
Int -> ReadS ChangeBatch
ReadS [ChangeBatch]
(Int -> ReadS ChangeBatch)
-> ReadS [ChangeBatch]
-> ReadPrec ChangeBatch
-> ReadPrec [ChangeBatch]
-> Read ChangeBatch
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ChangeBatch]
$creadListPrec :: ReadPrec [ChangeBatch]
readPrec :: ReadPrec ChangeBatch
$creadPrec :: ReadPrec ChangeBatch
readList :: ReadS [ChangeBatch]
$creadList :: ReadS [ChangeBatch]
readsPrec :: Int -> ReadS ChangeBatch
$creadsPrec :: Int -> ReadS ChangeBatch
Prelude.Read, Int -> ChangeBatch -> ShowS
[ChangeBatch] -> ShowS
ChangeBatch -> String
(Int -> ChangeBatch -> ShowS)
-> (ChangeBatch -> String)
-> ([ChangeBatch] -> ShowS)
-> Show ChangeBatch
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ChangeBatch] -> ShowS
$cshowList :: [ChangeBatch] -> ShowS
show :: ChangeBatch -> String
$cshow :: ChangeBatch -> String
showsPrec :: Int -> ChangeBatch -> ShowS
$cshowsPrec :: Int -> ChangeBatch -> ShowS
Prelude.Show, (forall x. ChangeBatch -> Rep ChangeBatch x)
-> (forall x. Rep ChangeBatch x -> ChangeBatch)
-> Generic ChangeBatch
forall x. Rep ChangeBatch x -> ChangeBatch
forall x. ChangeBatch -> Rep ChangeBatch x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ChangeBatch x -> ChangeBatch
$cfrom :: forall x. ChangeBatch -> Rep ChangeBatch x
Prelude.Generic)

-- |
-- Create a value of 'ChangeBatch' 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:
--
-- 'comment', 'changeBatch_comment' - /Optional:/ Any comments you want to include about a change batch
-- request.
--
-- 'changes', 'changeBatch_changes' - Information about the changes to make to the record sets.
newChangeBatch ::
  -- | 'changes'
  Prelude.NonEmpty Change ->
  ChangeBatch
newChangeBatch :: NonEmpty Change -> ChangeBatch
newChangeBatch NonEmpty Change
pChanges_ =
  ChangeBatch' :: Maybe Text -> NonEmpty Change -> ChangeBatch
ChangeBatch'
    { $sel:comment:ChangeBatch' :: Maybe Text
comment = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:changes:ChangeBatch' :: NonEmpty Change
changes = Tagged (NonEmpty Change) (Identity (NonEmpty Change))
-> Tagged (NonEmpty Change) (Identity (NonEmpty Change))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged (NonEmpty Change) (Identity (NonEmpty Change))
 -> Tagged (NonEmpty Change) (Identity (NonEmpty Change)))
-> NonEmpty Change -> NonEmpty Change
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Change
pChanges_
    }

-- | /Optional:/ Any comments you want to include about a change batch
-- request.
changeBatch_comment :: Lens.Lens' ChangeBatch (Prelude.Maybe Prelude.Text)
changeBatch_comment :: (Maybe Text -> f (Maybe Text)) -> ChangeBatch -> f ChangeBatch
changeBatch_comment = (ChangeBatch -> Maybe Text)
-> (ChangeBatch -> Maybe Text -> ChangeBatch)
-> Lens ChangeBatch ChangeBatch (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChangeBatch' {Maybe Text
comment :: Maybe Text
$sel:comment:ChangeBatch' :: ChangeBatch -> Maybe Text
comment} -> Maybe Text
comment) (\s :: ChangeBatch
s@ChangeBatch' {} Maybe Text
a -> ChangeBatch
s {$sel:comment:ChangeBatch' :: Maybe Text
comment = Maybe Text
a} :: ChangeBatch)

-- | Information about the changes to make to the record sets.
changeBatch_changes :: Lens.Lens' ChangeBatch (Prelude.NonEmpty Change)
changeBatch_changes :: (NonEmpty Change -> f (NonEmpty Change))
-> ChangeBatch -> f ChangeBatch
changeBatch_changes = (ChangeBatch -> NonEmpty Change)
-> (ChangeBatch -> NonEmpty Change -> ChangeBatch)
-> Lens ChangeBatch ChangeBatch (NonEmpty Change) (NonEmpty Change)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChangeBatch' {NonEmpty Change
changes :: NonEmpty Change
$sel:changes:ChangeBatch' :: ChangeBatch -> NonEmpty Change
changes} -> NonEmpty Change
changes) (\s :: ChangeBatch
s@ChangeBatch' {} NonEmpty Change
a -> ChangeBatch
s {$sel:changes:ChangeBatch' :: NonEmpty Change
changes = NonEmpty Change
a} :: ChangeBatch) ((NonEmpty Change -> f (NonEmpty Change))
 -> ChangeBatch -> f ChangeBatch)
-> ((NonEmpty Change -> f (NonEmpty Change))
    -> NonEmpty Change -> f (NonEmpty Change))
-> (NonEmpty Change -> f (NonEmpty Change))
-> ChangeBatch
-> f ChangeBatch
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Change -> f (NonEmpty Change))
-> NonEmpty Change -> f (NonEmpty Change)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable ChangeBatch

instance Prelude.NFData ChangeBatch

instance Core.ToXML ChangeBatch where
  toXML :: ChangeBatch -> XML
toXML ChangeBatch' {Maybe Text
NonEmpty Change
changes :: NonEmpty Change
comment :: Maybe Text
$sel:changes:ChangeBatch' :: ChangeBatch -> NonEmpty Change
$sel:comment:ChangeBatch' :: ChangeBatch -> Maybe Text
..} =
    [XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ Name
"Comment" Name -> Maybe Text -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe Text
comment,
        Name
"Changes" Name -> XML -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Name -> NonEmpty Change -> XML
forall a. (IsList a, ToXML (Item a)) => Name -> a -> XML
Core.toXMLList Name
"Change" NonEmpty Change
changes
      ]