{-# 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.DescribeScalingActivities
-- 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)
--
-- Gets information about the scaling activities in the account and Region.
--
-- When scaling events occur, you see a record of the scaling activity in
-- the scaling activities. For more information, see
-- <https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-verify-scaling-activity.html Verifying a scaling activity for an Auto Scaling group>
-- in the /Amazon EC2 Auto Scaling User Guide/.
--
-- If the scaling event succeeds, the value of the @StatusCode@ element in
-- the response is @Successful@. If an attempt to launch instances failed,
-- the @StatusCode@ value is @Failed@ or @Cancelled@ and the
-- @StatusMessage@ element in the response indicates the cause of the
-- failure. For help interpreting the @StatusMessage@, see
-- <https://docs.aws.amazon.com/autoscaling/ec2/userguide/CHAP_Troubleshooting.html Troubleshooting Amazon EC2 Auto Scaling>
-- in the /Amazon EC2 Auto Scaling User Guide/.
--
-- This operation returns paginated results.
module Amazonka.AutoScaling.DescribeScalingActivities
  ( -- * Creating a Request
    DescribeScalingActivities (..),
    newDescribeScalingActivities,

    -- * Request Lenses
    describeScalingActivities_nextToken,
    describeScalingActivities_autoScalingGroupName,
    describeScalingActivities_maxRecords,
    describeScalingActivities_includeDeletedGroups,
    describeScalingActivities_activityIds,

    -- * Destructuring the Response
    DescribeScalingActivitiesResponse (..),
    newDescribeScalingActivitiesResponse,

    -- * Response Lenses
    describeScalingActivitiesResponse_nextToken,
    describeScalingActivitiesResponse_httpStatus,
    describeScalingActivitiesResponse_activities,
  )
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:/ 'newDescribeScalingActivities' smart constructor.
data DescribeScalingActivities = DescribeScalingActivities'
  { -- | The token for the next set of items to return. (You received this token
    -- from a previous call.)
    DescribeScalingActivities -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The name of the Auto Scaling group.
    DescribeScalingActivities -> Maybe Text
autoScalingGroupName :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of items to return with this call. The default value
    -- is @100@ and the maximum value is @100@.
    DescribeScalingActivities -> Maybe Int
maxRecords :: Prelude.Maybe Prelude.Int,
    -- | Indicates whether to include scaling activity from deleted Auto Scaling
    -- groups.
    DescribeScalingActivities -> Maybe Bool
includeDeletedGroups :: Prelude.Maybe Prelude.Bool,
    -- | The activity IDs of the desired scaling activities. If you omit this
    -- parameter, all activities for the past six weeks are described. If
    -- unknown activities are requested, they are ignored with no error. If you
    -- specify an Auto Scaling group, the results are limited to that group.
    --
    -- Array Members: Maximum number of 50 IDs.
    DescribeScalingActivities -> Maybe [Text]
activityIds :: Prelude.Maybe [Prelude.Text]
  }
  deriving (DescribeScalingActivities -> DescribeScalingActivities -> Bool
(DescribeScalingActivities -> DescribeScalingActivities -> Bool)
-> (DescribeScalingActivities -> DescribeScalingActivities -> Bool)
-> Eq DescribeScalingActivities
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeScalingActivities -> DescribeScalingActivities -> Bool
$c/= :: DescribeScalingActivities -> DescribeScalingActivities -> Bool
== :: DescribeScalingActivities -> DescribeScalingActivities -> Bool
$c== :: DescribeScalingActivities -> DescribeScalingActivities -> Bool
Prelude.Eq, ReadPrec [DescribeScalingActivities]
ReadPrec DescribeScalingActivities
Int -> ReadS DescribeScalingActivities
ReadS [DescribeScalingActivities]
(Int -> ReadS DescribeScalingActivities)
-> ReadS [DescribeScalingActivities]
-> ReadPrec DescribeScalingActivities
-> ReadPrec [DescribeScalingActivities]
-> Read DescribeScalingActivities
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeScalingActivities]
$creadListPrec :: ReadPrec [DescribeScalingActivities]
readPrec :: ReadPrec DescribeScalingActivities
$creadPrec :: ReadPrec DescribeScalingActivities
readList :: ReadS [DescribeScalingActivities]
$creadList :: ReadS [DescribeScalingActivities]
readsPrec :: Int -> ReadS DescribeScalingActivities
$creadsPrec :: Int -> ReadS DescribeScalingActivities
Prelude.Read, Int -> DescribeScalingActivities -> ShowS
[DescribeScalingActivities] -> ShowS
DescribeScalingActivities -> String
(Int -> DescribeScalingActivities -> ShowS)
-> (DescribeScalingActivities -> String)
-> ([DescribeScalingActivities] -> ShowS)
-> Show DescribeScalingActivities
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeScalingActivities] -> ShowS
$cshowList :: [DescribeScalingActivities] -> ShowS
show :: DescribeScalingActivities -> String
$cshow :: DescribeScalingActivities -> String
showsPrec :: Int -> DescribeScalingActivities -> ShowS
$cshowsPrec :: Int -> DescribeScalingActivities -> ShowS
Prelude.Show, (forall x.
 DescribeScalingActivities -> Rep DescribeScalingActivities x)
