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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 KMS key to use for encryption.
    DestinationProperties -> Maybe Text
kmsKeyArn :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the resource to publish to.
    DestinationProperties -> Maybe Text
destinationArn :: Prelude.Maybe Prelude.Text
  }
  deriving (DestinationProperties -> DestinationProperties -> Bool
(DestinationProperties -> DestinationProperties -> Bool)
-> (DestinationProperties -> DestinationProperties -> Bool)
-> Eq DestinationProperties
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]
(Int -> ReadS DestinationProperties)
-> ReadS [DestinationProperties]
-> ReadPrec DestinationProperties
-> ReadPrec [DestinationProperties]
-> Read 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
(Int -> DestinationProperties -> ShowS)
-> (DestinationProperties -> String)
-> ([DestinationProperties] -> ShowS)
-> Show DestinationProperties
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. DestinationProperties -> Rep DestinationProperties x)
-> (forall x. Rep DestinationProperties x -> DestinationProperties)
-> Generic DestinationProperties
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:
--
-- 'kmsKeyArn', 'destinationProperties_kmsKeyArn' - The ARN of the KMS key to use for encryption.
--
-- 'destinationArn', 'destinationProperties_destinationArn' - The ARN of the resource to publish to.
newDestinationProperties ::
  DestinationProperties
newDestinationProperties :: DestinationProperties
newDestinationProperties =
  DestinationProperties' :: Maybe Text -> Maybe Text -> DestinationProperties
DestinationProperties'
    { $sel:kmsKeyArn:DestinationProperties' :: Maybe Text
kmsKeyArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:destinationArn:DestinationProperties' :: Maybe Text
destinationArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The ARN of the KMS key to use for encryption.
destinationProperties_kmsKeyArn :: Lens.Lens' DestinationProperties (Prelude.Maybe Prelude.Text)
destinationProperties_kmsKeyArn :: (Maybe Text -> f (Maybe Text))
-> DestinationProperties -> f DestinationProperties
destinationProperties_kmsKeyArn = (DestinationProperties -> Maybe Text)
-> (DestinationProperties -> Maybe Text -> DestinationProperties)
-> Lens
     DestinationProperties
     DestinationProperties
     (Maybe Text)
     (Maybe Text)
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)

-- | The ARN of the resource to publish to.
destinationProperties_destinationArn :: Lens.Lens' DestinationProperties (Prelude.Maybe Prelude.Text)
destinationProperties_destinationArn :: (Maybe Text -> f (Maybe Text))
-> DestinationProperties -> f DestinationProperties
destinationProperties_destinationArn = (DestinationProperties -> Maybe Text)
-> (DestinationProperties -> Maybe Text -> DestinationProperties)
-> Lens
     DestinationProperties
     DestinationProperties
     (Maybe Text)
     (Maybe Text)
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)

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

instance Prelude.Hashable DestinationProperties

instance Prelude.NFData DestinationProperties

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