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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Provides information about an API operation that an entity invoked for
-- an affected resource.
--
-- /See:/ 'newApiCallDetails' smart constructor.
data ApiCallDetails = ApiCallDetails'
  { -- | The first date and time, in UTC and extended ISO 8601 format, when any
    -- operation was invoked and produced the finding.
    ApiCallDetails -> Maybe POSIX
firstSeen :: Prelude.Maybe Core.POSIX,
    -- | The URL of the Amazon Web Service that provides the operation, for
    -- example: s3.amazonaws.com.
    ApiCallDetails -> Maybe Text
apiServiceName :: Prelude.Maybe Prelude.Text,
    -- | The most recent date and time, in UTC and extended ISO 8601 format, when
    -- the specified operation (api) was invoked and produced the finding.
    ApiCallDetails -> Maybe POSIX
lastSeen :: Prelude.Maybe Core.POSIX,
    -- | The name of the operation that was invoked most recently and produced
    -- the finding.
    ApiCallDetails -> Maybe Text
api :: Prelude.Maybe Prelude.Text
  }
  deriving (ApiCallDetails -> ApiCallDetails -> Bool
(ApiCallDetails -> ApiCallDetails -> Bool)
-> (ApiCallDetails -> ApiCallDetails -> Bool) -> Eq ApiCallDetails
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ApiCallDetails -> ApiCallDetails -> Bool
$c/= :: ApiCallDetails -> ApiCallDetails -> Bool
== :: ApiCallDetails -> ApiCallDetails -> Bool
$c== :: ApiCallDetails -> ApiCallDetails -> Bool
Prelude.Eq, ReadPrec [ApiCallDetails]
ReadPrec ApiCallDetails
Int -> ReadS ApiCallDetails
ReadS [ApiCallDetails]
(Int -> ReadS ApiCallDetails)
-> ReadS [ApiCallDetails]
-> ReadPrec ApiCallDetails
-> ReadPrec [ApiCallDetails]
-> Read ApiCallDetails
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ApiCallDetails]
$creadListPrec :: ReadPrec [ApiCallDetails]
readPrec :: ReadPrec ApiCallDetails
$creadPrec :: ReadPrec ApiCallDetails
readList :: ReadS [ApiCallDetails]
$creadList :: ReadS [ApiCallDetails]
readsPrec :: Int -> ReadS ApiCallDetails
$creadsPrec :: Int -> ReadS ApiCallDetails
Prelude.Read, Int -> ApiCallDetails -> ShowS
[ApiCallDetails] -> ShowS
ApiCallDetails -> String
(Int -> ApiCallDetails -> ShowS)
-> (ApiCallDetails -> String)
-> ([ApiCallDetails] -> ShowS)
-> Show ApiCallDetails
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ApiCallDetails] -> ShowS
$cshowList :: [ApiCallDetails] -> ShowS
show :: ApiCallDetails -> String
$cshow :: ApiCallDetails -> String
showsPrec :: Int -> ApiCallDetails -> ShowS
$cshowsPrec :: Int -> ApiCallDetails -> ShowS
Prelude.Show, (forall x. ApiCallDetails -> Rep ApiCallDetails x)
-> (forall x. Rep ApiCallDetails x -> ApiCallDetails)
-> Generic ApiCallDetails
forall x. Rep ApiCallDetails x -> ApiCallDetails
forall x. ApiCallDetails -> Rep ApiCallDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ApiCallDetails x -> ApiCallDetails
$cfrom :: forall x. ApiCallDetails -> Rep ApiCallDetails x
Prelude.Generic)

-- |
-- Create a value of 'ApiCallDetails' 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:
--
-- 'firstSeen', 'apiCallDetails_firstSeen' - The first date and time, in UTC and extended ISO 8601 format, when any
-- operation was invoked and produced the finding.
--
-- 'apiServiceName', 'apiCallDetails_apiServiceName' - The URL of the Amazon Web Service that provides the operation, for
-- example: s3.amazonaws.com.
--
-- 'lastSeen', 'apiCallDetails_lastSeen' - The most recent date and time, in UTC and extended ISO 8601 format, when
-- the specified operation (api) was invoked and produced the finding.
--
-- 'api', 'apiCallDetails_api' - The name of the operation that was invoked most recently and produced
-- the finding.
newApiCallDetails ::
  ApiCallDetails
newApiCallDetails :: ApiCallDetails
newApiCallDetails =
  ApiCallDetails' :: Maybe POSIX
-> Maybe Text -> Maybe POSIX -> Maybe Text -> ApiCallDetails
ApiCallDetails'
    { $sel:firstSeen:ApiCallDetails' :: Maybe POSIX
firstSeen = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:apiServiceName:ApiCallDetails' :: Maybe Text
apiServiceName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:lastSeen:ApiCallDetails' :: Maybe POSIX
lastSeen = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:api:ApiCallDetails' :: Maybe Text
api = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The first date and time, in UTC and extended ISO 8601 format, when any
-- operation was invoked and produced the finding.
apiCallDetails_firstSeen :: Lens.Lens' ApiCallDetails (Prelude.Maybe Prelude.UTCTime)
apiCallDetails_firstSeen :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ApiCallDetails -> f ApiCallDetails
apiCallDetails_firstSeen = (ApiCallDetails -> Maybe POSIX)
-> (ApiCallDetails -> Maybe POSIX -> ApiCallDetails)
-> Lens ApiCallDetails ApiCallDetails (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApiCallDetails' {Maybe POSIX
firstSeen :: Maybe POSIX
$sel:firstSeen:ApiCallDetails' :: ApiCallDetails -> Maybe POSIX
firstSeen} -> Maybe POSIX
firstSeen) (\s :: ApiCallDetails
s@ApiCallDetails' {} Maybe POSIX
a -> ApiCallDetails
s {$sel:firstSeen:ApiCallDetails' :: Maybe POSIX
firstSeen = Maybe POSIX
a} :: ApiCallDetails) ((Maybe POSIX -> f (Maybe POSIX))
 -> ApiCallDetails -> f ApiCallDetails)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ApiCallDetails
