{-# 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.GuardDuty.Types.DestinationProperties
-- 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.GuardDuty.Types.DestinationProperties 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

-- | Contains the Amazon Resource Name (ARN) of the resource to publish to,
-- such as an S3 bucket, and the ARN of the KMS key to use to encrypt
-- published findings.
--
-- /See:/ 'newDestinationProperties' smart constructor.
data DestinationProperties = DestinationProperties'
  { -- | The ARN of the resource to publish to.
    --
    -- To specify an S3 bucket folder use the following format:
    -- @arn:aws:s3:::DOC-EXAMPLE-BUCKET\/myFolder\/@
    DestinationProperties -> Maybe Text
destinationArn :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the KMS key to use for encryption.
    DestinationProperties -> Maybe Text
kmsKeyArn :: Prelude.Maybe Prelude.Text
  }
  deriving (DestinationProperties -> DestinationProperties -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DestinationProperties -> DestinationProperties -> Bool
$c/= :: DestinationProperties -> DestinationProperties -> Bool
== :: DestinationProperties -> DestinationProperties -> Bool
$c== :: DestinationProperties -> DestinationProperties -> Bool
Prelude.Eq, ReadPrec [DestinationProperties]
ReadPrec DestinationProperties
Int -> ReadS DestinationProperties
ReadS [DestinationProperties]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DestinationProperties]
$creadListPrec :: ReadPrec [DestinationProperties]
readPrec :: ReadPrec DestinationProperties
$creadPrec :: ReadPrec DestinationProperties
readList :: ReadS [DestinationProperties]
$creadList :: ReadS [DestinationProperties]
readsPrec :: Int -> ReadS DestinationProperties
$creadsPrec :: Int -> ReadS DestinationProperties
Prelude.Read, Int -> DestinationProperties -> ShowS
[DestinationProperties] -> ShowS
DestinationProperties -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DestinationProperties] -> ShowS
$cshowList :: [DestinationProperties] -> ShowS
show :: DestinationProperties -> String
$cshow :: DestinationProperties -> String
showsPrec :: Int -> DestinationProperties -> ShowS
$cshowsPrec :: Int -> DestinationProperties -> ShowS
Prelude.Show, forall x. Rep DestinationProperties x -> DestinationProperties
forall x. DestinationProperties -> Rep DestinationProperties x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DestinationProperties x -> DestinationProperties
$cfrom :: forall x. DestinationProperties -> Rep DestinationProperties x
Prelude.Generic)

-- |
-- Create a value of 'DestinationProperties' 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:
--
-- 'destinationArn', 'destinationProperties_destinationArn' - The ARN of the resource to publish to.
--
-- To specify an S3 bucket folder use the following format:
-- @arn:aws:s3:::DOC-EXAMPLE-BUCKET\/myFolder\/@
--
-- 'kmsKeyArn', 'destinationProperties_kmsKeyArn' - The ARN of the KMS key to use for encryption.
newDestinationProperties ::
  DestinationProperties
newDestinationProperties :: DestinationProperties
newDestinationProperties =
  DestinationProperties'
    { $sel:destinationArn:DestinationProperties' :: Maybe Text
destinationArn =
        forall a. Maybe a
Prelude.Nothing,
      $sel:kmsKeyArn:DestinationProperties' :: Maybe Text
kmsKeyArn = forall a. Maybe a
Prelude.Nothing
    }

-- | The ARN of the resource to publish to.
--
-- To specify an S3 bucket folder use the following format:
-- @arn:aws:s3:::DOC-EXAMPLE-BUCKET\/myFolder\/@
destinationProperties_destinationArn :: Lens.Lens' DestinationProperties (Prelude.Maybe Prelude.Text)
destinationProperties_destinationArn :: Lens' DestinationProperties (Maybe Text)
destinationProperties_destinationArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DestinationProperties' {Maybe Text
destinationArn :: Maybe Text
$sel:destinationArn:DestinationProperties' :: DestinationProperties -> Maybe Text
destinationArn} -> Maybe Text
destinationArn) (\s :: DestinationProperties
s@DestinationProperties' {} Maybe Text
a -> DestinationProperties
s {$sel:destinationArn:DestinationProperties' :: Maybe Text
destinationArn = Maybe Text
a} :: DestinationProperties)

-- | The ARN of the KMS key to use for encryption.
destinationProperties_kmsKeyArn :: Lens.Lens' DestinationProperties (Prelude.Maybe Prelude.Text)
destinationProperties_kmsKeyArn :: Lens' DestinationProperties (Maybe Text)
destinationProperties_kmsKeyArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DestinationProperties' {Maybe Text
kmsKeyArn :: Maybe Text
$sel:kmsKeyArn:DestinationProperties' :: DestinationProperties -> Maybe Text
kmsKeyArn} -> Maybe Text
kmsKeyArn) (\s :: DestinationProperties
s@DestinationProperties' {} Maybe Text
a -> DestinationProperties
s {$sel:kmsKeyArn:DestinationProperties' :: Maybe Text
kmsKeyArn = Maybe Text
a} :: DestinationProperties)

instance Data.FromJSON DestinationProperties where
  parseJSON :: Value -> Parser DestinationProperties
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DestinationProperties"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> DestinationProperties
DestinationProperties'
            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
"destinationArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"kmsKeyArn")
      )

instance Prelude.Hashable DestinationProperties where
  hashWithSalt :: Int -> DestinationProperties -> Int
hashWithSalt Int
_salt DestinationProperties' {Maybe Text
kmsKeyArn :: Maybe Text
destinationArn :: Maybe Text
$sel:kmsKeyArn:DestinationProperties' :: DestinationProperties -> Maybe Text
$sel:destinationArn:DestinationProperties' :: DestinationProperties -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
destinationArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
kmsKeyArn

instance Prelude.NFData DestinationProperties where
  rnf :: DestinationProperties -> ()
rnf DestinationProperties' {Maybe Text
kmsKeyArn :: Maybe Text
destinationArn :: Maybe Text
$sel:kmsKeyArn:DestinationProperties' :: DestinationProperties -> Maybe Text
$sel:destinationArn:DestinationProperties' :: DestinationProperties -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
destinationArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
kmsKeyArn

instance Data.ToJSON DestinationProperties where
  toJSON :: DestinationProperties -> Value
toJSON DestinationProperties' {Maybe Text
kmsKeyArn :: Maybe Text
destinationArn :: Maybe Text
$sel:kmsKeyArn:DestinationProperties' :: DestinationProperties -> Maybe Text
$sel:destinationArn:DestinationProperties' :: DestinationProperties -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"destinationArn" 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
destinationArn,
            (Key
"kmsKeyArn" 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
kmsKeyArn
          ]
      )