-> (forall x.
    Rep DescribeScalingActivities x -> DescribeScalingActivities)
-> Generic DescribeScalingActivities
forall x.
Rep DescribeScalingActivities x -> DescribeScalingActivities
forall x.
DescribeScalingActivities -> Rep DescribeScalingActivities x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeScalingActivities x -> DescribeScalingActivities
$cfrom :: forall x.
DescribeScalingActivities -> Rep DescribeScalingActivities x
Prelude.Generic)

-- |
-- Create a value of 'DescribeScalingActivities' 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:
--
-- 'nextToken', 'describeScalingActivities_nextToken' - The token for the next set of items to return. (You received this token
-- from a previous call.)
--
-- 'autoScalingGroupName', 'describeScalingActivities_autoScalingGroupName' - The name of the Auto Scaling group.
--
-- 'maxRecords', 'describeScalingActivities_maxRecords' - The maximum number of items to return with this call. The default value
-- is @100@ and the maximum value is @100@.
--
-- 'includeDeletedGroups', 'describeScalingActivities_includeDeletedGroups' - Indicates whether to include scaling activity from deleted Auto Scaling
-- groups.
--
-- 'activityIds', 'describeScalingActivities_activityIds' - The activity IDs of the desired scaling activities. If you omit this
-- parameter, all activities for the past six weeks are described. If
-- unknown activities are requested, they are ignored with no error. If you
-- specify an Auto Scaling group, the results are limited to that group.
--
-- Array Members: Maximum number of 50 IDs.
newDescribeScalingActivities ::
  DescribeScalingActivities
newDescribeScalingActivities :: DescribeScalingActivities
newDescribeScalingActivities =
  DescribeScalingActivities' :: Maybe Text
-> Maybe Text
-> Maybe Int
-> Maybe Bool
-> Maybe [Text]
-> DescribeScalingActivities
DescribeScalingActivities'
    { $sel:nextToken:DescribeScalingActivities' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:autoScalingGroupName:DescribeScalingActivities' :: Maybe Text
autoScalingGroupName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxRecords:DescribeScalingActivities' :: Maybe Int
maxRecords = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:includeDeletedGroups:DescribeScalingActivities' :: Maybe Bool
includeDeletedGroups = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:activityIds:DescribeScalingActivities' :: Maybe [Text]
activityIds = Maybe [Text]
forall a. Maybe a
Prelude.Nothing
    }

-- | The token for the next set of items to return. (You received this token
-- from a previous call.)
describeScalingActivities_nextToken :: Lens.Lens' DescribeScalingActivities (Prelude.Maybe Prelude.Text)
describeScalingActivities_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeScalingActivities -> f DescribeScalingActivities
describeScalingActivities_nextToken = (DescribeScalingActivities -> Maybe Text)
-> (DescribeScalingActivities
    -> Maybe Text -> DescribeScalingActivities)
