{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Amazonka.CustomerProfiles.MergeProfiles
(
MergeProfiles (..),
newMergeProfiles,
mergeProfiles_fieldSourceProfileIds,
mergeProfiles_domainName,
mergeProfiles_mainProfileId,
mergeProfiles_profileIdsToBeMerged,
MergeProfilesResponse (..),
newMergeProfilesResponse,
mergeProfilesResponse_message,
mergeProfilesResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import Amazonka.CustomerProfiles.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data MergeProfiles = MergeProfiles'
{
MergeProfiles -> Maybe FieldSourceProfileIds
fieldSourceProfileIds :: Prelude.Maybe FieldSourceProfileIds,
MergeProfiles -> Text
domainName :: Prelude.Text,
MergeProfiles -> Text
mainProfileId :: Prelude.Text,
MergeProfiles -> NonEmpty Text
profileIdsToBeMerged :: Prelude.NonEmpty Prelude.Text
}
deriving (MergeProfiles -> MergeProfiles -> Bool
(MergeProfiles -> MergeProfiles -> Bool)
-> (MergeProfiles -> MergeProfiles -> Bool) -> Eq MergeProfiles
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MergeProfiles -> MergeProfiles -> Bool
$c/= :: MergeProfiles -> MergeProfiles -> Bool
== :: MergeProfiles -> MergeProfiles -> Bool
$c== :: MergeProfiles -> MergeProfiles -> Bool
Prelude.Eq, ReadPrec [MergeProfiles]
ReadPrec MergeProfiles
Int -> ReadS MergeProfiles
ReadS [MergeProfiles]
(Int -> ReadS MergeProfiles)
-> ReadS [MergeProfiles]
-> ReadPrec MergeProfiles
-> ReadPrec [MergeProfiles]
-> Read MergeProfiles
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MergeProfiles]
$creadListPrec :: ReadPrec [MergeProfiles]
readPrec :: ReadPrec MergeProfiles
$creadPrec :: ReadPrec MergeProfiles
readList :: ReadS [MergeProfiles]
$creadList :: ReadS [MergeProfiles]
readsPrec :: Int -> ReadS MergeProfiles
$creadsPrec :: Int -> ReadS MergeProfiles
Prelude.Read, Int -> MergeProfiles -> ShowS
[MergeProfiles] -> ShowS
MergeProfiles -> String
(Int -> MergeProfiles -> ShowS)
-> (MergeProfiles -> String)
-> ([MergeProfiles] -> ShowS)
-> Show MergeProfiles
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MergeProfiles] -> ShowS
$cshowList :: [MergeProfiles] -> ShowS
show :: MergeProfiles -> String
$cshow :: MergeProfiles -> String
showsPrec :: Int -> MergeProfiles -> ShowS
$cshowsPrec :: Int -> MergeProfiles -> ShowS
Prelude.Show, (forall x. MergeProfiles -> Rep MergeProfiles x)
-> (forall x. Rep MergeProfiles x -> MergeProfiles)
-> Generic MergeProfiles
forall x. Rep MergeProfiles x -> MergeProfiles
forall x. MergeProfiles -> Rep MergeProfiles x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MergeProfiles x -> MergeProfiles
$cfrom :: forall x. MergeProfiles -> Rep MergeProfiles x
Prelude.Generic)
newMergeProfiles ::
Prelude.Text ->
Prelude.Text ->
Prelude.NonEmpty Prelude.Text ->
MergeProfiles
newMergeProfiles :: Text -> Text -> NonEmpty Text -> MergeProfiles
newMergeProfiles
Text
pDomainName_
Text
pMainProfileId_
NonEmpty Text
pProfileIdsToBeMerged_ =
MergeProfiles' :: Maybe FieldSourceProfileIds
-> Text -> Text -> NonEmpty Text -> MergeProfiles
MergeProfiles'
{ $sel:fieldSourceProfileIds:MergeProfiles' :: Maybe FieldSourceProfileIds
fieldSourceProfileIds =
Maybe FieldSourceProfileIds
forall a. Maybe a
Prelude.Nothing,
$sel:domainName:MergeProfiles' :: Text
domainName = Text
pDomainName_,
$sel:mainProfileId:MergeProfiles' :: Text
mainProfileId = Text
pMainProfileId_,
$sel:profileIdsToBeMerged:MergeProfiles' :: NonEmpty Text
profileIdsToBeMerged =
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
pProfileIdsToBeMerged_
}
mergeProfiles_fieldSourceProfileIds :: Lens.Lens' MergeProfiles (Prelude.Maybe FieldSourceProfileIds)
mergeProfiles_fieldSourceProfileIds :: (Maybe FieldSourceProfileIds -> f (Maybe FieldSourceProfileIds))
-> MergeProfiles -> f MergeProfiles
mergeProfiles_fieldSourceProfileIds = (MergeProfiles -> Maybe FieldSourceProfileIds)
-> (MergeProfiles -> Maybe FieldSourceProfileIds -> MergeProfiles)
-> Lens
MergeProfiles
MergeProfiles
(Maybe FieldSourceProfileIds)
(Maybe FieldSourceProfileIds)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MergeProfiles' {Maybe FieldSourceProfileIds
fieldSourceProfileIds :: Maybe FieldSourceProfileIds
$sel:fieldSourceProfileIds:MergeProfiles' :: MergeProfiles -> Maybe FieldSourceProfileIds
fieldSourceProfileIds} -> Maybe FieldSourceProfileIds
fieldSourceProfileIds) (\s :: MergeProfiles
s@MergeProfiles' {} Maybe FieldSourceProfileIds
a -> MergeProfiles
s {$sel:fieldSourceProfileIds:MergeProfiles' :: Maybe FieldSourceProfileIds
fieldSourceProfileIds = Maybe FieldSourceProfileIds
a} :: MergeProfiles)
mergeProfiles_domainName :: Lens.Lens' MergeProfiles Prelude.Text
mergeProfiles_domainName :: (Text -> f Text) -> MergeProfiles -> f MergeProfiles
mergeProfiles_domainName = (MergeProfiles -> Text)
-> (MergeProfiles -> Text -> MergeProfiles)
-> Lens MergeProfiles MergeProfiles Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MergeProfiles' {Text
domainName :: Text
$sel:domainName:MergeProfiles' :: MergeProfiles -> Text
domainName} -> Text
domainName) (\s :: MergeProfiles
s@MergeProfiles' {} Text
a -> MergeProfiles
s {$sel:domainName:MergeProfiles' :: Text
domainName = Text
a} :: MergeProfiles)
mergeProfiles_mainProfileId :: Lens.Lens' MergeProfiles Prelude.Text
mergeProfiles_mainProfileId :: (Text -> f Text) -> MergeProfiles -> f MergeProfiles
mergeProfiles_mainProfileId = (MergeProfiles -> Text)
-> (MergeProfiles -> Text -> MergeProfiles)
-> Lens MergeProfiles MergeProfiles Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MergeProfiles' {Text
mainProfileId :: Text
$sel:mainProfileId:MergeProfiles' :: MergeProfiles -> Text
mainProfileId} -> Text
mainProfileId) (\s :: MergeProfiles
s@MergeProfiles' {} Text
a -> MergeProfiles
s {$sel:mainProfileId:MergeProfiles' :: Text
mainProfileId = Text
a} :: MergeProfiles)
mergeProfiles_profileIdsToBeMerged :: Lens.Lens' MergeProfiles (Prelude.NonEmpty Prelude.Text)
mergeProfiles_profileIdsToBeMerged :: (NonEmpty Text -> f (NonEmpty Text))
-> MergeProfiles -> f MergeProfiles
mergeProfiles_profileIdsToBeMerged = (MergeProfiles -> NonEmpty Text)
-> (MergeProfiles -> NonEmpty Text -> MergeProfiles)
-> Lens MergeProfiles MergeProfiles (NonEmpty Text) (NonEmpty Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MergeProfiles' {NonEmpty Text
profileIdsToBeMerged :: NonEmpty Text
$sel:profileIdsToBeMerged:MergeProfiles' :: MergeProfiles -> NonEmpty Text
profileIdsToBeMerged} -> NonEmpty Text
profileIdsToBeMerged) (\s :: MergeProfiles
s@MergeProfiles' {} NonEmpty Text
a -> MergeProfiles
s {$sel:profileIdsToBeMerged:MergeProfiles' :: NonEmpty Text
profileIdsToBeMerged = NonEmpty Text
a} :: MergeProfiles) ((NonEmpty Text -> f (NonEmpty Text))
-> MergeProfiles -> f MergeProfiles)
-> ((NonEmpty Text -> f (NonEmpty Text))
-> NonEmpty Text -> f (NonEmpty Text))
-> (NonEmpty Text -> f (NonEmpty Text))
-> MergeProfiles
-> f MergeProfiles
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.AWSRequest MergeProfiles where
type
AWSResponse MergeProfiles =
MergeProfilesResponse
request :: MergeProfiles -> Request MergeProfiles
request = Service -> MergeProfiles -> Request MergeProfiles
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy MergeProfiles
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse MergeProfiles)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse MergeProfiles))
-> Logger
-> Service
-> Proxy MergeProfiles
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse MergeProfiles)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
( \Int
s ResponseHeaders
h Object
x ->
Maybe Text -> Int -> MergeProfilesResponse
MergeProfilesResponse'
(Maybe Text -> Int -> MergeProfilesResponse)
-> Either String (Maybe Text)
-> Either String (Int -> MergeProfilesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Message")
Either String (Int -> MergeProfilesResponse)
-> Either String Int -> Either String MergeProfilesResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
)
instance Prelude.Hashable MergeProfiles
instance Prelude.NFData MergeProfiles
instance Core.ToHeaders MergeProfiles where
toHeaders :: MergeProfiles -> ResponseHeaders
toHeaders =
ResponseHeaders -> MergeProfiles -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"Content-Type"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Core.ToJSON MergeProfiles where
toJSON :: MergeProfiles -> Value
toJSON MergeProfiles' {Maybe FieldSourceProfileIds
NonEmpty Text
Text
profileIdsToBeMerged :: NonEmpty Text
mainProfileId :: Text
domainName :: Text
fieldSourceProfileIds :: Maybe FieldSourceProfileIds
$sel:profileIdsToBeMerged:MergeProfiles' :: MergeProfiles -> NonEmpty Text
$sel:mainProfileId:MergeProfiles' :: MergeProfiles -> Text
$sel:domainName:MergeProfiles' :: MergeProfiles -> Text
$sel:fieldSourceProfileIds:MergeProfiles' :: MergeProfiles -> Maybe FieldSourceProfileIds
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"FieldSourceProfileIds" Text -> FieldSourceProfileIds -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(FieldSourceProfileIds -> Pair)
-> Maybe FieldSourceProfileIds -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe FieldSourceProfileIds
fieldSourceProfileIds,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"MainProfileId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
mainProfileId),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
( Text
"ProfileIdsToBeMerged"
Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty Text
profileIdsToBeMerged
)
]
)
instance Core.ToPath MergeProfiles where
toPath :: MergeProfiles -> ByteString
toPath MergeProfiles' {Maybe FieldSourceProfileIds
NonEmpty Text
Text
profileIdsToBeMerged :: NonEmpty Text
mainProfileId :: Text
domainName :: Text
fieldSourceProfileIds :: Maybe FieldSourceProfileIds
$sel:profileIdsToBeMerged:MergeProfiles' :: MergeProfiles -> NonEmpty Text
$sel:mainProfileId:MergeProfiles' :: MergeProfiles -> Text
$sel:domainName:MergeProfiles' :: MergeProfiles -> Text
$sel:fieldSourceProfileIds:MergeProfiles' :: MergeProfiles -> Maybe FieldSourceProfileIds
..} =
[ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"/domains/",
Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
domainName,
ByteString
"/profiles/objects/merge"
]
instance Core.ToQuery MergeProfiles where
toQuery :: MergeProfiles -> QueryString
toQuery = QueryString -> MergeProfiles -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data MergeProfilesResponse = MergeProfilesResponse'
{
MergeProfilesResponse -> Maybe Text
message :: Prelude.Maybe Prelude.Text,
MergeProfilesResponse -> Int
httpStatus :: Prelude.Int
}
deriving (MergeProfilesResponse -> MergeProfilesResponse -> Bool
(MergeProfilesResponse -> MergeProfilesResponse -> Bool)
-> (MergeProfilesResponse -> MergeProfilesResponse -> Bool)
-> Eq MergeProfilesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MergeProfilesResponse -> MergeProfilesResponse -> Bool
$c/= :: MergeProfilesResponse -> MergeProfilesResponse -> Bool
== :: MergeProfilesResponse -> MergeProfilesResponse -> Bool
$c== :: MergeProfilesResponse -> MergeProfilesResponse -> Bool
Prelude.Eq, ReadPrec [MergeProfilesResponse]
ReadPrec MergeProfilesResponse
Int -> ReadS MergeProfilesResponse
ReadS [MergeProfilesResponse]
(Int -> ReadS MergeProfilesResponse)
-> ReadS [MergeProfilesResponse]
-> ReadPrec MergeProfilesResponse
-> ReadPrec [MergeProfilesResponse]
-> Read MergeProfilesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MergeProfilesResponse]
$creadListPrec :: ReadPrec [MergeProfilesResponse]
readPrec :: ReadPrec MergeProfilesResponse
$creadPrec :: ReadPrec MergeProfilesResponse
readList :: ReadS [MergeProfilesResponse]
$creadList :: ReadS [MergeProfilesResponse]
readsPrec :: Int -> ReadS MergeProfilesResponse
$creadsPrec :: Int -> ReadS MergeProfilesResponse
Prelude.Read, Int -> MergeProfilesResponse -> ShowS
[MergeProfilesResponse] -> ShowS
MergeProfilesResponse -> String
(Int -> MergeProfilesResponse -> ShowS)
-> (MergeProfilesResponse -> String)
-> ([MergeProfilesResponse] -> ShowS)
-> Show MergeProfilesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MergeProfilesResponse] -> ShowS
$cshowList :: [MergeProfilesResponse] -> ShowS
show :: MergeProfilesResponse -> String
$cshow :: MergeProfilesResponse -> String
showsPrec :: Int -> MergeProfilesResponse -> ShowS
$cshowsPrec :: Int -> MergeProfilesResponse -> ShowS
Prelude.Show, (forall x. MergeProfilesResponse -> Rep MergeProfilesResponse x)
-> (forall x. Rep MergeProfilesResponse x -> MergeProfilesResponse)
-> Generic MergeProfilesResponse
forall x. Rep MergeProfilesResponse x -> MergeProfilesResponse
forall x. MergeProfilesResponse -> Rep MergeProfilesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MergeProfilesResponse x -> MergeProfilesResponse
$cfrom :: forall x. MergeProfilesResponse -> Rep MergeProfilesResponse x
Prelude.Generic)
newMergeProfilesResponse ::
Prelude.Int ->
MergeProfilesResponse
newMergeProfilesResponse :: Int -> MergeProfilesResponse
newMergeProfilesResponse Int
pHttpStatus_ =
MergeProfilesResponse' :: Maybe Text -> Int -> MergeProfilesResponse
MergeProfilesResponse'
{ $sel:message:MergeProfilesResponse' :: Maybe Text
message = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:MergeProfilesResponse' :: Int
httpStatus = Int
pHttpStatus_
}
mergeProfilesResponse_message :: Lens.Lens' MergeProfilesResponse (Prelude.Maybe Prelude.Text)
mergeProfilesResponse_message :: (Maybe Text -> f (Maybe Text))
-> MergeProfilesResponse -> f MergeProfilesResponse
mergeProfilesResponse_message = (MergeProfilesResponse -> Maybe Text)
-> (MergeProfilesResponse -> Maybe Text -> MergeProfilesResponse)
-> Lens
MergeProfilesResponse
MergeProfilesResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MergeProfilesResponse' {Maybe Text
message :: Maybe Text
$sel:message:MergeProfilesResponse' :: MergeProfilesResponse -> Maybe Text
message} -> Maybe Text
message) (\s :: MergeProfilesResponse
s@MergeProfilesResponse' {} Maybe Text
a -> MergeProfilesResponse
s {$sel:message:MergeProfilesResponse' :: Maybe Text
message = Maybe Text
a} :: MergeProfilesResponse)
mergeProfilesResponse_httpStatus :: Lens.Lens' MergeProfilesResponse Prelude.Int
mergeProfilesResponse_httpStatus :: (Int -> f Int) -> MergeProfilesResponse -> f MergeProfilesResponse
mergeProfilesResponse_httpStatus = (MergeProfilesResponse -> Int)
-> (MergeProfilesResponse -> Int -> MergeProfilesResponse)
-> Lens MergeProfilesResponse MergeProfilesResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MergeProfilesResponse' {Int
httpStatus :: Int
$sel:httpStatus:MergeProfilesResponse' :: MergeProfilesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: MergeProfilesResponse
s@MergeProfilesResponse' {} Int
a -> MergeProfilesResponse
s {$sel:httpStatus:MergeProfilesResponse' :: Int
httpStatus = Int
a} :: MergeProfilesResponse)
instance Prelude.NFData MergeProfilesResponse