{-# 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.GuardDuty.Types.GeoLocation
-- 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.GuardDuty.Types.GeoLocation 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

-- | Contains information about the location of the remote IP address.
--
-- /See:/ 'newGeoLocation' smart constructor.
data GeoLocation = GeoLocation'
  { -- | The latitude information of the remote IP address.
    GeoLocation -> Maybe Double
lat :: Prelude.Maybe Prelude.Double,
    -- | The longitude information of the remote IP address.
    GeoLocation -> Maybe Double
lon :: Prelude.Maybe Prelude.Double
  }
  deriving (GeoLocation -> GeoLocation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GeoLocation -> GeoLocation -> Bool
$c/= :: GeoLocation -> GeoLocation -> Bool
== :: GeoLocation -> GeoLocation -> Bool
$c== :: GeoLocation -> GeoLocation -> Bool
Prelude.Eq, ReadPrec [GeoLocation]
ReadPrec GeoLocation
Int -> ReadS GeoLocation
ReadS [GeoLocation]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GeoLocation]
$creadListPrec :: ReadPrec [GeoLocation]
readPrec :: ReadPrec GeoLocation
$creadPrec :: ReadPrec GeoLocation
readList :: ReadS [GeoLocation]
$creadList :: ReadS [GeoLocation]
readsPrec :: Int -> ReadS GeoLocation
$creadsPrec :: Int -> ReadS GeoLocation
Prelude.Read, Int -> GeoLocation -> ShowS
[GeoLocation] -> ShowS
GeoLocation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GeoLocation] -> ShowS
$cshowList :: [GeoLocation] -> ShowS
show :: GeoLocation -> String
$cshow :: GeoLocation -> String
showsPrec :: Int -> GeoLocation -> ShowS
$cshowsPrec :: Int -> GeoLocation -> ShowS
Prelude.Show, forall x. Rep GeoLocation x -> GeoLocation
forall x. GeoLocation -> Rep GeoLocation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GeoLocation x -> GeoLocation
$cfrom :: forall x. GeoLocation -> Rep GeoLocation x
Prelude.Generic)

-- |
-- Create a value of 'GeoLocation' 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', 'geoLocation_lat' - The latitude information of the remote IP address.
--
-- 'lon', 'geoLocation_lon' - The longitude information of the remote IP address.
newGeoLocation ::
  GeoLocation
newGeoLocation :: GeoLocation
newGeoLocation =
  GeoLocation'
    { $sel:lat:GeoLocation' :: Maybe Double
lat = forall a. Maybe a
Prelude.Nothing,
      $sel:lon:GeoLocation' :: Maybe Double
lon = forall a. Maybe a
Prelude.Nothing
    }

-- | The latitude information of the remote IP address.
geoLocation_lat :: Lens.Lens' GeoLocation (Prelude.Maybe Prelude.Double)
geoLocation_lat :: Lens' GeoLocation (Maybe Double)
geoLocation_lat = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GeoLocation' {Maybe Double
lat :: Maybe Double
$sel:lat:GeoLocation' :: GeoLocation -> Maybe Double
lat} -> Maybe Double
lat) (\s :: GeoLocation
s@GeoLocation' {} Maybe Double
a -> GeoLocation
s {$sel:lat:GeoLocation' :: Maybe Double
lat = Maybe Double
a} :: GeoLocation)

-- | The longitude information of the remote IP address.
geoLocation_lon :: Lens.Lens' GeoLocation (Prelude.Maybe Prelude.Double)
geoLocation_lon :: Lens' GeoLocation (Maybe Double)
geoLocation_lon = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GeoLocation' {Maybe Double
lon :: Maybe Double
$sel:lon:GeoLocation' :: GeoLocation -> Maybe Double
lon} -> Maybe Double
lon) (\s :: GeoLocation
s@GeoLocation' {} Maybe Double
a -> GeoLocation
s {$sel:lon:GeoLocation' :: Maybe Double
lon = Maybe Double
a} :: GeoLocation)

instance Data.FromJSON GeoLocation where
  parseJSON :: Value -> Parser GeoLocation
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"GeoLocation"
      ( \Object
x ->
          Maybe Double -> Maybe Double -> GeoLocation
GeoLocation'
            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 GeoLocation where
  hashWithSalt :: Int -> GeoLocation -> Int
hashWithSalt Int
_salt GeoLocation' {Maybe Double
lon :: Maybe Double
lat :: Maybe Double
$sel:lon:GeoLocation' :: GeoLocation -> Maybe Double
$sel:lat:GeoLocation' :: GeoLocation -> 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 GeoLocation where
  rnf :: GeoLocation -> ()
rnf GeoLocation' {Maybe Double
lon :: Maybe Double
lat :: Maybe Double
$sel:lon:GeoLocation' :: GeoLocation -> Maybe Double
$sel:lat:GeoLocation' :: GeoLocation -> 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