{-# 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.SuspendProcesses
-- 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)
--
-- Suspends the specified auto scaling processes, or all processes, for the
-- specified Auto Scaling group.
--
-- If you suspend either the @Launch@ or @Terminate@ process types, it can
-- prevent other process types from functioning properly. For more
-- information, see
-- <https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-suspend-resume-processes.html Suspending and resuming scaling processes>
-- in the /Amazon EC2 Auto Scaling User Guide/.
--
-- To resume processes that have been suspended, call the ResumeProcesses
-- API.
module Amazonka.AutoScaling.SuspendProcesses
  ( -- * Creating a Request
    SuspendProcesses (..),
    newSuspendProcesses,

    -- * Request Lenses
    suspendProcesses_scalingProcesses,
    suspendProcesses_autoScalingGroupName,

    -- * Destructuring the Response
    SuspendProcessesResponse (..),
    newSuspendProcessesResponse,
  )
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:/ 'newSuspendProcesses' smart constructor.
data SuspendProcesses = SuspendProcesses'
  { -- | One or more of the following processes:
    --
    -- -   @Launch@
    --
    -- -   @Terminate@
    --
    -- -   @AddToLoadBalancer@
    --
    -- -   @AlarmNotification@
    --
    -- -   @AZRebalance@
    --
    -- -   @HealthCheck@
    --
    -- -   @InstanceRefresh@
    --
    -- -   @ReplaceUnhealthy@
    --
    -- -   @ScheduledActions@
    --
    -- If you omit this parameter, all processes are specified.
    SuspendProcesses -> Maybe [Text]
scalingProcesses :: Prelude.Maybe [Prelude.Text],
    -- | The name of the Auto Scaling group.
    SuspendProcesses -> Text
autoScalingGroupName :: Prelude.Text
  }
  deriving (SuspendProcesses -> SuspendProcesses -> Bool
(SuspendProcesses -> SuspendProcesses -> Bool)
-> (SuspendProcesses -> SuspendProcesses -> Bool)
-> Eq SuspendProcesses
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SuspendProcesses -> SuspendProcesses -> Bool
$c/= :: SuspendProcesses -> SuspendProcesses -> Bool
== :: SuspendProcesses -> SuspendProcesses -> Bool
$c== :: SuspendProcesses -> SuspendProcesses -> Bool
Prelude.Eq, ReadPrec [SuspendProcesses]
ReadPrec SuspendProcesses
Int -> ReadS SuspendProcesses
ReadS [SuspendProcesses]
(Int -> ReadS SuspendProcesses)
-> ReadS [SuspendProcesses]
-> ReadPrec SuspendProcesses
-> ReadPrec [SuspendProcesses]
-> Read SuspendProcesses
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SuspendProcesses]
$creadListPrec :: ReadPrec [SuspendProcesses]
readPrec :: ReadPrec SuspendProcesses
$creadPrec :: ReadPrec SuspendProcesses
readList :: ReadS [SuspendProcesses]
$creadList :: ReadS [SuspendProcesses]
readsPrec :: Int -> ReadS SuspendProcesses
$creadsPrec :: Int -> ReadS SuspendProcesses
Prelude.Read, Int -> SuspendProcesses -> ShowS
[SuspendProcesses] -> ShowS
SuspendProcesses -> String
(Int -> SuspendProcesses -> ShowS)
-> (SuspendProcesses -> String)
-> ([SuspendProcesses] -> ShowS)
-> Show SuspendProcesses
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SuspendProcesses] -> ShowS
$cshowList :: [SuspendProcesses] -> ShowS
show :: SuspendProcesses -> String
$cshow :: SuspendProcesses -> String
showsPrec :: Int -> SuspendProcesses -> ShowS
$cshowsPrec :: Int -> SuspendProcesses -> ShowS
Prelude.Show, (forall x. SuspendProcesses -> Rep SuspendProcesses x)
-> (forall x. Rep SuspendProcesses x -> SuspendProcesses)
-> Generic SuspendProcesses
forall x. Rep SuspendProcesses x -> SuspendProcesses
forall x. SuspendProcesses -> Rep SuspendProcesses x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SuspendProcesses x -> SuspendProcesses
$cfrom :: forall x. SuspendProcesses -> Rep SuspendProcesses x
Prelude.Generic)

