{-# 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.Pinpoint.Types.SegmentReference where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data SegmentReference = SegmentReference'
{
SegmentReference -> Maybe Int
version :: Prelude.Maybe Prelude.Int,
SegmentReference -> Text
id :: Prelude.Text
}
deriving (SegmentReference -> SegmentReference -> Bool
(SegmentReference -> SegmentReference -> Bool)
-> (SegmentReference -> SegmentReference -> Bool)
-> Eq SegmentReference
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SegmentReference -> SegmentReference -> Bool
$c/= :: SegmentReference -> SegmentReference -> Bool
== :: SegmentReference -> SegmentReference -> Bool
$c== :: SegmentReference -> SegmentReference -> Bool
Prelude.Eq, ReadPrec [SegmentReference]
ReadPrec SegmentReference
Int -> ReadS SegmentReference
ReadS [SegmentReference]
(Int -> ReadS SegmentReference)
-> ReadS [SegmentReference]
-> ReadPrec SegmentReference
-> ReadPrec [SegmentReference]
-> Read SegmentReference
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SegmentReference]
$creadListPrec :: ReadPrec [SegmentReference]
readPrec :: ReadPrec SegmentReference
$creadPrec :: ReadPrec SegmentReference
readList :: ReadS [SegmentReference]
$creadList :: ReadS [SegmentReference]
readsPrec :: Int -> ReadS SegmentReference
$creadsPrec :: Int -> ReadS SegmentReference
Prelude.Read, Int -> SegmentReference -> ShowS
[SegmentReference] -> ShowS
SegmentReference -> String
(Int -> SegmentReference -> ShowS)
-> (SegmentReference -> String)
-> ([SegmentReference] -> ShowS)
-> Show SegmentReference
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SegmentReference] -> ShowS
$cshowList :: [SegmentReference] -> ShowS
show :: SegmentReference -> String
$cshow :: SegmentReference -> String
showsPrec :: Int -> SegmentReference -> ShowS
$cshowsPrec :: Int -> SegmentReference -> ShowS
Prelude.Show, (forall x. SegmentReference -> Rep SegmentReference x)
-> (forall x. Rep SegmentReference x -> SegmentReference)
-> Generic SegmentReference
forall x. Rep SegmentReference x -> SegmentReference
forall x. SegmentReference -> Rep SegmentReference x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SegmentReference x -> SegmentReference
$cfrom :: forall x. SegmentReference -> Rep SegmentReference x
Prelude.Generic)
newSegmentReference ::
Prelude.Text ->
SegmentReference
newSegmentReference :: Text -> SegmentReference
newSegmentReference Text
pId_ =
SegmentReference' :: Maybe Int -> Text -> SegmentReference
SegmentReference'
{ $sel:version:SegmentReference' :: Maybe Int
version = Maybe Int
forall a. Maybe a
Prelude.Nothing,
$sel:id:SegmentReference' :: Text
id = Text
pId_
}
segmentReference_version :: Lens.Lens' SegmentReference (Prelude.Maybe Prelude.Int)
segmentReference_version :: (Maybe Int -> f (Maybe Int))
-> SegmentReference -> f SegmentReference
segmentReference_version = (SegmentReference -> Maybe Int)
-> (SegmentReference -> Maybe Int -> SegmentReference)
-> Lens SegmentReference SegmentReference (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SegmentReference' {Maybe Int
version :: Maybe Int
$sel:version:SegmentReference' :: SegmentReference -> Maybe Int
version} -> Maybe Int
version) (\s :: SegmentReference
s@SegmentReference' {} Maybe Int
a -> SegmentReference
s {$sel:version:SegmentReference' :: Maybe Int
version = Maybe Int
a} :: SegmentReference)
segmentReference_id :: Lens.Lens' SegmentReference Prelude.Text
segmentReference_id :: (Text -> f Text) -> SegmentReference -> f SegmentReference
segmentReference_id = (SegmentReference -> Text)
-> (SegmentReference -> Text -> SegmentReference)
-> Lens SegmentReference SegmentReference Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SegmentReference' {Text
id :: Text
$sel:id:SegmentReference' :: SegmentReference -> Text
id} -> Text
id) (\s :: SegmentReference
s@SegmentReference' {} Text
a -> SegmentReference
s {$sel:id:SegmentReference' :: Text
id = Text
a} :: SegmentReference)
instance Core.FromJSON SegmentReference where
parseJSON :: Value -> Parser SegmentReference
parseJSON =
String
-> (Object -> Parser SegmentReference)
-> Value
-> Parser SegmentReference
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"SegmentReference"
( \Object
x ->
Maybe Int -> Text -> SegmentReference
SegmentReference'
(Maybe Int -> Text -> SegmentReference)
-> Parser (Maybe Int) -> Parser (Text -> SegmentReference)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Version") Parser (Text -> SegmentReference)
-> Parser Text -> Parser SegmentReference
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Id")
)
instance Prelude.Hashable SegmentReference
instance Prelude.NFData SegmentReference
instance Core.ToJSON SegmentReference where
toJSON :: SegmentReference -> Value
toJSON SegmentReference' {Maybe Int
Text
id :: Text
version :: Maybe Int
$sel:id:SegmentReference' :: SegmentReference -> Text
$sel:version:SegmentReference' :: SegmentReference -> Maybe Int
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"Version" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
version,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Id" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
id)
]
)