{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Network.AWS.Lightsail.CreateKeyPair
(
createKeyPair
, CreateKeyPair
, ckpKeyPairName
, createKeyPairResponse
, CreateKeyPairResponse
, ckprsKeyPair
, ckprsOperation
, ckprsPublicKeyBase64
, ckprsPrivateKeyBase64
, ckprsResponseStatus
) where
import Network.AWS.Lens
import Network.AWS.Lightsail.Types
import Network.AWS.Lightsail.Types.Product
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
newtype CreateKeyPair = CreateKeyPair'
{ _ckpKeyPairName :: Text
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createKeyPair
:: Text
-> CreateKeyPair
createKeyPair pKeyPairName_ = CreateKeyPair' {_ckpKeyPairName = pKeyPairName_}
ckpKeyPairName :: Lens' CreateKeyPair Text
ckpKeyPairName = lens _ckpKeyPairName (\ s a -> s{_ckpKeyPairName = a})
instance AWSRequest CreateKeyPair where
type Rs CreateKeyPair = CreateKeyPairResponse
request = postJSON lightsail
response
= receiveJSON
(\ s h x ->
CreateKeyPairResponse' <$>
(x .?> "keyPair") <*> (x .?> "operation") <*>
(x .?> "publicKeyBase64")
<*> (x .?> "privateKeyBase64")
<*> (pure (fromEnum s)))
instance Hashable CreateKeyPair where
instance NFData CreateKeyPair where
instance ToHeaders CreateKeyPair where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("Lightsail_20161128.CreateKeyPair" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON CreateKeyPair where
toJSON CreateKeyPair'{..}
= object
(catMaybes [Just ("keyPairName" .= _ckpKeyPairName)])
instance ToPath CreateKeyPair where
toPath = const "/"
instance ToQuery CreateKeyPair where
toQuery = const mempty
data CreateKeyPairResponse = CreateKeyPairResponse'
{ _ckprsKeyPair :: !(Maybe KeyPair)
, _ckprsOperation :: !(Maybe Operation)
, _ckprsPublicKeyBase64 :: !(Maybe Text)
, _ckprsPrivateKeyBase64 :: !(Maybe Text)
, _ckprsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createKeyPairResponse
:: Int
-> CreateKeyPairResponse
createKeyPairResponse pResponseStatus_ =
CreateKeyPairResponse'
{ _ckprsKeyPair = Nothing
, _ckprsOperation = Nothing
, _ckprsPublicKeyBase64 = Nothing
, _ckprsPrivateKeyBase64 = Nothing
, _ckprsResponseStatus = pResponseStatus_
}
ckprsKeyPair :: Lens' CreateKeyPairResponse (Maybe KeyPair)
ckprsKeyPair = lens _ckprsKeyPair (\ s a -> s{_ckprsKeyPair = a})
ckprsOperation :: Lens' CreateKeyPairResponse (Maybe Operation)
ckprsOperation = lens _ckprsOperation (\ s a -> s{_ckprsOperation = a})
ckprsPublicKeyBase64 :: Lens' CreateKeyPairResponse (Maybe Text)
ckprsPublicKeyBase64 = lens _ckprsPublicKeyBase64 (\ s a -> s{_ckprsPublicKeyBase64 = a})
ckprsPrivateKeyBase64 :: Lens' CreateKeyPairResponse (Maybe Text)
ckprsPrivateKeyBase64 = lens _ckprsPrivateKeyBase64 (\ s a -> s{_ckprsPrivateKeyBase64 = a})
ckprsResponseStatus :: Lens' CreateKeyPairResponse Int
ckprsResponseStatus = lens _ckprsResponseStatus (\ s a -> s{_ckprsResponseStatus = a})
instance NFData CreateKeyPairResponse where