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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.GuardDuty.Types.City
import Amazonka.GuardDuty.Types.Country
import Amazonka.GuardDuty.Types.GeoLocation
import Amazonka.GuardDuty.Types.Organization
import qualified Amazonka.Prelude as Prelude

-- | Contains information about the remote IP address of the connection.
--
-- /See:/ 'newRemoteIpDetails' smart constructor.
data RemoteIpDetails = RemoteIpDetails'
  { -- | The city information of the remote IP address.
    RemoteIpDetails -> Maybe City
city :: Prelude.Maybe City,
    -- | The country code of the remote IP address.
    RemoteIpDetails -> Maybe Country
country :: Prelude.Maybe Country,
    -- | The location information of the remote IP address.
    RemoteIpDetails -> Maybe GeoLocation
geoLocation :: Prelude.Maybe GeoLocation,
    -- | The IPv4 remote address of the connection.
    RemoteIpDetails -> Maybe Text
ipAddressV4 :: Prelude.Maybe Prelude.Text,
    -- | The ISP organization information of the remote IP address.
    RemoteIpDetails -> Maybe Organization
organization :: Prelude.Maybe Organization
  }
  deriving (RemoteIpDetails -> RemoteIpDetails -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RemoteIpDetails -> RemoteIpDetails -> Bool
$c/= :: RemoteIpDetails -> RemoteIpDetails -> Bool
== :: RemoteIpDetails -> RemoteIpDetails -> Bool
$c== :: RemoteIpDetails -> RemoteIpDetails -> Bool
Prelude.Eq, ReadPrec [RemoteIpDetails]
ReadPrec RemoteIpDetails
Int -> ReadS RemoteIpDetails
ReadS [RemoteIpDetails]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RemoteIpDetails]
$creadListPrec :: ReadPrec [RemoteIpDetails]
readPrec :: ReadPrec RemoteIpDetails
$creadPrec :: ReadPrec RemoteIpDetails
readList :: ReadS [RemoteIpDetails]
$creadList :: ReadS [RemoteIpDetails]
readsPrec :: Int -> ReadS RemoteIpDetails
$creadsPrec :: Int -> ReadS RemoteIpDetails
Prelude.Read, Int -> RemoteIpDetails -> ShowS
[RemoteIpDetails] -> ShowS
RemoteIpDetails -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RemoteIpDetails] -> ShowS
$cshowList :: [RemoteIpDetails] -> ShowS
show :: RemoteIpDetails -> String
$cshow :: RemoteIpDetails -> String
showsPrec :: Int -> RemoteIpDetails -> ShowS
$cshowsPrec :: Int -> RemoteIpDetails -> ShowS
Prelude.Show, forall x. Rep RemoteIpDetails x -> RemoteIpDetails
forall x. RemoteIpDetails -> Rep RemoteIpDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RemoteIpDetails x -> RemoteIpDetails
$cfrom :: forall x. RemoteIpDetails -> Rep RemoteIpDetails x
Prelude.Generic)

-- |
-- Create a value of 'RemoteIpDetails' 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:
--
-- 'city', 'remoteIpDetails_city' - The city information of the remote IP address.
--
-- 'country', 'remoteIpDetails_country' - The country code of the remote IP address.
--
-- 'geoLocation', 'remoteIpDetails_geoLocation' - The location information of the remote IP address.
--
-- 'ipAddressV4', 'remoteIpDetails_ipAddressV4' - The IPv4 remote address of the connection.
--
-- 'organization', 'remoteIpDetails_organization' - The ISP organization information of the remote IP address.
newRemoteIpDetails ::
  RemoteIpDetails
newRemoteIpDetails :: RemoteIpDetails
newRemoteIpDetails =
  RemoteIpDetails'
    { $sel:city:RemoteIpDetails' :: Maybe City
city = forall a. Maybe a
Prelude.Nothing,
      $sel:country:RemoteIpDetails' :: Maybe Country
country = forall a. Maybe a
Prelude.Nothing,
      $sel:geoLocation:RemoteIpDetails' :: Maybe GeoLocation
geoLocation = forall a. Maybe a
Prelude.Nothing,
      $sel:ipAddressV4:RemoteIpDetails' :: Maybe Text
ipAddressV4 = forall a. Maybe a
Prelude.Nothing,
      $sel:organization:RemoteIpDetails' :: Maybe Organization
organization = forall a. Maybe a
Prelude.Nothing
    }

-- | The city information of the remote IP address.
remoteIpDetails_city :: Lens.Lens' RemoteIpDetails (Prelude.Maybe City)
remoteIpDetails_city :: Lens' RemoteIpDetails (Maybe City)
remoteIpDetails_city = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoteIpDetails' {Maybe City
city :: Maybe City
$sel:city:RemoteIpDetails' :: RemoteIpDetails -> Maybe City
city} -> Maybe City
city) (\s :: RemoteIpDetails
s@RemoteIpDetails' {} Maybe City
a -> RemoteIpDetails
s {$sel:city:RemoteIpDetails' :: Maybe City
city = Maybe City
a} :: RemoteIpDetails)

