{-# 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.Route53AutoNaming.Types.DnsConfigChange
-- 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.Route53AutoNaming.Types.DnsConfigChange where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Route53AutoNaming.Types.DnsRecord

-- | A complex type that contains information about changes to the Route 53
-- DNS records that Cloud Map creates when you register an instance.
--
-- /See:/ 'newDnsConfigChange' smart constructor.
data DnsConfigChange = DnsConfigChange'
  { -- | An array that contains one @DnsRecord@ object for each Route 53 record
    -- that you want Cloud Map to create when you register an instance.
    DnsConfigChange -> [DnsRecord]
dnsRecords :: [DnsRecord]
  }
  deriving (DnsConfigChange -> DnsConfigChange -> Bool
(DnsConfigChange -> DnsConfigChange -> Bool)
-> (DnsConfigChange -> DnsConfigChange -> Bool)
-> Eq DnsConfigChange
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DnsConfigChange -> DnsConfigChange -> Bool
$c/= :: DnsConfigChange -> DnsConfigChange -> Bool
== :: DnsConfigChange -> DnsConfigChange -> Bool
$c== :: DnsConfigChange -> DnsConfigChange -> Bool
Prelude.Eq, ReadPrec [DnsConfigChange]
ReadPrec DnsConfigChange
Int -> ReadS DnsConfigChange
ReadS [DnsConfigChange]
(Int -> ReadS DnsConfigChange)
-> ReadS [DnsConfigChange]
-> ReadPrec DnsConfigChange
-> ReadPrec [DnsConfigChange]
-> Read DnsConfigChange
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DnsConfigChange]
$creadListPrec :: ReadPrec [DnsConfigChange]
readPrec :: ReadPrec DnsConfigChange
$creadPrec :: ReadPrec DnsConfigChange
readList :: ReadS [DnsConfigChange]
$creadList :: ReadS [DnsConfigChange]
readsPrec :: Int -> ReadS DnsConfigChange
$creadsPrec :: Int -> ReadS DnsConfigChange
Prelude.Read, Int -> DnsConfigChange -> ShowS
[DnsConfigChange] -> ShowS
DnsConfigChange -> String
(Int -> DnsConfigChange -> ShowS)
-> (DnsConfigChange -> String)
-> ([DnsConfigChange] -> ShowS)
-> Show DnsConfigChange
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DnsConfigChange] -> ShowS
$cshowList :: [DnsConfigChange] -> ShowS
show :: DnsConfigChange -> String
$cshow :: DnsConfigChange -> String
showsPrec :: Int -> DnsConfigChange -> ShowS
$cshowsPrec :: Int -> DnsConfigChange -> ShowS
Prelude.Show, (forall x. DnsConfigChange -> Rep DnsConfigChange x)
-> (forall x. Rep DnsConfigChange x -> DnsConfigChange)
-> Generic DnsConfigChange
forall x. Rep DnsConfigChange x -> DnsConfigChange
forall x. DnsConfigChange -> Rep DnsConfigChange x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DnsConfigChange x -> DnsConfigChange
$cfrom :: forall x. DnsConfigChange -> Rep DnsConfigChange x
Prelude.Generic)

-- |
-- Create a value of 'DnsConfigChange' 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:
--
-- 'dnsRecords', 'dnsConfigChange_dnsRecords' - An array that contains one @DnsRecord@ object for each Route 53 record
-- that you want Cloud Map to create when you register an instance.
newDnsConfigChange ::
  DnsConfigChange
newDnsConfigChange :: DnsConfigChange
newDnsConfigChange =
  DnsConfigChange' :: [DnsRecord] -> DnsConfigChange
DnsConfigChange' {$sel:dnsRecords:DnsConfigChange' :: [DnsRecord]
dnsRecords = [DnsRecord]
forall a. Monoid a => a
Prelude.mempty}

-- | An array that contains one @DnsRecord@ object for each Route 53 record
-- that you want Cloud Map to create when you register an instance.
dnsConfigChange_dnsRecords :: Lens.Lens' DnsConfigChange [DnsRecord]
dnsConfigChange_dnsRecords :: ([DnsRecord] -> f [DnsRecord])
-> DnsConfigChange -> f DnsConfigChange
dnsConfigChange_dnsRecords = (DnsConfigChange -> [DnsRecord])
-> (DnsConfigChange -> [DnsRecord] -> DnsConfigChange)
-> Lens DnsConfigChange DnsConfigChange [DnsRecord] [DnsRecord]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DnsConfigChange' {[DnsRecord]
dnsRecords :: [DnsRecord]
$sel:dnsRecords:DnsConfigChange' :: DnsConfigChange -> [DnsRecord]
dnsRecords} -> [DnsRecord]
dnsRecords) (\s :: DnsConfigChange
s@DnsConfigChange' {} [DnsRecord]
a -> DnsConfigChange
s {$sel:dnsRecords:DnsConfigChange' :: [DnsRecord]
dnsRecords = [DnsRecord]
a} :: DnsConfigChange) (([DnsRecord] -> f [DnsRecord])
 -> DnsConfigChange -> f DnsConfigChange)
-> (([DnsRecord] -> f [DnsRecord]) -> [DnsRecord] -> f [DnsRecord])
-> ([DnsRecord] -> f [DnsRecord])
-> DnsConfigChange
-> f DnsConfigChange
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([DnsRecord] -> f [DnsRecord]) -> [DnsRecord] -> f [DnsRecord]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable DnsConfigChange

instance Prelude.NFData DnsConfigChange

instance Core.ToJSON DnsConfigChange where
  toJSON :: DnsConfigChange -> Value
toJSON DnsConfigChange' {[DnsRecord]
dnsRecords :: [DnsRecord]
$sel:dnsRecords:DnsConfigChange' :: DnsConfigChange -> [DnsRecord]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"DnsRecords" Text -> [DnsRecord] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [DnsRecord]
dnsRecords)]
      )