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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SecurityHub.Types.WorkflowStatus

-- | Provides information about the status of the investigation into a
-- finding.
--
-- /See:/ 'newWorkflow' smart constructor.
data Workflow = Workflow'
  { -- | The status of the investigation into the finding. The workflow status is
    -- specific to an individual finding. It does not affect the generation of
    -- new findings. For example, setting the workflow status to @SUPPRESSED@
    -- or @RESOLVED@ does not prevent a new finding for the same issue.
    --
    -- The allowed values are the following.
    --
    -- -   @NEW@ - The initial state of a finding, before it is reviewed.
    --
    --     Security Hub also resets the workflow status from @NOTIFIED@ or
    --     @RESOLVED@ to @NEW@ in the following cases:
    --
    --     -   @RecordState@ changes from @ARCHIVED@ to @ACTIVE@.
    --
    --     -   @ComplianceStatus@ changes from @PASSED@ to either @WARNING@,
    --         @FAILED@, or @NOT_AVAILABLE@.
    --
    -- -   @NOTIFIED@ - Indicates that you notified the resource owner about
    --     the security issue. Used when the initial reviewer is not the
    --     resource owner, and needs intervention from the resource owner.
    --
    -- -   @SUPPRESSED@ - Indicates that you reviewed the finding and do not
    --     believe that any action is needed. The finding is no longer updated.
    --
    -- -   @RESOLVED@ - The finding was reviewed and remediated and is now
    --     considered resolved.
    Workflow -> Maybe WorkflowStatus
status :: Prelude.Maybe WorkflowStatus
  }
  deriving (Workflow -> Workflow -> Bool
(Workflow -> Workflow -> Bool)
-> (Workflow -> Workflow -> Bool) -> Eq Workflow
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Workflow -> Workflow -> Bool
$c/= :: Workflow -> Workflow -> Bool
== :: Workflow -> Workflow -> Bool
$c== :: Workflow -> Workflow -> Bool
Prelude.Eq, ReadPrec [Workflow]
ReadPrec Workflow
Int -> ReadS Workflow
ReadS [Workflow]
(Int -> ReadS Workflow)
-> ReadS [Workflow]
-> ReadPrec Workflow
-> ReadPrec [Workflow]
-> Read Workflow
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Workflow]
$creadListPrec :: ReadPrec [Workflow]
readPrec :: ReadPrec Workflow
$creadPrec :: ReadPrec Workflow
readList :: ReadS [Workflow]
$creadList :: ReadS [Workflow]
readsPrec :: Int -> ReadS Workflow
$creadsPrec :: Int -> ReadS Workflow
Prelude.Read, Int -> Workflow -> ShowS
[Workflow] -> ShowS
Workflow -> String
(Int -> Workflow -> ShowS)
-> (Workflow -> String) -> ([Workflow] -> ShowS) -> Show Workflow
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Workflow] -> ShowS
$cshowList :: [Workflow] -> ShowS
show :: Workflow -> String
$cshow :: Workflow -> String
showsPrec :: Int -> Workflow -> ShowS
$cshowsPrec :: Int -> Workflow -> ShowS
Prelude.Show, (forall x. Workflow -> Rep Workflow x)
-> (forall x. Rep Workflow x -> Workflow) -> Generic Workflow
forall x. Rep Workflow x -> Workflow
forall x. Workflow -> Rep Workflow x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Workflow x -> Workflow
$cfrom :: forall x. Workflow -> Rep Workflow x
Prelude.Generic)