-> Lens
     DescribeScalingActivities
     DescribeScalingActivities
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeScalingActivities' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeScalingActivities' :: DescribeScalingActivities -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeScalingActivities
s@DescribeScalingActivities' {} Maybe Text
a -> DescribeScalingActivities
s {$sel:nextToken:DescribeScalingActivities' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeScalingActivities)

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

-- | The maximum number of items to return with this call. The default value
-- is @100@ and the maximum value is @100@.
describeScalingActivities_maxRecords :: Lens.Lens' DescribeScalingActivities (Prelude.Maybe Prelude.Int)
describeScalingActivities_maxRecords :: (Maybe Int -> f (Maybe Int))
-> DescribeScalingActivities -> f DescribeScalingActivities
describeScalingActivities_maxRecords = (DescribeScalingActivities -> Maybe Int)
-> (DescribeScalingActivities
    -> Maybe Int -> DescribeScalingActivities)
-> Lens
     DescribeScalingActivities
     DescribeScalingActivities
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeScalingActivities' {Maybe Int
maxRecords :: Maybe Int
$sel:maxRecords:DescribeScalingActivities' :: DescribeScalingActivities -> Maybe Int
maxRecords} -> Maybe Int
maxRecords) (\s :: DescribeScalingActivities
s@DescribeScalingActivities' {} Maybe Int
a -> DescribeScalingActivities
s {$sel:maxRecords:DescribeScalingActivities' :: Maybe Int
maxRecords = Maybe Int
a} :: DescribeScalingActivities)

-- | Indicates whether to include scaling activity from deleted Auto Scaling
-- groups.
describeScalingActivities_includeDeletedGroups :: Lens.Lens' DescribeScalingActivities (Prelude.Maybe Prelude.Bool)
describeScalingActivities_includeDeletedGroups :: (Maybe Bool -> f (Maybe Bool))
-> DescribeScalingActivities -> f DescribeScalingActivities
describeScalingActivities_includeDeletedGroups = (DescribeScalingActivities -> Maybe Bool)
-> (DescribeScalingActivities
    -> Maybe Bool -> DescribeScalingActivities)
-> Lens
     DescribeScalingActivities
     DescribeScalingActivities
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeScalingActivities' {Maybe Bool
includeDeletedGroups :: Maybe Bool
$sel:includeDeletedGroups:DescribeScalingActivities' :: DescribeScalingActivities -> Maybe Bool
includeDeletedGroups} -> Maybe Bool
includeDeletedGroups) (\s :: DescribeScalingActivities
s@DescribeScalingActivities' {} Maybe Bool
a -> DescribeScalingActivities
s {$sel:includeDeletedGroups:DescribeScalingActivities' :: Maybe Bool
includeDeletedGroups = Maybe Bool
a} :: DescribeScalingActivities)

-- | The activity IDs of the desired scaling activities. If you omit this
-- parameter, all activities for the past six weeks are described. If
-- unknown activities are requested, they are ignored with no error. If you
-- specify an Auto Scaling group, the results are limited to that group.
--
-- Array Members: Maximum number of 50 IDs.
describeScalingActivities_activityIds :: Lens.Lens' DescribeScalingActivities (Prelude.Maybe [Prelude.Text])
describeScalingActivities_activityIds :: (Maybe [Text] -> f (Maybe [Text]))
-> DescribeScalingActivities -> f DescribeScalingActivities
describeScalingActivities_activityIds = (DescribeScalingActivities -> Maybe [Text])
-> (DescribeScalingActivities
    -> Maybe [Text] -> DescribeScalingActivities)
-> Lens
     DescribeScalingActivities
     DescribeScalingActivities
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeScalingActivities' {Maybe [Text]
activityIds :: Maybe [Text]
$sel:activityIds:DescribeScalingActivities' :: DescribeScalingActivities -> Maybe [Text]
activityIds} -> Maybe [Text]
activityIds) (\s :: DescribeScalingActivities
s@DescribeScalingActivities' {} Maybe [Text]
a -> DescribeScalingActivities
s {$sel:activityIds:DescribeScalingActivities' :: Maybe [Text]
activityIds = Maybe [Text]
a} :: DescribeScalingActivities) ((Maybe [Text] -> f (Maybe [Text]))
 -> DescribeScalingActivities -> f DescribeScalingActivities)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> DescribeScalingActivities
-> f DescribeScalingActivities
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

instance Core.AWSPager DescribeScalingActivities where
  page :: DescribeScalingActivities
-> AWSResponse DescribeScalingActivities
-> Maybe DescribeScalingActivities
page DescribeScalingActivities
rq AWSResponse DescribeScalingActivities
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeScalingActivities
DescribeScalingActivitiesResponse
rs
            DescribeScalingActivitiesResponse
-> Getting (First Text) DescribeScalingActivitiesResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeScalingActivitiesResponse
-> Const (First Text) DescribeScalingActivitiesResponse
Lens' DescribeScalingActivitiesResponse (Maybe Text)
describeScalingActivitiesResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeScalingActivitiesResponse
 -> Const (First Text) DescribeScalingActivitiesResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeScalingActivitiesResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe DescribeScalingActivities
