{-# 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.FindingActor
-- 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.MacieV2.Types.FindingActor where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MacieV2.Types.DomainDetails
import Amazonka.MacieV2.Types.IpAddressDetails
import Amazonka.MacieV2.Types.UserIdentity
import qualified Amazonka.Prelude as Prelude

-- | Provides information about an entity that performed an action that
-- produced a policy finding for a resource.
--
-- /See:/ 'newFindingActor' smart constructor.
data FindingActor = FindingActor'
  { -- | The type and other characteristics of the entity that performed the
    -- action on the affected resource.
    FindingActor -> Maybe UserIdentity
userIdentity :: Prelude.Maybe UserIdentity,
    -- | The IP address of the device that the entity used to perform the action
    -- on the affected resource. This object also provides information such as
    -- the owner and geographic location for the IP address.
    FindingActor -> Maybe IpAddressDetails
ipAddressDetails :: Prelude.Maybe IpAddressDetails,
    -- | The domain name of the device that the entity used to perform the action
    -- on the affected resource.
    FindingActor -> Maybe DomainDetails
domainDetails :: Prelude.Maybe DomainDetails
  }
  deriving (FindingActor -> FindingActor -> Bool
(FindingActor -> FindingActor -> Bool)
-> (FindingActor -> FindingActor -> Bool) -> Eq FindingActor
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FindingActor -> FindingActor -> Bool
$c/= :: FindingActor -> FindingActor -> Bool
== :: FindingActor -> FindingActor -> Bool
$c== :: FindingActor -> FindingActor -> Bool
Prelude.Eq, ReadPrec [FindingActor]
ReadPrec FindingActor
Int -> ReadS FindingActor
ReadS [FindingActor]
(Int -> ReadS FindingActor)
-> ReadS [FindingActor]
-> ReadPrec FindingActor
-> ReadPrec [FindingActor]
-> Read FindingActor
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FindingActor]
$creadListPrec :: ReadPrec [FindingActor]
readPrec :: ReadPrec FindingActor
$creadPrec :: ReadPrec FindingActor
readList :: ReadS [FindingActor]
$creadList :: ReadS [FindingActor]
readsPrec :: Int -> ReadS FindingActor
$creadsPrec :: Int -> ReadS FindingActor
Prelude.Read, Int -> FindingActor -> ShowS
[FindingActor] -> ShowS
FindingActor -> String
(Int -> FindingActor -> ShowS)
-> (FindingActor -> String)
-> ([FindingActor] -> ShowS)
-> Show FindingActor
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FindingActor] -> ShowS
$cshowList :: [FindingActor] -> ShowS
show :: FindingActor -> String
$cshow :: FindingActor -> String
showsPrec :: Int -> FindingActor -> ShowS
$cshowsPrec :: Int -> FindingActor -> ShowS
Prelude.Show, (forall x. FindingActor -> Rep FindingActor x)
-> (forall x. Rep FindingActor x -> FindingActor)
-> Generic FindingActor
forall x. Rep FindingActor x -> FindingActor
forall x. FindingActor -> Rep FindingActor x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FindingActor x -> FindingActor
$cfrom :: forall x. FindingActor -> Rep FindingActor x
Prelude.Generic)

-- |
-- Create a value of 'FindingActor' 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:
--
-- 'userIdentity', 'findingActor_userIdentity' - The type and other characteristics of the entity that performed the
-- action on the affected resource.
--
-- 'ipAddressDetails', 'findingActor_ipAddressDetails' - The IP address of the device that the entity used to perform the action
-- on the affected resource. This object also provides information such as
-- the owner and geographic location for the IP address.
--
-- 'domainDetails', 'findingActor_domainDetails' - The domain name of the device that the entity used to perform the action
-- on the affected resource.
newFindingActor ::
  FindingActor
newFindingActor :: FindingActor
newFindingActor =
  FindingActor' :: Maybe UserIdentity
-> Maybe IpAddressDetails -> Maybe DomainDetails -> FindingActor
FindingActor'
    { $sel:userIdentity:FindingActor' :: Maybe UserIdentity
userIdentity = Maybe UserIdentity
forall a. Maybe a
Prelude.Nothing,
      $sel:ipAddressDetails:FindingActor' :: Maybe IpAddressDetails
ipAddressDetails = Maybe IpAddressDetails
forall a. Maybe a
Prelude.Nothing,
      $sel:domainDetails:FindingActor' :: Maybe DomainDetails
domainDetails = Maybe DomainDetails
forall a. Maybe a
Prelude.Nothing
    }

