{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.MacieV2.Types.IpGeoLocation 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

-- | 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
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]
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
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. 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'
    { $sel:lat:IpGeoLocation' :: Maybe Double
lat = forall a. Maybe a
Prelude.Nothing,
      $sel:lon:IpGeoLocation' :: Maybe Double
lon = 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 :: Lens' IpGeoLocation (Maybe Double)
ipGeoLocation_lat = 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 :: Lens' IpGeoLocation (Maybe Double)
ipGeoLocation_lon = 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 Data.FromJSON IpGeoLocation where
  parseJSON :: Value -> Parser IpGeoLocation
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"IpGeoLocation"
      ( \Object
x ->
          Maybe Double -> Maybe Double -> IpGeoLocation
IpGeoLocation'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"lat")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"lon")
      )

instance Prelude.Hashable IpGeoLocation where
  hashWithSalt :: Int -> IpGeoLocation -> Int
hashWithSalt Int
_salt IpGeoLocation' {Maybe Double
lon :: Maybe Double
lat :: Maybe Double
$sel:lon:IpGeoLocation' :: IpGeoLocation -> Maybe Double
$sel:lat:IpGeoLocation' :: IpGeoLocation -> Maybe Double
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
lat
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
lon

instance Prelude.NFData IpGeoLocation where
  rnf :: IpGeoLocation -> ()
rnf IpGeoLocation' {Maybe Double
lon :: Maybe Double
lat :: Maybe Double
$sel:lon:IpGeoLocation' :: IpGeoLocation -> Maybe Double
$sel:lat:IpGeoLocation' :: IpGeoLocation -> Maybe Double
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
lat seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
lon