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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SecurityHub.Types.ActionRemoteIpDetails
import Amazonka.SecurityHub.Types.AwsApiCallActionDomainDetails

-- | Provided if @ActionType@ is @AWS_API_CALL@. It provides details about
-- the API call that was detected.
--
-- /See:/ 'newAwsApiCallAction' smart constructor.
data AwsApiCallAction = AwsApiCallAction'
  { -- | Provided if @CallerType@ is @remoteIp@. Provides information about the
    -- remote IP address that the API call originated from.
    AwsApiCallAction -> Maybe ActionRemoteIpDetails
remoteIpDetails :: Prelude.Maybe ActionRemoteIpDetails,
    -- | An ISO8601-formatted timestamp that indicates when the API call was
    -- first observed.
    AwsApiCallAction -> Maybe Text
firstSeen :: Prelude.Maybe Prelude.Text,
    -- | Indicates whether the API call originated from a remote IP address
    -- (@remoteip@) or from a DNS domain (@domain@).
    AwsApiCallAction -> Maybe Text
callerType :: Prelude.Maybe Prelude.Text,
    -- | Identifies the resources that were affected by the API call.
    AwsApiCallAction -> Maybe (HashMap Text Text)
affectedResources :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | An ISO8601-formatted timestamp that indicates when the API call was most
    -- recently observed.
    AwsApiCallAction -> Maybe Text
lastSeen :: Prelude.Maybe Prelude.Text,
    -- | Provided if @CallerType@ is @domain@. Provides information about the DNS
    -- domain that the API call originated from.
    AwsApiCallAction -> Maybe AwsApiCallActionDomainDetails
domainDetails :: Prelude.Maybe AwsApiCallActionDomainDetails,
    -- | The name of the Amazon Web Services service that the API method belongs
    -- to.
    AwsApiCallAction -> Maybe Text
serviceName :: Prelude.Maybe Prelude.Text,
    -- | The name of the API method that was issued.
    AwsApiCallAction -> Maybe Text
api :: Prelude.Maybe Prelude.Text
  }
  deriving (AwsApiCallAction -> AwsApiCallAction -> Bool
(AwsApiCallAction -> AwsApiCallAction -> Bool)
-> (AwsApiCallAction -> AwsApiCallAction -> Bool)
-> Eq AwsApiCallAction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsApiCallAction -> AwsApiCallAction -> Bool
$c/= :: AwsApiCallAction -> AwsApiCallAction -> Bool
== :: AwsApiCallAction -> AwsApiCallAction -> Bool
$c== :: AwsApiCallAction -> AwsApiCallAction -> Bool
Prelude.Eq, ReadPrec [AwsApiCallAction]
ReadPrec AwsApiCallAction
Int -> ReadS AwsApiCallAction
ReadS [AwsApiCallAction]
(Int -> ReadS AwsApiCallAction)
-> ReadS [AwsApiCallAction]
-> ReadPrec AwsApiCallAction
-> ReadPrec [AwsApiCallAction]
-> Read AwsApiCallAction
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsApiCallAction]
$creadListPrec :: ReadPrec [AwsApiCallAction]
readPrec :: ReadPrec AwsApiCallAction
$creadPrec :: ReadPrec AwsApiCallAction
readList :: ReadS [AwsApiCallAction]
$creadList :: ReadS [AwsApiCallAction]
readsPrec :: Int -> ReadS AwsApiCallAction
$creadsPrec :: Int -> ReadS AwsApiCallAction
Prelude.Read, Int -> AwsApiCallAction -> ShowS
[AwsApiCallAction] -> ShowS
AwsApiCallAction -> String
(Int -> AwsApiCallAction -> ShowS)
-> (AwsApiCallAction -> String)
-> ([AwsApiCallAction] -> ShowS)
-> Show AwsApiCallAction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsApiCallAction] -> ShowS
$cshowList :: [AwsApiCallAction] -> ShowS
show :: AwsApiCallAction -> String
$cshow :: AwsApiCallAction -> String
showsPrec :: Int -> AwsApiCallAction -> ShowS
$cshowsPrec :: Int -> AwsApiCallAction -> ShowS
Prelude.Show, (forall x. AwsApiCallAction -> Rep AwsApiCallAction x)
-> (forall x. Rep AwsApiCallAction x -> AwsApiCallAction)
-> Generic AwsApiCallAction
forall x. Rep AwsApiCallAction x -> AwsApiCallAction
forall x. AwsApiCallAction -> Rep AwsApiCallAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AwsApiCallAction x -> AwsApiCallAction
$cfrom :: forall x. AwsApiCallAction -> Rep AwsApiCallAction x
Prelude.Generic)