-> f ApiCallDetails
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The URL of the Amazon Web Service that provides the operation, for
-- example: s3.amazonaws.com.
apiCallDetails_apiServiceName :: Lens.Lens' ApiCallDetails (Prelude.Maybe Prelude.Text)
apiCallDetails_apiServiceName :: (Maybe Text -> f (Maybe Text))
-> ApiCallDetails -> f ApiCallDetails
apiCallDetails_apiServiceName = (ApiCallDetails -> Maybe Text)
-> (ApiCallDetails -> Maybe Text -> ApiCallDetails)
-> Lens ApiCallDetails ApiCallDetails (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApiCallDetails' {Maybe Text
apiServiceName :: Maybe Text
$sel:apiServiceName:ApiCallDetails' :: ApiCallDetails -> Maybe Text
apiServiceName} -> Maybe Text
apiServiceName) (\s :: ApiCallDetails
s@ApiCallDetails' {} Maybe Text
a -> ApiCallDetails
s {$sel:apiServiceName:ApiCallDetails' :: Maybe Text
apiServiceName = Maybe Text
a} :: ApiCallDetails)

-- | The most recent date and time, in UTC and extended ISO 8601 format, when
-- the specified operation (api) was invoked and produced the finding.
apiCallDetails_lastSeen :: Lens.Lens' ApiCallDetails (Prelude.Maybe Prelude.UTCTime)
apiCallDetails_lastSeen :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ApiCallDetails -> f ApiCallDetails
apiCallDetails_lastSeen = (ApiCallDetails -> Maybe POSIX)
-> (ApiCallDetails -> Maybe POSIX -> ApiCallDetails)
-> Lens ApiCallDetails ApiCallDetails (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApiCallDetails' {Maybe POSIX
lastSeen :: Maybe POSIX
$sel:lastSeen:ApiCallDetails' :: ApiCallDetails -> Maybe POSIX
lastSeen} -> Maybe POSIX
lastSeen) (\s :: ApiCallDetails
s@ApiCallDetails' {} Maybe POSIX
a -> ApiCallDetails
s {$sel:lastSeen:ApiCallDetails' :: Maybe POSIX
lastSeen = Maybe POSIX
a} :: ApiCallDetails) ((Maybe POSIX -> f (Maybe POSIX))
 -> ApiCallDetails -> f ApiCallDetails)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ApiCallDetails
-> f ApiCallDetails
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The name of the operation that was invoked most recently and produced
-- the finding.
apiCallDetails_api :: Lens.Lens' ApiCallDetails (Prelude.Maybe Prelude.Text)
apiCallDetails_api :: (Maybe Text -> f (Maybe Text))
-> ApiCallDetails -> f ApiCallDetails
apiCallDetails_api = (ApiCallDetails -> Maybe Text)
-> (ApiCallDetails -> Maybe Text -> ApiCallDetails)
-> Lens ApiCallDetails ApiCallDetails (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApiCallDetails' {Maybe Text
api :: Maybe Text
$sel:api:ApiCallDetails' :: ApiCallDetails -> Maybe Text
api} -> Maybe Text
api) (\s :: ApiCallDetails
s@ApiCallDetails' {} Maybe Text
a -> ApiCallDetails
s {$sel:api:ApiCallDetails' :: Maybe Text
api = Maybe Text
a} :: ApiCallDetails)

instance Core.FromJSON ApiCallDetails where
  parseJSON :: Value -> Parser ApiCallDetails
parseJSON =
    String
-> (Object -> Parser ApiCallDetails)
-> Value
-> Parser ApiCallDetails
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ApiCallDetails"
      ( \Object
x ->
          Maybe POSIX
-> Maybe Text -> Maybe POSIX -> Maybe Text -> ApiCallDetails
ApiCallDetails'
            (Maybe POSIX
 -> Maybe Text -> Maybe POSIX -> Maybe Text -> ApiCallDetails)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe Text -> Maybe POSIX -> Maybe Text -> ApiCallDetails)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"firstSeen")
            Parser (Maybe Text -> Maybe POSIX -> Maybe Text -> ApiCallDetails)
-> Parser (Maybe Text)
-> Parser (Maybe POSIX -> Maybe Text -> ApiCallDetails)
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
"apiServiceName")
            Parser (Maybe POSIX -> Maybe Text -> ApiCallDetails)
-> Parser (Maybe POSIX) -> Parser (Maybe Text -> ApiCallDetails)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"lastSeen")
            Parser (Maybe Text -> ApiCallDetails)
-> Parser (Maybe Text) -> Parser ApiCallDetails
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 ApiCallDetails

instance Prelude.NFData ApiCallDetails