{-# 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.Organizations.AcceptHandshake
(
AcceptHandshake (..),
newAcceptHandshake,
acceptHandshake_handshakeId,
AcceptHandshakeResponse (..),
newAcceptHandshakeResponse,
acceptHandshakeResponse_handshake,
acceptHandshakeResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Organizations.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data AcceptHandshake = AcceptHandshake'
{
AcceptHandshake -> Text
handshakeId :: Prelude.Text
}
deriving (AcceptHandshake -> AcceptHandshake -> Bool
(AcceptHandshake -> AcceptHandshake -> Bool)
-> (AcceptHandshake -> AcceptHandshake -> Bool)
-> Eq AcceptHandshake
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AcceptHandshake -> AcceptHandshake -> Bool
$c/= :: AcceptHandshake -> AcceptHandshake -> Bool
== :: AcceptHandshake -> AcceptHandshake -> Bool
$c== :: AcceptHandshake -> AcceptHandshake -> Bool
Prelude.Eq, ReadPrec [AcceptHandshake]
ReadPrec AcceptHandshake
Int -> ReadS AcceptHandshake
ReadS [AcceptHandshake]
(Int -> ReadS AcceptHandshake)
-> ReadS [AcceptHandshake]
-> ReadPrec AcceptHandshake
-> ReadPrec [AcceptHandshake]
-> Read AcceptHandshake
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AcceptHandshake]
$creadListPrec :: ReadPrec [AcceptHandshake]
readPrec :: ReadPrec AcceptHandshake
$creadPrec :: ReadPrec AcceptHandshake
readList :: ReadS [AcceptHandshake]
$creadList :: ReadS [AcceptHandshake]
readsPrec :: Int -> ReadS AcceptHandshake
$creadsPrec :: Int -> ReadS AcceptHandshake
Prelude.Read, Int -> AcceptHandshake -> ShowS
[AcceptHandshake] -> ShowS
AcceptHandshake -> String
(Int -> AcceptHandshake -> ShowS)
-> (AcceptHandshake -> String)
-> ([AcceptHandshake] -> ShowS)
-> Show AcceptHandshake
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AcceptHandshake] -> ShowS
$cshowList :: [AcceptHandshake] -> ShowS
show :: AcceptHandshake -> String
$cshow :: AcceptHandshake -> String
showsPrec :: Int -> AcceptHandshake -> ShowS
$cshowsPrec :: Int -> AcceptHandshake -> ShowS
Prelude.Show, (forall x. AcceptHandshake -> Rep AcceptHandshake x)
-> (forall x. Rep AcceptHandshake x -> AcceptHandshake)
-> Generic AcceptHandshake
forall x. Rep AcceptHandshake x -> AcceptHandshake
forall x. AcceptHandshake -> Rep AcceptHandshake x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AcceptHandshake x -> AcceptHandshake
$cfrom :: forall x. AcceptHandshake -> Rep AcceptHandshake x
Prelude.Generic)
newAcceptHandshake ::
Prelude.Text ->
AcceptHandshake
newAcceptHandshake :: Text -> AcceptHandshake
newAcceptHandshake Text
pHandshakeId_ =
AcceptHandshake' :: Text -> AcceptHandshake
AcceptHandshake' {$sel:handshakeId:AcceptHandshake' :: Text
handshakeId = Text
pHandshakeId_}
acceptHandshake_handshakeId :: Lens.Lens' AcceptHandshake Prelude.Text
acceptHandshake_handshakeId :: (Text -> f Text) -> AcceptHandshake -> f AcceptHandshake
acceptHandshake_handshakeId = (AcceptHandshake -> Text)
-> (AcceptHandshake -> Text -> AcceptHandshake)
-> Lens AcceptHandshake AcceptHandshake Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AcceptHandshake' {Text
handshakeId :: Text
$sel:handshakeId:AcceptHandshake' :: AcceptHandshake -> Text
handshakeId} -> Text
handshakeId) (\s :: AcceptHandshake
s@AcceptHandshake' {} Text
a -> AcceptHandshake
s {$sel:handshakeId:AcceptHandshake' :: Text
handshakeId = Text
a} :: AcceptHandshake)
instance Core.AWSRequest AcceptHandshake where
type
AWSResponse AcceptHandshake =
AcceptHandshakeResponse
request :: AcceptHandshake -> Request AcceptHandshake
request = Service -> AcceptHandshake -> Request AcceptHandshake
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy AcceptHandshake
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AcceptHandshake)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse AcceptHandshake))
-> Logger
-> Service
-> Proxy AcceptHandshake
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AcceptHandshake)))
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 Handshake -> Int -> AcceptHandshakeResponse
AcceptHandshakeResponse'
(Maybe Handshake -> Int -> AcceptHandshakeResponse)
-> Either String (Maybe Handshake)
-> Either String (Int -> AcceptHandshakeResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Handshake)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Handshake")
Either String (Int -> AcceptHandshakeResponse)
-> Either String Int -> Either String AcceptHandshakeResponse
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 AcceptHandshake
instance Prelude.NFData AcceptHandshake
instance Core.ToHeaders AcceptHandshake where
toHeaders :: AcceptHandshake -> ResponseHeaders
toHeaders =
ResponseHeaders -> AcceptHandshake -> 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
"AWSOrganizationsV20161128.AcceptHandshake" ::
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 AcceptHandshake where
toJSON :: AcceptHandshake -> Value
toJSON AcceptHandshake' {Text
handshakeId :: Text
$sel:handshakeId:AcceptHandshake' :: AcceptHandshake -> 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
"HandshakeId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
handshakeId)]
)
instance Core.ToPath AcceptHandshake where
toPath :: AcceptHandshake -> ByteString
toPath = ByteString -> AcceptHandshake -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery AcceptHandshake where
toQuery :: AcceptHandshake -> QueryString
toQuery = QueryString -> AcceptHandshake -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data AcceptHandshakeResponse = AcceptHandshakeResponse'
{
AcceptHandshakeResponse -> Maybe Handshake
handshake :: Prelude.Maybe Handshake,
AcceptHandshakeResponse -> Int
httpStatus :: Prelude.Int
}
deriving (AcceptHandshakeResponse -> AcceptHandshakeResponse -> Bool
(AcceptHandshakeResponse -> AcceptHandshakeResponse -> Bool)
-> (AcceptHandshakeResponse -> AcceptHandshakeResponse -> Bool)
-> Eq AcceptHandshakeResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AcceptHandshakeResponse -> AcceptHandshakeResponse -> Bool
$c/= :: AcceptHandshakeResponse -> AcceptHandshakeResponse -> Bool
== :: AcceptHandshakeResponse -> AcceptHandshakeResponse -> Bool
$c== :: AcceptHandshakeResponse -> AcceptHandshakeResponse -> Bool
Prelude.Eq, Int -> AcceptHandshakeResponse -> ShowS
[AcceptHandshakeResponse] -> ShowS
AcceptHandshakeResponse -> String
(Int -> AcceptHandshakeResponse -> ShowS)
-> (AcceptHandshakeResponse -> String)
-> ([AcceptHandshakeResponse] -> ShowS)
-> Show AcceptHandshakeResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AcceptHandshakeResponse] -> ShowS
$cshowList :: [AcceptHandshakeResponse] -> ShowS
show :: AcceptHandshakeResponse -> String
$cshow :: AcceptHandshakeResponse -> String
showsPrec :: Int -> AcceptHandshakeResponse -> ShowS
$cshowsPrec :: Int -> AcceptHandshakeResponse -> ShowS
Prelude.Show, (forall x.
AcceptHandshakeResponse -> Rep AcceptHandshakeResponse x)
-> (forall x.
Rep AcceptHandshakeResponse x -> AcceptHandshakeResponse)
-> Generic AcceptHandshakeResponse
forall x. Rep AcceptHandshakeResponse x -> AcceptHandshakeResponse
forall x. AcceptHandshakeResponse -> Rep AcceptHandshakeResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AcceptHandshakeResponse x -> AcceptHandshakeResponse
$cfrom :: forall x. AcceptHandshakeResponse -> Rep AcceptHandshakeResponse x
Prelude.Generic)
newAcceptHandshakeResponse ::
Prelude.Int ->
AcceptHandshakeResponse
newAcceptHandshakeResponse :: Int -> AcceptHandshakeResponse
newAcceptHandshakeResponse Int
pHttpStatus_ =
AcceptHandshakeResponse' :: Maybe Handshake -> Int -> AcceptHandshakeResponse
AcceptHandshakeResponse'
{ $sel:handshake:AcceptHandshakeResponse' :: Maybe Handshake
handshake =
Maybe Handshake
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:AcceptHandshakeResponse' :: Int
httpStatus = Int
pHttpStatus_
}
acceptHandshakeResponse_handshake :: Lens.Lens' AcceptHandshakeResponse (Prelude.Maybe Handshake)
acceptHandshakeResponse_handshake :: (Maybe Handshake -> f (Maybe Handshake))
-> AcceptHandshakeResponse -> f AcceptHandshakeResponse
acceptHandshakeResponse_handshake = (AcceptHandshakeResponse -> Maybe Handshake)
-> (AcceptHandshakeResponse
-> Maybe Handshake -> AcceptHandshakeResponse)
-> Lens
AcceptHandshakeResponse
AcceptHandshakeResponse
(Maybe Handshake)
(Maybe Handshake)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AcceptHandshakeResponse' {Maybe Handshake
handshake :: Maybe Handshake
$sel:handshake:AcceptHandshakeResponse' :: AcceptHandshakeResponse -> Maybe Handshake
handshake} -> Maybe Handshake
handshake) (\s :: AcceptHandshakeResponse
s@AcceptHandshakeResponse' {} Maybe Handshake
a -> AcceptHandshakeResponse
s {$sel:handshake:AcceptHandshakeResponse' :: Maybe Handshake
handshake = Maybe Handshake
a} :: AcceptHandshakeResponse)
acceptHandshakeResponse_httpStatus :: Lens.Lens' AcceptHandshakeResponse Prelude.Int
acceptHandshakeResponse_httpStatus :: (Int -> f Int)
-> AcceptHandshakeResponse -> f AcceptHandshakeResponse
acceptHandshakeResponse_httpStatus = (AcceptHandshakeResponse -> Int)
-> (AcceptHandshakeResponse -> Int -> AcceptHandshakeResponse)
-> Lens AcceptHandshakeResponse AcceptHandshakeResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AcceptHandshakeResponse' {Int
httpStatus :: Int
$sel:httpStatus:AcceptHandshakeResponse' :: AcceptHandshakeResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: AcceptHandshakeResponse
s@AcceptHandshakeResponse' {} Int
a -> AcceptHandshakeResponse
s {$sel:httpStatus:AcceptHandshakeResponse' :: Int
httpStatus = Int
a} :: AcceptHandshakeResponse)
instance Prelude.NFData AcceptHandshakeResponse