{-# 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.Change
-- 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.Change 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.ChangeAction
import Amazonka.Route53.Types.ResourceRecordSet

-- | The information for each resource record set that you want to change.
--
-- /See:/ 'newChange' smart constructor.
data Change = Change'
  { -- | The action to perform:
    --
    -- -   @CREATE@: Creates a resource record set that has the specified
    --     values.
    --
    -- -   @DELETE@: Deletes a existing resource record set.
    --
    --     To delete the resource record set that is associated with a traffic
    --     policy instance, use
    --     <https://docs.aws.amazon.com/Route53/latest/APIReference/API_DeleteTrafficPolicyInstance.html DeleteTrafficPolicyInstance>.
    --     Amazon Route 53 will delete the resource record set automatically.
    --     If you delete the resource record set by using
    --     @ChangeResourceRecordSets@, Route 53 doesn\'t automatically delete
    --     the traffic policy instance, and you\'ll continue to be charged for
    --     it even though it\'s no longer in use.
    --
    -- -   @UPSERT@: If a resource record set doesn\'t already exist, Route 53
    --     creates it. If a resource record set does exist, Route 53 updates it
    --     with the values in the request.
    Change -> ChangeAction
action :: ChangeAction,
    -- | Information about the resource record set to create, delete, or update.
    Change -> ResourceRecordSet
resourceRecordSet :: ResourceRecordSet
  }
  deriving (Change -> Change -> Bool
(Change -> Change -> Bool)
-> (Change -> Change -> Bool) -> Eq Change
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Change -> Change -> Bool
$c/= :: Change -> Change -> Bool
== :: Change -> Change -> Bool
$c== :: Change -> Change -> Bool
Prelude.Eq, ReadPrec [Change]
ReadPrec Change
Int -> ReadS Change
ReadS [Change]
(Int -> ReadS Change)
-> ReadS [Change]
-> ReadPrec Change
-> ReadPrec [Change]
-> Read Change
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Change]
$creadListPrec :: ReadPrec [Change]
readPrec :: ReadPrec Change
$creadPrec :: ReadPrec Change
readList :: ReadS [Change]
$creadList :: ReadS [Change]
readsPrec :: Int -> ReadS Change
$creadsPrec :: Int -> ReadS Change
Prelude.Read, Int -> Change -> ShowS
[Change] -> ShowS
Change -> String
(Int -> Change -> ShowS)
-> (Change -> String) -> ([Change] -> ShowS) -> Show Change
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Change] -> ShowS
$cshowList :: [Change] -> ShowS
show :: Change -> String
$cshow :: Change -> String
showsPrec :: Int -> Change -> ShowS
$cshowsPrec :: Int -> Change -> ShowS
Prelude.Show, (forall x. Change -> Rep Change x)
-> (forall x. Rep Change x -> Change) -> Generic Change
forall x. Rep Change x -> Change
forall x. Change -> Rep Change x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Change x -> Change
$cfrom :: forall x. Change -> Rep Change x
Prelude.Generic)

-- |
-- Create a value of 'Change' 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:
--
-- 'action', 'change_action' - The action to perform:
--
-- -   @CREATE@: Creates a resource record set that has the specified
--     values.
--
-- -   @DELETE@: Deletes a existing resource record set.
--
--     To delete the resource record set that is associated with a traffic
--     policy instance, use
--     <https://docs.aws.amazon.com/Route53/latest/APIReference/API_DeleteTrafficPolicyInstance.html DeleteTrafficPolicyInstance>.
--     Amazon Route 53 will delete the resource record set automatically.
--     If you delete the resource record set by using
--     @ChangeResourceRecordSets@, Route 53 doesn\'t automatically delete
--     the traffic policy instance, and you\'ll continue to be charged for
--     it even though it\'s no longer in use.
--
-- -   @UPSERT@: If a resource record set doesn\'t already exist, Route 53
--     creates it. If a resource record set does exist, Route 53 updates it
--     with the values in the request.
--
-- 'resourceRecordSet', 'change_resourceRecordSet' - Information about the resource record set to create, delete, or update.
newChange ::
  -- | 'action'
  ChangeAction ->
  -- | 'resourceRecordSet'
  ResourceRecordSet ->
  Change
newChange :: ChangeAction -> ResourceRecordSet -> Change
newChange ChangeAction
pAction_ ResourceRecordSet
pResourceRecordSet_ =
  Change' :: ChangeAction -> ResourceRecordSet -> Change
Change'
    { $sel:action:Change' :: ChangeAction
action = ChangeAction
pAction_,
      $sel:resourceRecordSet:Change' :: ResourceRecordSet
resourceRecordSet = ResourceRecordSet
pResourceRecordSet_
    }

-- | The action to perform:
--
-- -   @CREATE@: Creates a resource record set that has the specified
--     values.
--
-- -   @DELETE@: Deletes a existing resource record set.
--
--     To delete the resource record set that is associated with a traffic
--     policy instance, use
--     <https://docs.aws.amazon.com/Route53/latest/APIReference/API_DeleteTrafficPolicyInstance.html DeleteTrafficPolicyInstance>.
--     Amazon Route 53 will delete the resource record set automatically.
--     If you delete the resource record set by using
--     @ChangeResourceRecordSets@, Route 53 doesn\'t automatically delete
--     the traffic policy instance, and you\'ll continue to be charged for
--     it even though it\'s no longer in use.
--
-- -   @UPSERT@: If a resource record set doesn\'t already exist, Route 53
--     creates it. If a resource record set does exist, Route 53 updates it
--     with the values in the request.
change_action :: Lens.Lens' Change ChangeAction
change_action :: (ChangeAction -> f ChangeAction) -> Change -> f Change
change_action = (Change -> ChangeAction)
-> (Change -> ChangeAction -> Change)
-> Lens Change Change ChangeAction ChangeAction
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Change' {ChangeAction
action :: ChangeAction
$sel:action:Change' :: Change -> ChangeAction
action} -> ChangeAction
action) (\s :: Change
s@Change' {} ChangeAction
a -> Change
s {$sel:action:Change' :: ChangeAction
action = ChangeAction
a} :: Change)

-- | Information about the resource record set to create, delete, or update.
change_resourceRecordSet :: Lens.Lens' Change ResourceRecordSet
change_resourceRecordSet :: (ResourceRecordSet -> f ResourceRecordSet) -> Change -> f Change
change_resourceRecordSet = (Change -> ResourceRecordSet)
-> (Change -> ResourceRecordSet -> Change)
-> Lens Change Change ResourceRecordSet ResourceRecordSet
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Change' {ResourceRecordSet
resourceRecordSet :: ResourceRecordSet
$sel:resourceRecordSet:Change' :: Change -> ResourceRecordSet
resourceRecordSet} -> ResourceRecordSet
resourceRecordSet) (\s :: Change
s@Change' {} ResourceRecordSet
a -> Change
s {$sel:resourceRecordSet:Change' :: ResourceRecordSet
resourceRecordSet = ResourceRecordSet
a} :: Change)

instance Prelude.Hashable Change

instance Prelude.NFData Change

instance Core.ToXML Change where
  toXML :: Change -> XML
toXML Change' {ChangeAction
ResourceRecordSet
resourceRecordSet :: ResourceRecordSet
action :: ChangeAction
$sel:resourceRecordSet:Change' :: Change -> ResourceRecordSet
$sel:action:Change' :: Change -> ChangeAction
..} =
    [XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ Name
"Action" Name -> ChangeAction -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= ChangeAction
action,
        Name
"ResourceRecordSet" Name -> ResourceRecordSet -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= ResourceRecordSet
resourceRecordSet
      ]