{-# 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.HostedZone
-- 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.HostedZone 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.HostedZoneConfig
import Amazonka.Route53.Types.LinkedService

-- | A complex type that contains general information about the hosted zone.
--
-- /See:/ 'newHostedZone' smart constructor.
data HostedZone = HostedZone'
  { -- | If the hosted zone was created by another service, the service that
    -- created the hosted zone. When a hosted zone is created by another
    -- service, you can\'t edit or delete it using Route 53.
    HostedZone -> Maybe LinkedService
linkedService :: Prelude.Maybe LinkedService,
    -- | A complex type that includes the @Comment@ and @PrivateZone@ elements.
    -- If you omitted the @HostedZoneConfig@ and @Comment@ elements from the
    -- request, the @Config@ and @Comment@ elements don\'t appear in the
    -- response.
    HostedZone -> Maybe HostedZoneConfig
config :: Prelude.Maybe HostedZoneConfig,
    -- | The number of resource record sets in the hosted zone.
    HostedZone -> Maybe Integer
resourceRecordSetCount :: Prelude.Maybe Prelude.Integer,
    -- | The ID that Amazon Route 53 assigned to the hosted zone when you created
    -- it.
    HostedZone -> ResourceId
id :: ResourceId,
    -- | The name of the domain. For public hosted zones, this is the name that
    -- you have registered with your DNS registrar.
    --
    -- For information about how to specify characters other than @a-z@, @0-9@,
    -- and @-@ (hyphen) and how to specify internationalized domain names, see
    -- <https://docs.aws.amazon.com/Route53/latest/APIReference/API_CreateHostedZone.html CreateHostedZone>.
    HostedZone -> Text
name :: Prelude.Text,
    -- | The value that you specified for @CallerReference@ when you created the
    -- hosted zone.
    HostedZone -> Text
callerReference :: Prelude.Text
  }
  deriving (HostedZone -> HostedZone -> Bool
(HostedZone -> HostedZone -> Bool)
-> (HostedZone -> HostedZone -> Bool) -> Eq HostedZone
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HostedZone -> HostedZone -> Bool
$c/= :: HostedZone -> HostedZone -> Bool
== :: HostedZone -> HostedZone -> Bool
$c== :: HostedZone -> HostedZone -> Bool
Prelude.Eq, ReadPrec [HostedZone]
ReadPrec HostedZone
Int -> ReadS HostedZone
ReadS [HostedZone]
(Int -> ReadS HostedZone)
-> ReadS [HostedZone]
-> ReadPrec HostedZone
-> ReadPrec [HostedZone]
-> Read HostedZone
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HostedZone]
$creadListPrec :: ReadPrec [HostedZone]
readPrec :: ReadPrec HostedZone
$creadPrec :: ReadPrec HostedZone
readList :: ReadS [HostedZone]
$creadList :: ReadS [HostedZone]
readsPrec :: Int -> ReadS HostedZone
$creadsPrec :: Int -> ReadS HostedZone
Prelude.Read, Int -> HostedZone -> ShowS
[HostedZone] -> ShowS
HostedZone -> String
(Int -> HostedZone -> ShowS)
-> (HostedZone -> String)
-> ([HostedZone] -> ShowS)
-> Show HostedZone
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HostedZone] -> ShowS
$cshowList :: [HostedZone] -> ShowS
show :: HostedZone -> String
$cshow :: HostedZone -> String
showsPrec :: Int -> HostedZone -> ShowS
$cshowsPrec :: Int -> HostedZone -> ShowS
Prelude.Show, (forall x. HostedZone -> Rep HostedZone x)
-> (forall x. Rep HostedZone x -> HostedZone) -> Generic HostedZone
forall x. Rep HostedZone x -> HostedZone
forall x. HostedZone -> Rep HostedZone x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HostedZone x -> HostedZone
$cfrom :: forall x. HostedZone -> Rep HostedZone x
Prelude.Generic)

-- |
-- Create a value of 'HostedZone' 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:
--
-- 'linkedService', 'hostedZone_linkedService' - If the hosted zone was created by another service, the service that
-- created the hosted zone. When a hosted zone is created by another
-- service, you can\'t edit or delete it using Route 53.
--
-- 'config', 'hostedZone_config' - A complex type that includes the @Comment@ and @PrivateZone@ elements.
-- If you omitted the @HostedZoneConfig@ and @Comment@ elements from the
-- request, the @Config@ and @Comment@ elements don\'t appear in the
-- response.
--
-- 'resourceRecordSetCount', 'hostedZone_resourceRecordSetCount' - The number of resource record sets in the hosted zone.
--
-- 'id', 'hostedZone_id' - The ID that Amazon Route 53 assigned to the hosted zone when you created
-- it.
--
-- 'name', 'hostedZone_name' - The name of the domain. For public hosted zones, this is the name that
-- you have registered with your DNS registrar.
--
-- For information about how to specify characters other than @a-z@, @0-9@,
-- and @-@ (hyphen) and how to specify internationalized domain names, see
-- <https://docs.aws.amazon.com/Route53/latest/APIReference/API_CreateHostedZone.html CreateHostedZone>.
--
-- 'callerReference', 'hostedZone_callerReference' - The value that you specified for @CallerReference@ when you created the
-- hosted zone.
newHostedZone ::
  -- | 'id'
  ResourceId ->
  -- | 'name'
  Prelude.Text ->
  -- | 'callerReference'
  Prelude.Text ->
  HostedZone
