{-# 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.BatchDeleteScheduledAction
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes one or more scheduled actions for the specified Auto Scaling
-- group.
module Amazonka.AutoScaling.BatchDeleteScheduledAction
  ( -- * Creating a Request
    BatchDeleteScheduledAction (..),
    newBatchDeleteScheduledAction,

    -- * Request Lenses
    batchDeleteScheduledAction_autoScalingGroupName,
    batchDeleteScheduledAction_scheduledActionNames,

    -- * Destructuring the Response
    BatchDeleteScheduledActionResponse (..),
    newBatchDeleteScheduledActionResponse,

    -- * Response Lenses
    batchDeleteScheduledActionResponse_failedScheduledActions,
    batchDeleteScheduledActionResponse_httpStatus,
  )
where

import Amazonka.AutoScaling.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newBatchDeleteScheduledAction' smart constructor.
data BatchDeleteScheduledAction = BatchDeleteScheduledAction'
  { -- | The name of the Auto Scaling group.
    BatchDeleteScheduledAction -> Text
autoScalingGroupName :: Prelude.Text,
    -- | The names of the scheduled actions to delete. The maximum number allowed
    -- is 50.
    BatchDeleteScheduledAction -> [Text]
scheduledActionNames :: [Prelude.Text]
  }
  deriving (BatchDeleteScheduledAction -> BatchDeleteScheduledAction -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchDeleteScheduledAction -> BatchDeleteScheduledAction -> Bool
$c/= :: BatchDeleteScheduledAction -> BatchDeleteScheduledAction -> Bool
== :: BatchDeleteScheduledAction -> BatchDeleteScheduledAction -> Bool
$c== :: BatchDeleteScheduledAction -> BatchDeleteScheduledAction -> Bool
Prelude.Eq, ReadPrec [BatchDeleteScheduledAction]
ReadPrec BatchDeleteScheduledAction
Int -> ReadS BatchDeleteScheduledAction
ReadS [BatchDeleteScheduledAction]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchDeleteScheduledAction]
$creadListPrec :: ReadPrec [BatchDeleteScheduledAction]
readPrec :: ReadPrec BatchDeleteScheduledAction
$creadPrec :: ReadPrec BatchDeleteScheduledAction
readList :: ReadS [BatchDeleteScheduledAction]
$creadList :: ReadS [BatchDeleteScheduledAction]
readsPrec :: Int -> ReadS BatchDeleteScheduledAction
$creadsPrec :: Int -> ReadS BatchDeleteScheduledAction
Prelude.Read, Int -> BatchDeleteScheduledAction -> ShowS
[BatchDeleteScheduledAction] -> ShowS
BatchDeleteScheduledAction -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchDeleteScheduledAction] -> ShowS
$cshowList :: [BatchDeleteScheduledAction] -> ShowS
show :: BatchDeleteScheduledAction -> String
$cshow :: BatchDeleteScheduledAction -> String
showsPrec :: Int -> BatchDeleteScheduledAction -> ShowS
$cshowsPrec :: Int -> BatchDeleteScheduledAction -> ShowS
Prelude.Show, forall x.
Rep BatchDeleteScheduledAction x -> BatchDeleteScheduledAction
forall x.
BatchDeleteScheduledAction -> Rep BatchDeleteScheduledAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BatchDeleteScheduledAction x -> BatchDeleteScheduledAction
$cfrom :: forall x.
BatchDeleteScheduledAction -> Rep BatchDeleteScheduledAction x
Prelude.Generic)

-- |
-- Create a value of 'BatchDeleteScheduledAction' 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:
--
-- 'autoScalingGroupName', 'batchDeleteScheduledAction_autoScalingGroupName' - The name of the Auto Scaling group.
--
-- 'scheduledActionNames', 'batchDeleteScheduledAction_scheduledActionNames' - The names of the scheduled actions to delete. The maximum number allowed
-- is 50.
newBatchDeleteScheduledAction ::
  -- | 'autoScalingGroupName'
  Prelude.Text ->
  BatchDeleteScheduledAction
newBatchDeleteScheduledAction :: Text -> BatchDeleteScheduledAction
newBatchDeleteScheduledAction Text
pAutoScalingGroupName_ =
  BatchDeleteScheduledAction'
    { $sel:autoScalingGroupName:BatchDeleteScheduledAction' :: Text
autoScalingGroupName =
        Text
pAutoScalingGroupName_,
      $sel:scheduledActionNames:BatchDeleteScheduledAction' :: [Text]
scheduledActionNames = forall a. Monoid a => a
Prelude.mempty
    }

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

