{-# 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.SecurityHub.Types.ActionRemoteIpDetails
-- 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.SecurityHub.Types.ActionRemoteIpDetails where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SecurityHub.Types.City
import Amazonka.SecurityHub.Types.Country
import Amazonka.SecurityHub.Types.GeoLocation
import Amazonka.SecurityHub.Types.IpOrganizationDetails

-- | For @AwsApiAction@, @NetworkConnectionAction@, and @PortProbeAction@,
-- @RemoteIpDetails@ provides information about the remote IP address that
-- was involved in the action.
--
-- /See:/ 'newActionRemoteIpDetails' smart constructor.
data ActionRemoteIpDetails = ActionRemoteIpDetails'
  { -- | The country where the remote IP address is located.
    ActionRemoteIpDetails -> Maybe Country
country :: Prelude.Maybe Country,
    -- | The city where the remote IP address is located.
    ActionRemoteIpDetails -> Maybe City
city :: Prelude.Maybe City,
    -- | The IP address.
    ActionRemoteIpDetails -> Maybe Text
ipAddressV4 :: Prelude.Maybe Prelude.Text,
    -- | The coordinates of the location of the remote IP address.
    ActionRemoteIpDetails -> Maybe GeoLocation
geoLocation :: Prelude.Maybe GeoLocation,
    -- | The internet service provider (ISP) organization associated with the
    -- remote IP address.
    ActionRemoteIpDetails -> Maybe IpOrganizationDetails
organization :: Prelude.Maybe IpOrganizationDetails
  }
  deriving (ActionRemoteIpDetails -> ActionRemoteIpDetails -> Bool
(ActionRemoteIpDetails -> ActionRemoteIpDetails -> Bool)
-> (ActionRemoteIpDetails -> ActionRemoteIpDetails -> Bool)
-> Eq ActionRemoteIpDetails
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ActionRemoteIpDetails -> ActionRemoteIpDetails -> Bool
$c/= :: ActionRemoteIpDetails -> ActionRemoteIpDetails -> Bool
== :: ActionRemoteIpDetails -> ActionRemoteIpDetails -> Bool
$c== :: ActionRemoteIpDetails -> ActionRemoteIpDetails -> Bool
Prelude.Eq, ReadPrec [ActionRemoteIpDetails]
ReadPrec ActionRemoteIpDetails
Int -> ReadS ActionRemoteIpDetails
ReadS [ActionRemoteIpDetails]
(Int -> ReadS ActionRemoteIpDetails)
-> ReadS [ActionRemoteIpDetails]
-> ReadPrec ActionRemoteIpDetails
-> ReadPrec [ActionRemoteIpDetails]
-> Read ActionRemoteIpDetails
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ActionRemoteIpDetails]
$creadListPrec :: ReadPrec [ActionRemoteIpDetails]
readPrec :: ReadPrec ActionRemoteIpDetails
$creadPrec :: ReadPrec ActionRemoteIpDetails
readList :: ReadS [ActionRemoteIpDetails]
$creadList :: ReadS [ActionRemoteIpDetails]
readsPrec :: Int -> ReadS ActionRemoteIpDetails
$creadsPrec :: Int -> ReadS ActionRemoteIpDetails
Prelude.Read, Int -> ActionRemoteIpDetails -> ShowS
[ActionRemoteIpDetails] -> ShowS
ActionRemoteIpDetails -> String
(Int -> ActionRemoteIpDetails -> ShowS)
-> (ActionRemoteIpDetails -> String)
-> ([ActionRemoteIpDetails] -> ShowS)
-> Show ActionRemoteIpDetails
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ActionRemoteIpDetails] -> ShowS
$cshowList :: [ActionRemoteIpDetails] -> ShowS
show :: ActionRemoteIpDetails -> String
$cshow :: ActionRemoteIpDetails -> String
showsPrec :: Int -> ActionRemoteIpDetails -> ShowS
$cshowsPrec :: Int -> ActionRemoteIpDetails -> ShowS
Prelude.Show, (forall x. ActionRemoteIpDetails -> Rep ActionRemoteIpDetails x)
-> (forall x. Rep ActionRemoteIpDetails x -> ActionRemoteIpDetails)
-> Generic ActionRemoteIpDetails
forall x. Rep ActionRemoteIpDetails x -> ActionRemoteIpDetails
forall x. ActionRemoteIpDetails -> Rep ActionRemoteIpDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ActionRemoteIpDetails x -> ActionRemoteIpDetails
$cfrom :: forall x. ActionRemoteIpDetails -> Rep ActionRemoteIpDetails x
Prelude.Generic)

-- |
-- Create a value of 'ActionRemoteIpDetails' 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', 'actionRemoteIpDetails_country' - The country where the remote IP address is located.
--
-- 'city', 'actionRemoteIpDetails_city' - The city where the remote IP address is located.
--
-- 'ipAddressV4', 'actionRemoteIpDetails_ipAddressV4' - The IP address.
--
-- 'geoLocation', 'actionRemoteIpDetails_geoLocation' - The coordinates of the location of the remote IP address.
--
-- 'organization', 'actionRemoteIpDetails_organization' - The internet service provider (ISP) organization associated with the
-- remote IP address.
newActionRemoteIpDetails ::
  ActionRemoteIpDetails
