{-# 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.Unsubscribe
(
Unsubscribe (..),
newUnsubscribe,
unsubscribe_arn,
unsubscribe_targetAddress,
UnsubscribeResponse (..),
newUnsubscribeResponse,
unsubscribeResponse_httpStatus,
unsubscribeResponse_arn,
)
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 Unsubscribe = Unsubscribe'
{
Unsubscribe -> Text
arn :: Prelude.Text,
Unsubscribe -> Sensitive Text
targetAddress :: Core.Sensitive Prelude.Text
}
deriving (Unsubscribe -> Unsubscribe -> Bool
(Unsubscribe -> Unsubscribe -> Bool)
-> (Unsubscribe -> Unsubscribe -> Bool) -> Eq Unsubscribe
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Unsubscribe -> Unsubscribe -> Bool
$c/= :: Unsubscribe -> Unsubscribe -> Bool
== :: Unsubscribe -> Unsubscribe -> Bool
$c== :: Unsubscribe -> Unsubscribe -> Bool
Prelude.Eq, Int -> Unsubscribe -> ShowS
[Unsubscribe] -> ShowS
Unsubscribe -> String
(Int -> Unsubscribe -> ShowS)
-> (Unsubscribe -> String)
-> ([Unsubscribe] -> ShowS)
-> Show Unsubscribe
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Unsubscribe] -> ShowS
$cshowList :: [Unsubscribe] -> ShowS
show :: Unsubscribe -> String
$cshow :: Unsubscribe -> String
showsPrec :: Int -> Unsubscribe -> ShowS
$cshowsPrec :: Int -> Unsubscribe -> ShowS
Prelude.Show, (forall x. Unsubscribe -> Rep Unsubscribe x)
-> (forall x. Rep Unsubscribe x -> Unsubscribe)
-> Generic Unsubscribe
forall x. Rep Unsubscribe x -> Unsubscribe
forall x. Unsubscribe -> Rep Unsubscribe x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Unsubscribe x -> Unsubscribe
$cfrom :: forall x. Unsubscribe -> Rep Unsubscribe x
Prelude.Generic)
newUnsubscribe ::
Prelude.Text ->
Prelude.Text ->
Unsubscribe
newUnsubscribe :: Text -> Text -> Unsubscribe
newUnsubscribe Text
pArn_ Text
pTargetAddress_ =
Unsubscribe' :: Text -> Sensitive Text -> Unsubscribe
Unsubscribe'
{ $sel:arn:Unsubscribe' :: Text
arn = Text
pArn_,
$sel:targetAddress:Unsubscribe' :: Sensitive Text
targetAddress =
Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pTargetAddress_
}
unsubscribe_arn :: Lens.Lens' Unsubscribe Prelude.Text
unsubscribe_arn :: (Text -> f Text) -> Unsubscribe -> f Unsubscribe
unsubscribe_arn = (Unsubscribe -> Text)
-> (Unsubscribe -> Text -> Unsubscribe)
-> Lens Unsubscribe Unsubscribe Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Unsubscribe' {Text
arn :: Text
$sel:arn:Unsubscribe' :: Unsubscribe -> Text
arn} -> Text
arn) (\s :: Unsubscribe
s@Unsubscribe' {} Text
a -> Unsubscribe
s {$sel:arn:Unsubscribe' :: Text
arn = Text
a} :: Unsubscribe)
unsubscribe_targetAddress :: Lens.Lens' Unsubscribe Prelude.Text
unsubscribe_targetAddress :: (Text -> f Text) -> Unsubscribe -> f Unsubscribe
unsubscribe_targetAddress = (Unsubscribe -> Sensitive Text)
-> (Unsubscribe -> Sensitive Text -> Unsubscribe)
-> Lens Unsubscribe Unsubscribe (Sensitive Text) (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Unsubscribe' {Sensitive Text
targetAddress :: Sensitive Text
$sel:targetAddress:Unsubscribe' :: Unsubscribe -> Sensitive Text
targetAddress} -> Sensitive Text
targetAddress) (\s :: Unsubscribe
s@Unsubscribe' {} Sensitive Text
a -> Unsubscribe
s {$sel:targetAddress:Unsubscribe' :: Sensitive Text
targetAddress = Sensitive Text
a} :: Unsubscribe) ((Sensitive Text -> f (Sensitive Text))
-> Unsubscribe -> f Unsubscribe)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> Unsubscribe
-> f Unsubscribe
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive
instance Core.AWSRequest Unsubscribe where
type AWSResponse Unsubscribe = UnsubscribeResponse
request :: Unsubscribe -> Request Unsubscribe
request = Service -> Unsubscribe -> Request Unsubscribe
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy Unsubscribe
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse Unsubscribe)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse Unsubscribe))
-> Logger
-> Service
-> Proxy Unsubscribe
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse Unsubscribe)))
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 -> UnsubscribeResponse
UnsubscribeResponse'
(Int -> Text -> UnsubscribeResponse)
-> Either String Int -> Either String (Text -> UnsubscribeResponse)
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 -> UnsubscribeResponse)
-> Either String Text -> Either String UnsubscribeResponse
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
"Arn")
)
instance Prelude.Hashable Unsubscribe
instance Prelude.NFData Unsubscribe
instance Core.ToHeaders Unsubscribe where
toHeaders :: Unsubscribe -> ResponseHeaders
toHeaders =
ResponseHeaders -> Unsubscribe -> 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 Unsubscribe where
toJSON :: Unsubscribe -> Value
toJSON Unsubscribe' {Text
Sensitive Text
targetAddress :: Sensitive Text
arn :: Text
$sel:targetAddress:Unsubscribe' :: Unsubscribe -> Sensitive Text
$sel:arn:Unsubscribe' :: Unsubscribe -> Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ 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
"TargetAddress" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Text
targetAddress)
]
)
instance Core.ToPath Unsubscribe where
toPath :: Unsubscribe -> ByteString
toPath = ByteString -> Unsubscribe -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/unsubscribe"
instance Core.ToQuery Unsubscribe where
toQuery :: Unsubscribe -> QueryString
toQuery = QueryString -> Unsubscribe -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data UnsubscribeResponse = UnsubscribeResponse'
{
UnsubscribeResponse -> Int
httpStatus :: Prelude.Int,
UnsubscribeResponse -> Text
arn :: Prelude.Text
}
deriving (UnsubscribeResponse -> UnsubscribeResponse -> Bool
(UnsubscribeResponse -> UnsubscribeResponse -> Bool)
-> (UnsubscribeResponse -> UnsubscribeResponse -> Bool)
-> Eq UnsubscribeResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UnsubscribeResponse -> UnsubscribeResponse -> Bool
$c/= :: UnsubscribeResponse -> UnsubscribeResponse -> Bool
== :: UnsubscribeResponse -> UnsubscribeResponse -> Bool
$c== :: UnsubscribeResponse -> UnsubscribeResponse -> Bool
Prelude.Eq, ReadPrec [UnsubscribeResponse]
ReadPrec UnsubscribeResponse
Int -> ReadS UnsubscribeResponse
ReadS [UnsubscribeResponse]
(Int -> ReadS UnsubscribeResponse)
-> ReadS [UnsubscribeResponse]
-> ReadPrec UnsubscribeResponse
-> ReadPrec [UnsubscribeResponse]
-> Read UnsubscribeResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UnsubscribeResponse]
$creadListPrec :: ReadPrec [UnsubscribeResponse]
readPrec :: ReadPrec UnsubscribeResponse
$creadPrec :: ReadPrec UnsubscribeResponse
readList :: ReadS [UnsubscribeResponse]
$creadList :: ReadS [UnsubscribeResponse]
readsPrec :: Int -> ReadS UnsubscribeResponse
$creadsPrec :: Int -> ReadS UnsubscribeResponse
Prelude.Read, Int -> UnsubscribeResponse -> ShowS
[UnsubscribeResponse] -> ShowS
UnsubscribeResponse -> String
(Int -> UnsubscribeResponse -> ShowS)
-> (UnsubscribeResponse -> String)
-> ([UnsubscribeResponse] -> ShowS)
-> Show UnsubscribeResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UnsubscribeResponse] -> ShowS
$cshowList :: [UnsubscribeResponse] -> ShowS
show :: UnsubscribeResponse -> String
$cshow :: UnsubscribeResponse -> String
showsPrec :: Int -> UnsubscribeResponse -> ShowS
$cshowsPrec :: Int -> UnsubscribeResponse -> ShowS
Prelude.Show, (forall x. UnsubscribeResponse -> Rep UnsubscribeResponse x)
-> (forall x. Rep UnsubscribeResponse x -> UnsubscribeResponse)
-> Generic UnsubscribeResponse
forall x. Rep UnsubscribeResponse x -> UnsubscribeResponse
forall x. UnsubscribeResponse -> Rep UnsubscribeResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UnsubscribeResponse x -> UnsubscribeResponse
$cfrom :: forall x. UnsubscribeResponse -> Rep UnsubscribeResponse x
Prelude.Generic)
newUnsubscribeResponse ::
Prelude.Int ->
Prelude.Text ->
UnsubscribeResponse
newUnsubscribeResponse :: Int -> Text -> UnsubscribeResponse
newUnsubscribeResponse Int
pHttpStatus_ Text
pArn_ =
UnsubscribeResponse' :: Int -> Text -> UnsubscribeResponse
UnsubscribeResponse'
{ $sel:httpStatus:UnsubscribeResponse' :: Int
httpStatus = Int
pHttpStatus_,
$sel:arn:UnsubscribeResponse' :: Text
arn = Text
pArn_
}
unsubscribeResponse_httpStatus :: Lens.Lens' UnsubscribeResponse Prelude.Int
unsubscribeResponse_httpStatus :: (Int -> f Int) -> UnsubscribeResponse -> f UnsubscribeResponse
unsubscribeResponse_httpStatus = (UnsubscribeResponse -> Int)
-> (UnsubscribeResponse -> Int -> UnsubscribeResponse)
-> Lens UnsubscribeResponse UnsubscribeResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UnsubscribeResponse' {Int
httpStatus :: Int
$sel:httpStatus:UnsubscribeResponse' :: UnsubscribeResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: UnsubscribeResponse
s@UnsubscribeResponse' {} Int
a -> UnsubscribeResponse
s {$sel:httpStatus:UnsubscribeResponse' :: Int
httpStatus = Int
a} :: UnsubscribeResponse)
unsubscribeResponse_arn :: Lens.Lens' UnsubscribeResponse Prelude.Text
unsubscribeResponse_arn :: (Text -> f Text) -> UnsubscribeResponse -> f UnsubscribeResponse
unsubscribeResponse_arn = (UnsubscribeResponse -> Text)
-> (UnsubscribeResponse -> Text -> UnsubscribeResponse)
-> Lens UnsubscribeResponse UnsubscribeResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UnsubscribeResponse' {Text
arn :: Text
$sel:arn:UnsubscribeResponse' :: UnsubscribeResponse -> Text
arn} -> Text
arn) (\s :: UnsubscribeResponse
s@UnsubscribeResponse' {} Text
a -> UnsubscribeResponse
s {$sel:arn:UnsubscribeResponse' :: Text
arn = Text
a} :: UnsubscribeResponse)
instance Prelude.NFData UnsubscribeResponse