-- |
-- Create a value of 'AwsApiCallAction' 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:
--
-- 'remoteIpDetails', 'awsApiCallAction_remoteIpDetails' - Provided if @CallerType@ is @remoteIp@. Provides information about the
-- remote IP address that the API call originated from.
--
-- 'firstSeen', 'awsApiCallAction_firstSeen' - An ISO8601-formatted timestamp that indicates when the API call was
-- first observed.
--
-- 'callerType', 'awsApiCallAction_callerType' - Indicates whether the API call originated from a remote IP address
-- (@remoteip@) or from a DNS domain (@domain@).
--
-- 'affectedResources', 'awsApiCallAction_affectedResources' - Identifies the resources that were affected by the API call.
--
-- 'lastSeen', 'awsApiCallAction_lastSeen' - An ISO8601-formatted timestamp that indicates when the API call was most
-- recently observed.
--
-- 'domainDetails', 'awsApiCallAction_domainDetails' - Provided if @CallerType@ is @domain@. Provides information about the DNS
-- domain that the API call originated from.
--
-- 'serviceName', 'awsApiCallAction_serviceName' - The name of the Amazon Web Services service that the API method belongs
-- to.
--
-- 'api', 'awsApiCallAction_api' - The name of the API method that was issued.
newAwsApiCallAction ::
  AwsApiCallAction
newAwsApiCallAction :: AwsApiCallAction
newAwsApiCallAction =
  AwsApiCallAction' :: Maybe ActionRemoteIpDetails
-> Maybe Text
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Maybe Text
-> Maybe AwsApiCallActionDomainDetails
-> Maybe Text
-> Maybe Text
-> AwsApiCallAction
AwsApiCallAction'
    { $sel:remoteIpDetails:AwsApiCallAction' :: Maybe ActionRemoteIpDetails
remoteIpDetails =
        Maybe ActionRemoteIpDetails
forall a. Maybe a
Prelude.Nothing,
      $sel:firstSeen:AwsApiCallAction' :: Maybe Text
firstSeen = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:callerType:AwsApiCallAction' :: Maybe Text
callerType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:affectedResources:AwsApiCallAction' :: Maybe (HashMap Text Text)
affectedResources = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:lastSeen:AwsApiCallAction' :: Maybe Text
lastSeen = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:domainDetails:AwsApiCallAction' :: Maybe AwsApiCallActionDomainDetails
domainDetails = Maybe AwsApiCallActionDomainDetails
forall a. Maybe a
Prelude.Nothing,
      $sel:serviceName:AwsApiCallAction' :: Maybe Text
serviceName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:api:AwsApiCallAction' :: Maybe Text
api = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Provided if @CallerType@ is @remoteIp@. Provides information about the
-- remote IP address that the API call originated from.
awsApiCallAction_remoteIpDetails :: Lens.Lens' AwsApiCallAction (Prelude.Maybe ActionRemoteIpDetails)
awsApiCallAction_remoteIpDetails :: (Maybe ActionRemoteIpDetails -> f (Maybe ActionRemoteIpDetails))
-> AwsApiCallAction -> f AwsApiCallAction
awsApiCallAction_remoteIpDetails = (AwsApiCallAction -> Maybe ActionRemoteIpDetails)
-> (AwsApiCallAction
    -> Maybe ActionRemoteIpDetails -> AwsApiCallAction)
-> Lens
     AwsApiCallAction
     AwsApiCallAction
     (Maybe ActionRemoteIpDetails)
     (Maybe ActionRemoteIpDetails)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsApiCallAction' {Maybe ActionRemoteIpDetails
remoteIpDetails :: Maybe ActionRemoteIpDetails
$sel:remoteIpDetails:AwsApiCallAction' :: AwsApiCallAction -> Maybe ActionRemoteIpDetails
remoteIpDetails} -> Maybe ActionRemoteIpDetails
remoteIpDetails) (\s :: AwsApiCallAction
s@AwsApiCallAction' {} Maybe ActionRemoteIpDetails
a -> AwsApiCallAction
s {$sel:remoteIpDetails:AwsApiCallAction' :: Maybe ActionRemoteIpDetails
remoteIpDetails = Maybe ActionRemoteIpDetails
a} :: AwsApiCallAction)

