{-# 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.SetDesiredCapacity
-- 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)
--
-- Sets the size of the specified Auto Scaling group.
--
-- If a scale-in activity occurs as a result of a new @DesiredCapacity@
-- value that is lower than the current size of the group, the Auto Scaling
-- group uses its termination policy to determine which instances to
-- terminate.
--
-- For more information, see
-- <https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-manual-scaling.html Manual scaling>
-- in the /Amazon EC2 Auto Scaling User Guide/.
module Amazonka.AutoScaling.SetDesiredCapacity
  ( -- * Creating a Request
    SetDesiredCapacity (..),
    newSetDesiredCapacity,

    -- * Request Lenses
    setDesiredCapacity_honorCooldown,
    setDesiredCapacity_autoScalingGroupName,
    setDesiredCapacity_desiredCapacity,

    -- * Destructuring the Response
    SetDesiredCapacityResponse (..),
    newSetDesiredCapacityResponse,
  )
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:/ 'newSetDesiredCapacity' smart constructor.
data SetDesiredCapacity = SetDesiredCapacity'
  { -- | Indicates whether Amazon EC2 Auto Scaling waits for the cooldown period
    -- to complete before initiating a scaling activity to set your Auto
    -- Scaling group to its new capacity. By default, Amazon EC2 Auto Scaling
    -- does not honor the cooldown period during manual scaling activities.
    SetDesiredCapacity -> Maybe Bool
honorCooldown :: Prelude.Maybe Prelude.Bool,
    -- | The name of the Auto Scaling group.
    SetDesiredCapacity -> Text
autoScalingGroupName :: Prelude.Text,
    -- | The desired capacity is the initial capacity of the Auto Scaling group
    -- after this operation completes and the capacity it attempts to maintain.
    SetDesiredCapacity -> Int
desiredCapacity :: Prelude.Int
  }
  deriving (SetDesiredCapacity -> SetDesiredCapacity -> Bool
(SetDesiredCapacity -> SetDesiredCapacity -> Bool)
-> (SetDesiredCapacity -> SetDesiredCapacity -> Bool)
-> Eq SetDesiredCapacity
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SetDesiredCapacity -> SetDesiredCapacity -> Bool
$c/= :: SetDesiredCapacity -> SetDesiredCapacity -> Bool
== :: SetDesiredCapacity -> SetDesiredCapacity -> Bool
$c== :: SetDesiredCapacity -> SetDesiredCapacity -> Bool
Prelude.Eq, ReadPrec [SetDesiredCapacity]
ReadPrec SetDesiredCapacity
Int -> ReadS SetDesiredCapacity
ReadS [SetDesiredCapacity]
(Int -> ReadS SetDesiredCapacity)
-> ReadS [SetDesiredCapacity]
-> ReadPrec SetDesiredCapacity
-> ReadPrec [SetDesiredCapacity]
-> Read SetDesiredCapacity
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SetDesiredCapacity]
$creadListPrec :: ReadPrec [SetDesiredCapacity]
readPrec :: ReadPrec SetDesiredCapacity
$creadPrec :: ReadPrec SetDesiredCapacity
readList :: ReadS [SetDesiredCapacity]
$creadList :: ReadS [SetDesiredCapacity]
readsPrec :: Int -> ReadS SetDesiredCapacity
$creadsPrec :: Int -> ReadS SetDesiredCapacity
Prelude.Read, Int -> SetDesiredCapacity -> ShowS
[SetDesiredCapacity] -> ShowS
SetDesiredCapacity -> String
(Int -> SetDesiredCapacity -> ShowS)
-> (SetDesiredCapacity -> String)
-> ([SetDesiredCapacity] -> ShowS)
-> Show SetDesiredCapacity
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SetDesiredCapacity] -> ShowS
$cshowList :: [SetDesiredCapacity] -> ShowS
show :: SetDesiredCapacity -> String
$cshow :: SetDesiredCapacity -> String
showsPrec :: Int -> SetDesiredCapacity -> ShowS
$cshowsPrec :: Int -> SetDesiredCapacity -> ShowS
Prelude.Show, (forall x. SetDesiredCapacity -> Rep SetDesiredCapacity x)
-> (forall x. Rep SetDesiredCapacity x -> SetDesiredCapacity)
-> Generic SetDesiredCapacity
forall x. Rep SetDesiredCapacity x -> SetDesiredCapacity
forall x. SetDesiredCapacity -> Rep SetDesiredCapacity x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SetDesiredCapacity x -> SetDesiredCapacity
$cfrom :: forall x. SetDesiredCapacity -> Rep SetDesiredCapacity x
Prelude.Generic)

