{-# 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.Inspector.Types.ExclusionPreview
-- 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.Inspector.Types.ExclusionPreview where

import qualified Amazonka.Core as Core
import Amazonka.Inspector.Types.Attribute
import Amazonka.Inspector.Types.Scope
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about what is excluded from an assessment run given
-- the current state of the assessment template.
--
-- /See:/ 'newExclusionPreview' smart constructor.
data ExclusionPreview = ExclusionPreview'
  { -- | The system-defined attributes for the exclusion preview.
    ExclusionPreview -> Maybe [Attribute]
attributes :: Prelude.Maybe [Attribute],
    -- | The name of the exclusion preview.
    ExclusionPreview -> Text
title :: Prelude.Text,
    -- | The description of the exclusion preview.
    ExclusionPreview -> Text
description :: Prelude.Text,
    -- | The recommendation for the exclusion preview.
    ExclusionPreview -> Text
recommendation :: Prelude.Text,
    -- | The AWS resources for which the exclusion preview pertains.
    ExclusionPreview -> NonEmpty Scope
scopes :: Prelude.NonEmpty Scope
  }
  deriving (ExclusionPreview -> ExclusionPreview -> Bool
(ExclusionPreview -> ExclusionPreview -> Bool)
-> (ExclusionPreview -> ExclusionPreview -> Bool)
-> Eq ExclusionPreview
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExclusionPreview -> ExclusionPreview -> Bool
$c/= :: ExclusionPreview -> ExclusionPreview -> Bool
== :: ExclusionPreview -> ExclusionPreview -> Bool
$c== :: ExclusionPreview -> ExclusionPreview -> Bool
Prelude.Eq, ReadPrec [ExclusionPreview]
ReadPrec ExclusionPreview
Int -> ReadS ExclusionPreview
ReadS [ExclusionPreview]
(Int -> ReadS ExclusionPreview)
-> ReadS [ExclusionPreview]
-> ReadPrec ExclusionPreview
-> ReadPrec [ExclusionPreview]
-> Read ExclusionPreview
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExclusionPreview]
$creadListPrec :: ReadPrec [ExclusionPreview]
readPrec :: ReadPrec ExclusionPreview
$creadPrec :: ReadPrec ExclusionPreview
readList :: ReadS [ExclusionPreview]
$creadList :: ReadS [ExclusionPreview]
readsPrec :: Int -> ReadS ExclusionPreview
$creadsPrec :: Int -> ReadS ExclusionPreview
Prelude.Read, Int -> ExclusionPreview -> ShowS
[ExclusionPreview] -> ShowS
ExclusionPreview -> String
(Int -> ExclusionPreview -> ShowS)
-> (ExclusionPreview -> String)
-> ([ExclusionPreview] -> ShowS)
-> Show ExclusionPreview
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExclusionPreview] -> ShowS
$cshowList :: [ExclusionPreview] -> ShowS
show :: ExclusionPreview -> String
$cshow :: ExclusionPreview -> String
showsPrec :: Int -> ExclusionPreview -> ShowS
$cshowsPrec :: Int -> ExclusionPreview -> ShowS
Prelude.Show, (forall x. ExclusionPreview -> Rep ExclusionPreview x)
-> (forall x. Rep ExclusionPreview x -> ExclusionPreview)
-> Generic ExclusionPreview
forall x. Rep ExclusionPreview x -> ExclusionPreview
forall x. ExclusionPreview -> Rep ExclusionPreview x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExclusionPreview x -> ExclusionPreview
$cfrom :: forall x. ExclusionPreview -> Rep ExclusionPreview x
Prelude.Generic)

-- |
-- Create a value of 'ExclusionPreview' 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:
--
-- 'attributes', 'exclusionPreview_attributes' - The system-defined attributes for the exclusion preview.
--
-- 'title', 'exclusionPreview_title' - The name of the exclusion preview.
--
-- 'description', 'exclusionPreview_description' - The description of the exclusion preview.
--
-- 'recommendation', 'exclusionPreview_recommendation' - The recommendation for the exclusion preview.
--
-- 'scopes', 'exclusionPreview_scopes' - The AWS resources for which the exclusion preview pertains.
newExclusionPreview ::
  -- | 'title'
  Prelude.Text ->
  -- | 'description'
  Prelude.Text ->
  -- | 'recommendation'
  Prelude.Text ->
  -- | 'scopes'
  Prelude.NonEmpty Scope ->
  ExclusionPreview