forall a. Maybe a
Prelude.Nothing
    | [Activity] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeScalingActivities
DescribeScalingActivitiesResponse
rs
            DescribeScalingActivitiesResponse
-> Getting [Activity] DescribeScalingActivitiesResponse [Activity]
-> [Activity]
forall s a. s -> Getting a s a -> a
Lens.^. Getting [Activity] DescribeScalingActivitiesResponse [Activity]
Lens' DescribeScalingActivitiesResponse [Activity]
describeScalingActivitiesResponse_activities
        ) =
      Maybe DescribeScalingActivities
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      DescribeScalingActivities -> Maybe DescribeScalingActivities
forall a. a -> Maybe a
Prelude.Just (DescribeScalingActivities -> Maybe DescribeScalingActivities)
-> DescribeScalingActivities -> Maybe DescribeScalingActivities
forall a b. (a -> b) -> a -> b
Prelude.$
        DescribeScalingActivities
rq
          DescribeScalingActivities
-> (DescribeScalingActivities -> DescribeScalingActivities)
-> DescribeScalingActivities
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> DescribeScalingActivities -> Identity DescribeScalingActivities
Lens
  DescribeScalingActivities
  DescribeScalingActivities
  (Maybe Text)
  (Maybe Text)
describeScalingActivities_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> DescribeScalingActivities -> Identity DescribeScalingActivities)
-> Maybe Text
-> DescribeScalingActivities
-> DescribeScalingActivities
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse DescribeScalingActivities
DescribeScalingActivitiesResponse
rs
          DescribeScalingActivitiesResponse
-> Getting (First Text) DescribeScalingActivitiesResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeScalingActivitiesResponse
-> Const (First Text) DescribeScalingActivitiesResponse
Lens' DescribeScalingActivitiesResponse (Maybe Text)
describeScalingActivitiesResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeScalingActivitiesResponse
 -> Const (First Text) DescribeScalingActivitiesResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeScalingActivitiesResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest DescribeScalingActivities where
  type
    AWSResponse DescribeScalingActivities =
      DescribeScalingActivitiesResponse
  request :: DescribeScalingActivities -> Request DescribeScalingActivities
request = Service
-> DescribeScalingActivities -> Request DescribeScalingActivities
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeScalingActivities
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeScalingActivities)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse DescribeScalingActivities))
-> Logger
-> Service
-> Proxy DescribeScalingActivities
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeScalingActivities)))
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
"DescribeScalingActivitiesResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe Text
-> Int -> [Activity] -> DescribeScalingActivitiesResponse
DescribeScalingActivitiesResponse'
            (Maybe Text
 -> Int -> [Activity] -> DescribeScalingActivitiesResponse)
-> Either String (Maybe Text)
-> Either
     String (Int -> [Activity] -> DescribeScalingActivitiesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"NextToken")
            Either
  String (Int -> [Activity] -> DescribeScalingActivitiesResponse)
-> Either String Int
-> Either String ([Activity] -> DescribeScalingActivitiesResponse)
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))
            Either String ([Activity] -> DescribeScalingActivitiesResponse)
-> Either String [Activity]
-> Either String DescribeScalingActivitiesResponse
forall (f :: * -> *) a b. Applicative f => 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 [Activity]) -> Either String [Activity]
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= Text -> [Node] -> Either String [Activity]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member"
                        )
      )

instance Prelude.Hashable DescribeScalingActivities

instance Prelude.NFData DescribeScalingActivities

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

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

instance Core.ToQuery DescribeScalingActivities where
  toQuery :: DescribeScalingActivities -> QueryString
toQuery DescribeScalingActivities' {Maybe Bool
Maybe Int
Maybe [Text]
Maybe Text
activityIds :: Maybe [Text]
includeDeletedGroups :: Maybe Bool
maxRecords :: Maybe Int
autoScalingGroupName :: Maybe Text
nextToken :: Maybe Text
$sel:activityIds:DescribeScalingActivities' :: DescribeScalingActivities -> Maybe [Text]
$sel:includeDeletedGroups:DescribeScalingActivities' :: DescribeScalingActivities -> Maybe Bool
$sel:maxRecords:DescribeScalingActivities' :: DescribeScalingActivities -> Maybe Int
$sel:autoScalingGroupName:DescribeScalingActivities' :: DescribeScalingActivities -> Maybe Text
$sel:nextToken:DescribeScalingActivities' :: DescribeScalingActivities -> 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
"DescribeScalingActivities" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2011-01-01" :: Prelude.ByteString),
        ByteString
