{-# 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.Exclusion
-- 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.Exclusion 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 was excluded from an assessment run.
--
-- /See:/ 'newExclusion' smart constructor.
data Exclusion = Exclusion'
  { -- | The system-defined attributes for the exclusion.
    Exclusion -> Maybe [Attribute]
attributes :: Prelude.Maybe [Attribute],
    -- | The ARN that specifies the exclusion.
    Exclusion -> Text
arn :: Prelude.Text,
    -- | The name of the exclusion.
    Exclusion -> Text
title :: Prelude.Text,
    -- | The description of the exclusion.
    Exclusion -> Text
description :: Prelude.Text,
    -- | The recommendation for the exclusion.
    Exclusion -> Text
recommendation :: Prelude.Text,
    -- | The AWS resources for which the exclusion pertains.
    Exclusion -> NonEmpty Scope
scopes :: Prelude.NonEmpty Scope
  }
  deriving (Exclusion -> Exclusion -> Bool
(Exclusion -> Exclusion -> Bool)
-> (Exclusion -> Exclusion -> Bool) -> Eq Exclusion
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Exclusion -> Exclusion -> Bool
$c/= :: Exclusion -> Exclusion -> Bool
== :: Exclusion -> Exclusion -> Bool
$c== :: Exclusion -> Exclusion -> Bool
Prelude.Eq, ReadPrec [Exclusion]
ReadPrec Exclusion
Int -> ReadS Exclusion
ReadS [Exclusion]
(Int -> ReadS Exclusion)
-> ReadS [Exclusion]
-> ReadPrec Exclusion
-> ReadPrec [Exclusion]
-> Read Exclusion
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Exclusion]
$creadListPrec :: ReadPrec [Exclusion]
readPrec :: ReadPrec Exclusion
$creadPrec :: ReadPrec Exclusion
readList :: ReadS [Exclusion]
$creadList :: ReadS [Exclusion]
readsPrec :: Int -> ReadS Exclusion
$creadsPrec :: Int -> ReadS Exclusion
Prelude.Read, Int -> Exclusion -> ShowS
[Exclusion] -> ShowS
Exclusion -> String
(Int -> Exclusion -> ShowS)
-> (Exclusion -> String)
-> ([Exclusion] -> ShowS)
-> Show Exclusion
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Exclusion] -> ShowS
$cshowList :: [Exclusion] -> ShowS
show :: Exclusion -> String
$cshow :: Exclusion -> String
showsPrec :: Int -> Exclusion -> ShowS
$cshowsPrec :: Int -> Exclusion -> ShowS
Prelude.Show, (forall x. Exclusion -> Rep Exclusion x)
-> (forall x. Rep Exclusion x -> Exclusion) -> Generic Exclusion
forall x. Rep Exclusion x -> Exclusion
forall x. Exclusion -> Rep Exclusion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Exclusion x -> Exclusion
$cfrom :: forall x. Exclusion -> Rep Exclusion x
Prelude.Generic)

-- |
-- Create a value of 'Exclusion' 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', 'exclusion_attributes' - The system-defined attributes for the exclusion.
--
-- 'arn', 'exclusion_arn' - The ARN that specifies the exclusion.
--
-- 'title', 'exclusion_title' - The name of the exclusion.
--
-- 'description', 'exclusion_description' - The description of the exclusion.
--
-- 'recommendation', 'exclusion_recommendation' - The recommendation for the exclusion.
--
-- 'scopes', 'exclusion_scopes' - The AWS resources for which the exclusion pertains.
newExclusion ::
  -- | 'arn'
  Prelude.Text ->
  -- | 'title'
  Prelude.Text ->
  -- | 'description'
  Prelude.Text ->
  -- | 'recommendation'
  Prelude.Text ->
  -- | 'scopes'
  Prelude.NonEmpty Scope ->
  Exclusion
newExclusion :: Text -> Text -> Text -> Text -> NonEmpty Scope -> Exclusion
newExclusion
  Text
pArn_
  Text
pTitle_
  Text
pDescription_
  Text
pRecommendation_
  NonEmpty Scope
pScopes_ =
    Exclusion' :: Maybe [Attribute]