newExclusionPreview :: Text -> Text -> Text -> NonEmpty Scope -> ExclusionPreview
newExclusionPreview
  Text
pTitle_
  Text
pDescription_
  Text
pRecommendation_
  NonEmpty Scope
pScopes_ =
    ExclusionPreview' :: Maybe [Attribute]
-> Text -> Text -> Text -> NonEmpty Scope -> ExclusionPreview
ExclusionPreview'
      { $sel:attributes:ExclusionPreview' :: Maybe [Attribute]
attributes = Maybe [Attribute]
forall a. Maybe a
Prelude.Nothing,
        $sel:title:ExclusionPreview' :: Text
title = Text
pTitle_,
        $sel:description:ExclusionPreview' :: Text
description = Text
pDescription_,
        $sel:recommendation:ExclusionPreview' :: Text
recommendation = Text
pRecommendation_,
        $sel:scopes:ExclusionPreview' :: NonEmpty Scope
scopes = Tagged (NonEmpty Scope) (Identity (NonEmpty Scope))
-> Tagged (NonEmpty Scope) (Identity (NonEmpty Scope))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged (NonEmpty Scope) (Identity (NonEmpty Scope))
 -> Tagged (NonEmpty Scope) (Identity (NonEmpty Scope)))
-> NonEmpty Scope -> NonEmpty Scope
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Scope
pScopes_
      }

-- | The system-defined attributes for the exclusion preview.
exclusionPreview_attributes :: Lens.Lens' ExclusionPreview (Prelude.Maybe [Attribute])
exclusionPreview_attributes :: (Maybe [Attribute] -> f (Maybe [Attribute]))
-> ExclusionPreview -> f ExclusionPreview
exclusionPreview_attributes = (ExclusionPreview -> Maybe [Attribute])
-> (ExclusionPreview -> Maybe [Attribute] -> ExclusionPreview)
-> Lens
     ExclusionPreview
     ExclusionPreview
     (Maybe [Attribute])
     (Maybe [Attribute])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExclusionPreview' {Maybe [Attribute]
attributes :: Maybe [Attribute]
$sel:attributes:ExclusionPreview' :: ExclusionPreview -> Maybe [Attribute]
attributes} -> Maybe [Attribute]
attributes) (\s :: ExclusionPreview
s@ExclusionPreview' {} Maybe [Attribute]
a -> ExclusionPreview
s {$sel:attributes:ExclusionPreview' :: Maybe [Attribute]
attributes = Maybe [Attribute]
a} :: ExclusionPreview) ((Maybe [Attribute] -> f (Maybe [Attribute]))
 -> ExclusionPreview -> f ExclusionPreview)
-> ((Maybe [Attribute] -> f (Maybe [Attribute]))
    -> Maybe [Attribute] -> f (Maybe [Attribute]))
-> (Maybe [Attribute] -> f (Maybe [Attribute]))
-> ExclusionPreview
-> f ExclusionPreview
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Attribute] [Attribute] [Attribute] [Attribute]
-> Iso
     (Maybe [Attribute])
     (Maybe [Attribute])
     (Maybe [Attribute])
     (Maybe [Attribute])
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 [Attribute] [Attribute] [Attribute] [Attribute]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the exclusion preview.
exclusionPreview_title :: Lens.Lens' ExclusionPreview Prelude.Text
exclusionPreview_title :: (Text -> f Text) -> ExclusionPreview -> f ExclusionPreview
exclusionPreview_title = (ExclusionPreview -> Text)
-> (ExclusionPreview -> Text -> ExclusionPreview)
-> Lens ExclusionPreview ExclusionPreview Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExclusionPreview' {Text
title :: Text
$sel:title:ExclusionPreview' :: ExclusionPreview -> Text
title} -> Text
title) (\s :: ExclusionPreview
s@ExclusionPreview' {} Text
a -> ExclusionPreview
s {$sel:title:ExclusionPreview' :: Text
title = Text
a} :: ExclusionPreview)

-- | The description of the exclusion preview.
exclusionPreview_description :: Lens.Lens' ExclusionPreview Prelude.Text
exclusionPreview_description :: (Text -> f Text) -> ExclusionPreview -> f ExclusionPreview
exclusionPreview_description = (ExclusionPreview -> Text)
-> (ExclusionPreview -> Text -> ExclusionPreview)
-> Lens ExclusionPreview ExclusionPreview Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExclusionPreview' {Text
description :: Text
$sel:description:ExclusionPreview' :: ExclusionPreview -> Text
description} -> Text
description) (\s :: ExclusionPreview
s@ExclusionPreview' {} Text
a -> ExclusionPreview
s {$sel:description:ExclusionPreview' :: Text
description = Text
a} :: ExclusionPreview)

