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

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

-- | Contains information about the remote IP address of the connection.
--
-- /See:/ 'newRemoteIpDetails' smart constructor.
data RemoteIpDetails = RemoteIpDetails'
  { -- | The country code of the remote IP address.
    RemoteIpDetails -> Maybe Country
country :: Prelude.Maybe Country,
    -- | The city information of the remote IP address.
    RemoteIpDetails -> Maybe City
city :: Prelude.Maybe City,
    -- | The IPv4 remote address of the connection.
    RemoteIpDetails -> Maybe Text
ipAddressV4 :: Prelude.Maybe Prelude.Text,
    -- | The location information of the remote IP address.
    RemoteIpDetails -> Maybe GeoLocation
geoLocation :: Prelude.Maybe GeoLocation,
    -- | The ISP organization information of the remote IP address.
    RemoteIpDetails -> Maybe Organization
organization :: Prelude.Maybe Organization
  }
  deriving (RemoteIpDetails -> RemoteIpDetails -> Bool
(RemoteIpDetails -> RemoteIpDetails -> Bool)
-> (RemoteIpDetails -> RemoteIpDetails -> Bool)
-> Eq RemoteIpDetails
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]
(Int -> ReadS RemoteIpDetails)
-> ReadS [RemoteIpDetails]
-> ReadPrec RemoteIpDetails
-> ReadPrec [RemoteIpDetails]
-> Read 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
(Int -> RemoteIpDetails -> ShowS)
-> (RemoteIpDetails -> String)
-> ([RemoteIpDetails] -> ShowS)
-> Show RemoteIpDetails
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. RemoteIpDetails -> Rep RemoteIpDetails x)
-> (forall x. Rep RemoteIpDetails x -> RemoteIpDetails)
-> Generic RemoteIpDetails
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:
--
-- 'country', 'remoteIpDetails_country' - The country code of the remote IP address.
--
-- 'city', 'remoteIpDetails_city' - The city information of the remote IP address.
--
-- 'ipAddressV4', 'remoteIpDetails_ipAddressV4' - The IPv4 remote address of the connection.
--
-- 'geoLocation', 'remoteIpDetails_geoLocation' - The location information of the remote IP address.
--
-- 'organization', 'remoteIpDetails_organization' - The ISP organization information of the remote IP address.
newRemoteIpDetails ::
  RemoteIpDetails
newRemoteIpDetails :: RemoteIpDetails
newRemoteIpDetails =
  RemoteIpDetails' :: Maybe Country
-> Maybe City
-> Maybe Text
-> Maybe GeoLocation
-> Maybe Organization
-> RemoteIpDetails
RemoteIpDetails'
    { $sel:country:RemoteIpDetails' :: Maybe Country
country = Maybe Country
forall a. Maybe a
Prelude.Nothing,
      $sel:city:RemoteIpDetails' :: Maybe City
city = Maybe City
forall a. Maybe a
Prelude.Nothing,
      $sel:ipAddressV4:RemoteIpDetails' :: Maybe Text
ipAddressV4 = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:geoLocation:RemoteIpDetails' :: Maybe GeoLocation
geoLocation = Maybe GeoLocation
forall a. Maybe a
Prelude.Nothing,
      $sel:organization:RemoteIpDetails' :: Maybe Organization
organization = Maybe Organization
forall a. Maybe a
Prelude.Nothing
    }

