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