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