{-# 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.IoTAnalytics.Types.DatasetContentDeliveryRule
-- 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.IoTAnalytics.Types.DatasetContentDeliveryRule where

import qualified Amazonka.Core as Core
import Amazonka.IoTAnalytics.Types.DatasetContentDeliveryDestination
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | When dataset contents are created, they are delivered to destination
-- specified here.
--
-- /See:/ 'newDatasetContentDeliveryRule' smart constructor.
data DatasetContentDeliveryRule = DatasetContentDeliveryRule'
  { -- | The name of the dataset content delivery rules entry.
    DatasetContentDeliveryRule -> Maybe Text
entryName :: Prelude.Maybe Prelude.Text,
    -- | The destination to which dataset contents are delivered.
    DatasetContentDeliveryRule -> DatasetContentDeliveryDestination
destination :: DatasetContentDeliveryDestination
  }
  deriving (DatasetContentDeliveryRule -> DatasetContentDeliveryRule -> Bool
(DatasetContentDeliveryRule -> DatasetContentDeliveryRule -> Bool)
-> (DatasetContentDeliveryRule
    -> DatasetContentDeliveryRule -> Bool)
-> Eq DatasetContentDeliveryRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DatasetContentDeliveryRule -> DatasetContentDeliveryRule -> Bool
$c/= :: DatasetContentDeliveryRule -> DatasetContentDeliveryRule -> Bool
== :: DatasetContentDeliveryRule -> DatasetContentDeliveryRule -> Bool
$c== :: DatasetContentDeliveryRule -> DatasetContentDeliveryRule -> Bool
Prelude.Eq, ReadPrec [DatasetContentDeliveryRule]
ReadPrec DatasetContentDeliveryRule
Int -> ReadS DatasetContentDeliveryRule
ReadS [DatasetContentDeliveryRule]
(Int -> ReadS DatasetContentDeliveryRule)
-> ReadS [DatasetContentDeliveryRule]
-> ReadPrec DatasetContentDeliveryRule
-> ReadPrec [DatasetContentDeliveryRule]
-> Read DatasetContentDeliveryRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DatasetContentDeliveryRule]
$creadListPrec :: ReadPrec [DatasetContentDeliveryRule]
readPrec :: ReadPrec DatasetContentDeliveryRule
$creadPrec :: ReadPrec DatasetContentDeliveryRule
readList :: ReadS [DatasetContentDeliveryRule]
$creadList :: ReadS [DatasetContentDeliveryRule]
readsPrec :: Int -> ReadS DatasetContentDeliveryRule
$creadsPrec :: Int -> ReadS DatasetContentDeliveryRule
Prelude.Read, Int -> DatasetContentDeliveryRule -> ShowS
[DatasetContentDeliveryRule] -> ShowS
DatasetContentDeliveryRule -> String
(Int -> DatasetContentDeliveryRule -> ShowS)
-> (DatasetContentDeliveryRule -> String)
-> ([DatasetContentDeliveryRule] -> ShowS)
-> Show DatasetContentDeliveryRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DatasetContentDeliveryRule] -> ShowS
$cshowList :: [DatasetContentDeliveryRule] -> ShowS
show :: DatasetContentDeliveryRule -> String
$cshow :: DatasetContentDeliveryRule -> String
showsPrec :: Int -> DatasetContentDeliveryRule -> ShowS
$cshowsPrec :: Int -> DatasetContentDeliveryRule -> ShowS
Prelude.Show, (forall x.
 DatasetContentDeliveryRule -> Rep DatasetContentDeliveryRule x)
-> (forall x.
    Rep DatasetContentDeliveryRule x -> DatasetContentDeliveryRule)
-> Generic DatasetContentDeliveryRule
forall x.
Rep DatasetContentDeliveryRule x -> DatasetContentDeliveryRule
forall x.
DatasetContentDeliveryRule -> Rep DatasetContentDeliveryRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DatasetContentDeliveryRule x -> DatasetContentDeliveryRule
$cfrom :: forall x.
DatasetContentDeliveryRule -> Rep DatasetContentDeliveryRule x
Prelude.Generic)

-- |
-- Create a value of 'DatasetContentDeliveryRule' 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:
--
-- 'entryName', 'datasetContentDeliveryRule_entryName' - The name of the dataset content delivery rules entry.
--
-- 'destination', 'datasetContentDeliveryRule_destination' - The destination to which dataset contents are delivered.
newDatasetContentDeliveryRule ::
  -- | 'destination'
  DatasetContentDeliveryDestination ->
  DatasetContentDeliveryRule