-- | The type and other characteristics of the entity that performed the
-- action on the affected resource.
findingActor_userIdentity :: Lens.Lens' FindingActor (Prelude.Maybe UserIdentity)
findingActor_userIdentity :: (Maybe UserIdentity -> f (Maybe UserIdentity))
-> FindingActor -> f FindingActor
findingActor_userIdentity = (FindingActor -> Maybe UserIdentity)
-> (FindingActor -> Maybe UserIdentity -> FindingActor)
-> Lens
     FindingActor FindingActor (Maybe UserIdentity) (Maybe UserIdentity)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FindingActor' {Maybe UserIdentity
userIdentity :: Maybe UserIdentity
$sel:userIdentity:FindingActor' :: FindingActor -> Maybe UserIdentity
userIdentity} -> Maybe UserIdentity
userIdentity) (\s :: FindingActor
s@FindingActor' {} Maybe UserIdentity
a -> FindingActor
s {$sel:userIdentity:FindingActor' :: Maybe UserIdentity
userIdentity = Maybe UserIdentity
a} :: FindingActor)

-- | The IP address of the device that the entity used to perform the action
-- on the affected resource. This object also provides information such as
-- the owner and geographic location for the IP address.
findingActor_ipAddressDetails :: Lens.Lens' FindingActor (Prelude.Maybe IpAddressDetails)
findingActor_ipAddressDetails :: (Maybe IpAddressDetails -> f (Maybe IpAddressDetails))
-> FindingActor -> f FindingActor
findingActor_ipAddressDetails = (FindingActor -> Maybe IpAddressDetails)
-> (FindingActor -> Maybe IpAddressDetails -> FindingActor)
-> Lens
     FindingActor
     FindingActor
     (Maybe IpAddressDetails)
     (Maybe IpAddressDetails)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FindingActor' {Maybe IpAddressDetails
ipAddressDetails :: Maybe IpAddressDetails
$sel:ipAddressDetails:FindingActor' :: FindingActor -> Maybe IpAddressDetails
ipAddressDetails} -> Maybe IpAddressDetails
ipAddressDetails) (\s :: FindingActor
s@FindingActor' {} Maybe IpAddressDetails
a -> FindingActor
s {$sel:ipAddressDetails:FindingActor' :: Maybe IpAddressDetails
ipAddressDetails = Maybe IpAddressDetails
a} :: FindingActor)

-- | The domain name of the device that the entity used to perform the action
-- on the affected resource.
findingActor_domainDetails :: Lens.Lens' FindingActor (Prelude.Maybe DomainDetails)
findingActor_domainDetails :: (Maybe DomainDetails -> f (Maybe DomainDetails))
-> FindingActor -> f FindingActor
findingActor_domainDetails = (FindingActor -> Maybe DomainDetails)
-> (FindingActor -> Maybe DomainDetails -> FindingActor)
-> Lens
     FindingActor
     FindingActor
     (Maybe DomainDetails)
     (Maybe DomainDetails)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FindingActor' {Maybe DomainDetails
domainDetails :: Maybe DomainDetails
$sel:domainDetails:FindingActor' :: FindingActor -> Maybe DomainDetails
domainDetails} -> Maybe DomainDetails
domainDetails) (\s :: FindingActor
s@FindingActor' {} Maybe DomainDetails
a -> FindingActor
s {$sel:domainDetails:FindingActor' :: Maybe DomainDetails
domainDetails = Maybe DomainDetails
a} :: FindingActor)

instance Core.FromJSON FindingActor where
  parseJSON :: Value -> Parser FindingActor
parseJSON =
    String
-> (Object -> Parser FindingActor) -> Value -> Parser FindingActor
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"FindingActor"
      ( \Object
x ->
          Maybe UserIdentity
-> Maybe IpAddressDetails -> Maybe DomainDetails -> FindingActor
FindingActor'
            (Maybe UserIdentity
 -> Maybe IpAddressDetails -> Maybe DomainDetails -> FindingActor)
-> Parser (Maybe UserIdentity)
-> Parser
     (Maybe IpAddressDetails -> Maybe DomainDetails -> FindingActor)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe UserIdentity)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"userIdentity")
            Parser
  (Maybe IpAddressDetails -> Maybe DomainDetails -> FindingActor)
-> Parser (Maybe IpAddressDetails)
-> Parser (Maybe DomainDetails -> FindingActor)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe IpAddressDetails)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ipAddressDetails")
            Parser (Maybe DomainDetails -> FindingActor)
-> Parser (Maybe DomainDetails) -> Parser FindingActor
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe DomainDetails)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"domainDetails")
      )

instance Prelude.Hashable FindingActor

instance Prelude.NFData FindingActor