{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.AutoScaling.ExitStandby
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Moves the specified instances out of the standby state.
--
-- After you put the instances back in service, the desired capacity is
-- incremented.
--
-- For more information, see
-- <https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-enter-exit-standby.html Temporarily removing instances from your Auto Scaling group>
-- in the /Amazon EC2 Auto Scaling User Guide/.
module Amazonka.AutoScaling.ExitStandby
  ( -- * Creating a Request
    ExitStandby (..),
    newExitStandby,

    -- * Request Lenses
    exitStandby_instanceIds,
    exitStandby_autoScalingGroupName,

    -- * Destructuring the Response
    ExitStandbyResponse (..),
    newExitStandbyResponse,

    -- * Response Lenses
    exitStandbyResponse_activities,
    exitStandbyResponse_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

-- | /See:/ 'newExitStandby' smart constructor.
data ExitStandby = ExitStandby'
  { -- | The IDs of the instances. You can specify up to 20 instances.
    ExitStandby -> Maybe [Text]
instanceIds :: Prelude.Maybe [Prelude.Text],
    -- | The name of the Auto Scaling group.
    ExitStandby -> Text
autoScalingGroupName :: Prelude.Text
  }
  deriving (ExitStandby -> ExitStandby -> Bool
(ExitStandby -> ExitStandby -> Bool)
-> (ExitStandby -> ExitStandby -> Bool) -> Eq ExitStandby
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExitStandby -> ExitStandby -> Bool
$c/= :: ExitStandby -> ExitStandby -> Bool
== :: ExitStandby -> ExitStandby -> Bool
$c== :: ExitStandby -> ExitStandby -> Bool
Prelude.Eq, ReadPrec [ExitStandby]
ReadPrec ExitStandby
Int -> ReadS ExitStandby
ReadS [ExitStandby]
(Int -> ReadS ExitStandby)
-> ReadS [ExitStandby]
-> ReadPrec ExitStandby
-> ReadPrec [ExitStandby]
-> Read ExitStandby
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExitStandby]
$creadListPrec :: ReadPrec [ExitStandby]
readPrec :: ReadPrec ExitStandby
$creadPrec :: ReadPrec ExitStandby
readList :: ReadS [ExitStandby]
$creadList :: ReadS [ExitStandby]
readsPrec :: Int -> ReadS ExitStandby
$creadsPrec :: Int -> ReadS ExitStandby
Prelude.Read, Int -> ExitStandby -> ShowS
[ExitStandby] -> ShowS
ExitStandby -> String
(Int -> ExitStandby -> ShowS)
-> (ExitStandby -> String)
-> ([ExitStandby] -> ShowS)
-> Show ExitStandby
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExitStandby] -> ShowS
$cshowList :: [ExitStandby] -> ShowS
show :: ExitStandby -> String
$cshow :: ExitStandby -> String
showsPrec :: Int -> ExitStandby -> ShowS
$cshowsPrec :: Int -> ExitStandby -> ShowS
Prelude.Show, (forall x. ExitStandby -> Rep ExitStandby x)
-> (forall x. Rep ExitStandby x -> ExitStandby)
-> Generic ExitStandby
forall x. Rep ExitStandby x -> ExitStandby
forall x. ExitStandby -> Rep ExitStandby x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExitStandby x -> ExitStandby
$cfrom :: forall x. ExitStandby -> Rep ExitStandby x
Prelude.Generic)

-- |
-- Create a value of 'ExitStandby' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'instanceIds', 'exitStandby_instanceIds' - The IDs of the instances. You can specify up to 20 instances.
--
-- 'autoScalingGroupName', 'exitStandby_autoScalingGroupName' - The name of the Auto Scaling group.
newExitStandby ::
  -- | 'autoScalingGroupName'
  Prelude.Text ->
  ExitStandby
newExitStandby :: Text -> ExitStandby
newExitStandby Text
pAutoScalingGroupName_ =
  ExitStandby' :: Maybe [Text] -> Text -> ExitStandby
ExitStandby'
    { $sel:instanceIds:ExitStandby' :: Maybe [Text]
instanceIds = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:autoScalingGroupName:ExitStandby' :: Text
autoScalingGroupName = Text
pAutoScalingGroupName_
    }

