{-# 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.AccessAnalyzer.Types.AccessPreviewSummary
-- 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.AccessAnalyzer.Types.AccessPreviewSummary where

import Amazonka.AccessAnalyzer.Types.AccessPreviewStatus
import Amazonka.AccessAnalyzer.Types.AccessPreviewStatusReason
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains a summary of information about an access preview.
--
-- /See:/ 'newAccessPreviewSummary' smart constructor.
data AccessPreviewSummary = AccessPreviewSummary'
  { AccessPreviewSummary -> Maybe AccessPreviewStatusReason
statusReason :: Prelude.Maybe AccessPreviewStatusReason,
    -- | The ARN of the analyzer used to generate the access preview.
    AccessPreviewSummary -> Text
analyzerArn :: Prelude.Text,
    -- | The time at which the access preview was created.
    AccessPreviewSummary -> POSIX
createdAt :: Core.POSIX,
    -- | The unique ID for the access preview.
    AccessPreviewSummary -> Text
id :: Prelude.Text,
    -- | The status of the access preview.
    --
    -- -   @Creating@ - The access preview creation is in progress.
    --
    -- -   @Completed@ - The access preview is complete and previews the
    --     findings for external access to the resource.
    --
    -- -   @Failed@ - The access preview creation has failed.
    AccessPreviewSummary -> AccessPreviewStatus
status :: AccessPreviewStatus
  }
  deriving (AccessPreviewSummary -> AccessPreviewSummary -> Bool
(AccessPreviewSummary -> AccessPreviewSummary -> Bool)
-> (AccessPreviewSummary -> AccessPreviewSummary -> Bool)
-> Eq AccessPreviewSummary
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AccessPreviewSummary -> AccessPreviewSummary -> Bool
$c/= :: AccessPreviewSummary -> AccessPreviewSummary -> Bool
== :: AccessPreviewSummary -> AccessPreviewSummary -> Bool
$c== :: AccessPreviewSummary -> AccessPreviewSummary -> Bool
Prelude.Eq, ReadPrec [AccessPreviewSummary]
ReadPrec AccessPreviewSummary
Int -> ReadS AccessPreviewSummary
ReadS [AccessPreviewSummary]
(Int -> ReadS AccessPreviewSummary)
-> ReadS [AccessPreviewSummary]
-> ReadPrec AccessPreviewSummary
-> ReadPrec [AccessPreviewSummary]
-> Read AccessPreviewSummary
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AccessPreviewSummary]
$creadListPrec :: ReadPrec [AccessPreviewSummary]
readPrec :: ReadPrec AccessPreviewSummary
$creadPrec :: ReadPrec AccessPreviewSummary
readList :: ReadS [AccessPreviewSummary]
$creadList :: ReadS [AccessPreviewSummary]
readsPrec :: Int -> ReadS AccessPreviewSummary
$creadsPrec :: Int -> ReadS AccessPreviewSummary
Prelude.Read, Int -> AccessPreviewSummary -> ShowS
[AccessPreviewSummary] -> ShowS
AccessPreviewSummary -> String
(Int -> AccessPreviewSummary -> ShowS)
-> (AccessPreviewSummary -> String)
-> ([AccessPreviewSummary] -> ShowS)
-> Show AccessPreviewSummary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AccessPreviewSummary] -> ShowS
$cshowList :: [AccessPreviewSummary] -> ShowS
show :: AccessPreviewSummary -> String
$cshow :: AccessPreviewSummary -> String
showsPrec :: Int -> AccessPreviewSummary -> ShowS
$cshowsPrec :: Int -> AccessPreviewSummary -> ShowS
Prelude.Show, (forall x. AccessPreviewSummary -> Rep AccessPreviewSummary x)
-> (forall x. Rep AccessPreviewSummary x -> AccessPreviewSummary)
-> Generic AccessPreviewSummary
forall x. Rep AccessPreviewSummary x -> AccessPreviewSummary
forall x. AccessPreviewSummary -> Rep AccessPreviewSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AccessPreviewSummary x -> AccessPreviewSummary
$cfrom :: forall x. AccessPreviewSummary -> Rep AccessPreviewSummary x
Prelude.Generic)

-- |
-- Create a value of 'AccessPreviewSummary' 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:
--
-- 'statusReason', 'accessPreviewSummary_statusReason' - Undocumented member.
--
-- 'analyzerArn', 'accessPreviewSummary_analyzerArn' - The ARN of the analyzer used to generate the access preview.
--
-- 'createdAt', 'accessPreviewSummary_createdAt' - The time at which the access preview was created.
--
-- 'id', 'accessPreviewSummary_id' - The unique ID for the access preview.
--
-- 'status', 'accessPreviewSummary_status' - The status of the access preview.
--
-- -   @Creating@ - The access preview creation is in progress.
--
-- -   @Completed@ - The access preview is complete and previews the
--     findings for external access to the resource.
--
-- -   @Failed@ - The access preview creation has failed.
newAccessPreviewSummary ::
  -- | 'analyzerArn'
  Prelude.Text ->
  -- | 'createdAt'
  Prelude.UTCTime ->
  -- | 'id'
  Prelude.Text ->
  -- | 'status'
  AccessPreviewStatus ->
  AccessPreviewSummary
