{-# 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.IpAddressDetails
-- 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.IpAddressDetails where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MacieV2.Types.IpCity
import Amazonka.MacieV2.Types.IpCountry
import Amazonka.MacieV2.Types.IpGeoLocation
import Amazonka.MacieV2.Types.IpOwner
import qualified Amazonka.Prelude as Prelude

-- | Provides information about the IP address of the device that an entity
-- used to perform an action on an affected resource.
--
-- /See:/ 'newIpAddressDetails' smart constructor.
data IpAddressDetails = IpAddressDetails'
  { -- | The Internet Protocol version 4 (IPv4) address of the device.
    IpAddressDetails -> Maybe Text
ipAddressV4 :: Prelude.Maybe Prelude.Text,
    -- | The city that the IP address originated from.
    IpAddressDetails -> Maybe IpCity
ipCity :: Prelude.Maybe IpCity,
    -- | The country that the IP address originated from.
    IpAddressDetails -> Maybe IpCountry
ipCountry :: Prelude.Maybe IpCountry,
    -- | The geographic coordinates of the location that the IP address
    -- originated from.
    IpAddressDetails -> Maybe IpGeoLocation
ipGeoLocation :: Prelude.Maybe IpGeoLocation,
    -- | The registered owner of the IP address.
    IpAddressDetails -> Maybe IpOwner
ipOwner :: Prelude.Maybe IpOwner
  }
  deriving (IpAddressDetails -> IpAddressDetails -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IpAddressDetails -> IpAddressDetails -> Bool
$c/= :: IpAddressDetails -> IpAddressDetails -> Bool
== :: IpAddressDetails -> IpAddressDetails -> Bool
$c== :: IpAddressDetails -> IpAddressDetails -> Bool
Prelude.Eq, ReadPrec [IpAddressDetails]
ReadPrec IpAddressDetails
Int -> ReadS IpAddressDetails
ReadS [IpAddressDetails]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IpAddressDetails]
$creadListPrec :: ReadPrec [IpAddressDetails]
readPrec :: ReadPrec IpAddressDetails
$creadPrec :: ReadPrec IpAddressDetails
readList :: ReadS [IpAddressDetails]
$creadList :: ReadS [IpAddressDetails]
readsPrec :: Int -> ReadS IpAddressDetails
$creadsPrec :: Int -> ReadS IpAddressDetails
Prelude.Read, Int -> IpAddressDetails -> ShowS
[IpAddressDetails] -> ShowS
IpAddressDetails -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IpAddressDetails] -> ShowS
$cshowList :: [IpAddressDetails] -> ShowS
show :: IpAddressDetails -> String
$cshow :: IpAddressDetails -> String
showsPrec :: Int -> IpAddressDetails -> ShowS
$cshowsPrec :: Int -> IpAddressDetails -> ShowS
Prelude.Show, forall x. Rep IpAddressDetails x -> IpAddressDetails
forall x. IpAddressDetails -> Rep IpAddressDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IpAddressDetails x -> IpAddressDetails
$cfrom :: forall x. IpAddressDetails -> Rep IpAddressDetails x
Prelude.Generic)

-- |
-- Create a value of 'IpAddressDetails' 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:
--
-- 'ipAddressV4', 'ipAddressDetails_ipAddressV4' - The Internet Protocol version 4 (IPv4) address of the device.
--
-- 'ipCity', 'ipAddressDetails_ipCity' - The city that the IP address originated from.
--
-- 'ipCountry', 'ipAddressDetails_ipCountry' - The country that the IP address originated from.
--
-- 'ipGeoLocation', 'ipAddressDetails_ipGeoLocation' - The geographic coordinates of the location that the IP address
-- originated from.
--
-- 'ipOwner', 'ipAddressDetails_ipOwner' - The registered owner of the IP address.
newIpAddressDetails ::
  IpAddressDetails