-- | The country code of the remote IP address.
remoteIpDetails_country :: Lens.Lens' RemoteIpDetails (Prelude.Maybe Country)
remoteIpDetails_country :: Lens' RemoteIpDetails (Maybe Country)
remoteIpDetails_country = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoteIpDetails' {Maybe Country
country :: Maybe Country
$sel:country:RemoteIpDetails' :: RemoteIpDetails -> Maybe Country
country} -> Maybe Country
country) (\s :: RemoteIpDetails
s@RemoteIpDetails' {} Maybe Country
a -> RemoteIpDetails
s {$sel:country:RemoteIpDetails' :: Maybe Country
country = Maybe Country
a} :: RemoteIpDetails)

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

-- | The IPv4 remote address of the connection.
remoteIpDetails_ipAddressV4 :: Lens.Lens' RemoteIpDetails (Prelude.Maybe Prelude.Text)
remoteIpDetails_ipAddressV4 :: Lens' RemoteIpDetails (Maybe Text)
remoteIpDetails_ipAddressV4 = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoteIpDetails' {Maybe Text
ipAddressV4 :: Maybe Text
$sel:ipAddressV4:RemoteIpDetails' :: RemoteIpDetails -> Maybe Text
ipAddressV4} -> Maybe Text
ipAddressV4) (\s :: RemoteIpDetails
s@RemoteIpDetails' {} Maybe Text
a -> RemoteIpDetails
s {$sel:ipAddressV4:RemoteIpDetails' :: Maybe Text
ipAddressV4 = Maybe Text
a} :: RemoteIpDetails)

-- | The ISP organization information of the remote IP address.
remoteIpDetails_organization :: Lens.Lens' RemoteIpDetails (Prelude.Maybe Organization)
remoteIpDetails_organization :: Lens' RemoteIpDetails (Maybe Organization)
remoteIpDetails_organization = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoteIpDetails' {Maybe Organization
organization :: Maybe Organization
$sel:organization:RemoteIpDetails' :: RemoteIpDetails -> Maybe Organization
organization} -> Maybe Organization
organization) (\s :: RemoteIpDetails
s@RemoteIpDetails' {} Maybe Organization
a -> RemoteIpDetails
s {$sel:organization:RemoteIpDetails' :: Maybe Organization
organization = Maybe Organization
a} :: RemoteIpDetails)

instance Data.FromJSON RemoteIpDetails where
  parseJSON :: Value -> Parser RemoteIpDetails
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RemoteIpDetails"
      ( \Object
x ->
          Maybe City
-> Maybe Country
-> Maybe GeoLocation
-> Maybe Text
-> Maybe Organization
-> RemoteIpDetails
RemoteIpDetails'
            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
"city")
            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
"country")
            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
"geoLocation")
            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
"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
"organization")
      )

instance Prelude.Hashable RemoteIpDetails where
  hashWithSalt :: Int -> RemoteIpDetails -> Int
hashWithSalt Int
_salt RemoteIpDetails' {Maybe Text
Maybe City
Maybe Country
Maybe GeoLocation
Maybe Organization
organization :: Maybe Organization
ipAddressV4 :: Maybe Text
geoLocation :: Maybe GeoLocation
country :: Maybe Country
city :: Maybe City
$sel:organization:RemoteIpDetails' :: RemoteIpDetails -> Maybe Organization
$sel:ipAddressV4:RemoteIpDetails' :: RemoteIpDetails -> Maybe Text
$sel:geoLocation:RemoteIpDetails' :: RemoteIpDetails -> Maybe GeoLocation
$sel:country:RemoteIpDetails' :: RemoteIpDetails -> Maybe Country
$sel:city:RemoteIpDetails' :: RemoteIpDetails -> Maybe City
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe City
city
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Country
country
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe GeoLocation
geoLocation
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
ipAddressV4
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Organization
organization

instance Prelude.NFData RemoteIpDetails where
  rnf :: RemoteIpDetails -> ()
rnf RemoteIpDetails' {Maybe Text
Maybe City
Maybe Country
Maybe GeoLocation
Maybe Organization
organization :: Maybe Organization
ipAddressV4 :: Maybe Text
geoLocation :: Maybe GeoLocation
country :: Maybe Country
city :: Maybe City
$sel:organization:RemoteIpDetails' :: RemoteIpDetails -> Maybe Organization
$sel:ipAddressV4:RemoteIpDetails' :: RemoteIpDetails -> Maybe Text
$sel:geoLocation:RemoteIpDetails' :: RemoteIpDetails -> Maybe GeoLocation
$sel:country:RemoteIpDetails' :: RemoteIpDetails -> Maybe Country
$sel:city:RemoteIpDetails' :: RemoteIpDetails -> Maybe City
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe City
city
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Country
country
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe GeoLocation
geoLocation
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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 Organization
organization