newDatasetContentDeliveryRule :: DatasetContentDeliveryDestination -> DatasetContentDeliveryRule
newDatasetContentDeliveryRule DatasetContentDeliveryDestination
pDestination_ =
  DatasetContentDeliveryRule' :: Maybe Text
-> DatasetContentDeliveryDestination -> DatasetContentDeliveryRule
DatasetContentDeliveryRule'
    { $sel:entryName:DatasetContentDeliveryRule' :: Maybe Text
entryName =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:destination:DatasetContentDeliveryRule' :: DatasetContentDeliveryDestination
destination = DatasetContentDeliveryDestination
pDestination_
    }

-- | The name of the dataset content delivery rules entry.
datasetContentDeliveryRule_entryName :: Lens.Lens' DatasetContentDeliveryRule (Prelude.Maybe Prelude.Text)
datasetContentDeliveryRule_entryName :: (Maybe Text -> f (Maybe Text))
-> DatasetContentDeliveryRule -> f DatasetContentDeliveryRule
datasetContentDeliveryRule_entryName = (DatasetContentDeliveryRule -> Maybe Text)
-> (DatasetContentDeliveryRule
    -> Maybe Text -> DatasetContentDeliveryRule)
-> Lens
     DatasetContentDeliveryRule
     DatasetContentDeliveryRule
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DatasetContentDeliveryRule' {Maybe Text
entryName :: Maybe Text
$sel:entryName:DatasetContentDeliveryRule' :: DatasetContentDeliveryRule -> Maybe Text
entryName} -> Maybe Text
entryName) (\s :: DatasetContentDeliveryRule
s@DatasetContentDeliveryRule' {} Maybe Text
a -> DatasetContentDeliveryRule
s {$sel:entryName:DatasetContentDeliveryRule' :: Maybe Text
entryName = Maybe Text
a} :: DatasetContentDeliveryRule)

-- | The destination to which dataset contents are delivered.
datasetContentDeliveryRule_destination :: Lens.Lens' DatasetContentDeliveryRule DatasetContentDeliveryDestination
datasetContentDeliveryRule_destination :: (DatasetContentDeliveryDestination
 -> f DatasetContentDeliveryDestination)
-> DatasetContentDeliveryRule -> f DatasetContentDeliveryRule
datasetContentDeliveryRule_destination = (DatasetContentDeliveryRule -> DatasetContentDeliveryDestination)
-> (DatasetContentDeliveryRule
    -> DatasetContentDeliveryDestination -> DatasetContentDeliveryRule)
-> Lens
     DatasetContentDeliveryRule
     DatasetContentDeliveryRule
     DatasetContentDeliveryDestination
     DatasetContentDeliveryDestination
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DatasetContentDeliveryRule' {DatasetContentDeliveryDestination
destination :: DatasetContentDeliveryDestination
$sel:destination:DatasetContentDeliveryRule' :: DatasetContentDeliveryRule -> DatasetContentDeliveryDestination
destination} -> DatasetContentDeliveryDestination
destination) (\s :: DatasetContentDeliveryRule
s@DatasetContentDeliveryRule' {} DatasetContentDeliveryDestination
a -> DatasetContentDeliveryRule
s {$sel:destination:DatasetContentDeliveryRule' :: DatasetContentDeliveryDestination
destination = DatasetContentDeliveryDestination
a} :: DatasetContentDeliveryRule)

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

instance Prelude.Hashable DatasetContentDeliveryRule

instance Prelude.NFData DatasetContentDeliveryRule

instance Core.ToJSON DatasetContentDeliveryRule where
  toJSON :: DatasetContentDeliveryRule -> Value
toJSON DatasetContentDeliveryRule' {Maybe Text
DatasetContentDeliveryDestination
destination :: DatasetContentDeliveryDestination
entryName :: Maybe Text
$sel:destination:DatasetContentDeliveryRule' :: DatasetContentDeliveryRule -> DatasetContentDeliveryDestination
$sel:entryName:DatasetContentDeliveryRule' :: DatasetContentDeliveryRule -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"entryName" 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
entryName,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"destination" Text -> DatasetContentDeliveryDestination -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= DatasetContentDeliveryDestination
destination)
          ]
      )