-- | An ISO8601-formatted timestamp that indicates when the API call was
-- first observed.
awsApiCallAction_firstSeen :: Lens.Lens' AwsApiCallAction (Prelude.Maybe Prelude.Text)
awsApiCallAction_firstSeen :: (Maybe Text -> f (Maybe Text))
-> AwsApiCallAction -> f AwsApiCallAction
awsApiCallAction_firstSeen = (AwsApiCallAction -> Maybe Text)
-> (AwsApiCallAction -> Maybe Text -> AwsApiCallAction)
-> Lens AwsApiCallAction AwsApiCallAction (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsApiCallAction' {Maybe Text
firstSeen :: Maybe Text
$sel:firstSeen:AwsApiCallAction' :: AwsApiCallAction -> Maybe Text
firstSeen} -> Maybe Text
firstSeen) (\s :: AwsApiCallAction
s@AwsApiCallAction' {} Maybe Text
a -> AwsApiCallAction
s {$sel:firstSeen:AwsApiCallAction' :: Maybe Text
firstSeen = Maybe Text
a} :: AwsApiCallAction)

-- | Indicates whether the API call originated from a remote IP address
-- (@remoteip@) or from a DNS domain (@domain@).
awsApiCallAction_callerType :: Lens.Lens' AwsApiCallAction (Prelude.Maybe Prelude.Text)
awsApiCallAction_callerType :: (Maybe Text -> f (Maybe Text))
-> AwsApiCallAction -> f AwsApiCallAction
awsApiCallAction_callerType = (AwsApiCallAction -> Maybe Text)
-> (AwsApiCallAction -> Maybe Text -> AwsApiCallAction)
-> Lens AwsApiCallAction AwsApiCallAction (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsApiCallAction' {Maybe Text
callerType :: Maybe Text
$sel:callerType:AwsApiCallAction' :: AwsApiCallAction -> Maybe Text
callerType} -> Maybe Text
callerType) (\s :: AwsApiCallAction
s@AwsApiCallAction' {} Maybe Text
a -> AwsApiCallAction
s {$sel:callerType:AwsApiCallAction' :: Maybe Text
callerType = Maybe Text
a} :: AwsApiCallAction)

-- | Identifies the resources that were affected by the API call.
awsApiCallAction_affectedResources :: Lens.Lens' AwsApiCallAction (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
awsApiCallAction_affectedResources :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> AwsApiCallAction -> f AwsApiCallAction
awsApiCallAction_affectedResources = (AwsApiCallAction -> Maybe (HashMap Text Text))
-> (AwsApiCallAction
    -> Maybe (HashMap Text Text) -> AwsApiCallAction)