newHostedZone :: ResourceId -> Text -> Text -> HostedZone
newHostedZone ResourceId
pId_ Text
pName_ Text
pCallerReference_ =
  HostedZone' :: Maybe LinkedService
-> Maybe HostedZoneConfig
-> Maybe Integer
-> ResourceId
-> Text
-> Text
-> HostedZone
HostedZone'
    { $sel:linkedService:HostedZone' :: Maybe LinkedService
linkedService = Maybe LinkedService
forall a. Maybe a
Prelude.Nothing,
      $sel:config:HostedZone' :: Maybe HostedZoneConfig
config = Maybe HostedZoneConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceRecordSetCount:HostedZone' :: Maybe Integer
resourceRecordSetCount = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:id:HostedZone' :: ResourceId
id = ResourceId
pId_,
      $sel:name:HostedZone' :: Text
name = Text
pName_,
      $sel:callerReference:HostedZone' :: Text
callerReference = Text
pCallerReference_
    }

-- | If the hosted zone was created by another service, the service that
-- created the hosted zone. When a hosted zone is created by another
-- service, you can\'t edit or delete it using Route 53.
hostedZone_linkedService :: Lens.Lens' HostedZone (Prelude.Maybe LinkedService)
hostedZone_linkedService :: (Maybe LinkedService -> f (Maybe LinkedService))
-> HostedZone -> f HostedZone
hostedZone_linkedService = (HostedZone -> Maybe LinkedService)
-> (HostedZone -> Maybe LinkedService -> HostedZone)
-> Lens
     HostedZone HostedZone (Maybe LinkedService) (Maybe LinkedService)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HostedZone' {Maybe LinkedService
linkedService :: Maybe LinkedService
$sel:linkedService:HostedZone' :: HostedZone -> Maybe LinkedService
linkedService} -> Maybe LinkedService
linkedService) (\s :: HostedZone
s@HostedZone' {} Maybe LinkedService
a -> HostedZone
s {$sel:linkedService:HostedZone' :: Maybe LinkedService
linkedService = Maybe LinkedService
a} :: HostedZone)

-- | A complex type that includes the @Comment@ and @PrivateZone@ elements.
-- If you omitted the @HostedZoneConfig@ and @Comment@ elements from the
-- request, the @Config@ and @Comment@ elements don\'t appear in the
-- response.
hostedZone_config :: Lens.Lens' HostedZone (Prelude.Maybe HostedZoneConfig)
hostedZone_config :: (Maybe HostedZoneConfig -> f (Maybe HostedZoneConfig))
-> HostedZone -> f HostedZone
hostedZone_config = (HostedZone -> Maybe HostedZoneConfig)
-> (HostedZone -> Maybe HostedZoneConfig -> HostedZone)
-> Lens
     HostedZone
     HostedZone
     (Maybe HostedZoneConfig)
     (Maybe HostedZoneConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HostedZone' {Maybe HostedZoneConfig
config :: Maybe HostedZoneConfig
$sel:config:HostedZone' :: HostedZone -> Maybe HostedZoneConfig
config} -> Maybe HostedZoneConfig
config) (\s :: HostedZone
s@HostedZone' {} Maybe HostedZoneConfig
a -> HostedZone
s {$sel:config:HostedZone' :: Maybe HostedZoneConfig
config = Maybe HostedZoneConfig
a} :: HostedZone)

-- | The number of resource record sets in the hosted zone.
hostedZone_resourceRecordSetCount :: Lens.Lens' HostedZone (Prelude.Maybe Prelude.Integer)
hostedZone_resourceRecordSetCount :: (Maybe Integer -> f (Maybe Integer)) -> HostedZone -> f HostedZone
hostedZone_resourceRecordSetCount = (HostedZone -> Maybe Integer)
-> (HostedZone -> Maybe Integer -> HostedZone)
-> Lens HostedZone HostedZone (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HostedZone' {Maybe Integer
resourceRecordSetCount :: Maybe Integer
$sel:resourceRecordSetCount:HostedZone' :: HostedZone -> Maybe Integer
resourceRecordSetCount} -> Maybe Integer
resourceRecordSetCount) (\s :: HostedZone
s@HostedZone' {} Maybe Integer
a -> HostedZone
s {$sel:resourceRecordSetCount:HostedZone' :: Maybe Integer
resourceRecordSetCount = Maybe Integer
a} :: HostedZone)