-- | The IDs of the instances. You can specify up to 20 instances.
exitStandby_instanceIds :: Lens.Lens' ExitStandby (Prelude.Maybe [Prelude.Text])
exitStandby_instanceIds :: (Maybe [Text] -> f (Maybe [Text])) -> ExitStandby -> f ExitStandby
exitStandby_instanceIds = (ExitStandby -> Maybe [Text])
-> (ExitStandby -> Maybe [Text] -> ExitStandby)
-> Lens ExitStandby ExitStandby (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExitStandby' {Maybe [Text]
instanceIds :: Maybe [Text]
$sel:instanceIds:ExitStandby' :: ExitStandby -> Maybe [Text]
instanceIds} -> Maybe [Text]
instanceIds) (\s :: ExitStandby
s@ExitStandby' {} Maybe [Text]
a -> ExitStandby
s {$sel:instanceIds:ExitStandby' :: Maybe [Text]
instanceIds = Maybe [Text]
a} :: ExitStandby) ((Maybe [Text] -> f (Maybe [Text]))
 -> ExitStandby -> f ExitStandby)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ExitStandby
-> f ExitStandby
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

-- | The name of the Auto Scaling group.
exitStandby_autoScalingGroupName :: Lens.Lens' ExitStandby Prelude.Text
exitStandby_autoScalingGroupName :: (Text -> f Text) -> ExitStandby -> f ExitStandby
exitStandby_autoScalingGroupName = (ExitStandby -> Text)
-> (ExitStandby -> Text -> ExitStandby)
-> Lens ExitStandby ExitStandby Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExitStandby' {Text
autoScalingGroupName :: Text
$sel:autoScalingGroupName:ExitStandby' :: ExitStandby -> Text
autoScalingGroupName} -> Text
autoScalingGroupName) (\s :: ExitStandby
s@ExitStandby' {} Text
a -> ExitStandby
s {$sel:autoScalingGroupName:ExitStandby' :: Text
autoScalingGroupName = Text
a} :: ExitStandby)

instance Core.AWSRequest ExitStandby where
  type AWSResponse ExitStandby = ExitStandbyResponse
  request :: ExitStandby -> Request ExitStandby
request = Service -> ExitStandby -> Request ExitStandby
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy ExitStandby
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ExitStandby)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse ExitStandby))
-> Logger
-> Service
-> Proxy ExitStandby
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ExitStandby)))
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
"ExitStandbyResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe [Activity] -> Int -> ExitStandbyResponse
ExitStandbyResponse'
            (Maybe [Activity] -> Int -> ExitStandbyResponse)
-> Either String (Maybe [Activity])
-> Either String (Int -> ExitStandbyResponse)
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 -> ExitStandbyResponse)
-> Either String Int -> Either String ExitStandbyResponse
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 ExitStandby

instance Prelude.NFData ExitStandby

instance Core.ToHeaders ExitStandby where
  toHeaders :: ExitStandby -> ResponseHeaders
toHeaders = ResponseHeaders -> ExitStandby -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToPath ExitStandby where
  toPath :: ExitStandby -> ByteString
toPath = ByteString -> ExitStandby -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery ExitStandby where
  toQuery :: ExitStandby -> QueryString
toQuery ExitStandby' {Maybe [Text]
Text
autoScalingGroupName :: Text
instanceIds :: Maybe [Text]
$sel:autoScalingGroupName:ExitStandby' :: ExitStandby -> Text
$sel:instanceIds:ExitStandby' :: ExitStandby -> 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
"ExitStandby" :: 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
      ]

-- | /See:/ 'newExitStandbyResponse' smart constructor.
data ExitStandbyResponse = ExitStandbyResponse'
  { -- | The activities related to moving instances out of @Standby@ mode.
    ExitStandbyResponse -> Maybe [Activity]
activities :: Prelude.Maybe [Activity],
    -- | The response's http status code.
    ExitStandbyResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ExitStandbyResponse -> ExitStandbyResponse -> Bool
(ExitStandbyResponse -> ExitStandbyResponse -> Bool)
-> (ExitStandbyResponse -> ExitStandbyResponse -> Bool)
-> Eq ExitStandbyResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExitStandbyResponse -> ExitStandbyResponse -> Bool
$c/= :: ExitStandbyResponse -> ExitStandbyResponse -> Bool
== :: ExitStandbyResponse -> ExitStandbyResponse -> Bool
$c== :: ExitStandbyResponse -> ExitStandbyResponse -> Bool
Prelude.Eq, ReadPrec [ExitStandbyResponse]
ReadPrec ExitStandbyResponse
Int -> ReadS ExitStandbyResponse
ReadS [ExitStandbyResponse]
(Int -> ReadS ExitStandbyResponse)
-> ReadS [ExitStandbyResponse]
-> ReadPrec ExitStandbyResponse
-> ReadPrec [ExitStandbyResponse]
-> Read ExitStandbyResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExitStandbyResponse]
$creadListPrec :: ReadPrec [ExitStandbyResponse]
readPrec :: ReadPrec ExitStandbyResponse
$creadPrec :: ReadPrec ExitStandbyResponse
readList :: ReadS [ExitStandbyResponse]
$creadList :: ReadS [ExitStandbyResponse]
readsPrec :: Int -> ReadS ExitStandbyResponse
$creadsPrec :: Int -> ReadS ExitStandbyResponse
Prelude.Read, Int -> ExitStandbyResponse -> ShowS
[ExitStandbyResponse] -> ShowS
ExitStandbyResponse -> String
(Int -> ExitStandbyResponse -> ShowS)
-> (ExitStandbyResponse -> String)
-> ([ExitStandbyResponse] -> ShowS)
-> Show ExitStandbyResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExitStandbyResponse] -> ShowS
$cshowList :: [ExitStandbyResponse] -> ShowS
show :: ExitStandbyResponse -> String
$cshow :: ExitStandbyResponse -> String
showsPrec :: Int -> ExitStandbyResponse -> ShowS
$cshowsPrec :: Int -> ExitStandbyResponse -> ShowS
Prelude.Show, (forall x. ExitStandbyResponse -> Rep ExitStandbyResponse x)
-> (forall x. Rep ExitStandbyResponse x -> ExitStandbyResponse)
-> Generic ExitStandbyResponse
forall x. Rep ExitStandbyResponse x -> ExitStandbyResponse
forall x. ExitStandbyResponse -> Rep ExitStandbyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExitStandbyResponse x -> ExitStandbyResponse
$cfrom :: forall x. ExitStandbyResponse -> Rep ExitStandbyResponse x
Prelude.Generic)

