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

import qualified Amazonka.Core as Core
import Amazonka.GuardDuty.Types.DomainDetails
import Amazonka.GuardDuty.Types.RemoteIpDetails
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about the API action.
--
-- /See:/ 'newAwsApiCallAction' smart constructor.
data AwsApiCallAction = AwsApiCallAction'
  { -- | The remote IP information of the connection that initiated the AWS API
    -- call.
    AwsApiCallAction -> Maybe RemoteIpDetails
remoteIpDetails :: Prelude.Maybe RemoteIpDetails,
    -- | The AWS API caller type.
    AwsApiCallAction -> Maybe Text
callerType :: Prelude.Maybe Prelude.Text,
    -- | The domain information for the AWS API call.
    AwsApiCallAction -> Maybe DomainDetails
domainDetails :: Prelude.Maybe DomainDetails,
    -- | The AWS service name whose API was invoked.
    AwsApiCallAction -> Maybe Text
serviceName :: Prelude.Maybe Prelude.Text,
    -- | The error code of the failed AWS API action.
    AwsApiCallAction -> Maybe Text
errorCode :: Prelude.Maybe Prelude.Text,
    -- | The AWS API name.
    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' - The remote IP information of the connection that initiated the AWS API
-- call.
--
-- 'callerType', 'awsApiCallAction_callerType' - The AWS API caller type.
--
-- 'domainDetails', 'awsApiCallAction_domainDetails' - The domain information for the AWS API call.
--
-- 'serviceName', 'awsApiCallAction_serviceName' - The AWS service name whose API was invoked.
--
-- 'errorCode', 'awsApiCallAction_errorCode' - The error code of the failed AWS API action.
--
-- 'api', 'awsApiCallAction_api' - The AWS API name.
newAwsApiCallAction ::
  AwsApiCallAction
newAwsApiCallAction :: AwsApiCallAction
newAwsApiCallAction =
  AwsApiCallAction' :: Maybe RemoteIpDetails
-> Maybe Text
-> Maybe DomainDetails
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> AwsApiCallAction
AwsApiCallAction'
    { $sel:remoteIpDetails:AwsApiCallAction' :: Maybe RemoteIpDetails
remoteIpDetails =
        Maybe RemoteIpDetails
forall a. Maybe a
Prelude.Nothing,
      $sel:callerType:AwsApiCallAction' :: Maybe Text
callerType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:domainDetails:AwsApiCallAction' :: Maybe DomainDetails
domainDetails = Maybe DomainDetails
forall a. Maybe a
Prelude.Nothing,
      $sel:serviceName:AwsApiCallAction' :: Maybe Text
serviceName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:errorCode:AwsApiCallAction' :: Maybe Text
errorCode = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:api:AwsApiCallAction' :: Maybe Text
api = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The remote IP information of the connection that initiated the AWS API
-- call.
awsApiCallAction_remoteIpDetails :: Lens.Lens' AwsApiCallAction (Prelude.Maybe RemoteIpDetails)
awsApiCallAction_remoteIpDetails :: (Maybe RemoteIpDetails -> f (Maybe RemoteIpDetails))
-> AwsApiCallAction -> f AwsApiCallAction
awsApiCallAction_remoteIpDetails = (AwsApiCallAction -> Maybe RemoteIpDetails)
-> (AwsApiCallAction -> Maybe RemoteIpDetails -> AwsApiCallAction)
-> Lens
     AwsApiCallAction
     AwsApiCallAction
     (Maybe RemoteIpDetails)
     (Maybe RemoteIpDetails)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsApiCallAction' {Maybe RemoteIpDetails
remoteIpDetails :: Maybe RemoteIpDetails
$sel:remoteIpDetails:AwsApiCallAction' :: AwsApiCallAction -> Maybe RemoteIpDetails
remoteIpDetails} -> Maybe RemoteIpDetails
remoteIpDetails) (\s :: AwsApiCallAction
s@AwsApiCallAction' {} Maybe RemoteIpDetails
a -> AwsApiCallAction
s {$sel:remoteIpDetails:AwsApiCallAction' :: Maybe RemoteIpDetails
remoteIpDetails = Maybe RemoteIpDetails
a} :: AwsApiCallAction)

-- | The AWS API caller type.
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)

-- | The domain information for the AWS API call.
awsApiCallAction_domainDetails :: Lens.Lens' AwsApiCallAction (Prelude.Maybe DomainDetails)
awsApiCallAction_domainDetails :: (Maybe DomainDetails -> f (Maybe DomainDetails))
-> AwsApiCallAction -> f AwsApiCallAction
awsApiCallAction_domainDetails = (AwsApiCallAction -> Maybe DomainDetails)
-> (AwsApiCallAction -> Maybe DomainDetails -> AwsApiCallAction)
-> Lens
     AwsApiCallAction
     AwsApiCallAction
     (Maybe DomainDetails)
     (Maybe DomainDetails)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsApiCallAction' {Maybe DomainDetails
domainDetails :: Maybe DomainDetails
$sel:domainDetails:AwsApiCallAction' :: AwsApiCallAction -> Maybe DomainDetails
domainDetails} -> Maybe DomainDetails
domainDetails) (\s :: AwsApiCallAction
s@AwsApiCallAction' {} Maybe DomainDetails
a -> AwsApiCallAction
s {$sel:domainDetails:AwsApiCallAction' :: Maybe DomainDetails
domainDetails = Maybe DomainDetails
a} :: AwsApiCallAction)

-- | The AWS service name whose API was invoked.
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 error code of the failed AWS API action.
awsApiCallAction_errorCode :: Lens.Lens' AwsApiCallAction (Prelude.Maybe Prelude.Text)
awsApiCallAction_errorCode :: (Maybe Text -> f (Maybe Text))
-> AwsApiCallAction -> f AwsApiCallAction
awsApiCallAction_errorCode = (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
errorCode :: Maybe Text
$sel:errorCode:AwsApiCallAction' :: AwsApiCallAction -> Maybe Text
errorCode} -> Maybe Text
errorCode) (\s :: AwsApiCallAction
s@AwsApiCallAction' {} Maybe Text
a -> AwsApiCallAction
s {$sel:errorCode:AwsApiCallAction' :: Maybe Text
errorCode = Maybe Text
a} :: AwsApiCallAction)

-- | The AWS API name.
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 RemoteIpDetails
-> Maybe Text
-> Maybe DomainDetails
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> AwsApiCallAction
AwsApiCallAction'
            (Maybe RemoteIpDetails
 -> Maybe Text
 -> Maybe DomainDetails
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> AwsApiCallAction)
-> Parser (Maybe RemoteIpDetails)
-> Parser
     (Maybe Text
      -> Maybe DomainDetails
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> AwsApiCallAction)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe RemoteIpDetails)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"remoteIpDetails")
            Parser
  (Maybe Text
   -> Maybe DomainDetails
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> AwsApiCallAction)
-> Parser (Maybe Text)
-> Parser
     (Maybe DomainDetails
      -> Maybe Text -> 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 DomainDetails
   -> Maybe Text -> Maybe Text -> Maybe Text -> AwsApiCallAction)
-> Parser (Maybe DomainDetails)
-> Parser
     (Maybe Text -> 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 DomainDetails)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"domainDetails")
            Parser (Maybe Text -> Maybe Text -> Maybe Text -> AwsApiCallAction)
-> Parser (Maybe Text)
-> 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 Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"serviceName")
            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
"errorCode")
            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