-- | The ID that Amazon Route 53 assigned to the hosted zone when you created
-- it.
hostedZone_id :: Lens.Lens' HostedZone ResourceId
hostedZone_id :: (ResourceId -> f ResourceId) -> HostedZone -> f HostedZone
hostedZone_id = (HostedZone -> ResourceId)
-> (HostedZone -> ResourceId -> HostedZone)
-> Lens HostedZone HostedZone ResourceId ResourceId
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HostedZone' {ResourceId
id :: ResourceId
$sel:id:HostedZone' :: HostedZone -> ResourceId
id} -> ResourceId
id) (\s :: HostedZone
s@HostedZone' {} ResourceId
a -> HostedZone
s {$sel:id:HostedZone' :: ResourceId
id = ResourceId
a} :: HostedZone)

-- | The name of the domain. For public hosted zones, this is the name that
-- you have registered with your DNS registrar.
--
-- For information about how to specify characters other than @a-z@, @0-9@,
-- and @-@ (hyphen) and how to specify internationalized domain names, see
-- <https://docs.aws.amazon.com/Route53/latest/APIReference/API_CreateHostedZone.html CreateHostedZone>.
hostedZone_name :: Lens.Lens' HostedZone Prelude.Text
hostedZone_name :: (Text -> f Text) -> HostedZone -> f HostedZone
hostedZone_name = (HostedZone -> Text)
-> (HostedZone -> Text -> HostedZone)
-> Lens HostedZone HostedZone Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HostedZone' {Text
name :: Text
$sel:name:HostedZone' :: HostedZone -> Text
name} -> Text
name) (\s :: HostedZone
s@HostedZone' {} Text
a -> HostedZone
s {$sel:name:HostedZone' :: Text
name = Text
a} :: HostedZone)

-- | The value that you specified for @CallerReference@ when you created the
-- hosted zone.
hostedZone_callerReference :: Lens.Lens' HostedZone Prelude.Text
hostedZone_callerReference :: (Text -> f Text) -> HostedZone -> f HostedZone
hostedZone_callerReference = (HostedZone -> Text)
-> (HostedZone -> Text -> HostedZone)
-> Lens HostedZone HostedZone Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HostedZone' {Text
callerReference :: Text
$sel:callerReference:HostedZone' :: HostedZone -> Text
callerReference} -> Text
callerReference) (\s :: HostedZone
s@HostedZone' {} Text
a -> HostedZone
s {$sel:callerReference:HostedZone' :: Text
callerReference = Text
a} :: HostedZone)

instance Core.FromXML HostedZone where
  parseXML :: [Node] -> Either String HostedZone
parseXML [Node]
x =
    Maybe LinkedService
-> Maybe HostedZoneConfig
-> Maybe Integer
-> ResourceId
-> Text
-> Text
-> HostedZone
HostedZone'
      (Maybe LinkedService
 -> Maybe HostedZoneConfig
 -> Maybe Integer
 -> ResourceId
 -> Text
 -> Text
 -> HostedZone)
-> Either String (Maybe LinkedService)
-> Either
     String
     (Maybe HostedZoneConfig
      -> Maybe Integer -> ResourceId -> Text -> Text -> HostedZone)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe LinkedService)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"LinkedService")
      Either
  String
  (Maybe HostedZoneConfig
   -> Maybe Integer -> ResourceId -> Text -> Text -> HostedZone)
-> Either String (Maybe HostedZoneConfig)
-> Either
     String (Maybe Integer -> ResourceId -> Text -> Text -> HostedZone)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe HostedZoneConfig)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Config")
      Either
  String (Maybe Integer -> ResourceId -> Text -> Text -> HostedZone)
-> Either String (Maybe Integer)
-> Either String (ResourceId -> Text -> Text -> HostedZone)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Integer)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"ResourceRecordSetCount")
      Either String (ResourceId -> Text -> Text -> HostedZone)
-> Either String ResourceId
-> Either String (Text -> Text -> HostedZone)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String ResourceId
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Id")
      Either String (Text -> Text -> HostedZone)
-> Either String Text -> Either String (Text -> HostedZone)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Name")
      Either String (Text -> HostedZone)
-> Either String Text -> Either String HostedZone
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"CallerReference")

instance Prelude.Hashable HostedZone

instance Prelude.NFData HostedZone