{-# 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.OpsWorksCM.RestoreServer
(
RestoreServer (..),
newRestoreServer,
restoreServer_keyPair,
restoreServer_instanceType,
restoreServer_backupId,
restoreServer_serverName,
RestoreServerResponse (..),
newRestoreServerResponse,
restoreServerResponse_server,
restoreServerResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.OpsWorksCM.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data RestoreServer = RestoreServer'
{
RestoreServer -> Maybe Text
keyPair :: Prelude.Maybe Prelude.Text,
RestoreServer -> Maybe Text
instanceType :: Prelude.Maybe Prelude.Text,
RestoreServer -> Text
backupId :: Prelude.Text,
RestoreServer -> Text
serverName :: Prelude.Text
}
deriving (RestoreServer -> RestoreServer -> Bool
(RestoreServer -> RestoreServer -> Bool)
-> (RestoreServer -> RestoreServer -> Bool) -> Eq RestoreServer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RestoreServer -> RestoreServer -> Bool
$c/= :: RestoreServer -> RestoreServer -> Bool
== :: RestoreServer -> RestoreServer -> Bool
$c== :: RestoreServer -> RestoreServer -> Bool
Prelude.Eq, ReadPrec [RestoreServer]
ReadPrec RestoreServer
Int -> ReadS RestoreServer
ReadS [RestoreServer]
(Int -> ReadS RestoreServer)
-> ReadS [RestoreServer]
-> ReadPrec RestoreServer
-> ReadPrec [RestoreServer]
-> Read RestoreServer
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RestoreServer]
$creadListPrec :: ReadPrec [RestoreServer]
readPrec :: ReadPrec RestoreServer
$creadPrec :: ReadPrec RestoreServer
readList :: ReadS [RestoreServer]
$creadList :: ReadS [RestoreServer]
readsPrec :: Int -> ReadS RestoreServer
$creadsPrec :: Int -> ReadS RestoreServer
Prelude.Read, Int -> RestoreServer -> ShowS
[RestoreServer] -> ShowS
RestoreServer -> String
(Int -> RestoreServer -> ShowS)
-> (RestoreServer -> String)
-> ([RestoreServer] -> ShowS)
-> Show RestoreServer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RestoreServer] -> ShowS
$cshowList :: [RestoreServer] -> ShowS
show :: RestoreServer -> String
$cshow :: RestoreServer -> String
showsPrec :: Int -> RestoreServer -> ShowS
$cshowsPrec :: Int -> RestoreServer -> ShowS
Prelude.Show, (forall x. RestoreServer -> Rep RestoreServer x)
-> (forall x. Rep RestoreServer x -> RestoreServer)
-> Generic RestoreServer
forall x. Rep RestoreServer x -> RestoreServer
forall x. RestoreServer -> Rep RestoreServer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RestoreServer x -> RestoreServer
$cfrom :: forall x. RestoreServer -> Rep RestoreServer x
Prelude.Generic)
newRestoreServer ::
Prelude.Text ->
Prelude.Text ->
RestoreServer
newRestoreServer :: Text -> Text -> RestoreServer
newRestoreServer Text
pBackupId_ Text
pServerName_ =
RestoreServer' :: Maybe Text -> Maybe Text -> Text -> Text -> RestoreServer
RestoreServer'
{ $sel:keyPair:RestoreServer' :: Maybe Text
keyPair = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:instanceType:RestoreServer' :: Maybe Text
instanceType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:backupId:RestoreServer' :: Text
backupId = Text
pBackupId_,
$sel:serverName:RestoreServer' :: Text
serverName = Text
pServerName_
}
restoreServer_keyPair :: Lens.Lens' RestoreServer (Prelude.Maybe Prelude.Text)
restoreServer_keyPair :: (Maybe Text -> f (Maybe Text)) -> RestoreServer -> f RestoreServer
restoreServer_keyPair = (RestoreServer -> Maybe Text)
-> (RestoreServer -> Maybe Text -> RestoreServer)
-> Lens RestoreServer RestoreServer (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RestoreServer' {Maybe Text
keyPair :: Maybe Text
$sel:keyPair:RestoreServer' :: RestoreServer -> Maybe Text
keyPair} -> Maybe Text
keyPair) (\s :: RestoreServer
s@RestoreServer' {} Maybe Text
a -> RestoreServer
s {$sel:keyPair:RestoreServer' :: Maybe Text
keyPair = Maybe Text
a} :: RestoreServer)
restoreServer_instanceType :: Lens.Lens' RestoreServer (Prelude.Maybe Prelude.Text)
restoreServer_instanceType :: (Maybe Text -> f (Maybe Text)) -> RestoreServer -> f RestoreServer
restoreServer_instanceType = (RestoreServer -> Maybe Text)
-> (RestoreServer -> Maybe Text -> RestoreServer)
-> Lens RestoreServer RestoreServer (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RestoreServer' {Maybe Text
instanceType :: Maybe Text
$sel:instanceType:RestoreServer' :: RestoreServer -> Maybe Text
instanceType} -> Maybe Text
instanceType) (\s :: RestoreServer
s@RestoreServer' {} Maybe Text
a -> RestoreServer
s {$sel:instanceType:RestoreServer' :: Maybe Text
instanceType = Maybe Text
a} :: RestoreServer)
restoreServer_backupId :: Lens.Lens' RestoreServer Prelude.Text
restoreServer_backupId :: (Text -> f Text) -> RestoreServer -> f RestoreServer
restoreServer_backupId = (RestoreServer -> Text)
-> (RestoreServer -> Text -> RestoreServer)
-> Lens RestoreServer RestoreServer Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RestoreServer' {Text
backupId :: Text
$sel:backupId:RestoreServer' :: RestoreServer -> Text
backupId} -> Text
backupId) (\s :: RestoreServer
s@RestoreServer' {} Text
a -> RestoreServer
s {$sel:backupId:RestoreServer' :: Text
backupId = Text
a} :: RestoreServer)
restoreServer_serverName :: Lens.Lens' RestoreServer Prelude.Text
restoreServer_serverName :: (Text -> f Text) -> RestoreServer -> f RestoreServer
restoreServer_serverName = (RestoreServer -> Text)
-> (RestoreServer -> Text -> RestoreServer)
-> Lens RestoreServer RestoreServer Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RestoreServer' {Text
serverName :: Text
$sel:serverName:RestoreServer' :: RestoreServer -> Text
serverName} -> Text
serverName) (\s :: RestoreServer
s@RestoreServer' {} Text
a -> RestoreServer
s {$sel:serverName:RestoreServer' :: Text
serverName = Text
a} :: RestoreServer)
instance Core.AWSRequest RestoreServer where
type
AWSResponse RestoreServer =
RestoreServerResponse
request :: RestoreServer -> Request RestoreServer
request = Service -> RestoreServer -> Request RestoreServer
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy RestoreServer
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RestoreServer)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse RestoreServer))
-> Logger
-> Service
-> Proxy RestoreServer
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RestoreServer)))
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 Server -> Int -> RestoreServerResponse
RestoreServerResponse'
(Maybe Server -> Int -> RestoreServerResponse)
-> Either String (Maybe Server)
-> Either String (Int -> RestoreServerResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Server)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Server")
Either String (Int -> RestoreServerResponse)
-> Either String Int -> Either String RestoreServerResponse
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 RestoreServer
instance Prelude.NFData RestoreServer
instance Core.ToHeaders RestoreServer where
toHeaders :: RestoreServer -> ResponseHeaders
toHeaders =
ResponseHeaders -> RestoreServer -> 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
"OpsWorksCM_V2016_11_01.RestoreServer" ::
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 RestoreServer where
toJSON :: RestoreServer -> Value
toJSON RestoreServer' {Maybe Text
Text
serverName :: Text
backupId :: Text
instanceType :: Maybe Text
keyPair :: Maybe Text
$sel:serverName:RestoreServer' :: RestoreServer -> Text
$sel:backupId:RestoreServer' :: RestoreServer -> Text
$sel:instanceType:RestoreServer' :: RestoreServer -> Maybe Text
$sel:keyPair:RestoreServer' :: RestoreServer -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"KeyPair" 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
keyPair,
(Text
"InstanceType" 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
instanceType,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"BackupId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
backupId),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ServerName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
serverName)
]
)
instance Core.ToPath RestoreServer where
toPath :: RestoreServer -> ByteString
toPath = ByteString -> RestoreServer -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery RestoreServer where
toQuery :: RestoreServer -> QueryString
toQuery = QueryString -> RestoreServer -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data RestoreServerResponse = RestoreServerResponse'
{ RestoreServerResponse -> Maybe Server
server :: Prelude.Maybe Server,
RestoreServerResponse -> Int
httpStatus :: Prelude.Int
}
deriving (RestoreServerResponse -> RestoreServerResponse -> Bool
(RestoreServerResponse -> RestoreServerResponse -> Bool)
-> (RestoreServerResponse -> RestoreServerResponse -> Bool)
-> Eq RestoreServerResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RestoreServerResponse -> RestoreServerResponse -> Bool
$c/= :: RestoreServerResponse -> RestoreServerResponse -> Bool
== :: RestoreServerResponse -> RestoreServerResponse -> Bool
$c== :: RestoreServerResponse -> RestoreServerResponse -> Bool
Prelude.Eq, Int -> RestoreServerResponse -> ShowS
[RestoreServerResponse] -> ShowS
RestoreServerResponse -> String
(Int -> RestoreServerResponse -> ShowS)
-> (RestoreServerResponse -> String)
-> ([RestoreServerResponse] -> ShowS)
-> Show RestoreServerResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RestoreServerResponse] -> ShowS
$cshowList :: [RestoreServerResponse] -> ShowS
show :: RestoreServerResponse -> String
$cshow :: RestoreServerResponse -> String
showsPrec :: Int -> RestoreServerResponse -> ShowS
$cshowsPrec :: Int -> RestoreServerResponse -> ShowS
Prelude.Show, (forall x. RestoreServerResponse -> Rep RestoreServerResponse x)
-> (forall x. Rep RestoreServerResponse x -> RestoreServerResponse)
-> Generic RestoreServerResponse
forall x. Rep RestoreServerResponse x -> RestoreServerResponse
forall x. RestoreServerResponse -> Rep RestoreServerResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RestoreServerResponse x -> RestoreServerResponse
$cfrom :: forall x. RestoreServerResponse -> Rep RestoreServerResponse x
Prelude.Generic)
newRestoreServerResponse ::
Prelude.Int ->
RestoreServerResponse
newRestoreServerResponse :: Int -> RestoreServerResponse
newRestoreServerResponse Int
pHttpStatus_ =
RestoreServerResponse' :: Maybe Server -> Int -> RestoreServerResponse
RestoreServerResponse'
{ $sel:server:RestoreServerResponse' :: Maybe Server
server = Maybe Server
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:RestoreServerResponse' :: Int
httpStatus = Int
pHttpStatus_
}
restoreServerResponse_server :: Lens.Lens' RestoreServerResponse (Prelude.Maybe Server)
restoreServerResponse_server :: (Maybe Server -> f (Maybe Server))
-> RestoreServerResponse -> f RestoreServerResponse
restoreServerResponse_server = (RestoreServerResponse -> Maybe Server)
-> (RestoreServerResponse -> Maybe Server -> RestoreServerResponse)
-> Lens
RestoreServerResponse
RestoreServerResponse
(Maybe Server)
(Maybe Server)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RestoreServerResponse' {Maybe Server
server :: Maybe Server
$sel:server:RestoreServerResponse' :: RestoreServerResponse -> Maybe Server
server} -> Maybe Server
server) (\s :: RestoreServerResponse
s@RestoreServerResponse' {} Maybe Server
a -> RestoreServerResponse
s {$sel:server:RestoreServerResponse' :: Maybe Server
server = Maybe Server
a} :: RestoreServerResponse)
restoreServerResponse_httpStatus :: Lens.Lens' RestoreServerResponse Prelude.Int
restoreServerResponse_httpStatus :: (Int -> f Int) -> RestoreServerResponse -> f RestoreServerResponse
restoreServerResponse_httpStatus = (RestoreServerResponse -> Int)
-> (RestoreServerResponse -> Int -> RestoreServerResponse)
-> Lens RestoreServerResponse RestoreServerResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RestoreServerResponse' {Int
httpStatus :: Int
$sel:httpStatus:RestoreServerResponse' :: RestoreServerResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: RestoreServerResponse
s@RestoreServerResponse' {} Int
a -> RestoreServerResponse
s {$sel:httpStatus:RestoreServerResponse' :: Int
httpStatus = Int
a} :: RestoreServerResponse)
instance Prelude.NFData RestoreServerResponse