newIpAddressDetails :: IpAddressDetails
newIpAddressDetails =
  IpAddressDetails'
    { $sel:ipAddressV4:IpAddressDetails' :: Maybe Text
ipAddressV4 = forall a. Maybe a
Prelude.Nothing,
      $sel:ipCity:IpAddressDetails' :: Maybe IpCity
ipCity = forall a. Maybe a
Prelude.Nothing,
      $sel:ipCountry:IpAddressDetails' :: Maybe IpCountry
ipCountry = forall a. Maybe a
Prelude.Nothing,
      $sel:ipGeoLocation:IpAddressDetails' :: Maybe IpGeoLocation
ipGeoLocation = forall a. Maybe a
Prelude.Nothing,
      $sel:ipOwner:IpAddressDetails' :: Maybe IpOwner
ipOwner = forall a. Maybe a
Prelude.Nothing
    }

-- | The Internet Protocol version 4 (IPv4) address of the device.
ipAddressDetails_ipAddressV4 :: Lens.Lens' IpAddressDetails (Prelude.Maybe Prelude.Text)
ipAddressDetails_ipAddressV4 :: Lens' IpAddressDetails (Maybe Text)
ipAddressDetails_ipAddressV4 = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IpAddressDetails' {Maybe Text
ipAddressV4 :: Maybe Text
$sel:ipAddressV4:IpAddressDetails' :: IpAddressDetails -> Maybe Text
ipAddressV4} -> Maybe Text
ipAddressV4) (\s :: IpAddressDetails
s@IpAddressDetails' {} Maybe Text
a -> IpAddressDetails
s {$sel:ipAddressV4:IpAddressDetails' :: Maybe Text
ipAddressV4 = Maybe Text
a} :: IpAddressDetails)

-- | The city that the IP address originated from.
ipAddressDetails_ipCity :: Lens.Lens' IpAddressDetails (Prelude.Maybe IpCity)
ipAddressDetails_ipCity :: Lens' IpAddressDetails (Maybe IpCity)
ipAddressDetails_ipCity = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IpAddressDetails' {Maybe IpCity
ipCity :: Maybe IpCity
$sel:ipCity:IpAddressDetails' :: IpAddressDetails -> Maybe IpCity
ipCity} -> Maybe IpCity
ipCity) (\s :: IpAddressDetails
s@IpAddressDetails' {} Maybe IpCity
a -> IpAddressDetails
s {$sel:ipCity:IpAddressDetails' :: Maybe IpCity
ipCity = Maybe IpCity
a} :: IpAddressDetails)

-- | The country that the IP address originated from.
ipAddressDetails_ipCountry :: Lens.Lens' IpAddressDetails (Prelude.Maybe IpCountry)
ipAddressDetails_ipCountry :: Lens' IpAddressDetails (Maybe IpCountry)
ipAddressDetails_ipCountry = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IpAddressDetails' {Maybe IpCountry
ipCountry :: Maybe IpCountry
$sel:ipCountry:IpAddressDetails' :: IpAddressDetails -> Maybe IpCountry
ipCountry} -> Maybe IpCountry
ipCountry) (\s :: IpAddressDetails
s@IpAddressDetails' {} Maybe IpCountry
a -> IpAddressDetails
s {$sel:ipCountry:IpAddressDetails' :: Maybe IpCountry
ipCountry = Maybe IpCountry
a} :: IpAddressDetails)

-- | The geographic coordinates of the location that the IP address
-- originated from.
ipAddressDetails_ipGeoLocation :: Lens.Lens' IpAddressDetails (Prelude.Maybe IpGeoLocation)
ipAddressDetails_ipGeoLocation :: Lens' IpAddressDetails (Maybe IpGeoLocation)
ipAddressDetails_ipGeoLocation = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IpAddressDetails' {Maybe IpGeoLocation
ipGeoLocation :: Maybe IpGeoLocation
$sel:ipGeoLocation:IpAddressDetails' :: IpAddressDetails -> Maybe IpGeoLocation
ipGeoLocation} -> Maybe IpGeoLocation
ipGeoLocation) (\s :: IpAddressDetails
s@IpAddressDetails' {} Maybe IpGeoLocation
a -> IpAddressDetails
s {$sel:ipGeoLocation:IpAddressDetails' :: Maybe IpGeoLocation
ipGeoLocation = Maybe IpGeoLocation
a} :: IpAddressDetails)

