{-# 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.SSMContacts.CreateContact
(
CreateContact (..),
newCreateContact,
createContact_idempotencyToken,
createContact_displayName,
createContact_tags,
createContact_alias,
createContact_type,
createContact_plan,
CreateContactResponse (..),
newCreateContactResponse,
createContactResponse_httpStatus,
createContactResponse_contactArn,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SSMContacts.Types
data CreateContact = CreateContact'
{
CreateContact -> Maybe Text
idempotencyToken :: Prelude.Maybe Prelude.Text,
CreateContact -> Maybe Text
displayName :: Prelude.Maybe Prelude.Text,
CreateContact -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
CreateContact -> Text
alias :: Prelude.Text,
CreateContact -> ContactType
type' :: ContactType,
CreateContact -> Plan
plan :: Plan
}
deriving (CreateContact -> CreateContact -> Bool
(CreateContact -> CreateContact -> Bool)
-> (CreateContact -> CreateContact -> Bool) -> Eq CreateContact
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateContact -> CreateContact -> Bool
$c/= :: CreateContact -> CreateContact -> Bool
== :: CreateContact -> CreateContact -> Bool
$c== :: CreateContact -> CreateContact -> Bool
Prelude.Eq, ReadPrec [CreateContact]
ReadPrec CreateContact
Int -> ReadS CreateContact
ReadS [CreateContact]
(Int -> ReadS CreateContact)
-> ReadS [CreateContact]
-> ReadPrec CreateContact
-> ReadPrec [CreateContact]
-> Read CreateContact
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateContact]
$creadListPrec :: ReadPrec [CreateContact]
readPrec :: ReadPrec CreateContact
$creadPrec :: ReadPrec CreateContact
readList :: ReadS [CreateContact]
$creadList :: ReadS [CreateContact]
readsPrec :: Int -> ReadS CreateContact
$creadsPrec :: Int -> ReadS CreateContact
Prelude.Read, Int -> CreateContact -> ShowS
[CreateContact] -> ShowS
CreateContact -> String
(Int -> CreateContact -> ShowS)
-> (CreateContact -> String)
-> ([CreateContact] -> ShowS)
-> Show CreateContact
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateContact] -> ShowS
$cshowList :: [CreateContact] -> ShowS
show :: CreateContact -> String
$cshow :: CreateContact -> String
showsPrec :: Int -> CreateContact -> ShowS
$cshowsPrec :: Int -> CreateContact -> ShowS
Prelude.Show, (forall x. CreateContact -> Rep CreateContact x)
-> (forall x. Rep CreateContact x -> CreateContact)
-> Generic CreateContact
forall x. Rep CreateContact x -> CreateContact
forall x. CreateContact -> Rep CreateContact x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateContact x -> CreateContact
$cfrom :: forall x. CreateContact -> Rep CreateContact x
Prelude.Generic)
newCreateContact ::
Prelude.Text ->
ContactType ->
Plan ->
CreateContact
newCreateContact :: Text -> ContactType -> Plan -> CreateContact
newCreateContact Text
pAlias_ ContactType
pType_ Plan
pPlan_ =
CreateContact' :: Maybe Text
-> Maybe Text
-> Maybe [Tag]
-> Text
-> ContactType
-> Plan
-> CreateContact
CreateContact'
{ $sel:idempotencyToken:CreateContact' :: Maybe Text
idempotencyToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:displayName:CreateContact' :: Maybe Text
displayName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:tags:CreateContact' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
$sel:alias:CreateContact' :: Text
alias = Text
pAlias_,
$sel:type':CreateContact' :: ContactType
type' = ContactType
pType_,
$sel:plan:CreateContact' :: Plan
plan = Plan
pPlan_
}
createContact_idempotencyToken :: Lens.Lens' CreateContact (Prelude.Maybe Prelude.Text)
createContact_idempotencyToken :: (Maybe Text -> f (Maybe Text)) -> CreateContact -> f CreateContact
createContact_idempotencyToken = (CreateContact -> Maybe Text)
-> (CreateContact -> Maybe Text -> CreateContact)
-> Lens CreateContact CreateContact (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateContact' {Maybe Text
idempotencyToken :: Maybe Text
$sel:idempotencyToken:CreateContact' :: CreateContact -> Maybe Text
idempotencyToken} -> Maybe Text
idempotencyToken) (\s :: CreateContact
s@CreateContact' {} Maybe Text
a -> CreateContact
s {$sel:idempotencyToken:CreateContact' :: Maybe Text
idempotencyToken = Maybe Text
a} :: CreateContact)
createContact_displayName :: Lens.Lens' CreateContact (Prelude.Maybe Prelude.Text)
createContact_displayName :: (Maybe Text -> f (Maybe Text)) -> CreateContact -> f CreateContact
createContact_displayName = (CreateContact -> Maybe Text)
-> (CreateContact -> Maybe Text -> CreateContact)
-> Lens CreateContact CreateContact (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateContact' {Maybe Text
displayName :: Maybe Text
$sel:displayName:CreateContact' :: CreateContact -> Maybe Text
displayName} -> Maybe Text
displayName) (\s :: CreateContact
s@CreateContact' {} Maybe Text
a -> CreateContact
s {$sel:displayName:CreateContact' :: Maybe Text
displayName = Maybe Text
a} :: CreateContact)
createContact_tags :: Lens.Lens' CreateContact (Prelude.Maybe [Tag])
createContact_tags :: (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateContact -> f CreateContact
createContact_tags = (CreateContact -> Maybe [Tag])
-> (CreateContact -> Maybe [Tag] -> CreateContact)
-> Lens CreateContact CreateContact (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateContact' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreateContact' :: CreateContact -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreateContact
s@CreateContact' {} Maybe [Tag]
a -> CreateContact
s {$sel:tags:CreateContact' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreateContact) ((Maybe [Tag] -> f (Maybe [Tag]))
-> CreateContact -> f CreateContact)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
-> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateContact
-> f CreateContact
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
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 [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
createContact_alias :: Lens.Lens' CreateContact Prelude.Text
createContact_alias :: (Text -> f Text) -> CreateContact -> f CreateContact
createContact_alias = (CreateContact -> Text)
-> (CreateContact -> Text -> CreateContact)
-> Lens CreateContact CreateContact Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateContact' {Text
alias :: Text
$sel:alias:CreateContact' :: CreateContact -> Text
alias} -> Text
alias) (\s :: CreateContact
s@CreateContact' {} Text
a -> CreateContact
s {$sel:alias:CreateContact' :: Text
alias = Text
a} :: CreateContact)
createContact_type :: Lens.Lens' CreateContact ContactType
createContact_type :: (ContactType -> f ContactType) -> CreateContact -> f CreateContact
createContact_type = (CreateContact -> ContactType)
-> (CreateContact -> ContactType -> CreateContact)
-> Lens CreateContact CreateContact ContactType ContactType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateContact' {ContactType
type' :: ContactType
$sel:type':CreateContact' :: CreateContact -> ContactType
type'} -> ContactType
type') (\s :: CreateContact
s@CreateContact' {} ContactType
a -> CreateContact
s {$sel:type':CreateContact' :: ContactType
type' = ContactType
a} :: CreateContact)
createContact_plan :: Lens.Lens' CreateContact Plan
createContact_plan :: (Plan -> f Plan) -> CreateContact -> f CreateContact
createContact_plan = (CreateContact -> Plan)
-> (CreateContact -> Plan -> CreateContact)
-> Lens CreateContact CreateContact Plan Plan
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateContact' {Plan
plan :: Plan
$sel:plan:CreateContact' :: CreateContact -> Plan
plan} -> Plan
plan) (\s :: CreateContact
s@CreateContact' {} Plan
a -> CreateContact
s {$sel:plan:CreateContact' :: Plan
plan = Plan
a} :: CreateContact)
instance Core.AWSRequest CreateContact where
type
AWSResponse CreateContact =
CreateContactResponse
request :: CreateContact -> Request CreateContact
request = Service -> CreateContact -> Request CreateContact
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateContact
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateContact)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateContact))
-> Logger
-> Service
-> Proxy CreateContact
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateContact)))
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 ->
Int -> Text -> CreateContactResponse
CreateContactResponse'
(Int -> Text -> CreateContactResponse)
-> Either String Int
-> Either String (Text -> CreateContactResponse)
forall (f :: * -> *) a b. Functor 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))
Either String (Text -> CreateContactResponse)
-> Either String Text -> Either String CreateContactResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Text
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"ContactArn")
)
instance Prelude.Hashable CreateContact
instance Prelude.NFData CreateContact
instance Core.ToHeaders CreateContact where
toHeaders :: CreateContact -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateContact -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"X-Amz-Target"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# (ByteString
"SSMContacts.CreateContact" :: Prelude.ByteString),
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 CreateContact where
toJSON :: CreateContact -> Value
toJSON CreateContact' {Maybe [Tag]
Maybe Text
Text
ContactType
Plan
plan :: Plan
type' :: ContactType
alias :: Text
tags :: Maybe [Tag]
displayName :: Maybe Text
idempotencyToken :: Maybe Text
$sel:plan:CreateContact' :: CreateContact -> Plan
$sel:type':CreateContact' :: CreateContact -> ContactType
$sel:alias:CreateContact' :: CreateContact -> Text
$sel:tags:CreateContact' :: CreateContact -> Maybe [Tag]
$sel:displayName:CreateContact' :: CreateContact -> Maybe Text
$sel:idempotencyToken:CreateContact' :: CreateContact -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"IdempotencyToken" 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
idempotencyToken,
(Text
"DisplayName" 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
displayName,
(Text
"Tags" Text -> [Tag] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Tag] -> Pair) -> Maybe [Tag] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Alias" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
alias),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Type" Text -> ContactType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ContactType
type'),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Plan" Text -> Plan -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Plan
plan)
]
)
instance Core.ToPath CreateContact where
toPath :: CreateContact -> ByteString
toPath = ByteString -> CreateContact -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery CreateContact where
toQuery :: CreateContact -> QueryString
toQuery = QueryString -> CreateContact -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateContactResponse = CreateContactResponse'
{
CreateContactResponse -> Int
httpStatus :: Prelude.Int,
CreateContactResponse -> Text
contactArn :: Prelude.Text
}
deriving (CreateContactResponse -> CreateContactResponse -> Bool
(CreateContactResponse -> CreateContactResponse -> Bool)
-> (CreateContactResponse -> CreateContactResponse -> Bool)
-> Eq CreateContactResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateContactResponse -> CreateContactResponse -> Bool
$c/= :: CreateContactResponse -> CreateContactResponse -> Bool
== :: CreateContactResponse -> CreateContactResponse -> Bool
$c== :: CreateContactResponse -> CreateContactResponse -> Bool
Prelude.Eq, ReadPrec [CreateContactResponse]
ReadPrec CreateContactResponse
Int -> ReadS CreateContactResponse
ReadS [CreateContactResponse]
(Int -> ReadS CreateContactResponse)
-> ReadS [CreateContactResponse]
-> ReadPrec CreateContactResponse
-> ReadPrec [CreateContactResponse]
-> Read CreateContactResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateContactResponse]
$creadListPrec :: ReadPrec [CreateContactResponse]
readPrec :: ReadPrec CreateContactResponse
$creadPrec :: ReadPrec CreateContactResponse
readList :: ReadS [CreateContactResponse]
$creadList :: ReadS [CreateContactResponse]
readsPrec :: Int -> ReadS CreateContactResponse
$creadsPrec :: Int -> ReadS CreateContactResponse
Prelude.Read, Int -> CreateContactResponse -> ShowS
[CreateContactResponse] -> ShowS
CreateContactResponse -> String
(Int -> CreateContactResponse -> ShowS)
-> (CreateContactResponse -> String)
-> ([CreateContactResponse] -> ShowS)
-> Show CreateContactResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateContactResponse] -> ShowS
$cshowList :: [CreateContactResponse] -> ShowS
show :: CreateContactResponse -> String
$cshow :: CreateContactResponse -> String
showsPrec :: Int -> CreateContactResponse -> ShowS
$cshowsPrec :: Int -> CreateContactResponse -> ShowS
Prelude.Show, (forall x. CreateContactResponse -> Rep CreateContactResponse x)
-> (forall x. Rep CreateContactResponse x -> CreateContactResponse)
-> Generic CreateContactResponse
forall x. Rep CreateContactResponse x -> CreateContactResponse
forall x. CreateContactResponse -> Rep CreateContactResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateContactResponse x -> CreateContactResponse
$cfrom :: forall x. CreateContactResponse -> Rep CreateContactResponse x
Prelude.Generic)
newCreateContactResponse ::
Prelude.Int ->
Prelude.Text ->
CreateContactResponse
newCreateContactResponse :: Int -> Text -> CreateContactResponse
newCreateContactResponse Int
pHttpStatus_ Text
pContactArn_ =
CreateContactResponse' :: Int -> Text -> CreateContactResponse
CreateContactResponse'
{ $sel:httpStatus:CreateContactResponse' :: Int
httpStatus = Int
pHttpStatus_,
$sel:contactArn:CreateContactResponse' :: Text
contactArn = Text
pContactArn_
}
createContactResponse_httpStatus :: Lens.Lens' CreateContactResponse Prelude.Int
createContactResponse_httpStatus :: (Int -> f Int) -> CreateContactResponse -> f CreateContactResponse
createContactResponse_httpStatus = (CreateContactResponse -> Int)
-> (CreateContactResponse -> Int -> CreateContactResponse)
-> Lens CreateContactResponse CreateContactResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateContactResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateContactResponse' :: CreateContactResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateContactResponse
s@CreateContactResponse' {} Int
a -> CreateContactResponse
s {$sel:httpStatus:CreateContactResponse' :: Int
httpStatus = Int
a} :: CreateContactResponse)
createContactResponse_contactArn :: Lens.Lens' CreateContactResponse Prelude.Text
createContactResponse_contactArn :: (Text -> f Text)
-> CreateContactResponse -> f CreateContactResponse
createContactResponse_contactArn = (CreateContactResponse -> Text)
-> (CreateContactResponse -> Text -> CreateContactResponse)
-> Lens CreateContactResponse CreateContactResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateContactResponse' {Text
contactArn :: Text
$sel:contactArn:CreateContactResponse' :: CreateContactResponse -> Text
contactArn} -> Text
contactArn) (\s :: CreateContactResponse
s@CreateContactResponse' {} Text
a -> CreateContactResponse
s {$sel:contactArn:CreateContactResponse' :: Text
contactArn = Text
a} :: CreateContactResponse)
instance Prelude.NFData CreateContactResponse