-- | The names of the scheduled actions to delete. The maximum number allowed
-- is 50.
batchDeleteScheduledAction_scheduledActionNames :: Lens.Lens' BatchDeleteScheduledAction [Prelude.Text]
batchDeleteScheduledAction_scheduledActionNames :: Lens' BatchDeleteScheduledAction [Text]
batchDeleteScheduledAction_scheduledActionNames = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchDeleteScheduledAction' {[Text]
scheduledActionNames :: [Text]
$sel:scheduledActionNames:BatchDeleteScheduledAction' :: BatchDeleteScheduledAction -> [Text]
scheduledActionNames} -> [Text]
scheduledActionNames) (\s :: BatchDeleteScheduledAction
s@BatchDeleteScheduledAction' {} [Text]
a -> BatchDeleteScheduledAction
s {$sel:scheduledActionNames:BatchDeleteScheduledAction' :: [Text]
scheduledActionNames = [Text]
a} :: BatchDeleteScheduledAction) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest BatchDeleteScheduledAction where
  type
    AWSResponse BatchDeleteScheduledAction =
      BatchDeleteScheduledActionResponse
  request :: (Service -> Service)
-> BatchDeleteScheduledAction -> Request BatchDeleteScheduledAction
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy BatchDeleteScheduledAction
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse BatchDeleteScheduledAction)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"BatchDeleteScheduledActionResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe [FailedScheduledUpdateGroupActionRequest]
-> Int -> BatchDeleteScheduledActionResponse
BatchDeleteScheduledActionResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( [Node]
x
                            forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"FailedScheduledActions"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                            forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"member")
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable BatchDeleteScheduledAction where
  hashWithSalt :: Int -> BatchDeleteScheduledAction -> Int
hashWithSalt Int
_salt BatchDeleteScheduledAction' {[Text]
Text
scheduledActionNames :: [Text]
autoScalingGroupName :: Text
$sel:scheduledActionNames:BatchDeleteScheduledAction' :: BatchDeleteScheduledAction -> [Text]
$sel:autoScalingGroupName:BatchDeleteScheduledAction' :: BatchDeleteScheduledAction -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
autoScalingGroupName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Text]
scheduledActionNames

instance Prelude.NFData BatchDeleteScheduledAction where
  rnf :: BatchDeleteScheduledAction -> ()
rnf BatchDeleteScheduledAction' {[Text]
Text
scheduledActionNames :: [Text]
autoScalingGroupName :: Text
$sel:scheduledActionNames:BatchDeleteScheduledAction' :: BatchDeleteScheduledAction -> [Text]
$sel:autoScalingGroupName:BatchDeleteScheduledAction' :: BatchDeleteScheduledAction -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
autoScalingGroupName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Text]
scheduledActionNames

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

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

instance Data.ToQuery BatchDeleteScheduledAction where
  toQuery :: BatchDeleteScheduledAction -> QueryString
toQuery BatchDeleteScheduledAction' {[Text]
Text
scheduledActionNames :: [Text]
autoScalingGroupName :: Text
$sel:scheduledActionNames:BatchDeleteScheduledAction' :: BatchDeleteScheduledAction -> [Text]
$sel:autoScalingGroupName:BatchDeleteScheduledAction' :: BatchDeleteScheduledAction -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"BatchDeleteScheduledAction" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2011-01-01" :: Prelude.ByteString),
        ByteString
"AutoScalingGroupName" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
autoScalingGroupName,
        ByteString
"ScheduledActionNames"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"member" [Text]
scheduledActionNames
      ]

