{-# 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.Inspector2.Types.AutoEnable
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Inspector2.Types.AutoEnable where

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

-- | Represents which scan types are automatically enabled for new members of
-- your Amazon Inspector organization.
--
-- /See:/ 'newAutoEnable' smart constructor.
data AutoEnable = AutoEnable'
  { -- | Represents whether AWS Lambda scans are automatically enabled for new
    -- members of your Amazon Inspector organization.
    AutoEnable -> Maybe Bool
lambda :: Prelude.Maybe Prelude.Bool,
    -- | Represents whether Amazon EC2 scans are automatically enabled for new
    -- members of your Amazon Inspector organization.
    AutoEnable -> Bool
ec2 :: Prelude.Bool,
    -- | Represents whether Amazon ECR scans are automatically enabled for new
    -- members of your Amazon Inspector organization.
    AutoEnable -> Bool
ecr :: Prelude.Bool
  }
  deriving (AutoEnable -> AutoEnable -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AutoEnable -> AutoEnable -> Bool
$c/= :: AutoEnable -> AutoEnable -> Bool
== :: AutoEnable -> AutoEnable -> Bool
$c== :: AutoEnable -> AutoEnable -> Bool
Prelude.Eq, ReadPrec [AutoEnable]
ReadPrec AutoEnable
Int -> ReadS AutoEnable
ReadS [AutoEnable]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AutoEnable]
$creadListPrec :: ReadPrec [AutoEnable]
readPrec :: ReadPrec AutoEnable
$creadPrec :: ReadPrec AutoEnable
readList :: ReadS [AutoEnable]
$creadList :: ReadS [AutoEnable]
readsPrec :: Int -> ReadS AutoEnable
$creadsPrec :: Int -> ReadS AutoEnable
Prelude.Read, Int -> AutoEnable -> ShowS
[AutoEnable] -> ShowS
AutoEnable -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AutoEnable] -> ShowS
$cshowList :: [AutoEnable] -> ShowS
show :: AutoEnable -> String
$cshow :: AutoEnable -> String
showsPrec :: Int -> AutoEnable -> ShowS
$cshowsPrec :: Int -> AutoEnable -> ShowS
Prelude.Show, forall x. Rep AutoEnable x -> AutoEnable
forall x. AutoEnable -> Rep AutoEnable x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AutoEnable x -> AutoEnable
$cfrom :: forall x. AutoEnable -> Rep AutoEnable x
Prelude.Generic)

-- |
-- Create a value of 'AutoEnable' 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:
--
-- 'lambda', 'autoEnable_lambda' - Represents whether AWS Lambda scans are automatically enabled for new
-- members of your Amazon Inspector organization.
--
-- 'ec2', 'autoEnable_ec2' - Represents whether Amazon EC2 scans are automatically enabled for new
-- members of your Amazon Inspector organization.
--
-- 'ecr', 'autoEnable_ecr' - Represents whether Amazon ECR scans are automatically enabled for new
-- members of your Amazon Inspector organization.
newAutoEnable ::
  -- | 'ec2'
  Prelude.Bool ->
  -- | 'ecr'
  Prelude.Bool ->
  AutoEnable
newAutoEnable :: Bool -> Bool -> AutoEnable
newAutoEnable Bool
pEc2_ Bool
pEcr_ =
  AutoEnable'
    { $sel:lambda:AutoEnable' :: Maybe Bool
lambda = forall a. Maybe a
Prelude.Nothing,
      $sel:ec2:AutoEnable' :: Bool
ec2 = Bool
pEc2_,
      $sel:ecr:AutoEnable' :: Bool
ecr = Bool
pEcr_
    }

-- | Represents whether AWS Lambda scans are automatically enabled for new
-- members of your Amazon Inspector organization.
autoEnable_lambda :: Lens.Lens' AutoEnable (Prelude.Maybe Prelude.Bool)
autoEnable_lambda :: Lens' AutoEnable (Maybe Bool)
autoEnable_lambda = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoEnable' {Maybe Bool
lambda :: Maybe Bool
$sel:lambda:AutoEnable' :: AutoEnable -> Maybe Bool
lambda} -> Maybe Bool
lambda) (\s :: AutoEnable
s@AutoEnable' {} Maybe Bool
a -> AutoEnable
s {$sel:lambda:AutoEnable' :: Maybe Bool
lambda = Maybe Bool
a} :: AutoEnable)

-- | Represents whether Amazon EC2 scans are automatically enabled for new
-- members of your Amazon Inspector organization.
autoEnable_ec2 :: Lens.Lens' AutoEnable Prelude.Bool
autoEnable_ec2 :: Lens' AutoEnable Bool
autoEnable_ec2 = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoEnable' {Bool
ec2 :: Bool
$sel:ec2:AutoEnable' :: AutoEnable -> Bool
ec2} -> Bool
ec2) (\s :: AutoEnable
s@AutoEnable' {} Bool
a -> AutoEnable
s {$sel:ec2:AutoEnable' :: Bool
ec2 = Bool
a} :: AutoEnable)

-- | Represents whether Amazon ECR scans are automatically enabled for new
-- members of your Amazon Inspector organization.
autoEnable_ecr :: Lens.Lens' AutoEnable Prelude.Bool
autoEnable_ecr :: Lens' AutoEnable Bool
autoEnable_ecr = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoEnable' {Bool
ecr :: Bool
$sel:ecr:AutoEnable' :: AutoEnable -> Bool
ecr} -> Bool
ecr) (\s :: AutoEnable
s@AutoEnable' {} Bool
a -> AutoEnable
s {$sel:ecr:AutoEnable' :: Bool
ecr = Bool
a} :: AutoEnable)

instance Data.FromJSON AutoEnable where
  parseJSON :: Value -> Parser AutoEnable
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AutoEnable"
      ( \Object
x ->
          Maybe Bool -> Bool -> Bool -> AutoEnable
AutoEnable'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"lambda")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ec2")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ecr")
      )

instance Prelude.Hashable AutoEnable where
  hashWithSalt :: Int -> AutoEnable -> Int
hashWithSalt Int
_salt AutoEnable' {Bool
Maybe Bool
ecr :: Bool
ec2 :: Bool
lambda :: Maybe Bool
$sel:ecr:AutoEnable' :: AutoEnable -> Bool
$sel:ec2:AutoEnable' :: AutoEnable -> Bool
$sel:lambda:AutoEnable' :: AutoEnable -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
lambda
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Bool
ec2
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Bool
ecr

instance Prelude.NFData AutoEnable where
  rnf :: AutoEnable -> ()
rnf AutoEnable' {Bool
Maybe Bool
ecr :: Bool
ec2 :: Bool
lambda :: Maybe Bool
$sel:ecr:AutoEnable' :: AutoEnable -> Bool
$sel:ec2:AutoEnable' :: AutoEnable -> Bool
$sel:lambda:AutoEnable' :: AutoEnable -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
lambda
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Bool
ec2
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Bool
ecr

instance Data.ToJSON AutoEnable where
  toJSON :: AutoEnable -> Value
toJSON AutoEnable' {Bool
Maybe Bool
ecr :: Bool
ec2 :: Bool
lambda :: Maybe Bool
$sel:ecr:AutoEnable' :: AutoEnable -> Bool
$sel:ec2:AutoEnable' :: AutoEnable -> Bool
$sel:lambda:AutoEnable' :: AutoEnable -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"lambda" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
lambda,
            forall a. a -> Maybe a
Prelude.Just (Key
"ec2" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Bool
ec2),
            forall a. a -> Maybe a
Prelude.Just (Key
"ecr" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Bool
ecr)
          ]
      )