-> Lens
     AwsApiCallAction
     AwsApiCallAction
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsApiCallAction' {Maybe (HashMap Text Text)
affectedResources :: Maybe (HashMap Text Text)
$sel:affectedResources:AwsApiCallAction' :: AwsApiCallAction -> Maybe (HashMap Text Text)
affectedResources} -> Maybe (HashMap Text Text)
affectedResources) (\s :: AwsApiCallAction
s@AwsApiCallAction' {} Maybe (HashMap Text Text)
a -> AwsApiCallAction
s {$sel:affectedResources:AwsApiCallAction' :: Maybe (HashMap Text Text)
affectedResources = Maybe (HashMap Text Text)
a} :: AwsApiCallAction) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> AwsApiCallAction -> f AwsApiCallAction)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> AwsApiCallAction
-> f AwsApiCallAction
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | An ISO8601-formatted timestamp that indicates when the API call was most
-- recently observed.
awsApiCallAction_lastSeen :: Lens.Lens' AwsApiCallAction (Prelude.Maybe Prelude.Text)
awsApiCallAction_lastSeen :: (Maybe Text -> f (Maybe Text))
-> AwsApiCallAction -> f AwsApiCallAction
awsApiCallAction_lastSeen = (AwsApiCallAction -> Maybe Text)
-> (AwsApiCallAction -> Maybe Text -> AwsApiCallAction)
-> Lens AwsApiCallAction AwsApiCallAction (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsApiCallAction' {Maybe Text
lastSeen :: Maybe Text
$sel:lastSeen:AwsApiCallAction' :: AwsApiCallAction -> Maybe Text
lastSeen} -> Maybe Text
lastSeen) (\s :: AwsApiCallAction
s@AwsApiCallAction' {} Maybe Text
a -> AwsApiCallAction
s {$sel:lastSeen:AwsApiCallAction' :: Maybe Text
lastSeen = Maybe Text
a} :: AwsApiCallAction)

-- | Provided if @CallerType@ is @domain@. Provides information about the DNS
-- domain that the API call originated from.
awsApiCallAction_domainDetails :: Lens.Lens' AwsApiCallAction (Prelude.Maybe AwsApiCallActionDomainDetails)
awsApiCallAction_domainDetails :: (Maybe AwsApiCallActionDomainDetails
 -> f (Maybe AwsApiCallActionDomainDetails))
-> AwsApiCallAction -> f AwsApiCallAction
awsApiCallAction_domainDetails = (AwsApiCallAction -> Maybe AwsApiCallActionDomainDetails)
-> (AwsApiCallAction
    -> Maybe AwsApiCallActionDomainDetails -> AwsApiCallAction)
-> Lens
     AwsApiCallAction
     AwsApiCallAction
     (Maybe AwsApiCallActionDomainDetails)
     (Maybe AwsApiCallActionDomainDetails)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsApiCallAction' {Maybe AwsApiCallActionDomainDetails
domainDetails :: Maybe AwsApiCallActionDomainDetails
$sel:domainDetails:AwsApiCallAction' :: AwsApiCallAction -> Maybe AwsApiCallActionDomainDetails
domainDetails} -> Maybe AwsApiCallActionDomainDetails
domainDetails) (\s :: AwsApiCallAction
s@AwsApiCallAction' {} Maybe AwsApiCallActionDomainDetails
a -> AwsApiCallAction
s {$sel:domainDetails:AwsApiCallAction' :: Maybe AwsApiCallActionDomainDetails
domainDetails = Maybe AwsApiCallActionDomainDetails
a} :: AwsApiCallAction)