-- | The country code of the remote IP address.
remoteIpDetails_country :: Lens.Lens' RemoteIpDetails (Prelude.Maybe Country)
remoteIpDetails_country :: (Maybe Country -> f (Maybe Country))
-> RemoteIpDetails -> f RemoteIpDetails
remoteIpDetails_country = (RemoteIpDetails -> Maybe Country)
-> (RemoteIpDetails -> Maybe Country -> RemoteIpDetails)
-> Lens
     RemoteIpDetails RemoteIpDetails (Maybe Country) (Maybe 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 city information of the remote IP address.
remoteIpDetails_city :: Lens.Lens' RemoteIpDetails (Prelude.Maybe City)
remoteIpDetails_city :: (Maybe City -> f (Maybe City))
-> RemoteIpDetails -> f RemoteIpDetails
remoteIpDetails_city = (RemoteIpDetails -> Maybe City)
-> (RemoteIpDetails -> Maybe City -> RemoteIpDetails)
-> Lens RemoteIpDetails RemoteIpDetails (Maybe City) (Maybe 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 IPv4 remote address of the connection.
remoteIpDetails_ipAddressV4 :: Lens.Lens' RemoteIpDetails (Prelude.Maybe Prelude.Text)
remoteIpDetails_ipAddressV4 :: (Maybe Text -> f (Maybe Text))
-> RemoteIpDetails -> f RemoteIpDetails
remoteIpDetails_ipAddressV4 = (RemoteIpDetails -> Maybe Text)
-> (RemoteIpDetails -> Maybe Text -> RemoteIpDetails)
-> Lens RemoteIpDetails RemoteIpDetails (Maybe Text) (Maybe Text)
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 location information of the remote IP address.
remoteIpDetails_geoLocation :: Lens.Lens' RemoteIpDetails (Prelude.Maybe GeoLocation)
remoteIpDetails_geoLocation :: (Maybe GeoLocation -> f (Maybe GeoLocation))
-> RemoteIpDetails -> f RemoteIpDetails
remoteIpDetails_geoLocation = (RemoteIpDetails -> Maybe GeoLocation)
-> (RemoteIpDetails -> Maybe GeoLocation -> RemoteIpDetails)
-> Lens
     RemoteIpDetails
     RemoteIpDetails
     (Maybe GeoLocation)
     (Maybe 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 ISP organization information of the remote IP address.
remoteIpDetails_organization :: Lens.Lens' RemoteIpDetails (Prelude.Maybe Organization)
remoteIpDetails_organization :: (Maybe Organization -> f (Maybe Organization))
-> RemoteIpDetails -> f RemoteIpDetails
remoteIpDetails_organization = (RemoteIpDetails -> Maybe Organization)
-> (RemoteIpDetails -> Maybe Organization -> RemoteIpDetails)
-> Lens
     RemoteIpDetails
     RemoteIpDetails
     (Maybe Organization)
     (Maybe 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 Core.FromJSON RemoteIpDetails where
  parseJSON :: Value -> Parser RemoteIpDetails
parseJSON =
    String
-> (Object -> Parser RemoteIpDetails)
-> Value
-> Parser RemoteIpDetails
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RemoteIpDetails"
      ( \Object
x ->
          Maybe Country
-> Maybe City
-> Maybe Text
-> Maybe GeoLocation
-> Maybe Organization
-> RemoteIpDetails
RemoteIpDetails'
            (Maybe Country
 -> Maybe City
 -> Maybe Text
 -> Maybe GeoLocation
 -> Maybe Organization
 -> RemoteIpDetails)
-> Parser (Maybe Country)
-> Parser
     (Maybe City
      -> Maybe Text
      -> Maybe GeoLocation
      -> Maybe Organization
      -> RemoteIpDetails)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Country)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"country")
            Parser
  (Maybe City
   -> Maybe Text
   -> Maybe GeoLocation
   -> Maybe Organization
   -> RemoteIpDetails)
-> Parser (Maybe City)
-> Parser
     (Maybe Text
      -> Maybe GeoLocation -> Maybe Organization -> RemoteIpDetails)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe City)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"city")
            Parser
  (Maybe Text
   -> Maybe GeoLocation -> Maybe Organization -> RemoteIpDetails)
-> Parser (Maybe Text)
-> Parser
     (Maybe GeoLocation -> Maybe Organization -> RemoteIpDetails)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ipAddressV4")
            Parser (Maybe GeoLocation -> Maybe Organization -> RemoteIpDetails)
-> Parser (Maybe GeoLocation)
-> Parser (Maybe Organization -> RemoteIpDetails)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe GeoLocation)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"geoLocation")
            Parser (Maybe Organization -> RemoteIpDetails)
-> Parser (Maybe Organization) -> Parser RemoteIpDetails
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Organization)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"organization")
      )

instance Prelude.Hashable RemoteIpDetails

instance Prelude.NFData RemoteIpDetails