-- | The registered owner of the IP address.
ipAddressDetails_ipOwner :: Lens.Lens' IpAddressDetails (Prelude.Maybe IpOwner)
ipAddressDetails_ipOwner :: Lens' IpAddressDetails (Maybe IpOwner)
ipAddressDetails_ipOwner = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IpAddressDetails' {Maybe IpOwner
ipOwner :: Maybe IpOwner
$sel:ipOwner:IpAddressDetails' :: IpAddressDetails -> Maybe IpOwner
ipOwner} -> Maybe IpOwner
ipOwner) (\s :: IpAddressDetails
s@IpAddressDetails' {} Maybe IpOwner
a -> IpAddressDetails
s {$sel:ipOwner:IpAddressDetails' :: Maybe IpOwner
ipOwner = Maybe IpOwner
a} :: IpAddressDetails)

instance Data.FromJSON IpAddressDetails where
  parseJSON :: Value -> Parser IpAddressDetails
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"IpAddressDetails"
      ( \Object
x ->
          Maybe Text
-> Maybe IpCity
-> Maybe IpCountry
-> Maybe IpGeoLocation
-> Maybe IpOwner
-> IpAddressDetails
IpAddressDetails'
            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
"ipAddressV4")
            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
"ipCity")
            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
"ipCountry")
            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
"ipGeoLocation")
            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
"ipOwner")
      )

instance Prelude.Hashable IpAddressDetails where
  hashWithSalt :: Int -> IpAddressDetails -> Int
hashWithSalt Int
_salt IpAddressDetails' {Maybe Text
Maybe IpCity
Maybe IpCountry
Maybe IpGeoLocation
Maybe IpOwner
ipOwner :: Maybe IpOwner
ipGeoLocation :: Maybe IpGeoLocation
ipCountry :: Maybe IpCountry
ipCity :: Maybe IpCity
ipAddressV4 :: Maybe Text
$sel:ipOwner:IpAddressDetails' :: IpAddressDetails -> Maybe IpOwner
$sel:ipGeoLocation:IpAddressDetails' :: IpAddressDetails -> Maybe IpGeoLocation
$sel:ipCountry:IpAddressDetails' :: IpAddressDetails -> Maybe IpCountry
$sel:ipCity:IpAddressDetails' :: IpAddressDetails -> Maybe IpCity
$sel:ipAddressV4:IpAddressDetails' :: IpAddressDetails -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
ipAddressV4
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe IpCity
ipCity
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe IpCountry
ipCountry
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe IpGeoLocation
ipGeoLocation
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe IpOwner
ipOwner

instance Prelude.NFData IpAddressDetails where
  rnf :: IpAddressDetails -> ()
rnf IpAddressDetails' {Maybe Text
Maybe IpCity
Maybe IpCountry
Maybe IpGeoLocation
Maybe IpOwner
ipOwner :: Maybe IpOwner
ipGeoLocation :: Maybe IpGeoLocation
ipCountry :: Maybe IpCountry
ipCity :: Maybe IpCity
ipAddressV4 :: Maybe Text
$sel:ipOwner:IpAddressDetails' :: IpAddressDetails -> Maybe IpOwner
$sel:ipGeoLocation:IpAddressDetails' :: IpAddressDetails -> Maybe IpGeoLocation
$sel:ipCountry:IpAddressDetails' :: IpAddressDetails -> Maybe IpCountry
$sel:ipCity:IpAddressDetails' :: IpAddressDetails -> Maybe IpCity
$sel:ipAddressV4:IpAddressDetails' :: IpAddressDetails -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
ipAddressV4
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe IpCity
ipCity
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe IpCountry
ipCountry
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe IpGeoLocation
ipGeoLocation
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe IpOwner
ipOwner