-- |
-- Create a value of 'SetDesiredCapacity' 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:
--
-- 'honorCooldown', 'setDesiredCapacity_honorCooldown' - Indicates whether Amazon EC2 Auto Scaling waits for the cooldown period
-- to complete before initiating a scaling activity to set your Auto
-- Scaling group to its new capacity. By default, Amazon EC2 Auto Scaling
-- does not honor the cooldown period during manual scaling activities.
--
-- 'autoScalingGroupName', 'setDesiredCapacity_autoScalingGroupName' - The name of the Auto Scaling group.
--
-- 'desiredCapacity', 'setDesiredCapacity_desiredCapacity' - The desired capacity is the initial capacity of the Auto Scaling group
-- after this operation completes and the capacity it attempts to maintain.
newSetDesiredCapacity ::
  -- | 'autoScalingGroupName'
  Prelude.Text ->
  -- | 'desiredCapacity'
  Prelude.Int ->
  SetDesiredCapacity
newSetDesiredCapacity :: Text -> Int -> SetDesiredCapacity
newSetDesiredCapacity
  Text
pAutoScalingGroupName_
  Int
pDesiredCapacity_ =
    SetDesiredCapacity' :: Maybe Bool -> Text -> Int -> SetDesiredCapacity
SetDesiredCapacity'
      { $sel:honorCooldown:SetDesiredCapacity' :: Maybe Bool
honorCooldown =
          Maybe Bool
forall a. Maybe a
Prelude.Nothing,
        $sel:autoScalingGroupName:SetDesiredCapacity' :: Text
autoScalingGroupName = Text
pAutoScalingGroupName_,
        $sel:desiredCapacity:SetDesiredCapacity' :: Int
desiredCapacity = Int
pDesiredCapacity_
      }

-- | Indicates whether Amazon EC2 Auto Scaling waits for the cooldown period
-- to complete before initiating a scaling activity to set your Auto
-- Scaling group to its new capacity. By default, Amazon EC2 Auto Scaling
-- does not honor the cooldown period during manual scaling activities.
setDesiredCapacity_honorCooldown :: Lens.Lens' SetDesiredCapacity (Prelude.Maybe Prelude.Bool)
setDesiredCapacity_honorCooldown :: (Maybe Bool -> f (Maybe Bool))
-> SetDesiredCapacity -> f SetDesiredCapacity
setDesiredCapacity_honorCooldown = (SetDesiredCapacity -> Maybe Bool)
-> (SetDesiredCapacity -> Maybe Bool -> SetDesiredCapacity)
-> Lens
     SetDesiredCapacity SetDesiredCapacity (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SetDesiredCapacity' {Maybe Bool
honorCooldown :: Maybe Bool
$sel:honorCooldown:SetDesiredCapacity' :: SetDesiredCapacity -> Maybe Bool
honorCooldown} -> Maybe Bool
honorCooldown) (\s :: SetDesiredCapacity
s@SetDesiredCapacity' {} Maybe Bool
a -> SetDesiredCapacity
s {$sel:honorCooldown:SetDesiredCapacity' :: Maybe Bool
honorCooldown = Maybe Bool
a} :: SetDesiredCapacity)

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

-- | The desired capacity is the initial capacity of the Auto Scaling group
-- after this operation completes and the capacity it attempts to maintain.
setDesiredCapacity_desiredCapacity :: Lens.Lens' SetDesiredCapacity Prelude.Int
setDesiredCapacity_desiredCapacity :: (Int -> f Int) -> SetDesiredCapacity -> f SetDesiredCapacity
setDesiredCapacity_desiredCapacity = (SetDesiredCapacity -> Int)
-> (SetDesiredCapacity -> Int -> SetDesiredCapacity)
-> Lens SetDesiredCapacity SetDesiredCapacity Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SetDesiredCapacity' {Int
desiredCapacity :: Int
$sel:desiredCapacity:SetDesiredCapacity' :: SetDesiredCapacity -> Int
desiredCapacity} -> Int
desiredCapacity) (\s :: SetDesiredCapacity
s@SetDesiredCapacity' {} Int
a -> SetDesiredCapacity
s {$sel:desiredCapacity:SetDesiredCapacity' :: Int
desiredCapacity = Int
a} :: SetDesiredCapacity)

instance Core.AWSRequest SetDesiredCapacity where
  type
    AWSResponse SetDesiredCapacity =
      SetDesiredCapacityResponse
  request :: SetDesiredCapacity -> Request SetDesiredCapacity
request = Service -> SetDesiredCapacity -> Request SetDesiredCapacity
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy SetDesiredCapacity
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse SetDesiredCapacity)))
response =
    AWSResponse SetDesiredCapacity
-> Logger
-> Service
-> Proxy SetDesiredCapacity
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse SetDesiredCapacity)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse SetDesiredCapacity
SetDesiredCapacityResponse
SetDesiredCapacityResponse'

instance Prelude.Hashable SetDesiredCapacity

instance Prelude.NFData SetDesiredCapacity

instance Core.ToHeaders SetDesiredCapacity where
  toHeaders :: SetDesiredCapacity -> [Header]
