{-# 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.StopInstance
(
StopInstance (..),
newStopInstance,
stopInstance_force,
stopInstance_instanceName,
StopInstanceResponse (..),
newStopInstanceResponse,
stopInstanceResponse_operations,
stopInstanceResponse_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 StopInstance = StopInstance'
{
StopInstance -> Maybe Bool
force :: Prelude.Maybe Prelude.Bool,
StopInstance -> Text
instanceName :: Prelude.Text
}
deriving (StopInstance -> StopInstance -> Bool
(StopInstance -> StopInstance -> Bool)
-> (StopInstance -> StopInstance -> Bool) -> Eq StopInstance
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopInstance -> StopInstance -> Bool
$c/= :: StopInstance -> StopInstance -> Bool
== :: StopInstance -> StopInstance -> Bool
$c== :: StopInstance -> StopInstance -> Bool
Prelude.Eq, ReadPrec [StopInstance]
ReadPrec StopInstance
Int -> ReadS StopInstance
ReadS [StopInstance]
(Int -> ReadS StopInstance)
-> ReadS [StopInstance]
-> ReadPrec StopInstance
-> ReadPrec [StopInstance]
-> Read StopInstance
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopInstance]
$creadListPrec :: ReadPrec [StopInstance]
readPrec :: ReadPrec StopInstance
$creadPrec :: ReadPrec StopInstance
readList :: ReadS [StopInstance]
$creadList :: ReadS [StopInstance]
readsPrec :: Int -> ReadS StopInstance
$creadsPrec :: Int -> ReadS StopInstance
Prelude.Read, Int -> StopInstance -> ShowS
[StopInstance] -> ShowS
StopInstance -> String
(Int -> StopInstance -> ShowS)
-> (StopInstance -> String)
-> ([StopInstance] -> ShowS)
-> Show StopInstance
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopInstance] -> ShowS
$cshowList :: [StopInstance] -> ShowS
show :: StopInstance -> String
$cshow :: StopInstance -> String
showsPrec :: Int -> StopInstance -> ShowS
$cshowsPrec :: Int -> StopInstance -> ShowS
Prelude.Show, (forall x. StopInstance -> Rep StopInstance x)
-> (forall x. Rep StopInstance x -> StopInstance)
-> Generic StopInstance
forall x. Rep StopInstance x -> StopInstance
forall x. StopInstance -> Rep StopInstance x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StopInstance x -> StopInstance
$cfrom :: forall x. StopInstance -> Rep StopInstance x
Prelude.Generic)
newStopInstance ::
Prelude.Text ->
StopInstance
newStopInstance :: Text -> StopInstance
newStopInstance Text
pInstanceName_ =
StopInstance' :: Maybe Bool -> Text -> StopInstance
StopInstance'
{ $sel:force:StopInstance' :: Maybe Bool
force = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
$sel:instanceName:StopInstance' :: Text
instanceName = Text
pInstanceName_
}
stopInstance_force :: Lens.Lens' StopInstance (Prelude.Maybe Prelude.Bool)
stopInstance_force :: (Maybe Bool -> f (Maybe Bool)) -> StopInstance -> f StopInstance
stopInstance_force = (StopInstance -> Maybe Bool)
-> (StopInstance -> Maybe Bool -> StopInstance)
-> Lens StopInstance StopInstance (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopInstance' {Maybe Bool
force :: Maybe Bool
$sel:force:StopInstance' :: StopInstance -> Maybe Bool
force} -> Maybe Bool
force) (\s :: StopInstance
s@StopInstance' {} Maybe Bool
a -> StopInstance
s {$sel:force:StopInstance' :: Maybe Bool
force = Maybe Bool
a} :: StopInstance)
stopInstance_instanceName :: Lens.Lens' StopInstance Prelude.Text
stopInstance_instanceName :: (Text -> f Text) -> StopInstance -> f StopInstance
stopInstance_instanceName = (StopInstance -> Text)
-> (StopInstance -> Text -> StopInstance)
-> Lens StopInstance StopInstance Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopInstance' {Text
instanceName :: Text
$sel:instanceName:StopInstance' :: StopInstance -> Text
instanceName} -> Text
instanceName) (\s :: StopInstance
s@StopInstance' {} Text
a -> StopInstance
s {$sel:instanceName:StopInstance' :: Text
instanceName = Text
a} :: StopInstance)
instance Core.AWSRequest StopInstance where
type AWSResponse StopInstance = StopInstanceResponse
request :: StopInstance -> Request StopInstance
request = Service -> StopInstance -> Request StopInstance
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy StopInstance
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StopInstance)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse StopInstance))
-> Logger
-> Service
-> Proxy StopInstance
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StopInstance)))
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 -> StopInstanceResponse
StopInstanceResponse'
(Maybe [Operation] -> Int -> StopInstanceResponse)
-> Either String (Maybe [Operation])
-> Either String (Int -> StopInstanceResponse)
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 -> StopInstanceResponse)
-> Either String Int -> Either String StopInstanceResponse
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 StopInstance
instance Prelude.NFData StopInstance
instance Core.ToHeaders StopInstance where
toHeaders :: StopInstance -> ResponseHeaders
toHeaders =
ResponseHeaders -> StopInstance -> 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.StopInstance" ::
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 StopInstance where
toJSON :: StopInstance -> Value
toJSON StopInstance' {Maybe Bool
Text
instanceName :: Text
force :: Maybe Bool
$sel:instanceName:StopInstance' :: StopInstance -> Text
$sel:force:StopInstance' :: StopInstance -> Maybe Bool
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"force" 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
force,
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)
]
)
instance Core.ToPath StopInstance where
toPath :: StopInstance -> ByteString
toPath = ByteString -> StopInstance -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery StopInstance where
toQuery :: StopInstance -> QueryString
toQuery = QueryString -> StopInstance -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data StopInstanceResponse = StopInstanceResponse'
{
StopInstanceResponse -> Maybe [Operation]
operations :: Prelude.Maybe [Operation],
StopInstanceResponse -> Int
httpStatus :: Prelude.Int
}
deriving (StopInstanceResponse -> StopInstanceResponse -> Bool
(StopInstanceResponse -> StopInstanceResponse -> Bool)
-> (StopInstanceResponse -> StopInstanceResponse -> Bool)
-> Eq StopInstanceResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopInstanceResponse -> StopInstanceResponse -> Bool
$c/= :: StopInstanceResponse -> StopInstanceResponse -> Bool
== :: StopInstanceResponse -> StopInstanceResponse -> Bool
$c== :: StopInstanceResponse -> StopInstanceResponse -> Bool
Prelude.Eq, ReadPrec [StopInstanceResponse]
ReadPrec StopInstanceResponse
Int -> ReadS StopInstanceResponse
ReadS [StopInstanceResponse]
(Int -> ReadS StopInstanceResponse)
-> ReadS [StopInstanceResponse]
-> ReadPrec StopInstanceResponse
-> ReadPrec [StopInstanceResponse]
-> Read StopInstanceResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopInstanceResponse]
$creadListPrec :: ReadPrec [StopInstanceResponse]
readPrec :: ReadPrec StopInstanceResponse
$creadPrec :: ReadPrec StopInstanceResponse
readList :: ReadS [StopInstanceResponse]
$creadList :: ReadS [StopInstanceResponse]
readsPrec :: Int -> ReadS StopInstanceResponse
$creadsPrec :: Int -> ReadS StopInstanceResponse
Prelude.Read, Int -> StopInstanceResponse -> ShowS
[StopInstanceResponse] -> ShowS
StopInstanceResponse -> String
(Int -> StopInstanceResponse -> ShowS)
-> (StopInstanceResponse -> String)
-> ([StopInstanceResponse] -> ShowS)
-> Show StopInstanceResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopInstanceResponse] -> ShowS
$cshowList :: [StopInstanceResponse] -> ShowS
show :: StopInstanceResponse -> String
$cshow :: StopInstanceResponse -> String
showsPrec :: Int -> StopInstanceResponse -> ShowS
$cshowsPrec :: Int -> StopInstanceResponse -> ShowS
Prelude.Show, (forall x. StopInstanceResponse -> Rep StopInstanceResponse x)
-> (forall x. Rep StopInstanceResponse x -> StopInstanceResponse)
-> Generic StopInstanceResponse
forall x. Rep StopInstanceResponse x -> StopInstanceResponse
forall x. StopInstanceResponse -> Rep StopInstanceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StopInstanceResponse x -> StopInstanceResponse
$cfrom :: forall x. StopInstanceResponse -> Rep StopInstanceResponse x
Prelude.Generic)
newStopInstanceResponse ::
Prelude.Int ->
StopInstanceResponse
newStopInstanceResponse :: Int -> StopInstanceResponse
newStopInstanceResponse Int
pHttpStatus_ =
StopInstanceResponse' :: Maybe [Operation] -> Int -> StopInstanceResponse
StopInstanceResponse'
{ $sel:operations:StopInstanceResponse' :: Maybe [Operation]
operations = Maybe [Operation]
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:StopInstanceResponse' :: Int
httpStatus = Int
pHttpStatus_
}
stopInstanceResponse_operations :: Lens.Lens' StopInstanceResponse (Prelude.Maybe [Operation])
stopInstanceResponse_operations :: (Maybe [Operation] -> f (Maybe [Operation]))
-> StopInstanceResponse -> f StopInstanceResponse
stopInstanceResponse_operations = (StopInstanceResponse -> Maybe [Operation])
-> (StopInstanceResponse
-> Maybe [Operation] -> StopInstanceResponse)
-> Lens
StopInstanceResponse
StopInstanceResponse
(Maybe [Operation])
(Maybe [Operation])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopInstanceResponse' {Maybe [Operation]
operations :: Maybe [Operation]
$sel:operations:StopInstanceResponse' :: StopInstanceResponse -> Maybe [Operation]
operations} -> Maybe [Operation]
operations) (\s :: StopInstanceResponse
s@StopInstanceResponse' {} Maybe [Operation]
a -> StopInstanceResponse
s {$sel:operations:StopInstanceResponse' :: Maybe [Operation]
operations = Maybe [Operation]
a} :: StopInstanceResponse) ((Maybe [Operation] -> f (Maybe [Operation]))
-> StopInstanceResponse -> f StopInstanceResponse)
-> ((Maybe [Operation] -> f (Maybe [Operation]))
-> Maybe [Operation] -> f (Maybe [Operation]))
-> (Maybe [Operation] -> f (Maybe [Operation]))
-> StopInstanceResponse
-> f StopInstanceResponse
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
stopInstanceResponse_httpStatus :: Lens.Lens' StopInstanceResponse Prelude.Int
stopInstanceResponse_httpStatus :: (Int -> f Int) -> StopInstanceResponse -> f StopInstanceResponse
stopInstanceResponse_httpStatus = (StopInstanceResponse -> Int)
-> (StopInstanceResponse -> Int -> StopInstanceResponse)
-> Lens StopInstanceResponse StopInstanceResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopInstanceResponse' {Int
httpStatus :: Int
$sel:httpStatus:StopInstanceResponse' :: StopInstanceResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: StopInstanceResponse
s@StopInstanceResponse' {} Int
a -> StopInstanceResponse
s {$sel:httpStatus:StopInstanceResponse' :: Int
httpStatus = Int
a} :: StopInstanceResponse)
instance Prelude.NFData StopInstanceResponse