"NextToken" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
nextToken,
        ByteString
"AutoScalingGroupName" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
autoScalingGroupName,
        ByteString
"MaxRecords" ByteString -> Maybe Int -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Int
maxRecords,
        ByteString
"IncludeDeletedGroups" ByteString -> Maybe Bool -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Bool
includeDeletedGroups,
        ByteString
"ActivityIds"
          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]
activityIds)
      ]

-- | /See:/ 'newDescribeScalingActivitiesResponse' smart constructor.
data DescribeScalingActivitiesResponse = DescribeScalingActivitiesResponse'
  { -- | A string that indicates that the response contains more items than can
    -- be returned in a single response. To receive additional items, specify
    -- this string for the @NextToken@ value when requesting the next set of
    -- items. This value is null when there are no more items to return.
    DescribeScalingActivitiesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DescribeScalingActivitiesResponse -> Int
httpStatus :: Prelude.Int,
    -- | The scaling activities. Activities are sorted by start time. Activities
    -- still in progress are described first.
    DescribeScalingActivitiesResponse -> [Activity]
activities :: [Activity]
  }
  deriving (DescribeScalingActivitiesResponse
-> DescribeScalingActivitiesResponse -> Bool
(DescribeScalingActivitiesResponse
 -> DescribeScalingActivitiesResponse -> Bool)
-> (DescribeScalingActivitiesResponse
    -> DescribeScalingActivitiesResponse -> Bool)
-> Eq DescribeScalingActivitiesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeScalingActivitiesResponse
-> DescribeScalingActivitiesResponse -> Bool
$c/= :: DescribeScalingActivitiesResponse
-> DescribeScalingActivitiesResponse -> Bool
== :: DescribeScalingActivitiesResponse
-> DescribeScalingActivitiesResponse -> Bool
$c== :: DescribeScalingActivitiesResponse
-> DescribeScalingActivitiesResponse -> Bool
Prelude.Eq, ReadPrec [DescribeScalingActivitiesResponse]
ReadPrec DescribeScalingActivitiesResponse
Int -> ReadS DescribeScalingActivitiesResponse
ReadS [DescribeScalingActivitiesResponse]
(Int -> ReadS DescribeScalingActivitiesResponse)
-> ReadS [DescribeScalingActivitiesResponse]
-> ReadPrec DescribeScalingActivitiesResponse
-> ReadPrec [DescribeScalingActivitiesResponse]
-> Read DescribeScalingActivitiesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeScalingActivitiesResponse]
$creadListPrec :: ReadPrec [DescribeScalingActivitiesResponse]
readPrec :: ReadPrec DescribeScalingActivitiesResponse
$creadPrec :: ReadPrec DescribeScalingActivitiesResponse
readList :: ReadS [DescribeScalingActivitiesResponse]
$creadList :: ReadS [DescribeScalingActivitiesResponse]
readsPrec :: Int -> ReadS DescribeScalingActivitiesResponse
$creadsPrec :: Int -> ReadS DescribeScalingActivitiesResponse
Prelude.Read, Int -> DescribeScalingActivitiesResponse -> ShowS
[DescribeScalingActivitiesResponse] -> ShowS
DescribeScalingActivitiesResponse -> String
(Int -> DescribeScalingActivitiesResponse -> ShowS)
-> (DescribeScalingActivitiesResponse -> String)
-> ([DescribeScalingActivitiesResponse] -> ShowS)
-> Show DescribeScalingActivitiesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeScalingActivitiesResponse] -> ShowS
$cshowList :: [DescribeScalingActivitiesResponse] -> ShowS
show :: DescribeScalingActivitiesResponse -> String
$cshow :: DescribeScalingActivitiesResponse -> String
showsPrec :: Int -> DescribeScalingActivitiesResponse -> ShowS
$cshowsPrec :: Int -> DescribeScalingActivitiesResponse -> ShowS
Prelude.Show, (forall x.
 DescribeScalingActivitiesResponse
 -> Rep DescribeScalingActivitiesResponse x)
-> (forall x.
    Rep DescribeScalingActivitiesResponse x
    -> DescribeScalingActivitiesResponse)
