{-# 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.MacieV2.Types.RevealConfiguration
-- 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.MacieV2.Types.RevealConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MacieV2.Types.RevealStatus
import qualified Amazonka.Prelude as Prelude

-- | Specifies the configuration settings for retrieving occurrences of
-- sensitive data reported by findings, and the status of the configuration
-- for an Amazon Macie account. When you enable the configuration for the
-- first time, your request must specify an Key Management Service (KMS)
-- key. Otherwise, an error occurs. Macie uses the specified key to encrypt
-- the sensitive data that you retrieve.
--
-- /See:/ 'newRevealConfiguration' smart constructor.
data RevealConfiguration = RevealConfiguration'
  { -- | The Amazon Resource Name (ARN), ID, or alias of the KMS key to use to
    -- encrypt sensitive data that\'s retrieved. The key must be an existing,
    -- customer managed, symmetric encryption key that\'s in the same Amazon
    -- Web Services Region as the Amazon Macie account.
    --
    -- If this value specifies an alias, it must include the following prefix:
    -- alias\/. If this value specifies a key that\'s owned by another Amazon
    -- Web Services account, it must specify the ARN of the key or the ARN of
    -- the key\'s alias.
    RevealConfiguration -> Maybe Text
kmsKeyId :: Prelude.Maybe Prelude.Text,
    -- | The status of the configuration for the Amazon Macie account. In a
    -- request, valid values are: ENABLED, enable the configuration for the
    -- account; and, DISABLED, disable the configuration for the account. In a
    -- response, possible values are: ENABLED, the configuration is currently
    -- enabled for the account; and, DISABLED, the configuration is currently
    -- disabled for the account.
    RevealConfiguration -> RevealStatus
status :: RevealStatus
  }
  deriving (RevealConfiguration -> RevealConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RevealConfiguration -> RevealConfiguration -> Bool
$c/= :: RevealConfiguration -> RevealConfiguration -> Bool
== :: RevealConfiguration -> RevealConfiguration -> Bool
$c== :: RevealConfiguration -> RevealConfiguration -> Bool
Prelude.Eq, ReadPrec [RevealConfiguration]
ReadPrec RevealConfiguration
Int -> ReadS RevealConfiguration
ReadS [RevealConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RevealConfiguration]
$creadListPrec :: ReadPrec [RevealConfiguration]
readPrec :: ReadPrec RevealConfiguration
$creadPrec :: ReadPrec RevealConfiguration
readList :: ReadS [RevealConfiguration]
$creadList :: ReadS [RevealConfiguration]
readsPrec :: Int -> ReadS RevealConfiguration
$creadsPrec :: Int -> ReadS RevealConfiguration
Prelude.Read, Int -> RevealConfiguration -> ShowS
[RevealConfiguration] -> ShowS
RevealConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RevealConfiguration] -> ShowS
$cshowList :: [RevealConfiguration] -> ShowS
show :: RevealConfiguration -> String
$cshow :: RevealConfiguration -> String
showsPrec :: Int -> RevealConfiguration -> ShowS
$cshowsPrec :: Int -> RevealConfiguration -> ShowS
Prelude.Show, forall x. Rep RevealConfiguration x -> RevealConfiguration
forall x. RevealConfiguration -> Rep RevealConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RevealConfiguration x -> RevealConfiguration
$cfrom :: forall x. RevealConfiguration -> Rep RevealConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'RevealConfiguration' 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:
--
-- 'kmsKeyId', 'revealConfiguration_kmsKeyId' - The Amazon Resource Name (ARN), ID, or alias of the KMS key to use to
-- encrypt sensitive data that\'s retrieved. The key must be an existing,
-- customer managed, symmetric encryption key that\'s in the same Amazon
-- Web Services Region as the Amazon Macie account.
--
-- If this value specifies an alias, it must include the following prefix:
-- alias\/. If this value specifies a key that\'s owned by another Amazon
-- Web Services account, it must specify the ARN of the key or the ARN of
-- the key\'s alias.
--
-- 'status', 'revealConfiguration_status' - The status of the configuration for the Amazon Macie account. In a
-- request, valid values are: ENABLED, enable the configuration for the
-- account; and, DISABLED, disable the configuration for the account. In a
-- response, possible values are: ENABLED, the configuration is currently
-- enabled for the account; and, DISABLED, the configuration is currently
-- disabled for the account.
newRevealConfiguration ::
  -- | 'status'
  RevealStatus ->
  RevealConfiguration
newRevealConfiguration :: RevealStatus -> RevealConfiguration
newRevealConfiguration RevealStatus
pStatus_ =
  RevealConfiguration'
    { $sel:kmsKeyId:RevealConfiguration' :: Maybe Text
kmsKeyId = forall a. Maybe a
Prelude.Nothing,
      $sel:status:RevealConfiguration' :: RevealStatus
status = RevealStatus
pStatus_
    }

-- | The Amazon Resource Name (ARN), ID, or alias of the KMS key to use to
-- encrypt sensitive data that\'s retrieved. The key must be an existing,
-- customer managed, symmetric encryption key that\'s in the same Amazon
-- Web Services Region as the Amazon Macie account.
--
-- If this value specifies an alias, it must include the following prefix:
-- alias\/. If this value specifies a key that\'s owned by another Amazon
-- Web Services account, it must specify the ARN of the key or the ARN of
-- the key\'s alias.
revealConfiguration_kmsKeyId :: Lens.Lens' RevealConfiguration (Prelude.Maybe Prelude.Text)
revealConfiguration_kmsKeyId :: Lens' RevealConfiguration (Maybe Text)
revealConfiguration_kmsKeyId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RevealConfiguration' {Maybe Text
kmsKeyId :: Maybe Text
$sel:kmsKeyId:RevealConfiguration' :: RevealConfiguration -> Maybe Text
kmsKeyId} -> Maybe Text
kmsKeyId) (\s :: RevealConfiguration
s@RevealConfiguration' {} Maybe Text
a -> RevealConfiguration
s {$sel:kmsKeyId:RevealConfiguration' :: Maybe Text
kmsKeyId = Maybe Text
a} :: RevealConfiguration)

