{-# 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.MacieV2.Types.IpGeoLocation
-- 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.MacieV2.Types.IpGeoLocation where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Provides geographic coordinates that indicate where a specified IP
-- address originated from.
--
-- /See:/ 'newIpGeoLocation' smart constructor.
data IpGeoLocation = IpGeoLocation'
  { -- | The latitude coordinate of the location, rounded to four decimal places.
    IpGeoLocation -> Maybe Double
lat :: Prelude.Maybe Prelude.Double,
    -- | The longitude coordinate of the location, rounded to four decimal
    -- places.
    IpGeoLocation -> Maybe Double
lon :: Prelude.Maybe Prelude.Double
  }
  deriving (IpGeoLocation -> IpGeoLocation -> Bool
(IpGeoLocation -> IpGeoLocation -> Bool)
-> (IpGeoLocation -> IpGeoLocation -> Bool) -> Eq IpGeoLocation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IpGeoLocation -> IpGeoLocation -> Bool
$c/= :: IpGeoLocation -> IpGeoLocation -> Bool
== :: IpGeoLocation -> IpGeoLocation -> Bool
$c== :: IpGeoLocation -> IpGeoLocation -> Bool
Prelude.Eq, ReadPrec [IpGeoLocation]
ReadPrec IpGeoLocation
Int -> ReadS IpGeoLocation
ReadS [IpGeoLocation]
(Int -> ReadS IpGeoLocation)
-> ReadS [IpGeoLocation]
-> ReadPrec IpGeoLocation
-> ReadPrec [IpGeoLocation]
-> Read IpGeoLocation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IpGeoLocation]
$creadListPrec :: ReadPrec [IpGeoLocation]
readPrec :: ReadPrec IpGeoLocation
$creadPrec :: ReadPrec IpGeoLocation
readList :: ReadS [IpGeoLocation]
$creadList :: ReadS [IpGeoLocation]
readsPrec :: Int -> ReadS IpGeoLocation
$creadsPrec :: Int -> ReadS IpGeoLocation
Prelude.Read, Int -> IpGeoLocation -> ShowS
[IpGeoLocation] -> ShowS
IpGeoLocation -> String
(Int -> IpGeoLocation -> ShowS)
-> (IpGeoLocation -> String)
-> ([IpGeoLocation] -> ShowS)
-> Show IpGeoLocation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IpGeoLocation] -> ShowS
$cshowList :: [IpGeoLocation] -> ShowS
show :: IpGeoLocation -> String
$cshow :: IpGeoLocation -> String
showsPrec :: Int -> IpGeoLocation -> ShowS
$cshowsPrec :: Int -> IpGeoLocation -> ShowS
Prelude.Show, (forall x. IpGeoLocation -> Rep IpGeoLocation x)
-> (forall x. Rep IpGeoLocation x -> IpGeoLocation)
-> Generic IpGeoLocation
forall x. Rep IpGeoLocation x -> IpGeoLocation
forall x. IpGeoLocation -> Rep IpGeoLocation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IpGeoLocation x -> IpGeoLocation
$cfrom :: forall x. IpGeoLocation -> Rep IpGeoLocation x
Prelude.Generic)

-- |
-- Create a value of 'IpGeoLocation' 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:
--
-- 'lat', 'ipGeoLocation_lat' - The latitude coordinate of the location, rounded to four decimal places.
--
-- 'lon', 'ipGeoLocation_lon' - The longitude coordinate of the location, rounded to four decimal
-- places.
newIpGeoLocation ::
  IpGeoLocation
newIpGeoLocation :: IpGeoLocation
newIpGeoLocation =
  IpGeoLocation' :: Maybe Double -> Maybe Double -> IpGeoLocation
IpGeoLocation'
    { $sel:lat:IpGeoLocation' :: Maybe Double
lat = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:lon:IpGeoLocation' :: Maybe Double
lon = Maybe Double
forall a. Maybe a
Prelude.Nothing
    }

-- | The latitude coordinate of the location, rounded to four decimal places.
ipGeoLocation_lat :: Lens.Lens' IpGeoLocation (Prelude.Maybe Prelude.Double)
ipGeoLocation_lat :: (Maybe Double -> f (Maybe Double))
-> IpGeoLocation -> f IpGeoLocation
ipGeoLocation_lat = (IpGeoLocation -> Maybe Double)
-> (IpGeoLocation -> Maybe Double -> IpGeoLocation)
-> Lens IpGeoLocation IpGeoLocation (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IpGeoLocation' {Maybe Double
lat :: Maybe Double
$sel:lat:IpGeoLocation' :: IpGeoLocation -> Maybe Double
lat} -> Maybe Double
lat) (\s :: IpGeoLocation
s@IpGeoLocation' {} Maybe Double
a -> IpGeoLocation
s {$sel:lat:IpGeoLocation' :: Maybe Double
lat = Maybe Double
a} :: IpGeoLocation)

-- | The longitude coordinate of the location, rounded to four decimal
-- places.
ipGeoLocation_lon :: Lens.Lens' IpGeoLocation (Prelude.Maybe Prelude.Double)
ipGeoLocation_lon :: (Maybe Double -> f (Maybe Double))
-> IpGeoLocation -> f IpGeoLocation
ipGeoLocation_lon = (IpGeoLocation -> Maybe Double)
-> (IpGeoLocation -> Maybe Double -> IpGeoLocation)
-> Lens IpGeoLocation IpGeoLocation (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IpGeoLocation' {Maybe Double
lon :: Maybe Double
$sel:lon:IpGeoLocation' :: IpGeoLocation -> Maybe Double
lon} -> Maybe Double
lon) (\s :: IpGeoLocation
s@IpGeoLocation' {} Maybe Double
a -> IpGeoLocation
s {$sel:lon:IpGeoLocation' :: Maybe Double
lon = Maybe Double
a} :: IpGeoLocation)

instance Core.FromJSON IpGeoLocation where
  parseJSON :: Value -> Parser IpGeoLocation
parseJSON =
    String
-> (Object -> Parser IpGeoLocation)
-> Value
-> Parser IpGeoLocation
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"IpGeoLocation"
      ( \Object
x ->
          Maybe Double -> Maybe Double -> IpGeoLocation
IpGeoLocation'
            (Maybe Double -> Maybe Double -> IpGeoLocation)
-> Parser (Maybe Double) -> Parser (Maybe Double -> IpGeoLocation)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"lat") Parser (Maybe Double -> IpGeoLocation)
-> Parser (Maybe Double) -> Parser IpGeoLocation
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"lon")
      )

instance Prelude.Hashable IpGeoLocation

instance Prelude.NFData IpGeoLocation