{-# 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 #-}
module Amazonka.Route53Resolver.Types.TargetAddress where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data TargetAddress = TargetAddress'
{
TargetAddress -> Maybe Natural
port :: Prelude.Maybe Prelude.Natural,
TargetAddress -> Text
ip :: Prelude.Text
}
deriving (TargetAddress -> TargetAddress -> Bool
(TargetAddress -> TargetAddress -> Bool)
-> (TargetAddress -> TargetAddress -> Bool) -> Eq TargetAddress
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TargetAddress -> TargetAddress -> Bool
$c/= :: TargetAddress -> TargetAddress -> Bool
== :: TargetAddress -> TargetAddress -> Bool
$c== :: TargetAddress -> TargetAddress -> Bool
Prelude.Eq, ReadPrec [TargetAddress]
ReadPrec TargetAddress
Int -> ReadS TargetAddress
ReadS [TargetAddress]
(Int -> ReadS TargetAddress)
-> ReadS [TargetAddress]
-> ReadPrec TargetAddress
-> ReadPrec [TargetAddress]
-> Read TargetAddress
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TargetAddress]
$creadListPrec :: ReadPrec [TargetAddress]
readPrec :: ReadPrec TargetAddress
$creadPrec :: ReadPrec TargetAddress
readList :: ReadS [TargetAddress]
$creadList :: ReadS [TargetAddress]
readsPrec :: Int -> ReadS TargetAddress
$creadsPrec :: Int -> ReadS TargetAddress
Prelude.Read, Int -> TargetAddress -> ShowS
[TargetAddress] -> ShowS
TargetAddress -> String
(Int -> TargetAddress -> ShowS)
-> (TargetAddress -> String)
-> ([TargetAddress] -> ShowS)
-> Show TargetAddress
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TargetAddress] -> ShowS
$cshowList :: [TargetAddress] -> ShowS
show :: TargetAddress -> String
$cshow :: TargetAddress -> String
showsPrec :: Int -> TargetAddress -> ShowS
$cshowsPrec :: Int -> TargetAddress -> ShowS
Prelude.Show, (forall x. TargetAddress -> Rep TargetAddress x)
-> (forall x. Rep TargetAddress x -> TargetAddress)
-> Generic TargetAddress
forall x. Rep TargetAddress x -> TargetAddress
forall x. TargetAddress -> Rep TargetAddress x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TargetAddress x -> TargetAddress
$cfrom :: forall x. TargetAddress -> Rep TargetAddress x
Prelude.Generic)
newTargetAddress ::
Prelude.Text ->
TargetAddress
newTargetAddress :: Text -> TargetAddress
newTargetAddress Text
pIp_ =
TargetAddress' :: Maybe Natural -> Text -> TargetAddress
TargetAddress' {$sel:port:TargetAddress' :: Maybe Natural
port = Maybe Natural
forall a. Maybe a
Prelude.Nothing, $sel:ip:TargetAddress' :: Text
ip = Text
pIp_}
targetAddress_port :: Lens.Lens' TargetAddress (Prelude.Maybe Prelude.Natural)
targetAddress_port :: (Maybe Natural -> f (Maybe Natural))
-> TargetAddress -> f TargetAddress
targetAddress_port = (TargetAddress -> Maybe Natural)
-> (TargetAddress -> Maybe Natural -> TargetAddress)
-> Lens TargetAddress TargetAddress (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetAddress' {Maybe Natural
port :: Maybe Natural
$sel:port:TargetAddress' :: TargetAddress -> Maybe Natural
port} -> Maybe Natural
port) (\s :: TargetAddress
s@TargetAddress' {} Maybe Natural
a -> TargetAddress
s {$sel:port:TargetAddress' :: Maybe Natural
port = Maybe Natural
a} :: TargetAddress)
targetAddress_ip :: Lens.Lens' TargetAddress Prelude.Text
targetAddress_ip :: (Text -> f Text) -> TargetAddress -> f TargetAddress
targetAddress_ip = (TargetAddress -> Text)
-> (TargetAddress -> Text -> TargetAddress)
-> Lens TargetAddress TargetAddress Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetAddress' {Text
ip :: Text
$sel:ip:TargetAddress' :: TargetAddress -> Text
ip} -> Text
ip) (\s :: TargetAddress
s@TargetAddress' {} Text
a -> TargetAddress
s {$sel:ip:TargetAddress' :: Text
ip = Text
a} :: TargetAddress)
instance Core.FromJSON TargetAddress where
parseJSON :: Value -> Parser TargetAddress
parseJSON =
String
-> (Object -> Parser TargetAddress)
-> Value
-> Parser TargetAddress
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"TargetAddress"
( \Object
x ->
Maybe Natural -> Text -> TargetAddress
TargetAddress'
(Maybe Natural -> Text -> TargetAddress)
-> Parser (Maybe Natural) -> Parser (Text -> TargetAddress)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Port") Parser (Text -> TargetAddress)
-> Parser Text -> Parser TargetAddress
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Ip")
)
instance Prelude.Hashable TargetAddress
instance Prelude.NFData TargetAddress
instance Core.ToJSON TargetAddress where
toJSON :: TargetAddress -> Value
toJSON TargetAddress' {Maybe Natural
Text
ip :: Text
port :: Maybe Natural
$sel:ip:TargetAddress' :: TargetAddress -> Text
$sel:port:TargetAddress' :: TargetAddress -> Maybe Natural
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"Port" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
port,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Ip" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
ip)
]
)