-- | The recommendation for the exclusion preview.
exclusionPreview_recommendation :: Lens.Lens' ExclusionPreview Prelude.Text
exclusionPreview_recommendation :: (Text -> f Text) -> ExclusionPreview -> f ExclusionPreview
exclusionPreview_recommendation = (ExclusionPreview -> Text)
-> (ExclusionPreview -> Text -> ExclusionPreview)
-> Lens ExclusionPreview ExclusionPreview Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExclusionPreview' {Text
recommendation :: Text
$sel:recommendation:ExclusionPreview' :: ExclusionPreview -> Text
recommendation} -> Text
recommendation) (\s :: ExclusionPreview
s@ExclusionPreview' {} Text
a -> ExclusionPreview
s {$sel:recommendation:ExclusionPreview' :: Text
recommendation = Text
a} :: ExclusionPreview)

-- | The AWS resources for which the exclusion preview pertains.
exclusionPreview_scopes :: Lens.Lens' ExclusionPreview (Prelude.NonEmpty Scope)
exclusionPreview_scopes :: (NonEmpty Scope -> f (NonEmpty Scope))
-> ExclusionPreview -> f ExclusionPreview
exclusionPreview_scopes = (ExclusionPreview -> NonEmpty Scope)
-> (ExclusionPreview -> NonEmpty Scope -> ExclusionPreview)
-> Lens
     ExclusionPreview ExclusionPreview (NonEmpty Scope) (NonEmpty Scope)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExclusionPreview' {NonEmpty Scope
scopes :: NonEmpty Scope
$sel:scopes:ExclusionPreview' :: ExclusionPreview -> NonEmpty Scope
scopes} -> NonEmpty Scope
scopes) (\s :: ExclusionPreview
s@ExclusionPreview' {} NonEmpty Scope
a -> ExclusionPreview
s {$sel:scopes:ExclusionPreview' :: NonEmpty Scope
scopes = NonEmpty Scope
a} :: ExclusionPreview) ((NonEmpty Scope -> f (NonEmpty Scope))
 -> ExclusionPreview -> f ExclusionPreview)
-> ((NonEmpty Scope -> f (NonEmpty Scope))
    -> NonEmpty Scope -> f (NonEmpty Scope))
-> (NonEmpty Scope -> f (NonEmpty Scope))
-> ExclusionPreview
-> f ExclusionPreview
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Scope -> f (NonEmpty Scope))
-> NonEmpty Scope -> f (NonEmpty Scope)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON ExclusionPreview where
  parseJSON :: Value -> Parser ExclusionPreview
parseJSON =
    String
-> (Object -> Parser ExclusionPreview)
-> Value
-> Parser ExclusionPreview
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ExclusionPreview"
      ( \Object
x ->
          Maybe [Attribute]
-> Text -> Text -> Text -> NonEmpty Scope -> ExclusionPreview
ExclusionPreview'
            (Maybe [Attribute]
 -> Text -> Text -> Text -> NonEmpty Scope -> ExclusionPreview)
-> Parser (Maybe [Attribute])
-> Parser
     (Text -> Text -> Text -> NonEmpty Scope -> ExclusionPreview)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Attribute]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"attributes" Parser (Maybe (Maybe [Attribute]))
-> Maybe [Attribute] -> Parser (Maybe [Attribute])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Attribute]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Text -> Text -> Text -> NonEmpty Scope -> ExclusionPreview)
-> Parser Text
-> Parser (Text -> Text -> NonEmpty Scope -> ExclusionPreview)
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
"title")
            Parser (Text -> Text -> NonEmpty Scope -> ExclusionPreview)
-> Parser Text
-> Parser (Text -> NonEmpty Scope -> ExclusionPreview)
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
"description")
            Parser (Text -> NonEmpty Scope -> ExclusionPreview)
-> Parser Text -> Parser (NonEmpty Scope -> ExclusionPreview)
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
"recommendation")
            Parser (NonEmpty Scope -> ExclusionPreview)
-> Parser (NonEmpty Scope) -> Parser ExclusionPreview
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (NonEmpty Scope)
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"scopes")
      )

instance Prelude.Hashable ExclusionPreview

instance Prelude.NFData ExclusionPreview