-- |
-- Create a value of 'ExitStandbyResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'activities', 'exitStandbyResponse_activities' - The activities related to moving instances out of @Standby@ mode.
--
-- 'httpStatus', 'exitStandbyResponse_httpStatus' - The response's http status code.
newExitStandbyResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ExitStandbyResponse
newExitStandbyResponse :: Int -> ExitStandbyResponse
newExitStandbyResponse Int
pHttpStatus_ =
  ExitStandbyResponse' :: Maybe [Activity] -> Int -> ExitStandbyResponse
ExitStandbyResponse'
    { $sel:activities:ExitStandbyResponse' :: Maybe [Activity]
activities = Maybe [Activity]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ExitStandbyResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The activities related to moving instances out of @Standby@ mode.
exitStandbyResponse_activities :: Lens.Lens' ExitStandbyResponse (Prelude.Maybe [Activity])
exitStandbyResponse_activities :: (Maybe [Activity] -> f (Maybe [Activity]))
-> ExitStandbyResponse -> f ExitStandbyResponse
exitStandbyResponse_activities = (ExitStandbyResponse -> Maybe [Activity])
-> (ExitStandbyResponse -> Maybe [Activity] -> ExitStandbyResponse)
-> Lens
     ExitStandbyResponse
     ExitStandbyResponse
     (Maybe [Activity])
     (Maybe [Activity])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExitStandbyResponse' {Maybe [Activity]
activities :: Maybe [Activity]
$sel:activities:ExitStandbyResponse' :: ExitStandbyResponse -> Maybe [Activity]
activities} -> Maybe [Activity]
activities) (\s :: ExitStandbyResponse
s@ExitStandbyResponse' {} Maybe [Activity]
a -> ExitStandbyResponse
s {$sel:activities:ExitStandbyResponse' :: Maybe [Activity]
activities = Maybe [Activity]
a} :: ExitStandbyResponse) ((Maybe [Activity] -> f (Maybe [Activity]))
 -> ExitStandbyResponse -> f ExitStandbyResponse)
-> ((Maybe [Activity] -> f (Maybe [Activity]))
    -> Maybe [Activity] -> f (Maybe [Activity]))
-> (Maybe [Activity] -> f (Maybe [Activity]))
-> ExitStandbyResponse
-> f ExitStandbyResponse
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

-- | The response's http status code.
exitStandbyResponse_httpStatus :: Lens.Lens' ExitStandbyResponse Prelude.Int
exitStandbyResponse_httpStatus :: (Int -> f Int) -> ExitStandbyResponse -> f ExitStandbyResponse
exitStandbyResponse_httpStatus = (ExitStandbyResponse -> Int)
-> (ExitStandbyResponse -> Int -> ExitStandbyResponse)
-> Lens ExitStandbyResponse ExitStandbyResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExitStandbyResponse' {Int
httpStatus :: Int
$sel:httpStatus:ExitStandbyResponse' :: ExitStandbyResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ExitStandbyResponse
s@ExitStandbyResponse' {} Int
a -> ExitStandbyResponse
s {$sel:httpStatus:ExitStandbyResponse' :: Int
httpStatus = Int
a} :: ExitStandbyResponse)

instance Prelude.NFData ExitStandbyResponse