{-# 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.AuditManager.Types.AssessmentReportsDestination
-- 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.AuditManager.Types.AssessmentReportsDestination where

import Amazonka.AuditManager.Types.AssessmentReportDestinationType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The location in which Audit Manager saves assessment reports for the
-- given assessment.
--
-- /See:/ 'newAssessmentReportsDestination' smart constructor.
data AssessmentReportsDestination = AssessmentReportsDestination'
  { -- | The destination of the assessment report.
    AssessmentReportsDestination -> Maybe Text
destination :: Prelude.Maybe Prelude.Text,
    -- | The destination type, such as Amazon S3.
    AssessmentReportsDestination
-> Maybe AssessmentReportDestinationType
destinationType :: Prelude.Maybe AssessmentReportDestinationType
  }
  deriving (AssessmentReportsDestination
-> AssessmentReportsDestination -> Bool
(AssessmentReportsDestination
 -> AssessmentReportsDestination -> Bool)
-> (AssessmentReportsDestination
    -> AssessmentReportsDestination -> Bool)
-> Eq AssessmentReportsDestination
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssessmentReportsDestination
-> AssessmentReportsDestination -> Bool
$c/= :: AssessmentReportsDestination
-> AssessmentReportsDestination -> Bool
== :: AssessmentReportsDestination
-> AssessmentReportsDestination -> Bool
$c== :: AssessmentReportsDestination
-> AssessmentReportsDestination -> Bool
Prelude.Eq, ReadPrec [AssessmentReportsDestination]
ReadPrec AssessmentReportsDestination
Int -> ReadS AssessmentReportsDestination
ReadS [AssessmentReportsDestination]
(Int -> ReadS AssessmentReportsDestination)
-> ReadS [AssessmentReportsDestination]
-> ReadPrec AssessmentReportsDestination
-> ReadPrec [AssessmentReportsDestination]
-> Read AssessmentReportsDestination
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssessmentReportsDestination]
$creadListPrec :: ReadPrec [AssessmentReportsDestination]
readPrec :: ReadPrec AssessmentReportsDestination
$creadPrec :: ReadPrec AssessmentReportsDestination
readList :: ReadS [AssessmentReportsDestination]
$creadList :: ReadS [AssessmentReportsDestination]
readsPrec :: Int -> ReadS AssessmentReportsDestination
$creadsPrec :: Int -> ReadS AssessmentReportsDestination
Prelude.Read, Int -> AssessmentReportsDestination -> ShowS
[AssessmentReportsDestination] -> ShowS
AssessmentReportsDestination -> String
(Int -> AssessmentReportsDestination -> ShowS)
-> (AssessmentReportsDestination -> String)
-> ([AssessmentReportsDestination] -> ShowS)
-> Show AssessmentReportsDestination
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssessmentReportsDestination] -> ShowS
$cshowList :: [AssessmentReportsDestination] -> ShowS
show :: AssessmentReportsDestination -> String
$cshow :: AssessmentReportsDestination -> String
showsPrec :: Int -> AssessmentReportsDestination -> ShowS
$cshowsPrec :: Int -> AssessmentReportsDestination -> ShowS
Prelude.Show, (forall x.
 AssessmentReportsDestination -> Rep AssessmentReportsDestination x)
-> (forall x.
    Rep AssessmentReportsDestination x -> AssessmentReportsDestination)
-> Generic AssessmentReportsDestination
forall x.
Rep AssessmentReportsDestination x -> AssessmentReportsDestination
forall x.
AssessmentReportsDestination -> Rep AssessmentReportsDestination x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AssessmentReportsDestination x -> AssessmentReportsDestination
$cfrom :: forall x.
AssessmentReportsDestination -> Rep AssessmentReportsDestination x
Prelude.Generic)

-- |
-- Create a value of 'AssessmentReportsDestination' 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:
--
-- 'destination', 'assessmentReportsDestination_destination' - The destination of the assessment report.
--
-- 'destinationType', 'assessmentReportsDestination_destinationType' - The destination type, such as Amazon S3.
newAssessmentReportsDestination ::
  AssessmentReportsDestination
newAssessmentReportsDestination :: AssessmentReportsDestination
newAssessmentReportsDestination =
  AssessmentReportsDestination' :: Maybe Text
-> Maybe AssessmentReportDestinationType
-> AssessmentReportsDestination
AssessmentReportsDestination'
    { $sel:destination:AssessmentReportsDestination' :: Maybe Text
destination =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:destinationType:AssessmentReportsDestination' :: Maybe AssessmentReportDestinationType
destinationType = Maybe AssessmentReportDestinationType
forall a. Maybe a
Prelude.Nothing
    }

