{-# 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.AttachVolume
(
AttachVolume (..),
newAttachVolume,
attachVolume_diskId,
attachVolume_targetName,
attachVolume_gatewayARN,
attachVolume_volumeARN,
attachVolume_networkInterfaceId,
AttachVolumeResponse (..),
newAttachVolumeResponse,
attachVolumeResponse_targetARN,
attachVolumeResponse_volumeARN,
attachVolumeResponse_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 AttachVolume = AttachVolume'
{
AttachVolume -> Maybe Text
diskId :: Prelude.Maybe Prelude.Text,
AttachVolume -> Maybe Text
targetName :: Prelude.Maybe Prelude.Text,
AttachVolume -> Text
gatewayARN :: Prelude.Text,
AttachVolume -> Text
volumeARN :: Prelude.Text,
AttachVolume -> Text
networkInterfaceId :: Prelude.Text
}
deriving (AttachVolume -> AttachVolume -> Bool
(AttachVolume -> AttachVolume -> Bool)
-> (AttachVolume -> AttachVolume -> Bool) -> Eq AttachVolume
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AttachVolume -> AttachVolume -> Bool
$c/= :: AttachVolume -> AttachVolume -> Bool
== :: AttachVolume -> AttachVolume -> Bool
$c== :: AttachVolume -> AttachVolume -> Bool
Prelude.Eq, ReadPrec [AttachVolume]
ReadPrec AttachVolume
Int -> ReadS AttachVolume
ReadS [AttachVolume]
(Int -> ReadS AttachVolume)
-> ReadS [AttachVolume]
-> ReadPrec AttachVolume
-> ReadPrec [AttachVolume]
-> Read AttachVolume
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AttachVolume]
$creadListPrec :: ReadPrec [AttachVolume]
readPrec :: ReadPrec AttachVolume
$creadPrec :: ReadPrec AttachVolume
readList :: ReadS [AttachVolume]
$creadList :: ReadS [AttachVolume]
readsPrec :: Int -> ReadS AttachVolume
$creadsPrec :: Int -> ReadS AttachVolume
Prelude.Read, Int -> AttachVolume -> ShowS
[AttachVolume] -> ShowS
AttachVolume -> String
(Int -> AttachVolume -> ShowS)
-> (AttachVolume -> String)
-> ([AttachVolume] -> ShowS)
-> Show AttachVolume
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AttachVolume] -> ShowS
$cshowList :: [AttachVolume] -> ShowS
show :: AttachVolume -> String
$cshow :: AttachVolume -> String
showsPrec :: Int -> AttachVolume -> ShowS
$cshowsPrec :: Int -> AttachVolume -> ShowS
Prelude.Show, (forall x. AttachVolume -> Rep AttachVolume x)
-> (forall x. Rep AttachVolume x -> AttachVolume)
-> Generic AttachVolume
forall x. Rep AttachVolume x -> AttachVolume
forall x. AttachVolume -> Rep AttachVolume x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AttachVolume x -> AttachVolume
$cfrom :: forall x. AttachVolume -> Rep AttachVolume x
Prelude.Generic)
newAttachVolume ::
Prelude.Text ->
Prelude.Text ->
Prelude.Text ->
AttachVolume
newAttachVolume :: Text -> Text -> Text -> AttachVolume
newAttachVolume
Text
pGatewayARN_
Text
pVolumeARN_
Text
pNetworkInterfaceId_ =
AttachVolume' :: Maybe Text -> Maybe Text -> Text -> Text -> Text -> AttachVolume
AttachVolume'
{ $sel:diskId:AttachVolume' :: Maybe Text
diskId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:targetName:AttachVolume' :: Maybe Text
targetName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:gatewayARN:AttachVolume' :: Text
gatewayARN = Text
pGatewayARN_,
$sel:volumeARN:AttachVolume' :: Text
volumeARN = Text
pVolumeARN_,
$sel:networkInterfaceId:AttachVolume' :: Text
networkInterfaceId = Text
pNetworkInterfaceId_
}
attachVolume_diskId :: Lens.Lens' AttachVolume (Prelude.Maybe Prelude.Text)
attachVolume_diskId :: (Maybe Text -> f (Maybe Text)) -> AttachVolume -> f AttachVolume
attachVolume_diskId = (AttachVolume -> Maybe Text)
-> (AttachVolume -> Maybe Text -> AttachVolume)
-> Lens AttachVolume AttachVolume (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttachVolume' {Maybe Text
diskId :: Maybe Text
$sel:diskId:AttachVolume' :: AttachVolume -> Maybe Text
diskId} -> Maybe Text
diskId) (\s :: AttachVolume
s@AttachVolume' {} Maybe Text
a -> AttachVolume
s {$sel:diskId:AttachVolume' :: Maybe Text
diskId = Maybe Text
a} :: AttachVolume)
attachVolume_targetName :: Lens.Lens' AttachVolume (Prelude.Maybe Prelude.Text)
attachVolume_targetName :: (Maybe Text -> f (Maybe Text)) -> AttachVolume -> f AttachVolume
attachVolume_targetName = (AttachVolume -> Maybe Text)
-> (AttachVolume -> Maybe Text -> AttachVolume)
-> Lens AttachVolume AttachVolume (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttachVolume' {Maybe Text
targetName :: Maybe Text
$sel:targetName:AttachVolume' :: AttachVolume -> Maybe Text
targetName} -> Maybe Text
targetName) (\s :: AttachVolume
s@AttachVolume' {} Maybe Text
a -> AttachVolume
s {$sel:targetName:AttachVolume' :: Maybe Text
targetName = Maybe Text
a} :: AttachVolume)
attachVolume_gatewayARN :: Lens.Lens' AttachVolume Prelude.Text
attachVolume_gatewayARN :: (Text -> f Text) -> AttachVolume -> f AttachVolume
attachVolume_gatewayARN = (AttachVolume -> Text)
-> (AttachVolume -> Text -> AttachVolume)
-> Lens AttachVolume AttachVolume Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttachVolume' {Text
gatewayARN :: Text
$sel:gatewayARN:AttachVolume' :: AttachVolume -> Text
gatewayARN} -> Text
gatewayARN) (\s :: AttachVolume
s@AttachVolume' {} Text
a -> AttachVolume
s {$sel:gatewayARN:AttachVolume' :: Text
gatewayARN = Text
a} :: AttachVolume)
attachVolume_volumeARN :: Lens.Lens' AttachVolume Prelude.Text
attachVolume_volumeARN :: (Text -> f Text) -> AttachVolume -> f AttachVolume
attachVolume_volumeARN = (AttachVolume -> Text)
-> (AttachVolume -> Text -> AttachVolume)
-> Lens AttachVolume AttachVolume Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttachVolume' {Text
volumeARN :: Text
$sel:volumeARN:AttachVolume' :: AttachVolume -> Text
volumeARN} -> Text
volumeARN) (\s :: AttachVolume
s@AttachVolume' {} Text
a -> AttachVolume
s {$sel:volumeARN:AttachVolume' :: Text
volumeARN = Text
a} :: AttachVolume)
attachVolume_networkInterfaceId :: Lens.Lens' AttachVolume Prelude.Text
attachVolume_networkInterfaceId :: (Text -> f Text) -> AttachVolume -> f AttachVolume
attachVolume_networkInterfaceId = (AttachVolume -> Text)
-> (AttachVolume -> Text -> AttachVolume)
-> Lens AttachVolume AttachVolume Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttachVolume' {Text
networkInterfaceId :: Text
$sel:networkInterfaceId:AttachVolume' :: AttachVolume -> Text
networkInterfaceId} -> Text
networkInterfaceId) (\s :: AttachVolume
s@AttachVolume' {} Text
a -> AttachVolume
s {$sel:networkInterfaceId:AttachVolume' :: Text
networkInterfaceId = Text
a} :: AttachVolume)
instance Core.AWSRequest AttachVolume where
type AWSResponse AttachVolume = AttachVolumeResponse
request :: AttachVolume -> Request AttachVolume
request = Service -> AttachVolume -> Request AttachVolume
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy AttachVolume
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AttachVolume)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse AttachVolume))
-> Logger
-> Service
-> Proxy AttachVolume
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AttachVolume)))
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 -> Maybe Text -> Int -> AttachVolumeResponse
AttachVolumeResponse'
(Maybe Text -> Maybe Text -> Int -> AttachVolumeResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Int -> AttachVolumeResponse)
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
"TargetARN")
Either String (Maybe Text -> Int -> AttachVolumeResponse)
-> Either String (Maybe Text)
-> Either String (Int -> AttachVolumeResponse)
forall (f :: * -> *) a b. Applicative f => 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 -> AttachVolumeResponse)
-> Either String Int -> Either String AttachVolumeResponse
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 AttachVolume
instance Prelude.NFData AttachVolume
instance Core.ToHeaders AttachVolume where
toHeaders :: AttachVolume -> ResponseHeaders
toHeaders =
ResponseHeaders -> AttachVolume -> 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.AttachVolume" ::
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 AttachVolume where
toJSON :: AttachVolume -> Value
toJSON AttachVolume' {Maybe Text
Text
networkInterfaceId :: Text
volumeARN :: Text
gatewayARN :: Text
targetName :: Maybe Text
diskId :: Maybe Text
$sel:networkInterfaceId:AttachVolume' :: AttachVolume -> Text
$sel:volumeARN:AttachVolume' :: AttachVolume -> Text
$sel:gatewayARN:AttachVolume' :: AttachVolume -> Text
$sel:targetName:AttachVolume' :: AttachVolume -> Maybe Text
$sel:diskId:AttachVolume' :: AttachVolume -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"DiskId" 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
diskId,
(Text
"TargetName" 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
targetName,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"GatewayARN" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
gatewayARN),
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),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"NetworkInterfaceId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
networkInterfaceId)
]
)
instance Core.ToPath AttachVolume where
toPath :: AttachVolume -> ByteString
toPath = ByteString -> AttachVolume -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery AttachVolume where
toQuery :: AttachVolume -> QueryString
toQuery = QueryString -> AttachVolume -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data AttachVolumeResponse = AttachVolumeResponse'
{
AttachVolumeResponse -> Maybe Text
targetARN :: Prelude.Maybe Prelude.Text,
AttachVolumeResponse -> Maybe Text
volumeARN :: Prelude.Maybe Prelude.Text,
AttachVolumeResponse -> Int
httpStatus :: Prelude.Int
}
deriving (AttachVolumeResponse -> AttachVolumeResponse -> Bool
(AttachVolumeResponse -> AttachVolumeResponse -> Bool)
-> (AttachVolumeResponse -> AttachVolumeResponse -> Bool)
-> Eq AttachVolumeResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AttachVolumeResponse -> AttachVolumeResponse -> Bool
$c/= :: AttachVolumeResponse -> AttachVolumeResponse -> Bool
== :: AttachVolumeResponse -> AttachVolumeResponse -> Bool
$c== :: AttachVolumeResponse -> AttachVolumeResponse -> Bool
Prelude.Eq, ReadPrec [AttachVolumeResponse]
ReadPrec AttachVolumeResponse
Int -> ReadS AttachVolumeResponse
ReadS [AttachVolumeResponse]
(Int -> ReadS AttachVolumeResponse)
-> ReadS [AttachVolumeResponse]
-> ReadPrec AttachVolumeResponse
-> ReadPrec [AttachVolumeResponse]
-> Read AttachVolumeResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AttachVolumeResponse]
$creadListPrec :: ReadPrec [AttachVolumeResponse]
readPrec :: ReadPrec AttachVolumeResponse
$creadPrec :: ReadPrec AttachVolumeResponse
readList :: ReadS [AttachVolumeResponse]
$creadList :: ReadS [AttachVolumeResponse]
readsPrec :: Int -> ReadS AttachVolumeResponse
$creadsPrec :: Int -> ReadS AttachVolumeResponse
Prelude.Read, Int -> AttachVolumeResponse -> ShowS
[AttachVolumeResponse] -> ShowS
AttachVolumeResponse -> String
(Int -> AttachVolumeResponse -> ShowS)
-> (AttachVolumeResponse -> String)
-> ([AttachVolumeResponse] -> ShowS)
-> Show AttachVolumeResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AttachVolumeResponse] -> ShowS
$cshowList :: [AttachVolumeResponse] -> ShowS
show :: AttachVolumeResponse -> String
$cshow :: AttachVolumeResponse -> String
showsPrec :: Int -> AttachVolumeResponse -> ShowS
$cshowsPrec :: Int -> AttachVolumeResponse -> ShowS
Prelude.Show, (forall x. AttachVolumeResponse -> Rep AttachVolumeResponse x)
-> (forall x. Rep AttachVolumeResponse x -> AttachVolumeResponse)
-> Generic AttachVolumeResponse
forall x. Rep AttachVolumeResponse x -> AttachVolumeResponse
forall x. AttachVolumeResponse -> Rep AttachVolumeResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AttachVolumeResponse x -> AttachVolumeResponse
$cfrom :: forall x. AttachVolumeResponse -> Rep AttachVolumeResponse x
Prelude.Generic)
newAttachVolumeResponse ::
Prelude.Int ->
AttachVolumeResponse
newAttachVolumeResponse :: Int -> AttachVolumeResponse
newAttachVolumeResponse Int
pHttpStatus_ =
AttachVolumeResponse' :: Maybe Text -> Maybe Text -> Int -> AttachVolumeResponse
AttachVolumeResponse'
{ $sel:targetARN:AttachVolumeResponse' :: Maybe Text
targetARN = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:volumeARN:AttachVolumeResponse' :: Maybe Text
volumeARN = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:AttachVolumeResponse' :: Int
httpStatus = Int
pHttpStatus_
}
attachVolumeResponse_targetARN :: Lens.Lens' AttachVolumeResponse (Prelude.Maybe Prelude.Text)
attachVolumeResponse_targetARN :: (Maybe Text -> f (Maybe Text))
-> AttachVolumeResponse -> f AttachVolumeResponse
attachVolumeResponse_targetARN = (AttachVolumeResponse -> Maybe Text)
-> (AttachVolumeResponse -> Maybe Text -> AttachVolumeResponse)
-> Lens
AttachVolumeResponse AttachVolumeResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttachVolumeResponse' {Maybe Text
targetARN :: Maybe Text
$sel:targetARN:AttachVolumeResponse' :: AttachVolumeResponse -> Maybe Text
targetARN} -> Maybe Text
targetARN) (\s :: AttachVolumeResponse
s@AttachVolumeResponse' {} Maybe Text
a -> AttachVolumeResponse
s {$sel:targetARN:AttachVolumeResponse' :: Maybe Text
targetARN = Maybe Text
a} :: AttachVolumeResponse)
attachVolumeResponse_volumeARN :: Lens.Lens' AttachVolumeResponse (Prelude.Maybe Prelude.Text)
attachVolumeResponse_volumeARN :: (Maybe Text -> f (Maybe Text))
-> AttachVolumeResponse -> f AttachVolumeResponse
attachVolumeResponse_volumeARN = (AttachVolumeResponse -> Maybe Text)
-> (AttachVolumeResponse -> Maybe Text -> AttachVolumeResponse)
-> Lens
AttachVolumeResponse AttachVolumeResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttachVolumeResponse' {Maybe Text
volumeARN :: Maybe Text
$sel:volumeARN:AttachVolumeResponse' :: AttachVolumeResponse -> Maybe Text
volumeARN} -> Maybe Text
volumeARN) (\s :: AttachVolumeResponse
s@AttachVolumeResponse' {} Maybe Text
a -> AttachVolumeResponse
s {$sel:volumeARN:AttachVolumeResponse' :: Maybe Text
volumeARN = Maybe Text
a} :: AttachVolumeResponse)
attachVolumeResponse_httpStatus :: Lens.Lens' AttachVolumeResponse Prelude.Int
attachVolumeResponse_httpStatus :: (Int -> f Int) -> AttachVolumeResponse -> f AttachVolumeResponse
attachVolumeResponse_httpStatus = (AttachVolumeResponse -> Int)
-> (AttachVolumeResponse -> Int -> AttachVolumeResponse)
-> Lens AttachVolumeResponse AttachVolumeResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttachVolumeResponse' {Int
httpStatus :: Int
$sel:httpStatus:AttachVolumeResponse' :: AttachVolumeResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: AttachVolumeResponse
s@AttachVolumeResponse' {} Int
a -> AttachVolumeResponse
s {$sel:httpStatus:AttachVolumeResponse' :: Int
httpStatus = Int
a} :: AttachVolumeResponse)
instance Prelude.NFData AttachVolumeResponse