{-# 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.DelegationSet
-- 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.DelegationSet 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

-- | A complex type that lists the name servers in a delegation set, as well
-- as the @CallerReference@ and the @ID@ for the delegation set.
--
-- /See:/ 'newDelegationSet' smart constructor.
data DelegationSet = DelegationSet'
  { -- | The value that you specified for @CallerReference@ when you created the
    -- reusable delegation set.
    DelegationSet -> Maybe Text
callerReference :: Prelude.Maybe Prelude.Text,
    -- | The ID that Amazon Route 53 assigns to a reusable delegation set.
    DelegationSet -> Maybe ResourceId
id :: Prelude.Maybe ResourceId,
    -- | A complex type that contains a list of the authoritative name servers
    -- for a hosted zone or for a reusable delegation set.
    DelegationSet -> NonEmpty Text
nameServers :: Prelude.NonEmpty Prelude.Text
  }
  deriving (DelegationSet -> DelegationSet -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DelegationSet -> DelegationSet -> Bool
$c/= :: DelegationSet -> DelegationSet -> Bool
== :: DelegationSet -> DelegationSet -> Bool
$c== :: DelegationSet -> DelegationSet -> Bool
Prelude.Eq, ReadPrec [DelegationSet]
ReadPrec DelegationSet
Int -> ReadS DelegationSet
ReadS [DelegationSet]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DelegationSet]
$creadListPrec :: ReadPrec [DelegationSet]
readPrec :: ReadPrec DelegationSet
$creadPrec :: ReadPrec DelegationSet
readList :: ReadS [DelegationSet]
$creadList :: ReadS [DelegationSet]
readsPrec :: Int -> ReadS DelegationSet
$creadsPrec :: Int -> ReadS DelegationSet
Prelude.Read, Int -> DelegationSet -> ShowS
[DelegationSet] -> ShowS
DelegationSet -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DelegationSet] -> ShowS
$cshowList :: [DelegationSet] -> ShowS
show :: DelegationSet -> String
$cshow :: DelegationSet -> String
showsPrec :: Int -> DelegationSet -> ShowS
$cshowsPrec :: Int -> DelegationSet -> ShowS
Prelude.Show, forall x. Rep DelegationSet x -> DelegationSet
forall x. DelegationSet -> Rep DelegationSet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DelegationSet x -> DelegationSet
$cfrom :: forall x. DelegationSet -> Rep DelegationSet x
Prelude.Generic)

-- |
-- Create a value of 'DelegationSet' 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:
--
-- 'callerReference', 'delegationSet_callerReference' - The value that you specified for @CallerReference@ when you created the
-- reusable delegation set.
--
-- 'id', 'delegationSet_id' - The ID that Amazon Route 53 assigns to a reusable delegation set.
--
-- 'nameServers', 'delegationSet_nameServers' - A complex type that contains a list of the authoritative name servers
-- for a hosted zone or for a reusable delegation set.
newDelegationSet ::
  -- | 'nameServers'
  Prelude.NonEmpty Prelude.Text ->
  DelegationSet
newDelegationSet :: NonEmpty Text -> DelegationSet
newDelegationSet NonEmpty Text
pNameServers_ =
  DelegationSet'
    { $sel:callerReference:DelegationSet' :: Maybe Text
callerReference = forall a. Maybe a
Prelude.Nothing,
      $sel:id:DelegationSet' :: Maybe ResourceId
id = forall a. Maybe a
Prelude.Nothing,
      $sel:nameServers:DelegationSet' :: NonEmpty Text
nameServers = forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pNameServers_
    }

-- | The value that you specified for @CallerReference@ when you created the
-- reusable delegation set.
delegationSet_callerReference :: Lens.Lens' DelegationSet (Prelude.Maybe Prelude.Text)
delegationSet_callerReference :: Lens' DelegationSet (Maybe Text)
delegationSet_callerReference = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DelegationSet' {Maybe Text
callerReference :: Maybe Text
$sel:callerReference:DelegationSet' :: DelegationSet -> Maybe Text
callerReference} -> Maybe Text
callerReference) (\s :: DelegationSet
s@DelegationSet' {} Maybe Text
a -> DelegationSet
s {$sel:callerReference:DelegationSet' :: Maybe Text
callerReference = Maybe Text
a} :: DelegationSet)

-- | The ID that Amazon Route 53 assigns to a reusable delegation set.
delegationSet_id :: Lens.Lens' DelegationSet (Prelude.Maybe ResourceId)
delegationSet_id :: Lens' DelegationSet (Maybe ResourceId)
delegationSet_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DelegationSet' {Maybe ResourceId
id :: Maybe ResourceId
$sel:id:DelegationSet' :: DelegationSet -> Maybe ResourceId
id} -> Maybe ResourceId
id) (\s :: DelegationSet
s@DelegationSet' {} Maybe ResourceId
a -> DelegationSet
s {$sel:id:DelegationSet' :: Maybe ResourceId
id = Maybe ResourceId
a} :: DelegationSet)

-- | A complex type that contains a list of the authoritative name servers
-- for a hosted zone or for a reusable delegation set.
delegationSet_nameServers :: Lens.Lens' DelegationSet (Prelude.NonEmpty Prelude.Text)
delegationSet_nameServers :: Lens' DelegationSet (NonEmpty Text)
delegationSet_nameServers = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DelegationSet' {NonEmpty Text
nameServers :: NonEmpty Text
$sel:nameServers:DelegationSet' :: DelegationSet -> NonEmpty Text
nameServers} -> NonEmpty Text
nameServers) (\s :: DelegationSet
s@DelegationSet' {} NonEmpty Text
a -> DelegationSet
s {$sel:nameServers:DelegationSet' :: NonEmpty Text
nameServers = NonEmpty Text
a} :: DelegationSet) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromXML DelegationSet where
  parseXML :: [Node] -> Either String DelegationSet
parseXML [Node]
x =
    Maybe Text -> Maybe ResourceId -> NonEmpty Text -> DelegationSet
DelegationSet'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"CallerReference")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Id")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x
                      forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"NameServers"
                      forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                      forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall a. FromXML a => Text -> [Node] -> Either String (NonEmpty a)
Data.parseXMLList1 Text
"NameServer"
                  )

instance Prelude.Hashable DelegationSet where
  hashWithSalt :: Int -> DelegationSet -> Int
hashWithSalt Int
_salt DelegationSet' {Maybe Text
Maybe ResourceId
NonEmpty Text
nameServers :: NonEmpty Text
id :: Maybe ResourceId
callerReference :: Maybe Text
$sel:nameServers:DelegationSet' :: DelegationSet -> NonEmpty Text
$sel:id:DelegationSet' :: DelegationSet -> Maybe ResourceId
$sel:callerReference:DelegationSet' :: DelegationSet -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
callerReference
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ResourceId
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Text
nameServers

instance Prelude.NFData DelegationSet where
  rnf :: DelegationSet -> ()
rnf DelegationSet' {Maybe Text
Maybe ResourceId
NonEmpty Text
nameServers :: NonEmpty Text
id :: Maybe ResourceId
callerReference :: Maybe Text
$sel:nameServers:DelegationSet' :: DelegationSet -> NonEmpty Text
$sel:id:DelegationSet' :: DelegationSet -> Maybe ResourceId
$sel:callerReference:DelegationSet' :: DelegationSet -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
callerReference
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ResourceId
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty Text
nameServers