{-# 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.CodeStarNotifications.Subscribe
(
Subscribe (..),
newSubscribe,
subscribe_clientRequestToken,
subscribe_arn,
subscribe_target,
SubscribeResponse (..),
newSubscribeResponse,
subscribeResponse_arn,
subscribeResponse_httpStatus,
)
where
import Amazonka.CodeStarNotifications.Types
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
data Subscribe = Subscribe'
{
Subscribe -> Maybe Text
clientRequestToken :: Prelude.Maybe Prelude.Text,
Subscribe -> Text
arn :: Prelude.Text,
Subscribe -> Target
target :: Target
}
deriving (Subscribe -> Subscribe -> Bool
(Subscribe -> Subscribe -> Bool)
-> (Subscribe -> Subscribe -> Bool) -> Eq Subscribe
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Subscribe -> Subscribe -> Bool
$c/= :: Subscribe -> Subscribe -> Bool
== :: Subscribe -> Subscribe -> Bool
$c== :: Subscribe -> Subscribe -> Bool
Prelude.Eq, Int -> Subscribe -> ShowS
[Subscribe] -> ShowS
Subscribe -> String
(Int -> Subscribe -> ShowS)
-> (Subscribe -> String)
-> ([Subscribe] -> ShowS)
-> Show Subscribe
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Subscribe] -> ShowS
$cshowList :: [Subscribe] -> ShowS
show :: Subscribe -> String
$cshow :: Subscribe -> String
showsPrec :: Int -> Subscribe -> ShowS
$cshowsPrec :: Int -> Subscribe -> ShowS
Prelude.Show, (forall x. Subscribe -> Rep Subscribe x)
-> (forall x. Rep Subscribe x -> Subscribe) -> Generic Subscribe
forall x. Rep Subscribe x -> Subscribe
forall x. Subscribe -> Rep Subscribe x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Subscribe x -> Subscribe
$cfrom :: forall x. Subscribe -> Rep Subscribe x
Prelude.Generic)
newSubscribe ::
Prelude.Text ->
Target ->
Subscribe
newSubscribe :: Text -> Target -> Subscribe
newSubscribe Text
pArn_ Target
pTarget_ =
Subscribe' :: Maybe Text -> Text -> Target -> Subscribe
Subscribe'
{ $sel:clientRequestToken:Subscribe' :: Maybe Text
clientRequestToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:arn:Subscribe' :: Text
arn = Text
pArn_,
$sel:target:Subscribe' :: Target
target = Target
pTarget_
}
subscribe_clientRequestToken :: Lens.Lens' Subscribe (Prelude.Maybe Prelude.Text)
subscribe_clientRequestToken :: (Maybe Text -> f (Maybe Text)) -> Subscribe -> f Subscribe
subscribe_clientRequestToken = (Subscribe -> Maybe Text)
-> (Subscribe -> Maybe Text -> Subscribe)
-> Lens Subscribe Subscribe (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Subscribe' {Maybe Text
clientRequestToken :: Maybe Text
$sel:clientRequestToken:Subscribe' :: Subscribe -> Maybe Text
clientRequestToken} -> Maybe Text
clientRequestToken) (\s :: Subscribe
s@Subscribe' {} Maybe Text
a -> Subscribe
s {$sel:clientRequestToken:Subscribe' :: Maybe Text
clientRequestToken = Maybe Text
a} :: Subscribe)
subscribe_arn :: Lens.Lens' Subscribe Prelude.Text
subscribe_arn :: (Text -> f Text) -> Subscribe -> f Subscribe
subscribe_arn = (Subscribe -> Text)
-> (Subscribe -> Text -> Subscribe)
-> Lens Subscribe Subscribe Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Subscribe' {Text
arn :: Text
$sel:arn:Subscribe' :: Subscribe -> Text
arn} -> Text
arn) (\s :: Subscribe
s@Subscribe' {} Text
a -> Subscribe
s {$sel:arn:Subscribe' :: Text
arn = Text
a} :: Subscribe)
subscribe_target :: Lens.Lens' Subscribe Target
subscribe_target :: (Target -> f Target) -> Subscribe -> f Subscribe
subscribe_target = (Subscribe -> Target)
-> (Subscribe -> Target -> Subscribe)
-> Lens Subscribe Subscribe Target Target
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Subscribe' {Target
target :: Target
$sel:target:Subscribe' :: Subscribe -> Target
target} -> Target
target) (\s :: Subscribe
s@Subscribe' {} Target
a -> Subscribe
s {$sel:target:Subscribe' :: Target
target = Target
a} :: Subscribe)
instance Core.AWSRequest Subscribe where
type AWSResponse Subscribe = SubscribeResponse
request :: Subscribe -> Request Subscribe
request = Service -> Subscribe -> Request Subscribe
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy Subscribe
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse Subscribe)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse Subscribe))
-> Logger
-> Service
-> Proxy Subscribe
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse Subscribe)))
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 -> SubscribeResponse
SubscribeResponse'
(Maybe Text -> Int -> SubscribeResponse)
-> Either String (Maybe Text)
-> Either String (Int -> SubscribeResponse)
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
"Arn")
Either String (Int -> SubscribeResponse)
-> Either String Int -> Either String SubscribeResponse
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 Subscribe
instance Prelude.NFData Subscribe
instance Core.ToHeaders Subscribe where
toHeaders :: Subscribe -> ResponseHeaders
toHeaders =
ResponseHeaders -> Subscribe -> 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 Subscribe where
toJSON :: Subscribe -> Value
toJSON Subscribe' {Maybe Text
Text
Target
target :: Target
arn :: Text
clientRequestToken :: Maybe Text
$sel:target:Subscribe' :: Subscribe -> Target
$sel:arn:Subscribe' :: Subscribe -> Text
$sel:clientRequestToken:Subscribe' :: Subscribe -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"ClientRequestToken" 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
clientRequestToken,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Arn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
arn),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Target" Text -> Target -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Target
target)
]
)
instance Core.ToPath Subscribe where
toPath :: Subscribe -> ByteString
toPath = ByteString -> Subscribe -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/subscribe"
instance Core.ToQuery Subscribe where
toQuery :: Subscribe -> QueryString
toQuery = QueryString -> Subscribe -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data SubscribeResponse = SubscribeResponse'
{
SubscribeResponse -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
SubscribeResponse -> Int
httpStatus :: Prelude.Int
}
deriving (SubscribeResponse -> SubscribeResponse -> Bool
(SubscribeResponse -> SubscribeResponse -> Bool)
-> (SubscribeResponse -> SubscribeResponse -> Bool)
-> Eq SubscribeResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SubscribeResponse -> SubscribeResponse -> Bool
$c/= :: SubscribeResponse -> SubscribeResponse -> Bool
== :: SubscribeResponse -> SubscribeResponse -> Bool
$c== :: SubscribeResponse -> SubscribeResponse -> Bool
Prelude.Eq, ReadPrec [SubscribeResponse]
ReadPrec SubscribeResponse
Int -> ReadS SubscribeResponse
ReadS [SubscribeResponse]
(Int -> ReadS SubscribeResponse)
-> ReadS [SubscribeResponse]
-> ReadPrec SubscribeResponse
-> ReadPrec [SubscribeResponse]
-> Read SubscribeResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SubscribeResponse]
$creadListPrec :: ReadPrec [SubscribeResponse]
readPrec :: ReadPrec SubscribeResponse
$creadPrec :: ReadPrec SubscribeResponse
readList :: ReadS [SubscribeResponse]
$creadList :: ReadS [SubscribeResponse]
readsPrec :: Int -> ReadS SubscribeResponse
$creadsPrec :: Int -> ReadS SubscribeResponse
Prelude.Read, Int -> SubscribeResponse -> ShowS
[SubscribeResponse] -> ShowS
SubscribeResponse -> String
(Int -> SubscribeResponse -> ShowS)
-> (SubscribeResponse -> String)
-> ([SubscribeResponse] -> ShowS)
-> Show SubscribeResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SubscribeResponse] -> ShowS
$cshowList :: [SubscribeResponse] -> ShowS
show :: SubscribeResponse -> String
$cshow :: SubscribeResponse -> String
showsPrec :: Int -> SubscribeResponse -> ShowS
$cshowsPrec :: Int -> SubscribeResponse -> ShowS
Prelude.Show, (forall x. SubscribeResponse -> Rep SubscribeResponse x)
-> (forall x. Rep SubscribeResponse x -> SubscribeResponse)
-> Generic SubscribeResponse
forall x. Rep SubscribeResponse x -> SubscribeResponse
forall x. SubscribeResponse -> Rep SubscribeResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SubscribeResponse x -> SubscribeResponse
$cfrom :: forall x. SubscribeResponse -> Rep SubscribeResponse x
Prelude.Generic)
newSubscribeResponse ::
Prelude.Int ->
SubscribeResponse
newSubscribeResponse :: Int -> SubscribeResponse
newSubscribeResponse Int
pHttpStatus_ =
SubscribeResponse' :: Maybe Text -> Int -> SubscribeResponse
SubscribeResponse'
{ $sel:arn:SubscribeResponse' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:SubscribeResponse' :: Int
httpStatus = Int
pHttpStatus_
}
subscribeResponse_arn :: Lens.Lens' SubscribeResponse (Prelude.Maybe Prelude.Text)
subscribeResponse_arn :: (Maybe Text -> f (Maybe Text))
-> SubscribeResponse -> f SubscribeResponse
subscribeResponse_arn = (SubscribeResponse -> Maybe Text)
-> (SubscribeResponse -> Maybe Text -> SubscribeResponse)
-> Lens
SubscribeResponse SubscribeResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SubscribeResponse' {Maybe Text
arn :: Maybe Text
$sel:arn:SubscribeResponse' :: SubscribeResponse -> Maybe Text
arn} -> Maybe Text
arn) (\s :: SubscribeResponse
s@SubscribeResponse' {} Maybe Text
a -> SubscribeResponse
s {$sel:arn:SubscribeResponse' :: Maybe Text
arn = Maybe Text
a} :: SubscribeResponse)
subscribeResponse_httpStatus :: Lens.Lens' SubscribeResponse Prelude.Int
subscribeResponse_httpStatus :: (Int -> f Int) -> SubscribeResponse -> f SubscribeResponse
subscribeResponse_httpStatus = (SubscribeResponse -> Int)
-> (SubscribeResponse -> Int -> SubscribeResponse)
-> Lens SubscribeResponse SubscribeResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SubscribeResponse' {Int
httpStatus :: Int
$sel:httpStatus:SubscribeResponse' :: SubscribeResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: SubscribeResponse
s@SubscribeResponse' {} Int
a -> SubscribeResponse
s {$sel:httpStatus:SubscribeResponse' :: Int
httpStatus = Int
a} :: SubscribeResponse)
instance Prelude.NFData SubscribeResponse