-- | The status of the configuration for the Amazon Macie account. In a
-- request, valid values are: ENABLED, enable the configuration for the
-- account; and, DISABLED, disable the configuration for the account. In a
-- response, possible values are: ENABLED, the configuration is currently
-- enabled for the account; and, DISABLED, the configuration is currently
-- disabled for the account.
revealConfiguration_status :: Lens.Lens' RevealConfiguration RevealStatus
revealConfiguration_status :: Lens' RevealConfiguration RevealStatus
revealConfiguration_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RevealConfiguration' {RevealStatus
status :: RevealStatus
$sel:status:RevealConfiguration' :: RevealConfiguration -> RevealStatus
status} -> RevealStatus
status) (\s :: RevealConfiguration
s@RevealConfiguration' {} RevealStatus
a -> RevealConfiguration
s {$sel:status:RevealConfiguration' :: RevealStatus
status = RevealStatus
a} :: RevealConfiguration)

instance Data.FromJSON RevealConfiguration where
  parseJSON :: Value -> Parser RevealConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RevealConfiguration"
      ( \Object
x ->
          Maybe Text -> RevealStatus -> RevealConfiguration
RevealConfiguration'
            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
"kmsKeyId")
            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
"status")
      )

instance Prelude.Hashable RevealConfiguration where
  hashWithSalt :: Int -> RevealConfiguration -> Int
hashWithSalt Int
_salt RevealConfiguration' {Maybe Text
RevealStatus
status :: RevealStatus
kmsKeyId :: Maybe Text
$sel:status:RevealConfiguration' :: RevealConfiguration -> RevealStatus
$sel:kmsKeyId:RevealConfiguration' :: RevealConfiguration -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
kmsKeyId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` RevealStatus
status

instance Prelude.NFData RevealConfiguration where
  rnf :: RevealConfiguration -> ()
rnf RevealConfiguration' {Maybe Text
RevealStatus
status :: RevealStatus
kmsKeyId :: Maybe Text
$sel:status:RevealConfiguration' :: RevealConfiguration -> RevealStatus
$sel:kmsKeyId:RevealConfiguration' :: RevealConfiguration -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
kmsKeyId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf RevealStatus
status

instance Data.ToJSON RevealConfiguration where
  toJSON :: RevealConfiguration -> Value
toJSON RevealConfiguration' {Maybe Text
RevealStatus
status :: RevealStatus
kmsKeyId :: Maybe Text
$sel:status:RevealConfiguration' :: RevealConfiguration -> RevealStatus
$sel:kmsKeyId:RevealConfiguration' :: RevealConfiguration -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"kmsKeyId" 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 Text
kmsKeyId,
            forall a. a -> Maybe a
Prelude.Just (Key
"status" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= RevealStatus
status)
          ]
      )