toHeaders = [Header] -> SetDesiredCapacity -> [Header]
forall a b. a -> b -> a
Prelude.const [Header]
forall a. Monoid a => a
Prelude.mempty

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

instance Core.ToQuery SetDesiredCapacity where
  toQuery :: SetDesiredCapacity -> QueryString
toQuery SetDesiredCapacity' {Int
Maybe Bool
Text
desiredCapacity :: Int
autoScalingGroupName :: Text
honorCooldown :: Maybe Bool
$sel:desiredCapacity:SetDesiredCapacity' :: SetDesiredCapacity -> Int
$sel:autoScalingGroupName:SetDesiredCapacity' :: SetDesiredCapacity -> Text
$sel:honorCooldown:SetDesiredCapacity' :: SetDesiredCapacity -> Maybe Bool
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"SetDesiredCapacity" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2011-01-01" :: Prelude.ByteString),
        ByteString
"HonorCooldown" ByteString -> Maybe Bool -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Bool
honorCooldown,
        ByteString
"AutoScalingGroupName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
autoScalingGroupName,
        ByteString
"DesiredCapacity" ByteString -> Int -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Int
desiredCapacity
      ]

-- | /See:/ 'newSetDesiredCapacityResponse' smart constructor.
data SetDesiredCapacityResponse = SetDesiredCapacityResponse'
  {
  }
  deriving (SetDesiredCapacityResponse -> SetDesiredCapacityResponse -> Bool
(SetDesiredCapacityResponse -> SetDesiredCapacityResponse -> Bool)
-> (SetDesiredCapacityResponse
    -> SetDesiredCapacityResponse -> Bool)
-> Eq SetDesiredCapacityResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SetDesiredCapacityResponse -> SetDesiredCapacityResponse -> Bool
$c/= :: SetDesiredCapacityResponse -> SetDesiredCapacityResponse -> Bool
== :: SetDesiredCapacityResponse -> SetDesiredCapacityResponse -> Bool
$c== :: SetDesiredCapacityResponse -> SetDesiredCapacityResponse -> Bool
Prelude.Eq, ReadPrec [SetDesiredCapacityResponse]
ReadPrec SetDesiredCapacityResponse
Int -> ReadS SetDesiredCapacityResponse
ReadS [SetDesiredCapacityResponse]
(Int -> ReadS SetDesiredCapacityResponse)
-> ReadS [SetDesiredCapacityResponse]
-> ReadPrec SetDesiredCapacityResponse
-> ReadPrec [SetDesiredCapacityResponse]
-> Read SetDesiredCapacityResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SetDesiredCapacityResponse]
$creadListPrec :: ReadPrec [SetDesiredCapacityResponse]
readPrec :: ReadPrec SetDesiredCapacityResponse
$creadPrec :: ReadPrec SetDesiredCapacityResponse
readList :: ReadS [SetDesiredCapacityResponse]
$creadList :: ReadS [SetDesiredCapacityResponse]
readsPrec :: Int -> ReadS SetDesiredCapacityResponse
$creadsPrec :: Int -> ReadS SetDesiredCapacityResponse
Prelude.Read, Int -> SetDesiredCapacityResponse -> ShowS
[SetDesiredCapacityResponse] -> ShowS
SetDesiredCapacityResponse -> String
(Int -> SetDesiredCapacityResponse -> ShowS)
-> (SetDesiredCapacityResponse -> String)
-> ([SetDesiredCapacityResponse] -> ShowS)
-> Show SetDesiredCapacityResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SetDesiredCapacityResponse] -> ShowS
$cshowList :: [SetDesiredCapacityResponse] -> ShowS
show :: SetDesiredCapacityResponse -> String
$cshow :: SetDesiredCapacityResponse -> String
showsPrec :: Int -> SetDesiredCapacityResponse -> ShowS
$cshowsPrec :: Int -> SetDesiredCapacityResponse -> ShowS
Prelude.Show, (forall x.
 SetDesiredCapacityResponse -> Rep SetDesiredCapacityResponse x)
-> (forall x.
    Rep SetDesiredCapacityResponse x -> SetDesiredCapacityResponse)
-> Generic SetDesiredCapacityResponse
forall x.
Rep SetDesiredCapacityResponse x -> SetDesiredCapacityResponse
forall x.
SetDesiredCapacityResponse -> Rep SetDesiredCapacityResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SetDesiredCapacityResponse x -> SetDesiredCapacityResponse
$cfrom :: forall x.
SetDesiredCapacityResponse -> Rep SetDesiredCapacityResponse x
Prelude.Generic)

-- |
-- Create a value of 'SetDesiredCapacityResponse' 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.
newSetDesiredCapacityResponse ::
  SetDesiredCapacityResponse
newSetDesiredCapacityResponse :: SetDesiredCapacityResponse
newSetDesiredCapacityResponse =
  SetDesiredCapacityResponse
SetDesiredCapacityResponse'

instance Prelude.NFData SetDesiredCapacityResponse