{-# 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.IoT.Types.TopicRuleDestinationConfiguration
-- 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.IoT.Types.TopicRuleDestinationConfiguration where

import qualified Amazonka.Core as Core
import Amazonka.IoT.Types.HttpUrlDestinationConfiguration
import Amazonka.IoT.Types.VpcDestinationConfiguration
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Configuration of the topic rule destination.
--
-- /See:/ 'newTopicRuleDestinationConfiguration' smart constructor.
data TopicRuleDestinationConfiguration = TopicRuleDestinationConfiguration'
  { -- | Configuration of the virtual private cloud (VPC) connection.
    TopicRuleDestinationConfiguration
-> Maybe VpcDestinationConfiguration
vpcConfiguration :: Prelude.Maybe VpcDestinationConfiguration,
    -- | Configuration of the HTTP URL.
    TopicRuleDestinationConfiguration
-> Maybe HttpUrlDestinationConfiguration
httpUrlConfiguration :: Prelude.Maybe HttpUrlDestinationConfiguration
  }
  deriving (TopicRuleDestinationConfiguration
-> TopicRuleDestinationConfiguration -> Bool
(TopicRuleDestinationConfiguration
 -> TopicRuleDestinationConfiguration -> Bool)
-> (TopicRuleDestinationConfiguration
    -> TopicRuleDestinationConfiguration -> Bool)
-> Eq TopicRuleDestinationConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TopicRuleDestinationConfiguration
-> TopicRuleDestinationConfiguration -> Bool
$c/= :: TopicRuleDestinationConfiguration
-> TopicRuleDestinationConfiguration -> Bool
== :: TopicRuleDestinationConfiguration
-> TopicRuleDestinationConfiguration -> Bool
$c== :: TopicRuleDestinationConfiguration
-> TopicRuleDestinationConfiguration -> Bool
Prelude.Eq, ReadPrec [TopicRuleDestinationConfiguration]
ReadPrec TopicRuleDestinationConfiguration
Int -> ReadS TopicRuleDestinationConfiguration
ReadS [TopicRuleDestinationConfiguration]
(Int -> ReadS TopicRuleDestinationConfiguration)
-> ReadS [TopicRuleDestinationConfiguration]
-> ReadPrec TopicRuleDestinationConfiguration
-> ReadPrec [TopicRuleDestinationConfiguration]
-> Read TopicRuleDestinationConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TopicRuleDestinationConfiguration]
$creadListPrec :: ReadPrec [TopicRuleDestinationConfiguration]
readPrec :: ReadPrec TopicRuleDestinationConfiguration
$creadPrec :: ReadPrec TopicRuleDestinationConfiguration
readList :: ReadS [TopicRuleDestinationConfiguration]
$creadList :: ReadS [TopicRuleDestinationConfiguration]
readsPrec :: Int -> ReadS TopicRuleDestinationConfiguration
$creadsPrec :: Int -> ReadS TopicRuleDestinationConfiguration
Prelude.Read, Int -> TopicRuleDestinationConfiguration -> ShowS
[TopicRuleDestinationConfiguration] -> ShowS
TopicRuleDestinationConfiguration -> String
(Int -> TopicRuleDestinationConfiguration -> ShowS)
-> (TopicRuleDestinationConfiguration -> String)
-> ([TopicRuleDestinationConfiguration] -> ShowS)
-> Show TopicRuleDestinationConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TopicRuleDestinationConfiguration] -> ShowS
$cshowList :: [TopicRuleDestinationConfiguration] -> ShowS
show :: TopicRuleDestinationConfiguration -> String
$cshow :: TopicRuleDestinationConfiguration -> String
showsPrec :: Int -> TopicRuleDestinationConfiguration -> ShowS
$cshowsPrec :: Int -> TopicRuleDestinationConfiguration -> ShowS
Prelude.Show, (forall x.
 TopicRuleDestinationConfiguration
 -> Rep TopicRuleDestinationConfiguration x)
-> (forall x.
    Rep TopicRuleDestinationConfiguration x
    -> TopicRuleDestinationConfiguration)
-> Generic TopicRuleDestinationConfiguration
forall x.
Rep TopicRuleDestinationConfiguration x
-> TopicRuleDestinationConfiguration
forall x.
TopicRuleDestinationConfiguration
-> Rep TopicRuleDestinationConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep TopicRuleDestinationConfiguration x
-> TopicRuleDestinationConfiguration
$cfrom :: forall x.
TopicRuleDestinationConfiguration
-> Rep TopicRuleDestinationConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'TopicRuleDestinationConfiguration' 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:
--
-- 'vpcConfiguration', 'topicRuleDestinationConfiguration_vpcConfiguration' - Configuration of the virtual private cloud (VPC) connection.
--
-- 'httpUrlConfiguration', 'topicRuleDestinationConfiguration_httpUrlConfiguration' - Configuration of the HTTP URL.
newTopicRuleDestinationConfiguration ::
  TopicRuleDestinationConfiguration
newTopicRuleDestinationConfiguration :: TopicRuleDestinationConfiguration
newTopicRuleDestinationConfiguration =
  TopicRuleDestinationConfiguration' :: Maybe VpcDestinationConfiguration
-> Maybe HttpUrlDestinationConfiguration
-> TopicRuleDestinationConfiguration
TopicRuleDestinationConfiguration'
    { $sel:vpcConfiguration:TopicRuleDestinationConfiguration' :: Maybe VpcDestinationConfiguration
vpcConfiguration =
        Maybe VpcDestinationConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:httpUrlConfiguration:TopicRuleDestinationConfiguration' :: Maybe HttpUrlDestinationConfiguration
httpUrlConfiguration = Maybe HttpUrlDestinationConfiguration
forall a. Maybe a
Prelude.Nothing
    }