-- |
-- Create a value of 'Workflow' 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:
--
-- 'status', 'workflow_status' - The status of the investigation into the finding. The workflow status is
-- specific to an individual finding. It does not affect the generation of
-- new findings. For example, setting the workflow status to @SUPPRESSED@
-- or @RESOLVED@ does not prevent a new finding for the same issue.
--
-- The allowed values are the following.
--
-- -   @NEW@ - The initial state of a finding, before it is reviewed.
--
--     Security Hub also resets the workflow status from @NOTIFIED@ or
--     @RESOLVED@ to @NEW@ in the following cases:
--
--     -   @RecordState@ changes from @ARCHIVED@ to @ACTIVE@.
--
--     -   @ComplianceStatus@ changes from @PASSED@ to either @WARNING@,
--         @FAILED@, or @NOT_AVAILABLE@.
--
-- -   @NOTIFIED@ - Indicates that you notified the resource owner about
--     the security issue. Used when the initial reviewer is not the
--     resource owner, and needs intervention from the resource owner.
--
-- -   @SUPPRESSED@ - Indicates that you reviewed the finding and do not
--     believe that any action is needed. The finding is no longer updated.
--
-- -   @RESOLVED@ - The finding was reviewed and remediated and is now
--     considered resolved.
newWorkflow ::
  Workflow
newWorkflow :: Workflow
newWorkflow = Workflow' :: Maybe WorkflowStatus -> Workflow
Workflow' {$sel:status:Workflow' :: Maybe WorkflowStatus
status = Maybe WorkflowStatus
forall a. Maybe a
Prelude.Nothing}

-- | The status of the investigation into the finding. The workflow status is
-- specific to an individual finding. It does not affect the generation of
-- new findings. For example, setting the workflow status to @SUPPRESSED@
-- or @RESOLVED@ does not prevent a new finding for the same issue.
--
-- The allowed values are the following.
--
-- -   @NEW@ - The initial state of a finding, before it is reviewed.
--
--     Security Hub also resets the workflow status from @NOTIFIED@ or
--     @RESOLVED@ to @NEW@ in the following cases:
--
--     -   @RecordState@ changes from @ARCHIVED@ to @ACTIVE@.
--
--     -   @ComplianceStatus@ changes from @PASSED@ to either @WARNING@,
--         @FAILED@, or @NOT_AVAILABLE@.
--
-- -   @NOTIFIED@ - Indicates that you notified the resource owner about
--     the security issue. Used when the initial reviewer is not the
--     resource owner, and needs intervention from the resource owner.
--
-- -   @SUPPRESSED@ - Indicates that you reviewed the finding and do not
--     believe that any action is needed. The finding is no longer updated.
--
-- -   @RESOLVED@ - The finding was reviewed and remediated and is now
--     considered resolved.
workflow_status :: Lens.Lens' Workflow (Prelude.Maybe WorkflowStatus)
workflow_status :: (Maybe WorkflowStatus -> f (Maybe WorkflowStatus))
-> Workflow -> f Workflow
workflow_status = (Workflow -> Maybe WorkflowStatus)
-> (Workflow -> Maybe WorkflowStatus -> Workflow)
-> Lens
     Workflow Workflow (Maybe WorkflowStatus) (Maybe WorkflowStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Workflow' {Maybe WorkflowStatus
status :: Maybe WorkflowStatus
$sel:status:Workflow' :: Workflow -> Maybe WorkflowStatus
status} -> Maybe WorkflowStatus
status) (\s :: Workflow
s@Workflow' {} Maybe WorkflowStatus
a -> Workflow
s {$sel:status:Workflow' :: Maybe WorkflowStatus
status = Maybe WorkflowStatus
a} :: Workflow)

instance Core.FromJSON Workflow where
  parseJSON :: Value -> Parser Workflow
parseJSON =
    String -> (Object -> Parser Workflow) -> Value -> Parser Workflow
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Workflow"
      (\Object
x -> Maybe WorkflowStatus -> Workflow
Workflow' (Maybe WorkflowStatus -> Workflow)
-> Parser (Maybe WorkflowStatus) -> Parser Workflow
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe WorkflowStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Status"))

instance Prelude.Hashable Workflow

instance Prelude.NFData Workflow

instance Core.ToJSON Workflow where
  toJSON :: Workflow -> Value
toJSON Workflow' {Maybe WorkflowStatus
status :: Maybe WorkflowStatus
$sel:status:Workflow' :: Workflow -> Maybe WorkflowStatus
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"Status" Text -> WorkflowStatus -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (WorkflowStatus -> Pair) -> Maybe WorkflowStatus -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe WorkflowStatus
status]
      )