{-# 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.AutoScaling.DetachInstances
(
DetachInstances (..),
newDetachInstances,
detachInstances_instanceIds,
detachInstances_autoScalingGroupName,
detachInstances_shouldDecrementDesiredCapacity,
DetachInstancesResponse (..),
newDetachInstancesResponse,
detachInstancesResponse_activities,
detachInstancesResponse_httpStatus,
)
where
import Amazonka.AutoScaling.Types
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
data DetachInstances = DetachInstances'
{
DetachInstances -> Maybe [Text]
instanceIds :: Prelude.Maybe [Prelude.Text],
DetachInstances -> Text
autoScalingGroupName :: Prelude.Text,
DetachInstances -> Bool
shouldDecrementDesiredCapacity :: Prelude.Bool
}
deriving (DetachInstances -> DetachInstances -> Bool
(DetachInstances -> DetachInstances -> Bool)
-> (DetachInstances -> DetachInstances -> Bool)
-> Eq DetachInstances
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DetachInstances -> DetachInstances -> Bool
$c/= :: DetachInstances -> DetachInstances -> Bool
== :: DetachInstances -> DetachInstances -> Bool
$c== :: DetachInstances -> DetachInstances -> Bool
Prelude.Eq, ReadPrec [DetachInstances]
ReadPrec DetachInstances
Int -> ReadS DetachInstances
ReadS [DetachInstances]
(Int -> ReadS DetachInstances)
-> ReadS [DetachInstances]
-> ReadPrec DetachInstances
-> ReadPrec [DetachInstances]
-> Read DetachInstances
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DetachInstances]
$creadListPrec :: ReadPrec [DetachInstances]
readPrec :: ReadPrec DetachInstances
$creadPrec :: ReadPrec DetachInstances
readList :: ReadS [DetachInstances]
$creadList :: ReadS [DetachInstances]
readsPrec :: Int -> ReadS DetachInstances
$creadsPrec :: Int -> ReadS DetachInstances
Prelude.Read, Int -> DetachInstances -> ShowS
[DetachInstances] -> ShowS
DetachInstances -> String
(Int -> DetachInstances -> ShowS)
-> (DetachInstances -> String)
-> ([DetachInstances] -> ShowS)
-> Show DetachInstances
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DetachInstances] -> ShowS
$cshowList :: [DetachInstances] -> ShowS
show :: DetachInstances -> String
$cshow :: DetachInstances -> String
showsPrec :: Int -> DetachInstances -> ShowS
$cshowsPrec :: Int -> DetachInstances -> ShowS
Prelude.Show, (forall x. DetachInstances -> Rep DetachInstances x)
-> (forall x. Rep DetachInstances x -> DetachInstances)
-> Generic DetachInstances
forall x. Rep DetachInstances x -> DetachInstances
forall x. DetachInstances -> Rep DetachInstances x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DetachInstances x -> DetachInstances
$cfrom :: forall x. DetachInstances -> Rep DetachInstances x
Prelude.Generic)
newDetachInstances ::
Prelude.Text ->
Prelude.Bool ->
DetachInstances
newDetachInstances :: Text -> Bool -> DetachInstances
newDetachInstances
Text
pAutoScalingGroupName_
Bool
pShouldDecrementDesiredCapacity_ =
DetachInstances' :: Maybe [Text] -> Text -> Bool -> DetachInstances
DetachInstances'
{ $sel:instanceIds:DetachInstances' :: Maybe [Text]
instanceIds = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
$sel:autoScalingGroupName:DetachInstances' :: Text
autoScalingGroupName = Text
pAutoScalingGroupName_,
$sel:shouldDecrementDesiredCapacity:DetachInstances' :: Bool
shouldDecrementDesiredCapacity =
Bool
pShouldDecrementDesiredCapacity_
}
detachInstances_instanceIds :: Lens.Lens' DetachInstances (Prelude.Maybe [Prelude.Text])
detachInstances_instanceIds :: (Maybe [Text] -> f (Maybe [Text]))
-> DetachInstances -> f DetachInstances
detachInstances_instanceIds = (DetachInstances -> Maybe [Text])
-> (DetachInstances -> Maybe [Text] -> DetachInstances)
-> Lens
DetachInstances DetachInstances (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetachInstances' {Maybe [Text]
instanceIds :: Maybe [Text]
$sel:instanceIds:DetachInstances' :: DetachInstances -> Maybe [Text]
instanceIds} -> Maybe [Text]
instanceIds) (\s :: DetachInstances
s@DetachInstances' {} Maybe [Text]
a -> DetachInstances
s {$sel:instanceIds:DetachInstances' :: Maybe [Text]
instanceIds = Maybe [Text]
a} :: DetachInstances) ((Maybe [Text] -> f (Maybe [Text]))
-> DetachInstances -> f DetachInstances)
-> ((Maybe [Text] -> f (Maybe [Text]))
-> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> DetachInstances
-> f DetachInstances
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
detachInstances_autoScalingGroupName :: Lens.Lens' DetachInstances Prelude.Text
detachInstances_autoScalingGroupName :: (Text -> f Text) -> DetachInstances -> f DetachInstances
detachInstances_autoScalingGroupName = (DetachInstances -> Text)
-> (DetachInstances -> Text -> DetachInstances)
-> Lens DetachInstances DetachInstances Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetachInstances' {Text
autoScalingGroupName :: Text
$sel:autoScalingGroupName:DetachInstances' :: DetachInstances -> Text
autoScalingGroupName} -> Text
autoScalingGroupName) (\s :: DetachInstances
s@DetachInstances' {} Text
a -> DetachInstances
s {$sel:autoScalingGroupName:DetachInstances' :: Text
autoScalingGroupName = Text
a} :: DetachInstances)
detachInstances_shouldDecrementDesiredCapacity :: Lens.Lens' DetachInstances Prelude.Bool
detachInstances_shouldDecrementDesiredCapacity :: (Bool -> f Bool) -> DetachInstances -> f DetachInstances
detachInstances_shouldDecrementDesiredCapacity = (DetachInstances -> Bool)
-> (DetachInstances -> Bool -> DetachInstances)
-> Lens DetachInstances DetachInstances Bool Bool
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetachInstances' {Bool
shouldDecrementDesiredCapacity :: Bool
$sel:shouldDecrementDesiredCapacity:DetachInstances' :: DetachInstances -> Bool
shouldDecrementDesiredCapacity} -> Bool
shouldDecrementDesiredCapacity) (\s :: DetachInstances
s@DetachInstances' {} Bool
a -> DetachInstances
s {$sel:shouldDecrementDesiredCapacity:DetachInstances' :: Bool
shouldDecrementDesiredCapacity = Bool
a} :: DetachInstances)
instance Core.AWSRequest DetachInstances where
type
AWSResponse DetachInstances =
DetachInstancesResponse
request :: DetachInstances -> Request DetachInstances
request = Service -> DetachInstances -> Request DetachInstances
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
response :: Logger
-> Service
-> Proxy DetachInstances
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DetachInstances)))
response =
Text
-> (Int
-> ResponseHeaders
-> [Node]
-> Either String (AWSResponse DetachInstances))
-> Logger
-> Service
-> Proxy DetachInstances
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DetachInstances)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
-> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
Text
"DetachInstancesResult"
( \Int
s ResponseHeaders
h [Node]
x ->
Maybe [Activity] -> Int -> DetachInstancesResponse
DetachInstancesResponse'
(Maybe [Activity] -> Int -> DetachInstancesResponse)
-> Either String (Maybe [Activity])
-> Either String (Int -> DetachInstancesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Activities" Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
Either String [Node]
-> ([Node] -> Either String (Maybe [Activity]))
-> Either String (Maybe [Activity])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [Activity])
-> [Node] -> Either String (Maybe [Activity])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [Activity]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
)
Either String (Int -> DetachInstancesResponse)
-> Either String Int -> Either String DetachInstancesResponse
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 DetachInstances
instance Prelude.NFData DetachInstances
instance Core.ToHeaders DetachInstances where
toHeaders :: DetachInstances -> ResponseHeaders
toHeaders = ResponseHeaders -> DetachInstances -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty
instance Core.ToPath DetachInstances where
toPath :: DetachInstances -> ByteString
toPath = ByteString -> DetachInstances -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery DetachInstances where
toQuery :: DetachInstances -> QueryString
toQuery DetachInstances' {Bool
Maybe [Text]
Text
shouldDecrementDesiredCapacity :: Bool
autoScalingGroupName :: Text
instanceIds :: Maybe [Text]
$sel:shouldDecrementDesiredCapacity:DetachInstances' :: DetachInstances -> Bool
$sel:autoScalingGroupName:DetachInstances' :: DetachInstances -> Text
$sel:instanceIds:DetachInstances' :: DetachInstances -> Maybe [Text]
..} =
[QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"Action"
ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"DetachInstances" :: Prelude.ByteString),
ByteString
"Version"
ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2011-01-01" :: Prelude.ByteString),
ByteString
"InstanceIds"
ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
(ByteString -> [Text] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" ([Text] -> QueryString) -> Maybe [Text] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
instanceIds),
ByteString
"AutoScalingGroupName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
autoScalingGroupName,
ByteString
"ShouldDecrementDesiredCapacity"
ByteString -> Bool -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Bool
shouldDecrementDesiredCapacity
]
data DetachInstancesResponse = DetachInstancesResponse'
{
DetachInstancesResponse -> Maybe [Activity]
activities :: Prelude.Maybe [Activity],
DetachInstancesResponse -> Int
httpStatus :: Prelude.Int
}
deriving (DetachInstancesResponse -> DetachInstancesResponse -> Bool
(DetachInstancesResponse -> DetachInstancesResponse -> Bool)
-> (DetachInstancesResponse -> DetachInstancesResponse -> Bool)
-> Eq DetachInstancesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DetachInstancesResponse -> DetachInstancesResponse -> Bool
$c/= :: DetachInstancesResponse -> DetachInstancesResponse -> Bool
== :: DetachInstancesResponse -> DetachInstancesResponse -> Bool
$c== :: DetachInstancesResponse -> DetachInstancesResponse -> Bool
Prelude.Eq, ReadPrec [DetachInstancesResponse]
ReadPrec DetachInstancesResponse
Int -> ReadS DetachInstancesResponse
ReadS [DetachInstancesResponse]
(Int -> ReadS DetachInstancesResponse)
-> ReadS [DetachInstancesResponse]
-> ReadPrec DetachInstancesResponse
-> ReadPrec [DetachInstancesResponse]
-> Read DetachInstancesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DetachInstancesResponse]
$creadListPrec :: ReadPrec [DetachInstancesResponse]
readPrec :: ReadPrec DetachInstancesResponse
$creadPrec :: ReadPrec DetachInstancesResponse
readList :: ReadS [DetachInstancesResponse]
$creadList :: ReadS [DetachInstancesResponse]
readsPrec :: Int -> ReadS DetachInstancesResponse
$creadsPrec :: Int -> ReadS DetachInstancesResponse
Prelude.Read, Int -> DetachInstancesResponse -> ShowS
[DetachInstancesResponse] -> ShowS
DetachInstancesResponse -> String
(Int -> DetachInstancesResponse -> ShowS)
-> (DetachInstancesResponse -> String)
-> ([DetachInstancesResponse] -> ShowS)
-> Show DetachInstancesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DetachInstancesResponse] -> ShowS
$cshowList :: [DetachInstancesResponse] -> ShowS
show :: DetachInstancesResponse -> String
$cshow :: DetachInstancesResponse -> String
showsPrec :: Int -> DetachInstancesResponse -> ShowS
$cshowsPrec :: Int -> DetachInstancesResponse -> ShowS
Prelude.Show, (forall x.
DetachInstancesResponse -> Rep DetachInstancesResponse x)
-> (forall x.
Rep DetachInstancesResponse x -> DetachInstancesResponse)
-> Generic DetachInstancesResponse
forall x. Rep DetachInstancesResponse x -> DetachInstancesResponse
forall x. DetachInstancesResponse -> Rep DetachInstancesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DetachInstancesResponse x -> DetachInstancesResponse
$cfrom :: forall x. DetachInstancesResponse -> Rep DetachInstancesResponse x
Prelude.Generic)
newDetachInstancesResponse ::
Prelude.Int ->
DetachInstancesResponse
newDetachInstancesResponse :: Int -> DetachInstancesResponse
newDetachInstancesResponse Int
pHttpStatus_ =
DetachInstancesResponse' :: Maybe [Activity] -> Int -> DetachInstancesResponse
DetachInstancesResponse'
{ $sel:activities:DetachInstancesResponse' :: Maybe [Activity]
activities =
Maybe [Activity]
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:DetachInstancesResponse' :: Int
httpStatus = Int
pHttpStatus_
}
detachInstancesResponse_activities :: Lens.Lens' DetachInstancesResponse (Prelude.Maybe [Activity])
detachInstancesResponse_activities :: (Maybe [Activity] -> f (Maybe [Activity]))
-> DetachInstancesResponse -> f DetachInstancesResponse
detachInstancesResponse_activities = (DetachInstancesResponse -> Maybe [Activity])
-> (DetachInstancesResponse
-> Maybe [Activity] -> DetachInstancesResponse)
-> Lens
DetachInstancesResponse
DetachInstancesResponse
(Maybe [Activity])
(Maybe [Activity])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetachInstancesResponse' {Maybe [Activity]
activities :: Maybe [Activity]
$sel:activities:DetachInstancesResponse' :: DetachInstancesResponse -> Maybe [Activity]
activities} -> Maybe [Activity]
activities) (\s :: DetachInstancesResponse
s@DetachInstancesResponse' {} Maybe [Activity]
a -> DetachInstancesResponse
s {$sel:activities:DetachInstancesResponse' :: Maybe [Activity]
activities = Maybe [Activity]
a} :: DetachInstancesResponse) ((Maybe [Activity] -> f (Maybe [Activity]))
-> DetachInstancesResponse -> f DetachInstancesResponse)
-> ((Maybe [Activity] -> f (Maybe [Activity]))
-> Maybe [Activity] -> f (Maybe [Activity]))
-> (Maybe [Activity] -> f (Maybe [Activity]))
-> DetachInstancesResponse
-> f DetachInstancesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Activity] [Activity] [Activity] [Activity]
-> Iso
(Maybe [Activity])
(Maybe [Activity])
(Maybe [Activity])
(Maybe [Activity])
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 [Activity] [Activity] [Activity] [Activity]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
detachInstancesResponse_httpStatus :: Lens.Lens' DetachInstancesResponse Prelude.Int
detachInstancesResponse_httpStatus :: (Int -> f Int)
-> DetachInstancesResponse -> f DetachInstancesResponse
detachInstancesResponse_httpStatus = (DetachInstancesResponse -> Int)
-> (DetachInstancesResponse -> Int -> DetachInstancesResponse)
-> Lens DetachInstancesResponse DetachInstancesResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetachInstancesResponse' {Int
httpStatus :: Int
$sel:httpStatus:DetachInstancesResponse' :: DetachInstancesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DetachInstancesResponse
s@DetachInstancesResponse' {} Int
a -> DetachInstancesResponse
s {$sel:httpStatus:DetachInstancesResponse' :: Int
httpStatus = Int
a} :: DetachInstancesResponse)
instance Prelude.NFData DetachInstancesResponse