{-# 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.DetachDisk
(
DetachDisk (..),
newDetachDisk,
detachDisk_diskName,
DetachDiskResponse (..),
newDetachDiskResponse,
detachDiskResponse_operations,
detachDiskResponse_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 DetachDisk = DetachDisk'
{
DetachDisk -> Text
diskName :: Prelude.Text
}
deriving (DetachDisk -> DetachDisk -> Bool
(DetachDisk -> DetachDisk -> Bool)
-> (DetachDisk -> DetachDisk -> Bool) -> Eq DetachDisk
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DetachDisk -> DetachDisk -> Bool
$c/= :: DetachDisk -> DetachDisk -> Bool
== :: DetachDisk -> DetachDisk -> Bool
$c== :: DetachDisk -> DetachDisk -> Bool
Prelude.Eq, ReadPrec [DetachDisk]
ReadPrec DetachDisk
Int -> ReadS DetachDisk
ReadS [DetachDisk]
(Int -> ReadS DetachDisk)
-> ReadS [DetachDisk]
-> ReadPrec DetachDisk
-> ReadPrec [DetachDisk]
-> Read DetachDisk
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DetachDisk]
$creadListPrec :: ReadPrec [DetachDisk]
readPrec :: ReadPrec DetachDisk
$creadPrec :: ReadPrec DetachDisk
readList :: ReadS [DetachDisk]
$creadList :: ReadS [DetachDisk]
readsPrec :: Int -> ReadS DetachDisk
$creadsPrec :: Int -> ReadS DetachDisk
Prelude.Read, Int -> DetachDisk -> ShowS
[DetachDisk] -> ShowS
DetachDisk -> String
(Int -> DetachDisk -> ShowS)
-> (DetachDisk -> String)
-> ([DetachDisk] -> ShowS)
-> Show DetachDisk
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DetachDisk] -> ShowS
$cshowList :: [DetachDisk] -> ShowS
show :: DetachDisk -> String
$cshow :: DetachDisk -> String
showsPrec :: Int -> DetachDisk -> ShowS
$cshowsPrec :: Int -> DetachDisk -> ShowS
Prelude.Show, (forall x. DetachDisk -> Rep DetachDisk x)
-> (forall x. Rep DetachDisk x -> DetachDisk) -> Generic DetachDisk
forall x. Rep DetachDisk x -> DetachDisk
forall x. DetachDisk -> Rep DetachDisk x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DetachDisk x -> DetachDisk
$cfrom :: forall x. DetachDisk -> Rep DetachDisk x
Prelude.Generic)
newDetachDisk ::
Prelude.Text ->
DetachDisk
newDetachDisk :: Text -> DetachDisk
newDetachDisk Text
pDiskName_ =
DetachDisk' :: Text -> DetachDisk
DetachDisk' {$sel:diskName:DetachDisk' :: Text
diskName = Text
pDiskName_}
detachDisk_diskName :: Lens.Lens' DetachDisk Prelude.Text
detachDisk_diskName :: (Text -> f Text) -> DetachDisk -> f DetachDisk
detachDisk_diskName = (DetachDisk -> Text)
-> (DetachDisk -> Text -> DetachDisk)
-> Lens DetachDisk DetachDisk Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetachDisk' {Text
diskName :: Text
$sel:diskName:DetachDisk' :: DetachDisk -> Text
diskName} -> Text
diskName) (\s :: DetachDisk
s@DetachDisk' {} Text
a -> DetachDisk
s {$sel:diskName:DetachDisk' :: Text
diskName = Text
a} :: DetachDisk)
instance Core.AWSRequest DetachDisk where
type AWSResponse DetachDisk = DetachDiskResponse
request :: DetachDisk -> Request DetachDisk
request = Service -> DetachDisk -> Request DetachDisk
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy DetachDisk
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DetachDisk)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse DetachDisk))
-> Logger
-> Service
-> Proxy DetachDisk
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DetachDisk)))
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 [Operation] -> Int -> DetachDiskResponse
DetachDiskResponse'
(Maybe [Operation] -> Int -> DetachDiskResponse)
-> Either String (Maybe [Operation])
-> Either String (Int -> DetachDiskResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [Operation]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"operations" Either String (Maybe (Maybe [Operation]))
-> Maybe [Operation] -> Either String (Maybe [Operation])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Operation]
forall a. Monoid a => a
Prelude.mempty)
Either String (Int -> DetachDiskResponse)
-> Either String Int -> Either String DetachDiskResponse
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 DetachDisk
instance Prelude.NFData DetachDisk
instance Core.ToHeaders DetachDisk where
toHeaders :: DetachDisk -> ResponseHeaders
toHeaders =
ResponseHeaders -> DetachDisk -> 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.DetachDisk" ::
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 DetachDisk where
toJSON :: DetachDisk -> Value
toJSON DetachDisk' {Text
diskName :: Text
$sel:diskName:DetachDisk' :: DetachDisk -> 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 DetachDisk where
toPath :: DetachDisk -> ByteString
toPath = ByteString -> DetachDisk -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery DetachDisk where
toQuery :: DetachDisk -> QueryString
toQuery = QueryString -> DetachDisk -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data DetachDiskResponse = DetachDiskResponse'
{
DetachDiskResponse -> Maybe [Operation]
operations :: Prelude.Maybe [Operation],
DetachDiskResponse -> Int
httpStatus :: Prelude.Int
}
deriving (DetachDiskResponse -> DetachDiskResponse -> Bool
(DetachDiskResponse -> DetachDiskResponse -> Bool)
-> (DetachDiskResponse -> DetachDiskResponse -> Bool)
-> Eq DetachDiskResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DetachDiskResponse -> DetachDiskResponse -> Bool
$c/= :: DetachDiskResponse -> DetachDiskResponse -> Bool
== :: DetachDiskResponse -> DetachDiskResponse -> Bool
$c== :: DetachDiskResponse -> DetachDiskResponse -> Bool
Prelude.Eq, ReadPrec [DetachDiskResponse]
ReadPrec DetachDiskResponse
Int -> ReadS DetachDiskResponse
ReadS [DetachDiskResponse]
(Int -> ReadS DetachDiskResponse)
-> ReadS [DetachDiskResponse]
-> ReadPrec DetachDiskResponse
-> ReadPrec [DetachDiskResponse]
-> Read DetachDiskResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DetachDiskResponse]
$creadListPrec :: ReadPrec [DetachDiskResponse]
readPrec :: ReadPrec DetachDiskResponse
$creadPrec :: ReadPrec DetachDiskResponse
readList :: ReadS [DetachDiskResponse]
$creadList :: ReadS [DetachDiskResponse]
readsPrec :: Int -> ReadS DetachDiskResponse
$creadsPrec :: Int -> ReadS DetachDiskResponse
Prelude.Read, Int -> DetachDiskResponse -> ShowS
[DetachDiskResponse] -> ShowS
DetachDiskResponse -> String
(Int -> DetachDiskResponse -> ShowS)
-> (DetachDiskResponse -> String)
-> ([DetachDiskResponse] -> ShowS)
-> Show DetachDiskResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DetachDiskResponse] -> ShowS
$cshowList :: [DetachDiskResponse] -> ShowS
show :: DetachDiskResponse -> String
$cshow :: DetachDiskResponse -> String
showsPrec :: Int -> DetachDiskResponse -> ShowS
$cshowsPrec :: Int -> DetachDiskResponse -> ShowS
Prelude.Show, (forall x. DetachDiskResponse -> Rep DetachDiskResponse x)
-> (forall x. Rep DetachDiskResponse x -> DetachDiskResponse)
-> Generic DetachDiskResponse
forall x. Rep DetachDiskResponse x -> DetachDiskResponse
forall x. DetachDiskResponse -> Rep DetachDiskResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DetachDiskResponse x -> DetachDiskResponse
$cfrom :: forall x. DetachDiskResponse -> Rep DetachDiskResponse x
Prelude.Generic)
newDetachDiskResponse ::
Prelude.Int ->
DetachDiskResponse
newDetachDiskResponse :: Int -> DetachDiskResponse
newDetachDiskResponse Int
pHttpStatus_ =
DetachDiskResponse' :: Maybe [Operation] -> Int -> DetachDiskResponse
DetachDiskResponse'
{ $sel:operations:DetachDiskResponse' :: Maybe [Operation]
operations = Maybe [Operation]
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:DetachDiskResponse' :: Int
httpStatus = Int
pHttpStatus_
}
detachDiskResponse_operations :: Lens.Lens' DetachDiskResponse (Prelude.Maybe [Operation])
detachDiskResponse_operations :: (Maybe [Operation] -> f (Maybe [Operation]))
-> DetachDiskResponse -> f DetachDiskResponse
detachDiskResponse_operations = (DetachDiskResponse -> Maybe [Operation])
-> (DetachDiskResponse -> Maybe [Operation] -> DetachDiskResponse)
-> Lens
DetachDiskResponse
DetachDiskResponse
(Maybe [Operation])
(Maybe [Operation])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetachDiskResponse' {Maybe [Operation]
operations :: Maybe [Operation]
$sel:operations:DetachDiskResponse' :: DetachDiskResponse -> Maybe [Operation]
operations} -> Maybe [Operation]
operations) (\s :: DetachDiskResponse
s@DetachDiskResponse' {} Maybe [Operation]
a -> DetachDiskResponse
s {$sel:operations:DetachDiskResponse' :: Maybe [Operation]
operations = Maybe [Operation]
a} :: DetachDiskResponse) ((Maybe [Operation] -> f (Maybe [Operation]))
-> DetachDiskResponse -> f DetachDiskResponse)
-> ((Maybe [Operation] -> f (Maybe [Operation]))
-> Maybe [Operation] -> f (Maybe [Operation]))
-> (Maybe [Operation] -> f (Maybe [Operation]))
-> DetachDiskResponse
-> f DetachDiskResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Operation] [Operation] [Operation] [Operation]
-> Iso
(Maybe [Operation])
(Maybe [Operation])
(Maybe [Operation])
(Maybe [Operation])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Operation] [Operation] [Operation] [Operation]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
detachDiskResponse_httpStatus :: Lens.Lens' DetachDiskResponse Prelude.Int
detachDiskResponse_httpStatus :: (Int -> f Int) -> DetachDiskResponse -> f DetachDiskResponse
detachDiskResponse_httpStatus = (DetachDiskResponse -> Int)
-> (DetachDiskResponse -> Int -> DetachDiskResponse)
-> Lens DetachDiskResponse DetachDiskResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetachDiskResponse' {Int
httpStatus :: Int
$sel:httpStatus:DetachDiskResponse' :: DetachDiskResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DetachDiskResponse
s@DetachDiskResponse' {} Int
a -> DetachDiskResponse
s {$sel:httpStatus:DetachDiskResponse' :: Int
httpStatus = Int
a} :: DetachDiskResponse)
instance Prelude.NFData DetachDiskResponse