{-# 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.NetworkManager.Types.Location where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data Location = Location'
{
Location -> Maybe Text
latitude :: Prelude.Maybe Prelude.Text,
Location -> Maybe Text
address :: Prelude.Maybe Prelude.Text,
Location -> Maybe Text
longitude :: Prelude.Maybe Prelude.Text
}
deriving (Location -> Location -> Bool
(Location -> Location -> Bool)
-> (Location -> Location -> Bool) -> Eq Location
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Location -> Location -> Bool
$c/= :: Location -> Location -> Bool
== :: Location -> Location -> Bool
$c== :: Location -> Location -> Bool
Prelude.Eq, Int -> Location -> ShowS
[Location] -> ShowS
Location -> String
(Int -> Location -> ShowS)
-> (Location -> String) -> ([Location] -> ShowS) -> Show Location
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Location] -> ShowS
$cshowList :: [Location] -> ShowS
show :: Location -> String
$cshow :: Location -> String
showsPrec :: Int -> Location -> ShowS
$cshowsPrec :: Int -> Location -> ShowS
Prelude.Show, (forall x. Location -> Rep Location x)
-> (forall x. Rep Location x -> Location) -> Generic Location
forall x. Rep Location x -> Location
forall x. Location -> Rep Location x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Location x -> Location
$cfrom :: forall x. Location -> Rep Location x
Prelude.Generic)
newLocation ::
Location
newLocation :: Location
newLocation =
Location' :: Maybe Text -> Maybe Text -> Maybe Text -> Location
Location'
{ $sel:latitude:Location' :: Maybe Text
latitude = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:address:Location' :: Maybe Text
address = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:longitude:Location' :: Maybe Text
longitude = Maybe Text
forall a. Maybe a
Prelude.Nothing
}
location_latitude :: Lens.Lens' Location (Prelude.Maybe Prelude.Text)
location_latitude :: (Maybe Text -> f (Maybe Text)) -> Location -> f Location
location_latitude = (Location -> Maybe Text)
-> (Location -> Maybe Text -> Location)
-> Lens Location Location (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Location' {Maybe Text
latitude :: Maybe Text
$sel:latitude:Location' :: Location -> Maybe Text
latitude} -> Maybe Text
latitude) (\s :: Location
s@Location' {} Maybe Text
a -> Location
s {$sel:latitude:Location' :: Maybe Text
latitude = Maybe Text
a} :: Location)
location_address :: Lens.Lens' Location (Prelude.Maybe Prelude.Text)
location_address :: (Maybe Text -> f (Maybe Text)) -> Location -> f Location
location_address = (Location -> Maybe Text)
-> (Location -> Maybe Text -> Location)
-> Lens Location Location (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Location' {Maybe Text
address :: Maybe Text
$sel:address:Location' :: Location -> Maybe Text
address} -> Maybe Text
address) (\s :: Location
s@Location' {} Maybe Text
a -> Location
s {$sel:address:Location' :: Maybe Text
address = Maybe Text
a} :: Location)
location_longitude :: Lens.Lens' Location (Prelude.Maybe Prelude.Text)
location_longitude :: (Maybe Text -> f (Maybe Text)) -> Location -> f Location
location_longitude = (Location -> Maybe Text)
-> (Location -> Maybe Text -> Location)
-> Lens Location Location (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Location' {Maybe Text
longitude :: Maybe Text
$sel:longitude:Location' :: Location -> Maybe Text
longitude} -> Maybe Text
longitude) (\s :: Location
s@Location' {} Maybe Text
a -> Location
s {$sel:longitude:Location' :: Maybe Text
longitude = Maybe Text
a} :: Location)
instance Core.FromJSON Location where
parseJSON :: Value -> Parser Location
parseJSON =
String -> (Object -> Parser Location) -> Value -> Parser Location
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"Location"
( \Object
x ->
Maybe Text -> Maybe Text -> Maybe Text -> Location
Location'
(Maybe Text -> Maybe Text -> Maybe Text -> Location)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> Location)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Latitude")
Parser (Maybe Text -> Maybe Text -> Location)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Location)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Address")
Parser (Maybe Text -> Location)
-> Parser (Maybe Text) -> Parser Location
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Longitude")
)
instance Prelude.Hashable Location
instance Prelude.NFData Location
instance Core.ToJSON Location where
toJSON :: Location -> Value
toJSON Location' {Maybe Text
longitude :: Maybe Text
address :: Maybe Text
latitude :: Maybe Text
$sel:longitude:Location' :: Location -> Maybe Text
$sel:address:Location' :: Location -> Maybe Text
$sel:latitude:Location' :: Location -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"Latitude" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
latitude,
(Text
"Address" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
address,
(Text
"Longitude" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
longitude
]
)