newAccessPreviewSummary :: Text
-> UTCTime -> Text -> AccessPreviewStatus -> AccessPreviewSummary
newAccessPreviewSummary
  Text
pAnalyzerArn_
  UTCTime
pCreatedAt_
  Text
pId_
  AccessPreviewStatus
pStatus_ =
    AccessPreviewSummary' :: Maybe AccessPreviewStatusReason
-> Text
-> POSIX
-> Text
-> AccessPreviewStatus
-> AccessPreviewSummary
AccessPreviewSummary'
      { $sel:statusReason:AccessPreviewSummary' :: Maybe AccessPreviewStatusReason
statusReason =
          Maybe AccessPreviewStatusReason
forall a. Maybe a
Prelude.Nothing,
        $sel:analyzerArn:AccessPreviewSummary' :: Text
analyzerArn = Text
pAnalyzerArn_,
        $sel:createdAt:AccessPreviewSummary' :: POSIX
createdAt = Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pCreatedAt_,
        $sel:id:AccessPreviewSummary' :: Text
id = Text
pId_,
        $sel:status:AccessPreviewSummary' :: AccessPreviewStatus
status = AccessPreviewStatus
pStatus_
      }

-- | Undocumented member.
accessPreviewSummary_statusReason :: Lens.Lens' AccessPreviewSummary (Prelude.Maybe AccessPreviewStatusReason)
accessPreviewSummary_statusReason :: (Maybe AccessPreviewStatusReason
 -> f (Maybe AccessPreviewStatusReason))
-> AccessPreviewSummary -> f AccessPreviewSummary
accessPreviewSummary_statusReason = (AccessPreviewSummary -> Maybe AccessPreviewStatusReason)
-> (AccessPreviewSummary
    -> Maybe AccessPreviewStatusReason -> AccessPreviewSummary)
-> Lens
     AccessPreviewSummary
     AccessPreviewSummary
     (Maybe AccessPreviewStatusReason)
     (Maybe AccessPreviewStatusReason)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccessPreviewSummary' {Maybe AccessPreviewStatusReason
statusReason :: Maybe AccessPreviewStatusReason
$sel:statusReason:AccessPreviewSummary' :: AccessPreviewSummary -> Maybe AccessPreviewStatusReason
statusReason} -> Maybe AccessPreviewStatusReason
statusReason) (\s :: AccessPreviewSummary
s@AccessPreviewSummary' {} Maybe AccessPreviewStatusReason
a -> AccessPreviewSummary
s {$sel:statusReason:AccessPreviewSummary' :: Maybe AccessPreviewStatusReason
statusReason = Maybe AccessPreviewStatusReason
a} :: AccessPreviewSummary)

-- | The ARN of the analyzer used to generate the access preview.
accessPreviewSummary_analyzerArn :: Lens.Lens' AccessPreviewSummary Prelude.Text
accessPreviewSummary_analyzerArn :: (Text -> f Text) -> AccessPreviewSummary -> f AccessPreviewSummary
accessPreviewSummary_analyzerArn = (AccessPreviewSummary -> Text)
-> (AccessPreviewSummary -> Text -> AccessPreviewSummary)
-> Lens AccessPreviewSummary AccessPreviewSummary Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccessPreviewSummary' {Text
analyzerArn :: Text
$sel:analyzerArn:AccessPreviewSummary' :: AccessPreviewSummary -> Text
analyzerArn} -> Text
analyzerArn) (\s :: AccessPreviewSummary
s@AccessPreviewSummary' {} Text
a -> AccessPreviewSummary
s {$sel:analyzerArn:AccessPreviewSummary' :: Text
analyzerArn = Text
a} :: AccessPreviewSummary)

-- | The time at which the access preview was created.
accessPreviewSummary_createdAt :: Lens.Lens' AccessPreviewSummary Prelude.UTCTime
accessPreviewSummary_createdAt :: (UTCTime -> f UTCTime)
-> AccessPreviewSummary -> f AccessPreviewSummary
accessPreviewSummary_createdAt = (AccessPreviewSummary -> POSIX)
-> (AccessPreviewSummary -> POSIX -> AccessPreviewSummary)
-> Lens AccessPreviewSummary AccessPreviewSummary POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccessPreviewSummary' {POSIX
createdAt :: POSIX
$sel:createdAt:AccessPreviewSummary' :: AccessPreviewSummary -> POSIX
createdAt} -> POSIX
createdAt) (\s :: AccessPreviewSummary
s@AccessPreviewSummary' {} POSIX
a -> AccessPreviewSummary
s {$sel:createdAt:AccessPreviewSummary' :: POSIX
createdAt = POSIX
a} :: AccessPreviewSummary) ((POSIX -> f POSIX)
 -> AccessPreviewSummary -> f AccessPreviewSummary)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> AccessPreviewSummary