-> Generic DescribeScalingActivitiesResponse
forall x.
Rep DescribeScalingActivitiesResponse x
-> DescribeScalingActivitiesResponse
forall x.
DescribeScalingActivitiesResponse
-> Rep DescribeScalingActivitiesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeScalingActivitiesResponse x
-> DescribeScalingActivitiesResponse
$cfrom :: forall x.
DescribeScalingActivitiesResponse
-> Rep DescribeScalingActivitiesResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeScalingActivitiesResponse' 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:
--
-- 'nextToken', 'describeScalingActivitiesResponse_nextToken' - A string that indicates that the response contains more items than can
-- be returned in a single response. To receive additional items, specify
-- this string for the @NextToken@ value when requesting the next set of
-- items. This value is null when there are no more items to return.
--
-- 'httpStatus', 'describeScalingActivitiesResponse_httpStatus' - The response's http status code.
--
-- 'activities', 'describeScalingActivitiesResponse_activities' - The scaling activities. Activities are sorted by start time. Activities
-- still in progress are described first.
newDescribeScalingActivitiesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeScalingActivitiesResponse
newDescribeScalingActivitiesResponse :: Int -> DescribeScalingActivitiesResponse
newDescribeScalingActivitiesResponse Int
pHttpStatus_ =
  DescribeScalingActivitiesResponse' :: Maybe Text
-> Int -> [Activity] -> DescribeScalingActivitiesResponse
DescribeScalingActivitiesResponse'
    { $sel:nextToken:DescribeScalingActivitiesResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeScalingActivitiesResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:activities:DescribeScalingActivitiesResponse' :: [Activity]
activities = [Activity]
forall a. Monoid a => a
Prelude.mempty
    }

-- | A string that indicates that the response contains more items than can
-- be returned in a single response. To receive additional items, specify
-- this string for the @NextToken@ value when requesting the next set of
-- items. This value is null when there are no more items to return.
describeScalingActivitiesResponse_nextToken :: Lens.Lens' DescribeScalingActivitiesResponse (Prelude.Maybe Prelude.Text)
describeScalingActivitiesResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeScalingActivitiesResponse
-> f DescribeScalingActivitiesResponse
describeScalingActivitiesResponse_nextToken = (DescribeScalingActivitiesResponse -> Maybe Text)
-> (DescribeScalingActivitiesResponse
    -> Maybe Text -> DescribeScalingActivitiesResponse)
-> Lens' DescribeScalingActivitiesResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeScalingActivitiesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeScalingActivitiesResponse' :: DescribeScalingActivitiesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeScalingActivitiesResponse
s@DescribeScalingActivitiesResponse' {} Maybe Text
a -> DescribeScalingActivitiesResponse
s {$sel:nextToken:DescribeScalingActivitiesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeScalingActivitiesResponse)

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

-- | The scaling activities. Activities are sorted by start time. Activities
-- still in progress are described first.
describeScalingActivitiesResponse_activities :: Lens.Lens' DescribeScalingActivitiesResponse [Activity]
describeScalingActivitiesResponse_activities :: ([Activity] -> f [Activity])
-> DescribeScalingActivitiesResponse
-> f DescribeScalingActivitiesResponse
describeScalingActivitiesResponse_activities = (DescribeScalingActivitiesResponse -> [Activity])
-> (DescribeScalingActivitiesResponse
    -> [Activity] -> DescribeScalingActivitiesResponse)
-> Lens' DescribeScalingActivitiesResponse [Activity]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeScalingActivitiesResponse' {[Activity]
activities :: [Activity]
$sel:activities:DescribeScalingActivitiesResponse' :: DescribeScalingActivitiesResponse -> [Activity]
activities} -> [Activity]
activities) (\s :: DescribeScalingActivitiesResponse
s@DescribeScalingActivitiesResponse' {} [Activity]
a -> DescribeScalingActivitiesResponse
s {$sel:activities:DescribeScalingActivitiesResponse' :: [Activity]
activities = [Activity]
a} :: DescribeScalingActivitiesResponse) (([Activity] -> f [Activity])
 -> DescribeScalingActivitiesResponse
 -> f DescribeScalingActivitiesResponse)
-> (([Activity] -> f [Activity]) -> [Activity] -> f [Activity])
-> ([Activity] -> f [Activity])
-> DescribeScalingActivitiesResponse
-> f DescribeScalingActivitiesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Activity] -> f [Activity]) -> [Activity] -> f [Activity]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance
  Prelude.NFData
    DescribeScalingActivitiesResponse