{-# 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.ECS.Types.HostEntry where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data HostEntry = HostEntry'
{
HostEntry -> Text
hostname :: Prelude.Text,
HostEntry -> Text
ipAddress :: Prelude.Text
}
deriving (HostEntry -> HostEntry -> Bool
(HostEntry -> HostEntry -> Bool)
-> (HostEntry -> HostEntry -> Bool) -> Eq HostEntry
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HostEntry -> HostEntry -> Bool
$c/= :: HostEntry -> HostEntry -> Bool
== :: HostEntry -> HostEntry -> Bool
$c== :: HostEntry -> HostEntry -> Bool
Prelude.Eq, ReadPrec [HostEntry]
ReadPrec HostEntry
Int -> ReadS HostEntry
ReadS [HostEntry]
(Int -> ReadS HostEntry)
-> ReadS [HostEntry]
-> ReadPrec HostEntry
-> ReadPrec [HostEntry]
-> Read HostEntry
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HostEntry]
$creadListPrec :: ReadPrec [HostEntry]
readPrec :: ReadPrec HostEntry
$creadPrec :: ReadPrec HostEntry
readList :: ReadS [HostEntry]
$creadList :: ReadS [HostEntry]
readsPrec :: Int -> ReadS HostEntry
$creadsPrec :: Int -> ReadS HostEntry
Prelude.Read, Int -> HostEntry -> ShowS
[HostEntry] -> ShowS
HostEntry -> String
(Int -> HostEntry -> ShowS)
-> (HostEntry -> String)
-> ([HostEntry] -> ShowS)
-> Show HostEntry
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HostEntry] -> ShowS
$cshowList :: [HostEntry] -> ShowS
show :: HostEntry -> String
$cshow :: HostEntry -> String
showsPrec :: Int -> HostEntry -> ShowS
$cshowsPrec :: Int -> HostEntry -> ShowS
Prelude.Show, (forall x. HostEntry -> Rep HostEntry x)
-> (forall x. Rep HostEntry x -> HostEntry) -> Generic HostEntry
forall x. Rep HostEntry x -> HostEntry
forall x. HostEntry -> Rep HostEntry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HostEntry x -> HostEntry
$cfrom :: forall x. HostEntry -> Rep HostEntry x
Prelude.Generic)
newHostEntry ::
Prelude.Text ->
Prelude.Text ->
HostEntry
newHostEntry :: Text -> Text -> HostEntry
newHostEntry Text
pHostname_ Text
pIpAddress_ =
HostEntry' :: Text -> Text -> HostEntry
HostEntry'
{ $sel:hostname:HostEntry' :: Text
hostname = Text
pHostname_,
$sel:ipAddress:HostEntry' :: Text
ipAddress = Text
pIpAddress_
}
hostEntry_hostname :: Lens.Lens' HostEntry Prelude.Text
hostEntry_hostname :: (Text -> f Text) -> HostEntry -> f HostEntry
hostEntry_hostname = (HostEntry -> Text)
-> (HostEntry -> Text -> HostEntry)
-> Lens HostEntry HostEntry Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HostEntry' {Text
hostname :: Text
$sel:hostname:HostEntry' :: HostEntry -> Text
hostname} -> Text
hostname) (\s :: HostEntry
s@HostEntry' {} Text
a -> HostEntry
s {$sel:hostname:HostEntry' :: Text
hostname = Text
a} :: HostEntry)
hostEntry_ipAddress :: Lens.Lens' HostEntry Prelude.Text
hostEntry_ipAddress :: (Text -> f Text) -> HostEntry -> f HostEntry
hostEntry_ipAddress = (HostEntry -> Text)
-> (HostEntry -> Text -> HostEntry)
-> Lens HostEntry HostEntry Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HostEntry' {Text
ipAddress :: Text
$sel:ipAddress:HostEntry' :: HostEntry -> Text
ipAddress} -> Text
ipAddress) (\s :: HostEntry
s@HostEntry' {} Text
a -> HostEntry
s {$sel:ipAddress:HostEntry' :: Text
ipAddress = Text
a} :: HostEntry)
instance Core.FromJSON HostEntry where
parseJSON :: Value -> Parser HostEntry
parseJSON =
String -> (Object -> Parser HostEntry) -> Value -> Parser HostEntry
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"HostEntry"
( \Object
x ->
Text -> Text -> HostEntry
HostEntry'
(Text -> Text -> HostEntry)
-> Parser Text -> Parser (Text -> HostEntry)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"hostname")
Parser (Text -> HostEntry) -> Parser Text -> Parser HostEntry
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
"ipAddress")
)
instance Prelude.Hashable HostEntry
instance Prelude.NFData HostEntry
instance Core.ToJSON HostEntry where
toJSON :: HostEntry -> Value
toJSON HostEntry' {Text
ipAddress :: Text
hostname :: Text
$sel:ipAddress:HostEntry' :: HostEntry -> Text
$sel:hostname:HostEntry' :: HostEntry -> Text
..} =
[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
"hostname" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
hostname),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ipAddress" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
ipAddress)
]
)