{-# 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.AttachDisk
(
AttachDisk (..),
newAttachDisk,
attachDisk_diskName,
attachDisk_instanceName,
attachDisk_diskPath,
AttachDiskResponse (..),
newAttachDiskResponse,
attachDiskResponse_operations,
attachDiskResponse_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 AttachDisk = AttachDisk'
{
AttachDisk -> Text
diskName :: Prelude.Text,
AttachDisk -> Text
instanceName :: Prelude.Text,
AttachDisk -> Text
diskPath :: Prelude.Text
}
deriving (AttachDisk -> AttachDisk -> Bool
(AttachDisk -> AttachDisk -> Bool)
-> (AttachDisk -> AttachDisk -> Bool) -> Eq AttachDisk
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AttachDisk -> AttachDisk -> Bool
$c/= :: AttachDisk -> AttachDisk -> Bool
== :: AttachDisk -> AttachDisk -> Bool
$c== :: AttachDisk -> AttachDisk -> Bool
Prelude.Eq, ReadPrec [AttachDisk]
ReadPrec AttachDisk
Int -> ReadS AttachDisk
ReadS [AttachDisk]
(Int -> ReadS AttachDisk)
-> ReadS [AttachDisk]
-> ReadPrec AttachDisk
-> ReadPrec [AttachDisk]
-> Read AttachDisk
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AttachDisk]
$creadListPrec :: ReadPrec [AttachDisk]
readPrec :: ReadPrec AttachDisk
$creadPrec :: ReadPrec AttachDisk
readList :: ReadS [AttachDisk]
$creadList :: ReadS [AttachDisk]
readsPrec :: Int -> ReadS AttachDisk
$creadsPrec :: Int -> ReadS AttachDisk
Prelude.Read, Int -> AttachDisk -> ShowS
[AttachDisk] -> ShowS
AttachDisk -> String
(Int -> AttachDisk -> ShowS)
-> (AttachDisk -> String)
-> ([AttachDisk] -> ShowS)
-> Show AttachDisk
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AttachDisk] -> ShowS
$cshowList :: [AttachDisk] -> ShowS
show :: AttachDisk -> String
$cshow :: AttachDisk -> String
showsPrec :: Int -> AttachDisk -> ShowS
$cshowsPrec :: Int -> AttachDisk -> ShowS
Prelude.Show, (forall x. AttachDisk -> Rep AttachDisk x)
-> (forall x. Rep AttachDisk x -> AttachDisk) -> Generic AttachDisk
forall x. Rep AttachDisk x -> AttachDisk
forall x. AttachDisk -> Rep AttachDisk x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AttachDisk x -> AttachDisk
$cfrom :: forall x. AttachDisk -> Rep AttachDisk x
Prelude.Generic)
newAttachDisk ::
Prelude.Text ->
Prelude.Text ->
Prelude.Text ->
AttachDisk
newAttachDisk :: Text -> Text -> Text -> AttachDisk
newAttachDisk Text
pDiskName_ Text
pInstanceName_ Text
pDiskPath_ =
AttachDisk' :: Text -> Text -> Text -> AttachDisk
AttachDisk'
{ $sel:diskName:AttachDisk' :: Text
diskName = Text
pDiskName_,
$sel:instanceName:AttachDisk' :: Text
instanceName = Text
pInstanceName_,
$sel:diskPath:AttachDisk' :: Text
diskPath = Text
pDiskPath_
}
attachDisk_diskName :: Lens.Lens' AttachDisk Prelude.Text
attachDisk_diskName :: (Text -> f Text) -> AttachDisk -> f AttachDisk
attachDisk_diskName = (AttachDisk -> Text)
-> (AttachDisk -> Text -> AttachDisk)
-> Lens AttachDisk AttachDisk Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttachDisk' {Text
diskName :: Text
$sel:diskName:AttachDisk' :: AttachDisk -> Text
diskName} -> Text
diskName) (\s :: AttachDisk
s@AttachDisk' {} Text
a -> AttachDisk
s {$sel:diskName:AttachDisk' :: Text
diskName = Text
a} :: AttachDisk)
attachDisk_instanceName :: Lens.Lens' AttachDisk Prelude.Text
attachDisk_instanceName :: (Text -> f Text) -> AttachDisk -> f AttachDisk
attachDisk_instanceName = (AttachDisk -> Text)
-> (AttachDisk -> Text -> AttachDisk)
-> Lens AttachDisk AttachDisk Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttachDisk' {Text
instanceName :: Text
$sel:instanceName:AttachDisk' :: AttachDisk -> Text
instanceName} -> Text
instanceName) (\s :: AttachDisk
s@AttachDisk' {} Text
a -> AttachDisk
s {$sel:instanceName:AttachDisk' :: Text
instanceName = Text
a} :: AttachDisk)
attachDisk_diskPath :: Lens.Lens' AttachDisk Prelude.Text
attachDisk_diskPath :: (Text -> f Text) -> AttachDisk -> f AttachDisk
attachDisk_diskPath = (AttachDisk -> Text)
-> (AttachDisk -> Text -> AttachDisk)
-> Lens AttachDisk AttachDisk Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttachDisk' {Text
diskPath :: Text
$sel:diskPath:AttachDisk' :: AttachDisk -> Text
diskPath} -> Text
diskPath) (\s :: AttachDisk
s@AttachDisk' {} Text
a -> AttachDisk
s {$sel:diskPath:AttachDisk' :: Text
diskPath = Text
a} :: AttachDisk)
instance Core.AWSRequest AttachDisk where
type AWSResponse AttachDisk = AttachDiskResponse
request :: AttachDisk -> Request AttachDisk
request = Service -> AttachDisk -> Request AttachDisk
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy AttachDisk
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AttachDisk)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse AttachDisk))
-> Logger
-> Service
-> Proxy AttachDisk
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AttachDisk)))
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 -> AttachDiskResponse
AttachDiskResponse'
(Maybe [Operation] -> Int -> AttachDiskResponse)
-> Either String (Maybe [Operation])
-> Either String (Int -> AttachDiskResponse)
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 -> AttachDiskResponse)
-> Either String Int -> Either String AttachDiskResponse
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 AttachDisk
instance Prelude.NFData AttachDisk
instance Core.ToHeaders AttachDisk where
toHeaders :: AttachDisk -> ResponseHeaders
toHeaders =
ResponseHeaders -> AttachDisk -> 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.AttachDisk" ::
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 AttachDisk where
toJSON :: AttachDisk -> Value
toJSON AttachDisk' {Text
diskPath :: Text
instanceName :: Text
diskName :: Text
$sel:diskPath:AttachDisk' :: AttachDisk -> Text
$sel:instanceName:AttachDisk' :: AttachDisk -> Text
$sel:diskName:AttachDisk' :: AttachDisk -> 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),
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),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"diskPath" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
diskPath)
]
)
instance Core.ToPath AttachDisk where
toPath :: AttachDisk -> ByteString
toPath = ByteString -> AttachDisk -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery AttachDisk where
toQuery :: AttachDisk -> QueryString
toQuery = QueryString -> AttachDisk -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data AttachDiskResponse = AttachDiskResponse'
{
AttachDiskResponse -> Maybe [Operation]
operations :: Prelude.Maybe [Operation],
AttachDiskResponse -> Int
httpStatus :: Prelude.Int
}
deriving (AttachDiskResponse -> AttachDiskResponse -> Bool
(AttachDiskResponse -> AttachDiskResponse -> Bool)
-> (AttachDiskResponse -> AttachDiskResponse -> Bool)
-> Eq AttachDiskResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AttachDiskResponse -> AttachDiskResponse -> Bool
$c/= :: AttachDiskResponse -> AttachDiskResponse -> Bool
== :: AttachDiskResponse -> AttachDiskResponse -> Bool
$c== :: AttachDiskResponse -> AttachDiskResponse -> Bool
Prelude.Eq, ReadPrec [AttachDiskResponse]
ReadPrec AttachDiskResponse
Int -> ReadS AttachDiskResponse
ReadS [AttachDiskResponse]
(Int -> ReadS AttachDiskResponse)
-> ReadS [AttachDiskResponse]
-> ReadPrec AttachDiskResponse
-> ReadPrec [AttachDiskResponse]
-> Read AttachDiskResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AttachDiskResponse]
$creadListPrec :: ReadPrec [AttachDiskResponse]
readPrec :: ReadPrec AttachDiskResponse
$creadPrec :: ReadPrec AttachDiskResponse
readList :: ReadS [AttachDiskResponse]
$creadList :: ReadS [AttachDiskResponse]
readsPrec :: Int -> ReadS AttachDiskResponse
$creadsPrec :: Int -> ReadS AttachDiskResponse
Prelude.Read, Int -> AttachDiskResponse -> ShowS
[AttachDiskResponse] -> ShowS
AttachDiskResponse -> String
(Int -> AttachDiskResponse -> ShowS)
-> (AttachDiskResponse -> String)
-> ([AttachDiskResponse] -> ShowS)
-> Show AttachDiskResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AttachDiskResponse] -> ShowS
$cshowList :: [AttachDiskResponse] -> ShowS
show :: AttachDiskResponse -> String
$cshow :: AttachDiskResponse -> String
showsPrec :: Int -> AttachDiskResponse -> ShowS
$cshowsPrec :: Int -> AttachDiskResponse -> ShowS
Prelude.Show, (forall x. AttachDiskResponse -> Rep AttachDiskResponse x)
-> (forall x. Rep AttachDiskResponse x -> AttachDiskResponse)
-> Generic AttachDiskResponse
forall x. Rep AttachDiskResponse x -> AttachDiskResponse
forall x. AttachDiskResponse -> Rep AttachDiskResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AttachDiskResponse x -> AttachDiskResponse
$cfrom :: forall x. AttachDiskResponse -> Rep AttachDiskResponse x
Prelude.Generic)
newAttachDiskResponse ::
Prelude.Int ->
AttachDiskResponse
newAttachDiskResponse :: Int -> AttachDiskResponse
newAttachDiskResponse Int
pHttpStatus_ =
AttachDiskResponse' :: Maybe [Operation] -> Int -> AttachDiskResponse
AttachDiskResponse'
{ $sel:operations:AttachDiskResponse' :: Maybe [Operation]
operations = Maybe [Operation]
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:AttachDiskResponse' :: Int
httpStatus = Int
pHttpStatus_
}
attachDiskResponse_operations :: Lens.Lens' AttachDiskResponse (Prelude.Maybe [Operation])
attachDiskResponse_operations :: (Maybe [Operation] -> f (Maybe [Operation]))
-> AttachDiskResponse -> f AttachDiskResponse
attachDiskResponse_operations = (AttachDiskResponse -> Maybe [Operation])
-> (AttachDiskResponse -> Maybe [Operation] -> AttachDiskResponse)
-> Lens
AttachDiskResponse
AttachDiskResponse
(Maybe [Operation])
(Maybe [Operation])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttachDiskResponse' {Maybe [Operation]
operations :: Maybe [Operation]
$sel:operations:AttachDiskResponse' :: AttachDiskResponse -> Maybe [Operation]
operations} -> Maybe [Operation]
operations) (\s :: AttachDiskResponse
s@AttachDiskResponse' {} Maybe [Operation]
a -> AttachDiskResponse
s {$sel:operations:AttachDiskResponse' :: Maybe [Operation]
operations = Maybe [Operation]
a} :: AttachDiskResponse) ((Maybe [Operation] -> f (Maybe [Operation]))
-> AttachDiskResponse -> f AttachDiskResponse)
-> ((Maybe [Operation] -> f (Maybe [Operation]))
-> Maybe [Operation] -> f (Maybe [Operation]))
-> (Maybe [Operation] -> f (Maybe [Operation]))
-> AttachDiskResponse
-> f AttachDiskResponse
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
attachDiskResponse_httpStatus :: Lens.Lens' AttachDiskResponse Prelude.Int
attachDiskResponse_httpStatus :: (Int -> f Int) -> AttachDiskResponse -> f AttachDiskResponse
attachDiskResponse_httpStatus = (AttachDiskResponse -> Int)
-> (AttachDiskResponse -> Int -> AttachDiskResponse)
-> Lens AttachDiskResponse AttachDiskResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttachDiskResponse' {Int
httpStatus :: Int
$sel:httpStatus:AttachDiskResponse' :: AttachDiskResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: AttachDiskResponse
s@AttachDiskResponse' {} Int
a -> AttachDiskResponse
s {$sel:httpStatus:AttachDiskResponse' :: Int
httpStatus = Int
a} :: AttachDiskResponse)
instance Prelude.NFData AttachDiskResponse