newActionRemoteIpDetails :: ActionRemoteIpDetails
newActionRemoteIpDetails =
  ActionRemoteIpDetails' :: Maybe Country
-> Maybe City
-> Maybe Text
-> Maybe GeoLocation
-> Maybe IpOrganizationDetails
-> ActionRemoteIpDetails
ActionRemoteIpDetails'
    { $sel:country:ActionRemoteIpDetails' :: Maybe Country
country = Maybe Country
forall a. Maybe a
Prelude.Nothing,
      $sel:city:ActionRemoteIpDetails' :: Maybe City
city = Maybe City
forall a. Maybe a
Prelude.Nothing,
      $sel:ipAddressV4:ActionRemoteIpDetails' :: Maybe Text
ipAddressV4 = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:geoLocation:ActionRemoteIpDetails' :: Maybe GeoLocation
geoLocation = Maybe GeoLocation
forall a. Maybe a
Prelude.Nothing,
      $sel:organization:ActionRemoteIpDetails' :: Maybe IpOrganizationDetails
organization = Maybe IpOrganizationDetails
forall a. Maybe a
Prelude.Nothing
    }

-- | The country where the remote IP address is located.
actionRemoteIpDetails_country :: Lens.Lens' ActionRemoteIpDetails (Prelude.Maybe Country)
actionRemoteIpDetails_country :: (Maybe Country -> f (Maybe Country))
-> ActionRemoteIpDetails -> f ActionRemoteIpDetails
actionRemoteIpDetails_country = (ActionRemoteIpDetails -> Maybe Country)
-> (ActionRemoteIpDetails
    -> Maybe Country -> ActionRemoteIpDetails)
-> Lens
     ActionRemoteIpDetails
     ActionRemoteIpDetails
     (Maybe Country)
     (Maybe Country)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActionRemoteIpDetails' {Maybe Country
country :: Maybe Country
$sel:country:ActionRemoteIpDetails' :: ActionRemoteIpDetails -> Maybe Country
country} -> Maybe Country
country) (\s :: ActionRemoteIpDetails
s@ActionRemoteIpDetails' {} Maybe Country
a -> ActionRemoteIpDetails
s {$sel:country:ActionRemoteIpDetails' :: Maybe Country
country = Maybe Country
a} :: ActionRemoteIpDetails)

-- | The city where the remote IP address is located.
actionRemoteIpDetails_city :: Lens.Lens' ActionRemoteIpDetails (Prelude.Maybe City)
actionRemoteIpDetails_city :: (Maybe City -> f (Maybe City))
-> ActionRemoteIpDetails -> f ActionRemoteIpDetails
actionRemoteIpDetails_city = (ActionRemoteIpDetails -> Maybe City)
-> (ActionRemoteIpDetails -> Maybe City -> ActionRemoteIpDetails)
-> Lens
     ActionRemoteIpDetails
     ActionRemoteIpDetails
     (Maybe City)
     (Maybe City)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActionRemoteIpDetails' {Maybe City
city :: Maybe City
$sel:city:ActionRemoteIpDetails' :: ActionRemoteIpDetails -> Maybe City
city} -> Maybe City
city) (\s :: ActionRemoteIpDetails
s@ActionRemoteIpDetails' {} Maybe City
a -> ActionRemoteIpDetails
s {$sel:city:ActionRemoteIpDetails' :: Maybe City
city = Maybe City
a} :: ActionRemoteIpDetails)

-- | The IP address.
actionRemoteIpDetails_ipAddressV4 :: Lens.Lens' ActionRemoteIpDetails (Prelude.Maybe Prelude.Text)
actionRemoteIpDetails_ipAddressV4 :: (Maybe Text -> f (Maybe Text))
-> ActionRemoteIpDetails -> f ActionRemoteIpDetails
actionRemoteIpDetails_ipAddressV4 = (ActionRemoteIpDetails -> Maybe Text)
-> (ActionRemoteIpDetails -> Maybe Text -> ActionRemoteIpDetails)
-> Lens
     ActionRemoteIpDetails
     ActionRemoteIpDetails
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActionRemoteIpDetails' {Maybe Text
ipAddressV4 :: Maybe Text
$sel:ipAddressV4:ActionRemoteIpDetails' :: ActionRemoteIpDetails -> Maybe Text
ipAddressV4} -> Maybe Text
ipAddressV4) (\s :: ActionRemoteIpDetails
s@ActionRemoteIpDetails' {} Maybe Text
a -> ActionRemoteIpDetails
s {$sel:ipAddressV4:ActionRemoteIpDetails' :: Maybe Text
ipAddressV4 = Maybe Text
a} :: ActionRemoteIpDetails)

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