-- | The name of the Amazon Web Services service that the API method belongs
-- to.
awsApiCallAction_serviceName :: Lens.Lens' AwsApiCallAction (Prelude.Maybe Prelude.Text)
awsApiCallAction_serviceName :: (Maybe Text -> f (Maybe Text))
-> AwsApiCallAction -> f AwsApiCallAction
awsApiCallAction_serviceName = (AwsApiCallAction -> Maybe Text)
-> (AwsApiCallAction -> Maybe Text -> AwsApiCallAction)
-> Lens AwsApiCallAction AwsApiCallAction (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsApiCallAction' {Maybe Text
serviceName :: Maybe Text
$sel:serviceName:AwsApiCallAction' :: AwsApiCallAction -> Maybe Text
serviceName} -> Maybe Text
serviceName) (\s :: AwsApiCallAction
s@AwsApiCallAction' {} Maybe Text
a -> AwsApiCallAction
s {$sel:serviceName:AwsApiCallAction' :: Maybe Text
serviceName = Maybe Text
a} :: AwsApiCallAction)

-- | The name of the API method that was issued.
awsApiCallAction_api :: Lens.Lens' AwsApiCallAction (Prelude.Maybe Prelude.Text)
awsApiCallAction_api :: (Maybe Text -> f (Maybe Text))
-> AwsApiCallAction -> f AwsApiCallAction
awsApiCallAction_api = (AwsApiCallAction -> Maybe Text)
-> (AwsApiCallAction -> Maybe Text -> AwsApiCallAction)
-> Lens AwsApiCallAction AwsApiCallAction (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsApiCallAction' {Maybe Text
api :: Maybe Text
$sel:api:AwsApiCallAction' :: AwsApiCallAction -> Maybe Text
api} -> Maybe Text
api) (\s :: AwsApiCallAction
s@AwsApiCallAction' {} Maybe Text
a -> AwsApiCallAction
s {$sel:api:AwsApiCallAction' :: Maybe Text
api = Maybe Text
a} :: AwsApiCallAction)

instance Core.FromJSON AwsApiCallAction where
  parseJSON :: Value -> Parser AwsApiCallAction
parseJSON =
    String
-> (Object -> Parser AwsApiCallAction)
-> Value
-> Parser AwsApiCallAction
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsApiCallAction"
      ( \Object
x ->
          Maybe ActionRemoteIpDetails
-> Maybe Text
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Maybe Text
-> Maybe AwsApiCallActionDomainDetails
-> Maybe Text
-> Maybe Text
-> AwsApiCallAction
AwsApiCallAction'
            (Maybe ActionRemoteIpDetails
 -> Maybe Text
 -> Maybe Text
 -> Maybe (HashMap Text Text)
 -> Maybe Text
 -> Maybe AwsApiCallActionDomainDetails
 -> Maybe Text
 -> Maybe Text
 -> AwsApiCallAction)
-> Parser (Maybe ActionRemoteIpDetails)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe (HashMap Text Text)
      -> Maybe Text
      -> Maybe AwsApiCallActionDomainDetails
      -> Maybe Text
      -> Maybe Text
      -> AwsApiCallAction)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ActionRemoteIpDetails)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RemoteIpDetails")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe (HashMap Text Text)
   -> Maybe Text
   -> Maybe AwsApiCallActionDomainDetails
   -> Maybe Text
   -> Maybe Text
   -> AwsApiCallAction)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe (HashMap Text Text)
      -> Maybe Text
      -> Maybe AwsApiCallActionDomainDetails
      -> Maybe Text
      -> Maybe Text
      -> AwsApiCallAction)
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
"FirstSeen")
            Parser
  (Maybe Text
   -> Maybe (HashMap Text Text)
   -> Maybe Text
   -> Maybe AwsApiCallActionDomainDetails
   -> Maybe Text
   -> Maybe Text
   -> AwsApiCallAction)
-> Parser (Maybe Text)
-> Parser
     (Maybe (HashMap Text Text)
      -> Maybe Text
      -> Maybe AwsApiCallActionDomainDetails
      -> Maybe Text
      -> Maybe Text
      -> AwsApiCallAction)
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
"CallerType")
            Parser
  (Maybe (HashMap Text Text)
   -> Maybe Text
   -> Maybe AwsApiCallActionDomainDetails
   -> Maybe Text
   -> Maybe Text
   -> AwsApiCallAction)
