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

-- | The object that is specified in resource record set object when you are
-- linking a resource record set to a CIDR location.
--
-- A @LocationName@ with an asterisk “*” can be used to create a default
-- CIDR record. @CollectionId@ is still required for default record.
--
-- /See:/ 'newCidrRoutingConfig' smart constructor.
data CidrRoutingConfig = CidrRoutingConfig'
  { -- | The CIDR collection ID.
    CidrRoutingConfig -> Text
collectionId :: Prelude.Text,
    -- | The CIDR collection location name.
    CidrRoutingConfig -> Text
locationName :: Prelude.Text
  }
  deriving (CidrRoutingConfig -> CidrRoutingConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CidrRoutingConfig -> CidrRoutingConfig -> Bool
$c/= :: CidrRoutingConfig -> CidrRoutingConfig -> Bool
== :: CidrRoutingConfig -> CidrRoutingConfig -> Bool
$c== :: CidrRoutingConfig -> CidrRoutingConfig -> Bool
Prelude.Eq, ReadPrec [CidrRoutingConfig]
ReadPrec CidrRoutingConfig
Int -> ReadS CidrRoutingConfig
ReadS [CidrRoutingConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CidrRoutingConfig]
$creadListPrec :: ReadPrec [CidrRoutingConfig]
readPrec :: ReadPrec CidrRoutingConfig
$creadPrec :: ReadPrec CidrRoutingConfig
readList :: ReadS [CidrRoutingConfig]
$creadList :: ReadS [CidrRoutingConfig]
readsPrec :: Int -> ReadS CidrRoutingConfig
$creadsPrec :: Int -> ReadS CidrRoutingConfig
Prelude.Read, Int -> CidrRoutingConfig -> ShowS
[CidrRoutingConfig] -> ShowS
CidrRoutingConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CidrRoutingConfig] -> ShowS
$cshowList :: [CidrRoutingConfig] -> ShowS
show :: CidrRoutingConfig -> String
$cshow :: CidrRoutingConfig -> String
showsPrec :: Int -> CidrRoutingConfig -> ShowS
$cshowsPrec :: Int -> CidrRoutingConfig -> ShowS
Prelude.Show, forall x. Rep CidrRoutingConfig x -> CidrRoutingConfig
forall x. CidrRoutingConfig -> Rep CidrRoutingConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CidrRoutingConfig x -> CidrRoutingConfig
$cfrom :: forall x. CidrRoutingConfig -> Rep CidrRoutingConfig x
Prelude.Generic)

-- |
-- Create a value of 'CidrRoutingConfig' 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:
--
-- 'collectionId', 'cidrRoutingConfig_collectionId' - The CIDR collection ID.
--
-- 'locationName', 'cidrRoutingConfig_locationName' - The CIDR collection location name.
newCidrRoutingConfig ::
  -- | 'collectionId'
  Prelude.Text ->
  -- | 'locationName'
  Prelude.Text ->
  CidrRoutingConfig
newCidrRoutingConfig :: Text -> Text -> CidrRoutingConfig
newCidrRoutingConfig Text
pCollectionId_ Text
pLocationName_ =
  CidrRoutingConfig'
    { $sel:collectionId:CidrRoutingConfig' :: Text
collectionId = Text
pCollectionId_,
      $sel:locationName:CidrRoutingConfig' :: Text
locationName = Text
pLocationName_
    }

-- | The CIDR collection ID.
cidrRoutingConfig_collectionId :: Lens.Lens' CidrRoutingConfig Prelude.Text
cidrRoutingConfig_collectionId :: Lens' CidrRoutingConfig Text
cidrRoutingConfig_collectionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CidrRoutingConfig' {Text
collectionId :: Text
$sel:collectionId:CidrRoutingConfig' :: CidrRoutingConfig -> Text
collectionId} -> Text
collectionId) (\s :: CidrRoutingConfig
s@CidrRoutingConfig' {} Text
a -> CidrRoutingConfig
s {$sel:collectionId:CidrRoutingConfig' :: Text
collectionId = Text
a} :: CidrRoutingConfig)

-- | The CIDR collection location name.
cidrRoutingConfig_locationName :: Lens.Lens' CidrRoutingConfig Prelude.Text
cidrRoutingConfig_locationName :: Lens' CidrRoutingConfig Text
cidrRoutingConfig_locationName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CidrRoutingConfig' {Text
locationName :: Text
$sel:locationName:CidrRoutingConfig' :: CidrRoutingConfig -> Text
locationName} -> Text
locationName) (\s :: CidrRoutingConfig
s@CidrRoutingConfig' {} Text
a -> CidrRoutingConfig
s {$sel:locationName:CidrRoutingConfig' :: Text
locationName = Text
a} :: CidrRoutingConfig)

instance Data.FromXML CidrRoutingConfig where
  parseXML :: [Node] -> Either String CidrRoutingConfig
parseXML [Node]
x =
    Text -> Text -> CidrRoutingConfig
CidrRoutingConfig'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"CollectionId")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"LocationName")

instance Prelude.Hashable CidrRoutingConfig where
  hashWithSalt :: Int -> CidrRoutingConfig -> Int
hashWithSalt Int
_salt CidrRoutingConfig' {Text
locationName :: Text
collectionId :: Text
$sel:locationName:CidrRoutingConfig' :: CidrRoutingConfig -> Text
$sel:collectionId:CidrRoutingConfig' :: CidrRoutingConfig -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
collectionId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
locationName

instance Prelude.NFData CidrRoutingConfig where
  rnf :: CidrRoutingConfig -> ()
rnf CidrRoutingConfig' {Text
locationName :: Text
collectionId :: Text
$sel:locationName:CidrRoutingConfig' :: CidrRoutingConfig -> Text
$sel:collectionId:CidrRoutingConfig' :: CidrRoutingConfig -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
collectionId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
locationName

instance Data.ToXML CidrRoutingConfig where
  toXML :: CidrRoutingConfig -> XML
toXML CidrRoutingConfig' {Text
locationName :: Text
collectionId :: Text
$sel:locationName:CidrRoutingConfig' :: CidrRoutingConfig -> Text
$sel:collectionId:CidrRoutingConfig' :: CidrRoutingConfig -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ Name
"CollectionId" forall a. ToXML a => Name -> a -> XML
Data.@= Text
collectionId,
        Name
"LocationName" forall a. ToXML a => Name -> a -> XML
Data.@= Text
locationName
      ]