-- | The internet service provider (ISP) organization associated with the
-- remote IP address.
actionRemoteIpDetails_organization :: Lens.Lens' ActionRemoteIpDetails (Prelude.Maybe IpOrganizationDetails)
actionRemoteIpDetails_organization :: (Maybe IpOrganizationDetails -> f (Maybe IpOrganizationDetails))
-> ActionRemoteIpDetails -> f ActionRemoteIpDetails
actionRemoteIpDetails_organization = (ActionRemoteIpDetails -> Maybe IpOrganizationDetails)
-> (ActionRemoteIpDetails
    -> Maybe IpOrganizationDetails -> ActionRemoteIpDetails)
-> Lens
     ActionRemoteIpDetails
     ActionRemoteIpDetails
     (Maybe IpOrganizationDetails)
     (Maybe IpOrganizationDetails)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActionRemoteIpDetails' {Maybe IpOrganizationDetails
organization :: Maybe IpOrganizationDetails
$sel:organization:ActionRemoteIpDetails' :: ActionRemoteIpDetails -> Maybe IpOrganizationDetails
organization} -> Maybe IpOrganizationDetails
organization) (\s :: ActionRemoteIpDetails
s@ActionRemoteIpDetails' {} Maybe IpOrganizationDetails
a -> ActionRemoteIpDetails
s {$sel:organization:ActionRemoteIpDetails' :: Maybe IpOrganizationDetails
organization = Maybe IpOrganizationDetails
a} :: ActionRemoteIpDetails)

instance Core.FromJSON ActionRemoteIpDetails where
  parseJSON :: Value -> Parser ActionRemoteIpDetails
parseJSON =
    String
-> (Object -> Parser ActionRemoteIpDetails)
-> Value
-> Parser ActionRemoteIpDetails
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ActionRemoteIpDetails"
      ( \Object
x ->
          Maybe Country
-> Maybe City
-> Maybe Text
-> Maybe GeoLocation
-> Maybe IpOrganizationDetails
-> ActionRemoteIpDetails
ActionRemoteIpDetails'
            (Maybe Country
 -> Maybe City
 -> Maybe Text
 -> Maybe GeoLocation
 -> Maybe IpOrganizationDetails
 -> ActionRemoteIpDetails)
-> Parser (Maybe Country)
-> Parser
     (Maybe City
      -> Maybe Text
      -> Maybe GeoLocation
      -> Maybe IpOrganizationDetails
      -> ActionRemoteIpDetails)
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 IpOrganizationDetails
   -> ActionRemoteIpDetails)
-> Parser (Maybe City)
-> Parser
     (Maybe Text
      -> Maybe GeoLocation
      -> Maybe IpOrganizationDetails
      -> ActionRemoteIpDetails)
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 IpOrganizationDetails
   -> ActionRemoteIpDetails)
-> Parser (Maybe Text)
-> Parser
     (Maybe GeoLocation
      -> Maybe IpOrganizationDetails -> ActionRemoteIpDetails)
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 IpOrganizationDetails -> ActionRemoteIpDetails)
-> Parser (Maybe GeoLocation)
-> Parser (Maybe IpOrganizationDetails -> ActionRemoteIpDetails)
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 IpOrganizationDetails -> ActionRemoteIpDetails)
-> Parser (Maybe IpOrganizationDetails)
-> Parser ActionRemoteIpDetails
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe IpOrganizationDetails)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Organization")
      )

instance Prelude.Hashable ActionRemoteIpDetails

instance Prelude.NFData ActionRemoteIpDetails

instance Core.ToJSON ActionRemoteIpDetails where
  toJSON :: ActionRemoteIpDetails -> Value
toJSON ActionRemoteIpDetails' {Maybe Text
Maybe City
Maybe Country
Maybe GeoLocation
Maybe IpOrganizationDetails
organization :: Maybe IpOrganizationDetails
geoLocation :: Maybe GeoLocation
ipAddressV4 :: Maybe Text
city :: Maybe City
country :: Maybe Country
$sel:organization:ActionRemoteIpDetails' :: ActionRemoteIpDetails -> Maybe IpOrganizationDetails
$sel:geoLocation:ActionRemoteIpDetails' :: ActionRemoteIpDetails -> Maybe GeoLocation
$sel:ipAddressV4:ActionRemoteIpDetails' :: ActionRemoteIpDetails -> Maybe Text
$sel:city:ActionRemoteIpDetails' :: ActionRemoteIpDetails -> Maybe City
$sel:country:ActionRemoteIpDetails' :: ActionRemoteIpDetails -> Maybe Country
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Country" Text -> Country -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Country -> Pair) -> Maybe Country -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Country
country,
            (Text
"City" Text -> City -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (City -> Pair) -> Maybe City -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe City
city,
            (Text
"IpAddressV4" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
ipAddressV4,
            (Text
"GeoLocation" Text -> GeoLocation -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (GeoLocation -> Pair) -> Maybe GeoLocation -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe GeoLocation
geoLocation,
            (Text
"Organization" Text -> IpOrganizationDetails -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (IpOrganizationDetails -> Pair)
-> Maybe IpOrganizationDetails -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe IpOrganizationDetails
organization
          ]
      )