-- | The destination of the assessment report.
assessmentReportsDestination_destination :: Lens.Lens' AssessmentReportsDestination (Prelude.Maybe Prelude.Text)
assessmentReportsDestination_destination :: (Maybe Text -> f (Maybe Text))
-> AssessmentReportsDestination -> f AssessmentReportsDestination
assessmentReportsDestination_destination = (AssessmentReportsDestination -> Maybe Text)
-> (AssessmentReportsDestination
    -> Maybe Text -> AssessmentReportsDestination)
-> Lens
     AssessmentReportsDestination
     AssessmentReportsDestination
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssessmentReportsDestination' {Maybe Text
destination :: Maybe Text
$sel:destination:AssessmentReportsDestination' :: AssessmentReportsDestination -> Maybe Text
destination} -> Maybe Text
destination) (\s :: AssessmentReportsDestination
s@AssessmentReportsDestination' {} Maybe Text
a -> AssessmentReportsDestination
s {$sel:destination:AssessmentReportsDestination' :: Maybe Text
destination = Maybe Text
a} :: AssessmentReportsDestination)

-- | The destination type, such as Amazon S3.
assessmentReportsDestination_destinationType :: Lens.Lens' AssessmentReportsDestination (Prelude.Maybe AssessmentReportDestinationType)
assessmentReportsDestination_destinationType :: (Maybe AssessmentReportDestinationType
 -> f (Maybe AssessmentReportDestinationType))
-> AssessmentReportsDestination -> f AssessmentReportsDestination
assessmentReportsDestination_destinationType = (AssessmentReportsDestination
 -> Maybe AssessmentReportDestinationType)
-> (AssessmentReportsDestination
    -> Maybe AssessmentReportDestinationType
    -> AssessmentReportsDestination)
-> Lens
     AssessmentReportsDestination
     AssessmentReportsDestination
     (Maybe AssessmentReportDestinationType)
     (Maybe AssessmentReportDestinationType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssessmentReportsDestination' {Maybe AssessmentReportDestinationType
destinationType :: Maybe AssessmentReportDestinationType
$sel:destinationType:AssessmentReportsDestination' :: AssessmentReportsDestination
-> Maybe AssessmentReportDestinationType
destinationType} -> Maybe AssessmentReportDestinationType
destinationType) (\s :: AssessmentReportsDestination
s@AssessmentReportsDestination' {} Maybe AssessmentReportDestinationType
a -> AssessmentReportsDestination
s {$sel:destinationType:AssessmentReportsDestination' :: Maybe AssessmentReportDestinationType
destinationType = Maybe AssessmentReportDestinationType
a} :: AssessmentReportsDestination)

instance Core.FromJSON AssessmentReportsDestination where
  parseJSON :: Value -> Parser AssessmentReportsDestination
parseJSON =
    String
-> (Object -> Parser AssessmentReportsDestination)
-> Value
-> Parser AssessmentReportsDestination
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AssessmentReportsDestination"
      ( \Object
x ->
          Maybe Text
-> Maybe AssessmentReportDestinationType
-> AssessmentReportsDestination
AssessmentReportsDestination'
            (Maybe Text
 -> Maybe AssessmentReportDestinationType
 -> AssessmentReportsDestination)
-> Parser (Maybe Text)
-> Parser
     (Maybe AssessmentReportDestinationType
      -> AssessmentReportsDestination)
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
"destination")
            Parser
  (Maybe AssessmentReportDestinationType
   -> AssessmentReportsDestination)
-> Parser (Maybe AssessmentReportDestinationType)
-> Parser AssessmentReportsDestination
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe AssessmentReportDestinationType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"destinationType")
      )

instance
  Prelude.Hashable
    AssessmentReportsDestination

instance Prelude.NFData AssessmentReportsDestination

instance Core.ToJSON AssessmentReportsDestination where
  toJSON :: AssessmentReportsDestination -> Value
toJSON AssessmentReportsDestination' {Maybe Text
Maybe AssessmentReportDestinationType
destinationType :: Maybe AssessmentReportDestinationType
destination :: Maybe Text
$sel:destinationType:AssessmentReportsDestination' :: AssessmentReportsDestination
-> Maybe AssessmentReportDestinationType
$sel:destination:AssessmentReportsDestination' :: AssessmentReportsDestination -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"destination" 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
destination,
            (Text
"destinationType" Text -> AssessmentReportDestinationType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (AssessmentReportDestinationType -> Pair)
-> Maybe AssessmentReportDestinationType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AssessmentReportDestinationType
destinationType
          ]
      )