{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Route53.Types.Change where

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
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
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]
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
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. 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'
    { $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 :: Lens' Change ChangeAction
change_action = 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 :: Lens' Change ResourceRecordSet
change_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 where
  hashWithSalt :: Int -> Change -> Int
hashWithSalt Int
_salt Change' {ChangeAction
ResourceRecordSet
resourceRecordSet :: ResourceRecordSet
action :: ChangeAction
$sel:resourceRecordSet:Change' :: Change -> ResourceRecordSet
$sel:action:Change' :: Change -> ChangeAction
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ChangeAction
action
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ResourceRecordSet
resourceRecordSet

instance Prelude.NFData Change where
  rnf :: Change -> ()
rnf Change' {ChangeAction
ResourceRecordSet
resourceRecordSet :: ResourceRecordSet
action :: ChangeAction
$sel:resourceRecordSet:Change' :: Change -> ResourceRecordSet
$sel:action:Change' :: Change -> ChangeAction
..} =
    forall a. NFData a => a -> ()
Prelude.rnf ChangeAction
action
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ResourceRecordSet
resourceRecordSet

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