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