-- |
-- Create a value of 'SuspendProcesses' 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:
--
-- 'scalingProcesses', 'suspendProcesses_scalingProcesses' - One or more of the following processes:
--
-- -   @Launch@
--
-- -   @Terminate@
--
-- -   @AddToLoadBalancer@
--
-- -   @AlarmNotification@
--
-- -   @AZRebalance@
--
-- -   @HealthCheck@
--
-- -   @InstanceRefresh@
--
-- -   @ReplaceUnhealthy@
--
-- -   @ScheduledActions@
--
-- If you omit this parameter, all processes are specified.
--
-- 'autoScalingGroupName', 'suspendProcesses_autoScalingGroupName' - The name of the Auto Scaling group.
newSuspendProcesses ::
  -- | 'autoScalingGroupName'
  Prelude.Text ->
  SuspendProcesses
newSuspendProcesses :: Text -> SuspendProcesses
newSuspendProcesses Text
pAutoScalingGroupName_ =
  SuspendProcesses' :: Maybe [Text] -> Text -> SuspendProcesses
SuspendProcesses'
    { $sel:scalingProcesses:SuspendProcesses' :: Maybe [Text]
scalingProcesses =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:autoScalingGroupName:SuspendProcesses' :: Text
autoScalingGroupName = Text
pAutoScalingGroupName_
    }

-- | One or more of the following processes:
--
-- -   @Launch@
--
-- -   @Terminate@
--
-- -   @AddToLoadBalancer@
--
-- -   @AlarmNotification@
--
-- -   @AZRebalance@
--
-- -   @HealthCheck@
--
-- -   @InstanceRefresh@
--
-- -   @ReplaceUnhealthy@
--
-- -   @ScheduledActions@
--
-- If you omit this parameter, all processes are specified.
suspendProcesses_scalingProcesses :: Lens.Lens' SuspendProcesses (Prelude.Maybe [Prelude.Text])
suspendProcesses_scalingProcesses :: (Maybe [Text] -> f (Maybe [Text]))
-> SuspendProcesses -> f SuspendProcesses
suspendProcesses_scalingProcesses = (SuspendProcesses -> Maybe [Text])
-> (SuspendProcesses -> Maybe [Text] -> SuspendProcesses)
-> Lens
     SuspendProcesses SuspendProcesses (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SuspendProcesses' {Maybe [Text]
scalingProcesses :: Maybe [Text]
$sel:scalingProcesses:SuspendProcesses' :: SuspendProcesses -> Maybe [Text]
scalingProcesses} -> Maybe [Text]
scalingProcesses) (\s :: SuspendProcesses
s@SuspendProcesses' {} Maybe [Text]
a -> SuspendProcesses
s {$sel:scalingProcesses:SuspendProcesses' :: Maybe [Text]
scalingProcesses = Maybe [Text]
a} :: SuspendProcesses) ((Maybe [Text] -> f (Maybe [Text]))
 -> SuspendProcesses -> f SuspendProcesses)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> SuspendProcesses
-> f SuspendProcesses
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.
suspendProcesses_autoScalingGroupName :: Lens.Lens' SuspendProcesses Prelude.Text
suspendProcesses_autoScalingGroupName :: (Text -> f Text) -> SuspendProcesses -> f SuspendProcesses
suspendProcesses_autoScalingGroupName = (SuspendProcesses -> Text)
-> (SuspendProcesses -> Text -> SuspendProcesses)
-> Lens SuspendProcesses SuspendProcesses Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SuspendProcesses' {Text
autoScalingGroupName :: Text
$sel:autoScalingGroupName:SuspendProcesses' :: SuspendProcesses -> Text
autoScalingGroupName} -> Text
autoScalingGroupName) (\s :: SuspendProcesses
s@SuspendProcesses' {} Text
a -> SuspendProcesses
s {$sel:autoScalingGroupName:SuspendProcesses' :: Text
autoScalingGroupName = Text
a} :: SuspendProcesses)

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

instance Prelude.Hashable SuspendProcesses

instance Prelude.NFData SuspendProcesses

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

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

instance Core.ToQuery SuspendProcesses where
  toQuery :: SuspendProcesses -> QueryString
toQuery SuspendProcesses' {Maybe [Text]
Text
autoScalingGroupName :: Text
scalingProcesses :: Maybe [Text]
$sel:autoScalingGroupName:SuspendProcesses' :: SuspendProcesses -> Text
$sel:scalingProcesses:SuspendProcesses' :: SuspendProcesses -> 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
"SuspendProcesses" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2011-01-01" :: Prelude.ByteString),
        ByteString
"ScalingProcesses"
          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]
scalingProcesses
            ),
        ByteString
"AutoScalingGroupName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
autoScalingGroupName
      ]

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

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

instance Prelude.NFData SuspendProcessesResponse