{-# 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.Chime.Types.Origination where
import Amazonka.Chime.Types.OriginationRoute
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data Origination = Origination'
{
Origination -> Maybe [OriginationRoute]
routes :: Prelude.Maybe [OriginationRoute],
Origination -> Maybe Bool
disabled :: Prelude.Maybe Prelude.Bool
}
deriving (Origination -> Origination -> Bool
(Origination -> Origination -> Bool)
-> (Origination -> Origination -> Bool) -> Eq Origination
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Origination -> Origination -> Bool
$c/= :: Origination -> Origination -> Bool
== :: Origination -> Origination -> Bool
$c== :: Origination -> Origination -> Bool
Prelude.Eq, ReadPrec [Origination]
ReadPrec Origination
Int -> ReadS Origination
ReadS [Origination]
(Int -> ReadS Origination)
-> ReadS [Origination]
-> ReadPrec Origination
-> ReadPrec [Origination]
-> Read Origination
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Origination]
$creadListPrec :: ReadPrec [Origination]
readPrec :: ReadPrec Origination
$creadPrec :: ReadPrec Origination
readList :: ReadS [Origination]
$creadList :: ReadS [Origination]
readsPrec :: Int -> ReadS Origination
$creadsPrec :: Int -> ReadS Origination
Prelude.Read, Int -> Origination -> ShowS
[Origination] -> ShowS
Origination -> String
(Int -> Origination -> ShowS)
-> (Origination -> String)
-> ([Origination] -> ShowS)
-> Show Origination
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Origination] -> ShowS
$cshowList :: [Origination] -> ShowS
show :: Origination -> String
$cshow :: Origination -> String
showsPrec :: Int -> Origination -> ShowS
$cshowsPrec :: Int -> Origination -> ShowS
Prelude.Show, (forall x. Origination -> Rep Origination x)
-> (forall x. Rep Origination x -> Origination)
-> Generic Origination
forall x. Rep Origination x -> Origination
forall x. Origination -> Rep Origination x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Origination x -> Origination
$cfrom :: forall x. Origination -> Rep Origination x
Prelude.Generic)
newOrigination ::
Origination
newOrigination :: Origination
newOrigination =
Origination' :: Maybe [OriginationRoute] -> Maybe Bool -> Origination
Origination'
{ $sel:routes:Origination' :: Maybe [OriginationRoute]
routes = Maybe [OriginationRoute]
forall a. Maybe a
Prelude.Nothing,
$sel:disabled:Origination' :: Maybe Bool
disabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing
}
origination_routes :: Lens.Lens' Origination (Prelude.Maybe [OriginationRoute])
origination_routes :: (Maybe [OriginationRoute] -> f (Maybe [OriginationRoute]))
-> Origination -> f Origination
origination_routes = (Origination -> Maybe [OriginationRoute])
-> (Origination -> Maybe [OriginationRoute] -> Origination)
-> Lens
Origination
Origination
(Maybe [OriginationRoute])
(Maybe [OriginationRoute])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Origination' {Maybe [OriginationRoute]
routes :: Maybe [OriginationRoute]
$sel:routes:Origination' :: Origination -> Maybe [OriginationRoute]
routes} -> Maybe [OriginationRoute]
routes) (\s :: Origination
s@Origination' {} Maybe [OriginationRoute]
a -> Origination
s {$sel:routes:Origination' :: Maybe [OriginationRoute]
routes = Maybe [OriginationRoute]
a} :: Origination) ((Maybe [OriginationRoute] -> f (Maybe [OriginationRoute]))
-> Origination -> f Origination)
-> ((Maybe [OriginationRoute] -> f (Maybe [OriginationRoute]))
-> Maybe [OriginationRoute] -> f (Maybe [OriginationRoute]))
-> (Maybe [OriginationRoute] -> f (Maybe [OriginationRoute]))
-> Origination
-> f Origination
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
[OriginationRoute]
[OriginationRoute]
[OriginationRoute]
[OriginationRoute]
-> Iso
(Maybe [OriginationRoute])
(Maybe [OriginationRoute])
(Maybe [OriginationRoute])
(Maybe [OriginationRoute])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
[OriginationRoute]
[OriginationRoute]
[OriginationRoute]
[OriginationRoute]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
origination_disabled :: Lens.Lens' Origination (Prelude.Maybe Prelude.Bool)
origination_disabled :: (Maybe Bool -> f (Maybe Bool)) -> Origination -> f Origination
origination_disabled = (Origination -> Maybe Bool)
-> (Origination -> Maybe Bool -> Origination)
-> Lens Origination Origination (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Origination' {Maybe Bool
disabled :: Maybe Bool
$sel:disabled:Origination' :: Origination -> Maybe Bool
disabled} -> Maybe Bool
disabled) (\s :: Origination
s@Origination' {} Maybe Bool
a -> Origination
s {$sel:disabled:Origination' :: Maybe Bool
disabled = Maybe Bool
a} :: Origination)
instance Core.FromJSON Origination where
parseJSON :: Value -> Parser Origination
parseJSON =
String
-> (Object -> Parser Origination) -> Value -> Parser Origination
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"Origination"
( \Object
x ->
Maybe [OriginationRoute] -> Maybe Bool -> Origination
Origination'
(Maybe [OriginationRoute] -> Maybe Bool -> Origination)
-> Parser (Maybe [OriginationRoute])
-> Parser (Maybe Bool -> Origination)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [OriginationRoute]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Routes" Parser (Maybe (Maybe [OriginationRoute]))
-> Maybe [OriginationRoute] -> Parser (Maybe [OriginationRoute])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [OriginationRoute]
forall a. Monoid a => a
Prelude.mempty)
Parser (Maybe Bool -> Origination)
-> Parser (Maybe Bool) -> Parser Origination
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Disabled")
)
instance Prelude.Hashable Origination
instance Prelude.NFData Origination
instance Core.ToJSON Origination where
toJSON :: Origination -> Value
toJSON Origination' {Maybe Bool
Maybe [OriginationRoute]
disabled :: Maybe Bool
routes :: Maybe [OriginationRoute]
$sel:disabled:Origination' :: Origination -> Maybe Bool
$sel:routes:Origination' :: Origination -> Maybe [OriginationRoute]
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"Routes" Text -> [OriginationRoute] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([OriginationRoute] -> Pair)
-> Maybe [OriginationRoute] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [OriginationRoute]
routes,
(Text
"Disabled" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
disabled
]
)