-- | /See:/ 'newBatchDeleteScheduledActionResponse' smart constructor.
data BatchDeleteScheduledActionResponse = BatchDeleteScheduledActionResponse'
  { -- | The names of the scheduled actions that could not be deleted, including
    -- an error message.
    BatchDeleteScheduledActionResponse
-> Maybe [FailedScheduledUpdateGroupActionRequest]
failedScheduledActions :: Prelude.Maybe [FailedScheduledUpdateGroupActionRequest],
    -- | The response's http status code.
    BatchDeleteScheduledActionResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (BatchDeleteScheduledActionResponse
-> BatchDeleteScheduledActionResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchDeleteScheduledActionResponse
-> BatchDeleteScheduledActionResponse -> Bool
$c/= :: BatchDeleteScheduledActionResponse
-> BatchDeleteScheduledActionResponse -> Bool
== :: BatchDeleteScheduledActionResponse
-> BatchDeleteScheduledActionResponse -> Bool
$c== :: BatchDeleteScheduledActionResponse
-> BatchDeleteScheduledActionResponse -> Bool
Prelude.Eq, ReadPrec [BatchDeleteScheduledActionResponse]
ReadPrec BatchDeleteScheduledActionResponse
Int -> ReadS BatchDeleteScheduledActionResponse
ReadS [BatchDeleteScheduledActionResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchDeleteScheduledActionResponse]
$creadListPrec :: ReadPrec [BatchDeleteScheduledActionResponse]
readPrec :: ReadPrec BatchDeleteScheduledActionResponse
$creadPrec :: ReadPrec BatchDeleteScheduledActionResponse
readList :: ReadS [BatchDeleteScheduledActionResponse]
$creadList :: ReadS [BatchDeleteScheduledActionResponse]
readsPrec :: Int -> ReadS BatchDeleteScheduledActionResponse
$creadsPrec :: Int -> ReadS BatchDeleteScheduledActionResponse
Prelude.Read, Int -> BatchDeleteScheduledActionResponse -> ShowS
[BatchDeleteScheduledActionResponse] -> ShowS
BatchDeleteScheduledActionResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchDeleteScheduledActionResponse] -> ShowS
$cshowList :: [BatchDeleteScheduledActionResponse] -> ShowS
show :: BatchDeleteScheduledActionResponse -> String
$cshow :: BatchDeleteScheduledActionResponse -> String
showsPrec :: Int -> BatchDeleteScheduledActionResponse -> ShowS
$cshowsPrec :: Int -> BatchDeleteScheduledActionResponse -> ShowS
Prelude.Show, forall x.
Rep BatchDeleteScheduledActionResponse x
-> BatchDeleteScheduledActionResponse
forall x.
BatchDeleteScheduledActionResponse
-> Rep BatchDeleteScheduledActionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BatchDeleteScheduledActionResponse x
-> BatchDeleteScheduledActionResponse
$cfrom :: forall x.
BatchDeleteScheduledActionResponse
-> Rep BatchDeleteScheduledActionResponse x
Prelude.Generic)

-- |
-- Create a value of 'BatchDeleteScheduledActionResponse' 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:
--
-- 'failedScheduledActions', 'batchDeleteScheduledActionResponse_failedScheduledActions' - The names of the scheduled actions that could not be deleted, including
-- an error message.
--
-- 'httpStatus', 'batchDeleteScheduledActionResponse_httpStatus' - The response's http status code.
newBatchDeleteScheduledActionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  BatchDeleteScheduledActionResponse
newBatchDeleteScheduledActionResponse :: Int -> BatchDeleteScheduledActionResponse
newBatchDeleteScheduledActionResponse Int
pHttpStatus_ =
  BatchDeleteScheduledActionResponse'
    { $sel:failedScheduledActions:BatchDeleteScheduledActionResponse' :: Maybe [FailedScheduledUpdateGroupActionRequest]
failedScheduledActions =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:BatchDeleteScheduledActionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The names of the scheduled actions that could not be deleted, including
-- an error message.
batchDeleteScheduledActionResponse_failedScheduledActions :: Lens.Lens' BatchDeleteScheduledActionResponse (Prelude.Maybe [FailedScheduledUpdateGroupActionRequest])
batchDeleteScheduledActionResponse_failedScheduledActions :: Lens'
  BatchDeleteScheduledActionResponse
  (Maybe [FailedScheduledUpdateGroupActionRequest])
batchDeleteScheduledActionResponse_failedScheduledActions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchDeleteScheduledActionResponse' {Maybe [FailedScheduledUpdateGroupActionRequest]
failedScheduledActions :: Maybe [FailedScheduledUpdateGroupActionRequest]
$sel:failedScheduledActions:BatchDeleteScheduledActionResponse' :: BatchDeleteScheduledActionResponse
-> Maybe [FailedScheduledUpdateGroupActionRequest]
failedScheduledActions} -> Maybe [FailedScheduledUpdateGroupActionRequest]
failedScheduledActions) (\s :: BatchDeleteScheduledActionResponse
s@BatchDeleteScheduledActionResponse' {} Maybe [FailedScheduledUpdateGroupActionRequest]
a -> BatchDeleteScheduledActionResponse
s {$sel:failedScheduledActions:BatchDeleteScheduledActionResponse' :: Maybe [FailedScheduledUpdateGroupActionRequest]
failedScheduledActions = Maybe [FailedScheduledUpdateGroupActionRequest]
a} :: BatchDeleteScheduledActionResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance
  Prelude.NFData
    BatchDeleteScheduledActionResponse
  where
  rnf :: BatchDeleteScheduledActionResponse -> ()
rnf BatchDeleteScheduledActionResponse' {Int
Maybe [FailedScheduledUpdateGroupActionRequest]
httpStatus :: Int
failedScheduledActions :: Maybe [FailedScheduledUpdateGroupActionRequest]
$sel:httpStatus:BatchDeleteScheduledActionResponse' :: BatchDeleteScheduledActionResponse -> Int
$sel:failedScheduledActions:BatchDeleteScheduledActionResponse' :: BatchDeleteScheduledActionResponse
-> Maybe [FailedScheduledUpdateGroupActionRequest]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [FailedScheduledUpdateGroupActionRequest]
failedScheduledActions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus