{-# 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.GetDisk
(
GetDisk (..),
newGetDisk,
getDisk_diskName,
GetDiskResponse (..),
newGetDiskResponse,
getDiskResponse_disk,
getDiskResponse_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 GetDisk = GetDisk'
{
GetDisk -> Text
diskName :: Prelude.Text
}
deriving (GetDisk -> GetDisk -> Bool
(GetDisk -> GetDisk -> Bool)
-> (GetDisk -> GetDisk -> Bool) -> Eq GetDisk
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDisk -> GetDisk -> Bool
$c/= :: GetDisk -> GetDisk -> Bool
== :: GetDisk -> GetDisk -> Bool
$c== :: GetDisk -> GetDisk -> Bool
Prelude.Eq, ReadPrec [GetDisk]
ReadPrec GetDisk
Int -> ReadS GetDisk
ReadS [GetDisk]
(Int -> ReadS GetDisk)
-> ReadS [GetDisk]
-> ReadPrec GetDisk
-> ReadPrec [GetDisk]
-> Read GetDisk
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDisk]
$creadListPrec :: ReadPrec [GetDisk]
readPrec :: ReadPrec GetDisk
$creadPrec :: ReadPrec GetDisk
readList :: ReadS [GetDisk]
$creadList :: ReadS [GetDisk]
readsPrec :: Int -> ReadS GetDisk
$creadsPrec :: Int -> ReadS GetDisk
Prelude.Read, Int -> GetDisk -> ShowS
[GetDisk] -> ShowS
GetDisk -> String
(Int -> GetDisk -> ShowS)
-> (GetDisk -> String) -> ([GetDisk] -> ShowS) -> Show GetDisk
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDisk] -> ShowS
$cshowList :: [GetDisk] -> ShowS
show :: GetDisk -> String
$cshow :: GetDisk -> String
showsPrec :: Int -> GetDisk -> ShowS
$cshowsPrec :: Int -> GetDisk -> ShowS
Prelude.Show, (forall x. GetDisk -> Rep GetDisk x)
-> (forall x. Rep GetDisk x -> GetDisk) -> Generic GetDisk
forall x. Rep GetDisk x -> GetDisk
forall x. GetDisk -> Rep GetDisk x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDisk x -> GetDisk
$cfrom :: forall x. GetDisk -> Rep GetDisk x
Prelude.Generic)
newGetDisk ::
Prelude.Text ->
GetDisk
newGetDisk :: Text -> GetDisk
newGetDisk Text
pDiskName_ =
GetDisk' :: Text -> GetDisk
GetDisk' {$sel:diskName:GetDisk' :: Text
diskName = Text
pDiskName_}
getDisk_diskName :: Lens.Lens' GetDisk Prelude.Text
getDisk_diskName :: (Text -> f Text) -> GetDisk -> f GetDisk
getDisk_diskName = (GetDisk -> Text)
-> (GetDisk -> Text -> GetDisk) -> Lens GetDisk GetDisk Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDisk' {Text
diskName :: Text
$sel:diskName:GetDisk' :: GetDisk -> Text
diskName} -> Text
diskName) (\s :: GetDisk
s@GetDisk' {} Text
a -> GetDisk
s {$sel:diskName:GetDisk' :: Text
diskName = Text
a} :: GetDisk)
instance Core.AWSRequest GetDisk where
type AWSResponse GetDisk = GetDiskResponse
request :: GetDisk -> Request GetDisk
request = Service -> GetDisk -> Request GetDisk
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy GetDisk
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetDisk)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse GetDisk))
-> Logger
-> Service
-> Proxy GetDisk
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetDisk)))
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 Disk -> Int -> GetDiskResponse
GetDiskResponse'
(Maybe Disk -> Int -> GetDiskResponse)
-> Either String (Maybe Disk)
-> Either String (Int -> GetDiskResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Disk)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"disk")
Either String (Int -> GetDiskResponse)
-> Either String Int -> Either String GetDiskResponse
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 GetDisk
instance Prelude.NFData GetDisk
instance Core.ToHeaders GetDisk where
toHeaders :: GetDisk -> ResponseHeaders
toHeaders =
ResponseHeaders -> GetDisk -> 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.GetDisk" :: 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 GetDisk where
toJSON :: GetDisk -> Value
toJSON GetDisk' {Text
diskName :: Text
$sel:diskName:GetDisk' :: GetDisk -> 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
"diskName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
diskName)]
)
instance Core.ToPath GetDisk where
toPath :: GetDisk -> ByteString
toPath = ByteString -> GetDisk -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery GetDisk where
toQuery :: GetDisk -> QueryString
toQuery = QueryString -> GetDisk -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data GetDiskResponse = GetDiskResponse'
{
GetDiskResponse -> Maybe Disk
disk :: Prelude.Maybe Disk,
GetDiskResponse -> Int
httpStatus :: Prelude.Int
}
deriving (GetDiskResponse -> GetDiskResponse -> Bool
(GetDiskResponse -> GetDiskResponse -> Bool)
-> (GetDiskResponse -> GetDiskResponse -> Bool)
-> Eq GetDiskResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDiskResponse -> GetDiskResponse -> Bool
$c/= :: GetDiskResponse -> GetDiskResponse -> Bool
== :: GetDiskResponse -> GetDiskResponse -> Bool
$c== :: GetDiskResponse -> GetDiskResponse -> Bool
Prelude.Eq, ReadPrec [GetDiskResponse]
ReadPrec GetDiskResponse
Int -> ReadS GetDiskResponse
ReadS [GetDiskResponse]
(Int -> ReadS GetDiskResponse)
-> ReadS [GetDiskResponse]
-> ReadPrec GetDiskResponse
-> ReadPrec [GetDiskResponse]
-> Read GetDiskResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDiskResponse]
$creadListPrec :: ReadPrec [GetDiskResponse]
readPrec :: ReadPrec GetDiskResponse
$creadPrec :: ReadPrec GetDiskResponse
readList :: ReadS [GetDiskResponse]
$creadList :: ReadS [GetDiskResponse]
readsPrec :: Int -> ReadS GetDiskResponse
$creadsPrec :: Int -> ReadS GetDiskResponse
Prelude.Read, Int -> GetDiskResponse -> ShowS
[GetDiskResponse] -> ShowS
GetDiskResponse -> String
(Int -> GetDiskResponse -> ShowS)
-> (GetDiskResponse -> String)
-> ([GetDiskResponse] -> ShowS)
-> Show GetDiskResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDiskResponse] -> ShowS
$cshowList :: [GetDiskResponse] -> ShowS
show :: GetDiskResponse -> String
$cshow :: GetDiskResponse -> String
showsPrec :: Int -> GetDiskResponse -> ShowS
$cshowsPrec :: Int -> GetDiskResponse -> ShowS
Prelude.Show, (forall x. GetDiskResponse -> Rep GetDiskResponse x)
-> (forall x. Rep GetDiskResponse x -> GetDiskResponse)
-> Generic GetDiskResponse
forall x. Rep GetDiskResponse x -> GetDiskResponse
forall x. GetDiskResponse -> Rep GetDiskResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDiskResponse x -> GetDiskResponse
$cfrom :: forall x. GetDiskResponse -> Rep GetDiskResponse x
Prelude.Generic)
newGetDiskResponse ::
Prelude.Int ->
GetDiskResponse
newGetDiskResponse :: Int -> GetDiskResponse
newGetDiskResponse Int
pHttpStatus_ =
GetDiskResponse' :: Maybe Disk -> Int -> GetDiskResponse
GetDiskResponse'
{ $sel:disk:GetDiskResponse' :: Maybe Disk
disk = Maybe Disk
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:GetDiskResponse' :: Int
httpStatus = Int
pHttpStatus_
}
getDiskResponse_disk :: Lens.Lens' GetDiskResponse (Prelude.Maybe Disk)
getDiskResponse_disk :: (Maybe Disk -> f (Maybe Disk))
-> GetDiskResponse -> f GetDiskResponse
getDiskResponse_disk = (GetDiskResponse -> Maybe Disk)
-> (GetDiskResponse -> Maybe Disk -> GetDiskResponse)
-> Lens GetDiskResponse GetDiskResponse (Maybe Disk) (Maybe Disk)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDiskResponse' {Maybe Disk
disk :: Maybe Disk
$sel:disk:GetDiskResponse' :: GetDiskResponse -> Maybe Disk
disk} -> Maybe Disk
disk) (\s :: GetDiskResponse
s@GetDiskResponse' {} Maybe Disk
a -> GetDiskResponse
s {$sel:disk:GetDiskResponse' :: Maybe Disk
disk = Maybe Disk
a} :: GetDiskResponse)
getDiskResponse_httpStatus :: Lens.Lens' GetDiskResponse Prelude.Int
getDiskResponse_httpStatus :: (Int -> f Int) -> GetDiskResponse -> f GetDiskResponse
getDiskResponse_httpStatus = (GetDiskResponse -> Int)
-> (GetDiskResponse -> Int -> GetDiskResponse)
-> Lens GetDiskResponse GetDiskResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDiskResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetDiskResponse' :: GetDiskResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetDiskResponse
s@GetDiskResponse' {} Int
a -> GetDiskResponse
s {$sel:httpStatus:GetDiskResponse' :: Int
httpStatus = Int
a} :: GetDiskResponse)
instance Prelude.NFData GetDiskResponse