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

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

-- | Specifies an S3 bucket to store data classification results in, and the
-- encryption settings to use when storing results in that bucket.
--
-- /See:/ 'newS3Destination' smart constructor.
data S3Destination = S3Destination'
  { -- | The path prefix to use in the path to the location in the bucket. This
    -- prefix specifies where to store classification results in the bucket.
    S3Destination -> Maybe Text
keyPrefix :: Prelude.Maybe Prelude.Text,
    -- | The name of the bucket.
    S3Destination -> Text
bucketName :: Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the KMS key to use for encryption of
    -- the results. This must be the ARN of an existing, symmetric, customer
    -- managed KMS key that\'s in the same Amazon Web Services Region as the
    -- bucket.
    S3Destination -> Text
kmsKeyArn :: Prelude.Text
  }
  deriving (S3Destination -> S3Destination -> Bool
(S3Destination -> S3Destination -> Bool)
-> (S3Destination -> S3Destination -> Bool) -> Eq S3Destination
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3Destination -> S3Destination -> Bool
$c/= :: S3Destination -> S3Destination -> Bool
== :: S3Destination -> S3Destination -> Bool
$c== :: S3Destination -> S3Destination -> Bool
Prelude.Eq, ReadPrec [S3Destination]
ReadPrec S3Destination
Int -> ReadS S3Destination
ReadS [S3Destination]
(Int -> ReadS S3Destination)
-> ReadS [S3Destination]
-> ReadPrec S3Destination
-> ReadPrec [S3Destination]
-> Read S3Destination
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3Destination]
$creadListPrec :: ReadPrec [S3Destination]
readPrec :: ReadPrec S3Destination
$creadPrec :: ReadPrec S3Destination
readList :: ReadS [S3Destination]
$creadList :: ReadS [S3Destination]
readsPrec :: Int -> ReadS S3Destination
$creadsPrec :: Int -> ReadS S3Destination
Prelude.Read, Int -> S3Destination -> ShowS
[S3Destination] -> ShowS
S3Destination -> String
(Int -> S3Destination -> ShowS)
-> (S3Destination -> String)
-> ([S3Destination] -> ShowS)
-> Show S3Destination
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3Destination] -> ShowS
$cshowList :: [S3Destination] -> ShowS
show :: S3Destination -> String
$cshow :: S3Destination -> String
showsPrec :: Int -> S3Destination -> ShowS
$cshowsPrec :: Int -> S3Destination -> ShowS
Prelude.Show, (forall x. S3Destination -> Rep S3Destination x)
-> (forall x. Rep S3Destination x -> S3Destination)
-> Generic S3Destination
forall x. Rep S3Destination x -> S3Destination
forall x. S3Destination -> Rep S3Destination x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3Destination x -> S3Destination
$cfrom :: forall x. S3Destination -> Rep S3Destination x
Prelude.Generic)

-- |
-- Create a value of 'S3Destination' 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:
--
-- 'keyPrefix', 's3Destination_keyPrefix' - The path prefix to use in the path to the location in the bucket. This
-- prefix specifies where to store classification results in the bucket.
--
-- 'bucketName', 's3Destination_bucketName' - The name of the bucket.
--
-- 'kmsKeyArn', 's3Destination_kmsKeyArn' - The Amazon Resource Name (ARN) of the KMS key to use for encryption of
-- the results. This must be the ARN of an existing, symmetric, customer
-- managed KMS key that\'s in the same Amazon Web Services Region as the
-- bucket.
newS3Destination ::
  -- | 'bucketName'
  Prelude.Text ->
  -- | 'kmsKeyArn'
  Prelude.Text ->
  S3Destination
newS3Destination :: Text -> Text -> S3Destination
newS3Destination Text
pBucketName_ Text
pKmsKeyArn_ =
  S3Destination' :: Maybe Text -> Text -> Text -> S3Destination
S3Destination'
    { $sel:keyPrefix:S3Destination' :: Maybe Text
keyPrefix = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:bucketName:S3Destination' :: Text
bucketName = Text
pBucketName_,
      $sel:kmsKeyArn:S3Destination' :: Text
kmsKeyArn = Text
pKmsKeyArn_
    }

-- | The path prefix to use in the path to the location in the bucket. This
-- prefix specifies where to store classification results in the bucket.
s3Destination_keyPrefix :: Lens.Lens' S3Destination (Prelude.Maybe Prelude.Text)
s3Destination_keyPrefix :: (Maybe Text -> f (Maybe Text)) -> S3Destination -> f S3Destination
s3Destination_keyPrefix = (S3Destination -> Maybe Text)
-> (S3Destination -> Maybe Text -> S3Destination)
-> Lens S3Destination S3Destination (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Destination' {Maybe Text
keyPrefix :: Maybe Text
$sel:keyPrefix:S3Destination' :: S3Destination -> Maybe Text
keyPrefix} -> Maybe Text
keyPrefix) (\s :: S3Destination
s@S3Destination' {} Maybe Text
a -> S3Destination
s {$sel:keyPrefix:S3Destination' :: Maybe Text
keyPrefix = Maybe Text
a} :: S3Destination)

-- | The name of the bucket.
s3Destination_bucketName :: Lens.Lens' S3Destination Prelude.Text
s3Destination_bucketName :: (Text -> f Text) -> S3Destination -> f S3Destination
s3Destination_bucketName = (S3Destination -> Text)
-> (S3Destination -> Text -> S3Destination)
-> Lens S3Destination S3Destination Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Destination' {Text
bucketName :: Text
$sel:bucketName:S3Destination' :: S3Destination -> Text
bucketName} -> Text
bucketName) (\s :: S3Destination
s@S3Destination' {} Text
a -> S3Destination
s {$sel:bucketName:S3Destination' :: Text
bucketName = Text
a} :: S3Destination)

-- | The Amazon Resource Name (ARN) of the KMS key to use for encryption of
-- the results. This must be the ARN of an existing, symmetric, customer
-- managed KMS key that\'s in the same Amazon Web Services Region as the
-- bucket.
s3Destination_kmsKeyArn :: Lens.Lens' S3Destination Prelude.Text
s3Destination_kmsKeyArn :: (Text -> f Text) -> S3Destination -> f S3Destination
s3Destination_kmsKeyArn = (S3Destination -> Text)
-> (S3Destination -> Text -> S3Destination)
-> Lens S3Destination S3Destination Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Destination' {Text
kmsKeyArn :: Text
$sel:kmsKeyArn:S3Destination' :: S3Destination -> Text
kmsKeyArn} -> Text
kmsKeyArn) (\s :: S3Destination
s@S3Destination' {} Text
a -> S3Destination
s {$sel:kmsKeyArn:S3Destination' :: Text
kmsKeyArn = Text
a} :: S3Destination)

instance Core.FromJSON S3Destination where
  parseJSON :: Value -> Parser S3Destination
parseJSON =
    String
-> (Object -> Parser S3Destination)
-> Value
-> Parser S3Destination
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"S3Destination"
      ( \Object
x ->
          Maybe Text -> Text -> Text -> S3Destination
S3Destination'
            (Maybe Text -> Text -> Text -> S3Destination)
-> Parser (Maybe Text) -> Parser (Text -> Text -> S3Destination)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"keyPrefix")
            Parser (Text -> Text -> S3Destination)
-> Parser Text -> Parser (Text -> S3Destination)
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
"bucketName")
            Parser (Text -> S3Destination)
-> Parser Text -> Parser S3Destination
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
"kmsKeyArn")
      )

instance Prelude.Hashable S3Destination

instance Prelude.NFData S3Destination

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