-> Parser (Maybe (HashMap Text Text))
-> Parser
     (Maybe Text
      -> Maybe AwsApiCallActionDomainDetails
      -> Maybe Text
      -> Maybe Text
      -> AwsApiCallAction)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text Text)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AffectedResources"
                            Parser (Maybe (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> Parser (Maybe (HashMap Text Text))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text Text)
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser
  (Maybe Text
   -> Maybe AwsApiCallActionDomainDetails
   -> Maybe Text
   -> Maybe Text
   -> AwsApiCallAction)
-> Parser (Maybe Text)
-> Parser
     (Maybe AwsApiCallActionDomainDetails
      -> Maybe Text -> Maybe Text -> AwsApiCallAction)
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
"LastSeen")
            Parser
  (Maybe AwsApiCallActionDomainDetails
   -> Maybe Text -> Maybe Text -> AwsApiCallAction)
-> Parser (Maybe AwsApiCallActionDomainDetails)
-> Parser (Maybe Text -> Maybe Text -> AwsApiCallAction)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe AwsApiCallActionDomainDetails)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DomainDetails")
            Parser (Maybe Text -> Maybe Text -> AwsApiCallAction)
-> Parser (Maybe Text) -> Parser (Maybe Text -> AwsApiCallAction)
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
"ServiceName")
            Parser (Maybe Text -> AwsApiCallAction)
-> Parser (Maybe Text) -> Parser AwsApiCallAction
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
"Api")
      )

instance Prelude.Hashable AwsApiCallAction

instance Prelude.NFData AwsApiCallAction

instance Core.ToJSON AwsApiCallAction where
  toJSON :: AwsApiCallAction -> Value
toJSON AwsApiCallAction' {Maybe Text
Maybe (HashMap Text Text)
Maybe AwsApiCallActionDomainDetails
Maybe ActionRemoteIpDetails
api :: Maybe Text
serviceName :: Maybe Text
domainDetails :: Maybe AwsApiCallActionDomainDetails
lastSeen :: Maybe Text
affectedResources :: Maybe (HashMap Text Text)
callerType :: Maybe Text
firstSeen :: Maybe Text
remoteIpDetails :: Maybe ActionRemoteIpDetails
$sel:api:AwsApiCallAction' :: AwsApiCallAction -> Maybe Text
$sel:serviceName:AwsApiCallAction' :: AwsApiCallAction -> Maybe Text
$sel:domainDetails:AwsApiCallAction' :: AwsApiCallAction -> Maybe AwsApiCallActionDomainDetails
$sel:lastSeen:AwsApiCallAction' :: AwsApiCallAction -> Maybe Text
$sel:affectedResources:AwsApiCallAction' :: AwsApiCallAction -> Maybe (HashMap Text Text)
$sel:callerType:AwsApiCallAction' :: AwsApiCallAction -> Maybe Text
$sel:firstSeen:AwsApiCallAction' :: AwsApiCallAction -> Maybe Text
$sel:remoteIpDetails:AwsApiCallAction' :: AwsApiCallAction -> Maybe ActionRemoteIpDetails
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"RemoteIpDetails" Text -> ActionRemoteIpDetails -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ActionRemoteIpDetails -> Pair)
-> Maybe ActionRemoteIpDetails -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ActionRemoteIpDetails
remoteIpDetails,
            (Text
"FirstSeen" 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
firstSeen,
            (Text
"CallerType" 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
callerType,
            (Text
"AffectedResources" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
affectedResources,
            (Text
"LastSeen" 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
lastSeen,
            (Text
"DomainDetails" Text -> AwsApiCallActionDomainDetails -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (AwsApiCallActionDomainDetails -> Pair)
-> Maybe AwsApiCallActionDomainDetails -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AwsApiCallActionDomainDetails
domainDetails,
            (Text
"ServiceName" 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
serviceName,
            (Text
"Api" 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
api
          ]
      )