-> f AccessPreviewSummary
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The unique ID for the access preview.
accessPreviewSummary_id :: Lens.Lens' AccessPreviewSummary Prelude.Text
accessPreviewSummary_id :: (Text -> f Text) -> AccessPreviewSummary -> f AccessPreviewSummary
accessPreviewSummary_id = (AccessPreviewSummary -> Text)
-> (AccessPreviewSummary -> Text -> AccessPreviewSummary)
-> Lens AccessPreviewSummary AccessPreviewSummary Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccessPreviewSummary' {Text
id :: Text
$sel:id:AccessPreviewSummary' :: AccessPreviewSummary -> Text
id} -> Text
id) (\s :: AccessPreviewSummary
s@AccessPreviewSummary' {} Text
a -> AccessPreviewSummary
s {$sel:id:AccessPreviewSummary' :: Text
id = Text
a} :: AccessPreviewSummary)

-- | The status of the access preview.
--
-- -   @Creating@ - The access preview creation is in progress.
--
-- -   @Completed@ - The access preview is complete and previews the
--     findings for external access to the resource.
--
-- -   @Failed@ - The access preview creation has failed.
accessPreviewSummary_status :: Lens.Lens' AccessPreviewSummary AccessPreviewStatus
accessPreviewSummary_status :: (AccessPreviewStatus -> f AccessPreviewStatus)
-> AccessPreviewSummary -> f AccessPreviewSummary
accessPreviewSummary_status = (AccessPreviewSummary -> AccessPreviewStatus)
-> (AccessPreviewSummary
    -> AccessPreviewStatus -> AccessPreviewSummary)
-> Lens
     AccessPreviewSummary
     AccessPreviewSummary
     AccessPreviewStatus
     AccessPreviewStatus
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccessPreviewSummary' {AccessPreviewStatus
status :: AccessPreviewStatus
$sel:status:AccessPreviewSummary' :: AccessPreviewSummary -> AccessPreviewStatus
status} -> AccessPreviewStatus
status) (\s :: AccessPreviewSummary
s@AccessPreviewSummary' {} AccessPreviewStatus
a -> AccessPreviewSummary
s {$sel:status:AccessPreviewSummary' :: AccessPreviewStatus
status = AccessPreviewStatus
a} :: AccessPreviewSummary)

instance Core.FromJSON AccessPreviewSummary where
  parseJSON :: Value -> Parser AccessPreviewSummary
parseJSON =
    String
-> (Object -> Parser AccessPreviewSummary)
-> Value
-> Parser AccessPreviewSummary
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AccessPreviewSummary"
      ( \Object
x ->
          Maybe AccessPreviewStatusReason
-> Text
-> POSIX
-> Text
-> AccessPreviewStatus
-> AccessPreviewSummary
AccessPreviewSummary'
            (Maybe AccessPreviewStatusReason
 -> Text
 -> POSIX
 -> Text
 -> AccessPreviewStatus
 -> AccessPreviewSummary)
-> Parser (Maybe AccessPreviewStatusReason)
-> Parser
     (Text
      -> POSIX -> Text -> AccessPreviewStatus -> AccessPreviewSummary)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe AccessPreviewStatusReason)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"statusReason")
            Parser
  (Text
   -> POSIX -> Text -> AccessPreviewStatus -> AccessPreviewSummary)
-> Parser Text
-> Parser
     (POSIX -> Text -> AccessPreviewStatus -> AccessPreviewSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"analyzerArn")
            Parser
  (POSIX -> Text -> AccessPreviewStatus -> AccessPreviewSummary)
-> Parser POSIX
-> Parser (Text -> AccessPreviewStatus -> AccessPreviewSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser POSIX
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"createdAt")
            Parser (Text -> AccessPreviewStatus -> AccessPreviewSummary)
-> Parser Text
-> Parser (AccessPreviewStatus -> AccessPreviewSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"id")
            Parser (AccessPreviewStatus -> AccessPreviewSummary)
-> Parser AccessPreviewStatus -> Parser AccessPreviewSummary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser AccessPreviewStatus
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"status")
      )

instance Prelude.Hashable AccessPreviewSummary

instance Prelude.NFData AccessPreviewSummary