{-# 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 #-}
module Amazonka.IoTSecureTunneling.Types.DestinationConfig where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data DestinationConfig = DestinationConfig'
{
DestinationConfig -> Maybe Text
thingName :: Prelude.Maybe Prelude.Text,
DestinationConfig -> NonEmpty Text
services :: Prelude.NonEmpty Prelude.Text
}
deriving (DestinationConfig -> DestinationConfig -> Bool
(DestinationConfig -> DestinationConfig -> Bool)
-> (DestinationConfig -> DestinationConfig -> Bool)
-> Eq DestinationConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DestinationConfig -> DestinationConfig -> Bool
$c/= :: DestinationConfig -> DestinationConfig -> Bool
== :: DestinationConfig -> DestinationConfig -> Bool
$c== :: DestinationConfig -> DestinationConfig -> Bool
Prelude.Eq, ReadPrec [DestinationConfig]
ReadPrec DestinationConfig
Int -> ReadS DestinationConfig
ReadS [DestinationConfig]
(Int -> ReadS DestinationConfig)
-> ReadS [DestinationConfig]
-> ReadPrec DestinationConfig
-> ReadPrec [DestinationConfig]
-> Read DestinationConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DestinationConfig]
$creadListPrec :: ReadPrec [DestinationConfig]
readPrec :: ReadPrec DestinationConfig
$creadPrec :: ReadPrec DestinationConfig
readList :: ReadS [DestinationConfig]
$creadList :: ReadS [DestinationConfig]
readsPrec :: Int -> ReadS DestinationConfig
$creadsPrec :: Int -> ReadS DestinationConfig
Prelude.Read, Int -> DestinationConfig -> ShowS
[DestinationConfig] -> ShowS
DestinationConfig -> String
(Int -> DestinationConfig -> ShowS)
-> (DestinationConfig -> String)
-> ([DestinationConfig] -> ShowS)
-> Show DestinationConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DestinationConfig] -> ShowS
$cshowList :: [DestinationConfig] -> ShowS
show :: DestinationConfig -> String
$cshow :: DestinationConfig -> String
showsPrec :: Int -> DestinationConfig -> ShowS
$cshowsPrec :: Int -> DestinationConfig -> ShowS
Prelude.Show, (forall x. DestinationConfig -> Rep DestinationConfig x)
-> (forall x. Rep DestinationConfig x -> DestinationConfig)
-> Generic DestinationConfig
forall x. Rep DestinationConfig x -> DestinationConfig
forall x. DestinationConfig -> Rep DestinationConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DestinationConfig x -> DestinationConfig
$cfrom :: forall x. DestinationConfig -> Rep DestinationConfig x
Prelude.Generic)
newDestinationConfig ::
Prelude.NonEmpty Prelude.Text ->
DestinationConfig
newDestinationConfig :: NonEmpty Text -> DestinationConfig
newDestinationConfig NonEmpty Text
pServices_ =
DestinationConfig' :: Maybe Text -> NonEmpty Text -> DestinationConfig
DestinationConfig'
{ $sel:thingName:DestinationConfig' :: Maybe Text
thingName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:services:DestinationConfig' :: NonEmpty Text
services = Tagged (NonEmpty Text) (Identity (NonEmpty Text))
-> Tagged (NonEmpty Text) (Identity (NonEmpty Text))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged (NonEmpty Text) (Identity (NonEmpty Text))
-> Tagged (NonEmpty Text) (Identity (NonEmpty Text)))
-> NonEmpty Text -> NonEmpty Text
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pServices_
}
destinationConfig_thingName :: Lens.Lens' DestinationConfig (Prelude.Maybe Prelude.Text)
destinationConfig_thingName :: (Maybe Text -> f (Maybe Text))
-> DestinationConfig -> f DestinationConfig
destinationConfig_thingName = (DestinationConfig -> Maybe Text)
-> (DestinationConfig -> Maybe Text -> DestinationConfig)
-> Lens
DestinationConfig DestinationConfig (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DestinationConfig' {Maybe Text
thingName :: Maybe Text
$sel:thingName:DestinationConfig' :: DestinationConfig -> Maybe Text
thingName} -> Maybe Text
thingName) (\s :: DestinationConfig
s@DestinationConfig' {} Maybe Text
a -> DestinationConfig
s {$sel:thingName:DestinationConfig' :: Maybe Text
thingName = Maybe Text
a} :: DestinationConfig)
destinationConfig_services :: Lens.Lens' DestinationConfig (Prelude.NonEmpty Prelude.Text)
destinationConfig_services :: (NonEmpty Text -> f (NonEmpty Text))
-> DestinationConfig -> f DestinationConfig
destinationConfig_services = (DestinationConfig -> NonEmpty Text)
-> (DestinationConfig -> NonEmpty Text -> DestinationConfig)
-> Lens
DestinationConfig DestinationConfig (NonEmpty Text) (NonEmpty Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DestinationConfig' {NonEmpty Text
services :: NonEmpty Text
$sel:services:DestinationConfig' :: DestinationConfig -> NonEmpty Text
services} -> NonEmpty Text
services) (\s :: DestinationConfig
s@DestinationConfig' {} NonEmpty Text
a -> DestinationConfig
s {$sel:services:DestinationConfig' :: NonEmpty Text
services = NonEmpty Text
a} :: DestinationConfig) ((NonEmpty Text -> f (NonEmpty Text))
-> DestinationConfig -> f DestinationConfig)
-> ((NonEmpty Text -> f (NonEmpty Text))
-> NonEmpty Text -> f (NonEmpty Text))
-> (NonEmpty Text -> f (NonEmpty Text))
-> DestinationConfig
-> f DestinationConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Text -> f (NonEmpty Text))
-> NonEmpty Text -> f (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.FromJSON DestinationConfig where
parseJSON :: Value -> Parser DestinationConfig
parseJSON =
String
-> (Object -> Parser DestinationConfig)
-> Value
-> Parser DestinationConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"DestinationConfig"
( \Object
x ->
Maybe Text -> NonEmpty Text -> DestinationConfig
DestinationConfig'
(Maybe Text -> NonEmpty Text -> DestinationConfig)
-> Parser (Maybe Text)
-> Parser (NonEmpty Text -> DestinationConfig)
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
"thingName")
Parser (NonEmpty Text -> DestinationConfig)
-> Parser (NonEmpty Text) -> Parser DestinationConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (NonEmpty Text)
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"services")
)
instance Prelude.Hashable DestinationConfig
instance Prelude.NFData DestinationConfig
instance Core.ToJSON DestinationConfig where
toJSON :: DestinationConfig -> Value
toJSON DestinationConfig' {Maybe Text
NonEmpty Text
services :: NonEmpty Text
thingName :: Maybe Text
$sel:services:DestinationConfig' :: DestinationConfig -> NonEmpty Text
$sel:thingName:DestinationConfig' :: DestinationConfig -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"thingName" 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
thingName,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"services" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty Text
services)
]
)