-- | Configuration of the virtual private cloud (VPC) connection.
topicRuleDestinationConfiguration_vpcConfiguration :: Lens.Lens' TopicRuleDestinationConfiguration (Prelude.Maybe VpcDestinationConfiguration)
topicRuleDestinationConfiguration_vpcConfiguration :: (Maybe VpcDestinationConfiguration
 -> f (Maybe VpcDestinationConfiguration))
-> TopicRuleDestinationConfiguration
-> f TopicRuleDestinationConfiguration
topicRuleDestinationConfiguration_vpcConfiguration = (TopicRuleDestinationConfiguration
 -> Maybe VpcDestinationConfiguration)
-> (TopicRuleDestinationConfiguration
    -> Maybe VpcDestinationConfiguration
    -> TopicRuleDestinationConfiguration)
-> Lens
     TopicRuleDestinationConfiguration
     TopicRuleDestinationConfiguration
     (Maybe VpcDestinationConfiguration)
     (Maybe VpcDestinationConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TopicRuleDestinationConfiguration' {Maybe VpcDestinationConfiguration
vpcConfiguration :: Maybe VpcDestinationConfiguration
$sel:vpcConfiguration:TopicRuleDestinationConfiguration' :: TopicRuleDestinationConfiguration
-> Maybe VpcDestinationConfiguration
vpcConfiguration} -> Maybe VpcDestinationConfiguration
vpcConfiguration) (\s :: TopicRuleDestinationConfiguration
s@TopicRuleDestinationConfiguration' {} Maybe VpcDestinationConfiguration
a -> TopicRuleDestinationConfiguration
s {$sel:vpcConfiguration:TopicRuleDestinationConfiguration' :: Maybe VpcDestinationConfiguration
vpcConfiguration = Maybe VpcDestinationConfiguration
a} :: TopicRuleDestinationConfiguration)

-- | Configuration of the HTTP URL.
topicRuleDestinationConfiguration_httpUrlConfiguration :: Lens.Lens' TopicRuleDestinationConfiguration (Prelude.Maybe HttpUrlDestinationConfiguration)
topicRuleDestinationConfiguration_httpUrlConfiguration :: (Maybe HttpUrlDestinationConfiguration
 -> f (Maybe HttpUrlDestinationConfiguration))
-> TopicRuleDestinationConfiguration
-> f TopicRuleDestinationConfiguration
topicRuleDestinationConfiguration_httpUrlConfiguration = (TopicRuleDestinationConfiguration
 -> Maybe HttpUrlDestinationConfiguration)
-> (TopicRuleDestinationConfiguration
    -> Maybe HttpUrlDestinationConfiguration
    -> TopicRuleDestinationConfiguration)
-> Lens
     TopicRuleDestinationConfiguration
     TopicRuleDestinationConfiguration
     (Maybe HttpUrlDestinationConfiguration)
     (Maybe HttpUrlDestinationConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TopicRuleDestinationConfiguration' {Maybe HttpUrlDestinationConfiguration
httpUrlConfiguration :: Maybe HttpUrlDestinationConfiguration
$sel:httpUrlConfiguration:TopicRuleDestinationConfiguration' :: TopicRuleDestinationConfiguration
-> Maybe HttpUrlDestinationConfiguration
httpUrlConfiguration} -> Maybe HttpUrlDestinationConfiguration
httpUrlConfiguration) (\s :: TopicRuleDestinationConfiguration
s@TopicRuleDestinationConfiguration' {} Maybe HttpUrlDestinationConfiguration
a -> TopicRuleDestinationConfiguration
s {$sel:httpUrlConfiguration:TopicRuleDestinationConfiguration' :: Maybe HttpUrlDestinationConfiguration
httpUrlConfiguration = Maybe HttpUrlDestinationConfiguration
a} :: TopicRuleDestinationConfiguration)

instance
  Prelude.Hashable
    TopicRuleDestinationConfiguration

instance
  Prelude.NFData
    TopicRuleDestinationConfiguration

instance
  Core.ToJSON
    TopicRuleDestinationConfiguration
  where
  toJSON :: TopicRuleDestinationConfiguration -> Value
toJSON TopicRuleDestinationConfiguration' {Maybe HttpUrlDestinationConfiguration
Maybe VpcDestinationConfiguration
httpUrlConfiguration :: Maybe HttpUrlDestinationConfiguration
vpcConfiguration :: Maybe VpcDestinationConfiguration
$sel:httpUrlConfiguration:TopicRuleDestinationConfiguration' :: TopicRuleDestinationConfiguration
-> Maybe HttpUrlDestinationConfiguration
$sel:vpcConfiguration:TopicRuleDestinationConfiguration' :: TopicRuleDestinationConfiguration
-> Maybe VpcDestinationConfiguration
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"vpcConfiguration" Text -> VpcDestinationConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (VpcDestinationConfiguration -> Pair)
-> Maybe VpcDestinationConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe VpcDestinationConfiguration
vpcConfiguration,
            (Text
"httpUrlConfiguration" Text -> HttpUrlDestinationConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (HttpUrlDestinationConfiguration -> Pair)
-> Maybe HttpUrlDestinationConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe HttpUrlDestinationConfiguration
httpUrlConfiguration
          ]
      )