-> Text -> Text -> Text -> Text -> NonEmpty Scope -> Exclusion
Exclusion'
      { $sel:attributes:Exclusion' :: Maybe [Attribute]
attributes = Maybe [Attribute]
forall a. Maybe a
Prelude.Nothing,
        $sel:arn:Exclusion' :: Text
arn = Text
pArn_,
        $sel:title:Exclusion' :: Text
title = Text
pTitle_,
        $sel:description:Exclusion' :: Text
description = Text
pDescription_,
        $sel:recommendation:Exclusion' :: Text
recommendation = Text
pRecommendation_,
        $sel:scopes:Exclusion' :: 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.
exclusion_attributes :: Lens.Lens' Exclusion (Prelude.Maybe [Attribute])
exclusion_attributes :: (Maybe [Attribute] -> f (Maybe [Attribute]))
-> Exclusion -> f Exclusion
exclusion_attributes = (Exclusion -> Maybe [Attribute])
-> (Exclusion -> Maybe [Attribute] -> Exclusion)
-> Lens Exclusion Exclusion (Maybe [Attribute]) (Maybe [Attribute])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Exclusion' {Maybe [Attribute]
attributes :: Maybe [Attribute]
$sel:attributes:Exclusion' :: Exclusion -> Maybe [Attribute]
attributes} -> Maybe [Attribute]
attributes) (\s :: Exclusion
s@Exclusion' {} Maybe [Attribute]
a -> Exclusion
s {$sel:attributes:Exclusion' :: Maybe [Attribute]
attributes = Maybe [Attribute]
a} :: Exclusion) ((Maybe [Attribute] -> f (Maybe [Attribute]))
 -> Exclusion -> f Exclusion)
-> ((Maybe [Attribute] -> f (Maybe [Attribute]))
    -> Maybe [Attribute] -> f (Maybe [Attribute]))
-> (Maybe [Attribute] -> f (Maybe [Attribute]))
-> Exclusion
-> f Exclusion
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 ARN that specifies the exclusion.
exclusion_arn :: Lens.Lens' Exclusion Prelude.Text
exclusion_arn :: (Text -> f Text) -> Exclusion -> f Exclusion
exclusion_arn = (Exclusion -> Text)
-> (Exclusion -> Text -> Exclusion)
-> Lens Exclusion Exclusion Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Exclusion' {Text
arn :: Text
$sel:arn:Exclusion' :: Exclusion -> Text
arn} -> Text
arn) (\s :: Exclusion
s@Exclusion' {} Text
a -> Exclusion
s {$sel:arn:Exclusion' :: Text
arn = Text
a} :: Exclusion)

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

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

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

-- | The AWS resources for which the exclusion pertains.
exclusion_scopes :: Lens.Lens' Exclusion (Prelude.NonEmpty Scope)
exclusion_scopes :: (NonEmpty Scope -> f (NonEmpty Scope)) -> Exclusion -> f Exclusion
exclusion_scopes = (Exclusion -> NonEmpty Scope)
-> (Exclusion -> NonEmpty Scope -> Exclusion)
-> Lens Exclusion Exclusion (NonEmpty Scope) (NonEmpty Scope)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Exclusion' {NonEmpty Scope
scopes :: NonEmpty Scope
$sel:scopes:Exclusion' :: Exclusion -> NonEmpty Scope
scopes} -> NonEmpty Scope
scopes) (\s :: Exclusion
s@Exclusion' {} NonEmpty Scope
a -> Exclusion
s {$sel:scopes:Exclusion' :: NonEmpty Scope
scopes = NonEmpty Scope
a} :: Exclusion) ((NonEmpty Scope -> f (NonEmpty Scope))
 -> Exclusion -> f Exclusion)
-> ((NonEmpty Scope -> f (NonEmpty Scope))
    -> NonEmpty Scope -> f (NonEmpty Scope))
-> (NonEmpty Scope -> f (NonEmpty Scope))
-> Exclusion
-> f Exclusion
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 Exclusion where
  parseJSON :: Value -> Parser Exclusion
parseJSON =
    String -> (Object -> Parser Exclusion) -> Value -> Parser Exclusion
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Exclusion"
      ( \Object
x ->
          Maybe [Attribute]
-> Text -> Text -> Text -> Text -> NonEmpty Scope -> Exclusion
Exclusion'
            (Maybe [Attribute]
 -> Text -> Text -> Text -> Text -> NonEmpty Scope -> Exclusion)
-> Parser (Maybe [Attribute])
-> Parser
     (Text -> Text -> Text -> Text -> NonEmpty Scope -> Exclusion)
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 -> Text -> NonEmpty Scope -> Exclusion)
-> Parser Text
-> Parser (Text -> Text -> Text -> NonEmpty Scope -> Exclusion)
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
"arn")
            Parser (Text -> Text -> Text -> NonEmpty Scope -> Exclusion)
-> Parser Text
-> Parser (Text -> Text -> NonEmpty Scope -> Exclusion)
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 -> Exclusion)
-> Parser Text -> Parser (Text -> NonEmpty Scope -> Exclusion)
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 -> Exclusion)
-> Parser Text -> Parser (NonEmpty Scope -> Exclusion)
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 -> Exclusion)
-> Parser (NonEmpty Scope) -> Parser Exclusion
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 Exclusion

instance Prelude.NFData Exclusion