{-# 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.DescribeAutoScalingGroups
-- 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 Auto Scaling groups in the account and
-- Region.
--
-- If you specify Auto Scaling group names, the output includes information
-- for only the specified Auto Scaling groups. If you specify filters, the
-- output includes information for only those Auto Scaling groups that meet
-- the filter criteria. If you do not specify group names or filters, the
-- output includes information for all Auto Scaling groups.
--
-- This operation also returns information about instances in Auto Scaling
-- groups. To retrieve information about the instances in a warm pool, you
-- must call the DescribeWarmPool API.
--
-- This operation returns paginated results.
module Amazonka.AutoScaling.DescribeAutoScalingGroups
  ( -- * Creating a Request
    DescribeAutoScalingGroups (..),
    newDescribeAutoScalingGroups,

    -- * Request Lenses
    describeAutoScalingGroups_filters,
    describeAutoScalingGroups_autoScalingGroupNames,
    describeAutoScalingGroups_nextToken,
    describeAutoScalingGroups_maxRecords,

    -- * Destructuring the Response
    DescribeAutoScalingGroupsResponse (..),
    newDescribeAutoScalingGroupsResponse,

    -- * Response Lenses
    describeAutoScalingGroupsResponse_nextToken,
    describeAutoScalingGroupsResponse_httpStatus,
    describeAutoScalingGroupsResponse_autoScalingGroups,
  )
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:/ 'newDescribeAutoScalingGroups' smart constructor.
data DescribeAutoScalingGroups = DescribeAutoScalingGroups'
  { -- | One or more filters to limit the results based on specific tags.
    DescribeAutoScalingGroups -> Maybe [Filter]
filters :: Prelude.Maybe [Filter],
    -- | The names of the Auto Scaling groups. By default, you can only specify
    -- up to 50 names. You can optionally increase this limit using the
    -- @MaxRecords@ parameter.
    --
    -- If you omit this parameter, all Auto Scaling groups are described.
    DescribeAutoScalingGroups -> Maybe [Text]
autoScalingGroupNames :: Prelude.Maybe [Prelude.Text],
    -- | The token for the next set of items to return. (You received this token
    -- from a previous call.)
    DescribeAutoScalingGroups -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of items to return with this call. The default value
    -- is @50@ and the maximum value is @100@.
    DescribeAutoScalingGroups -> Maybe Int
maxRecords :: Prelude.Maybe Prelude.Int
  }
  deriving (DescribeAutoScalingGroups -> DescribeAutoScalingGroups -> Bool
(DescribeAutoScalingGroups -> DescribeAutoScalingGroups -> Bool)
-> (DescribeAutoScalingGroups -> DescribeAutoScalingGroups -> Bool)
-> Eq DescribeAutoScalingGroups
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeAutoScalingGroups -> DescribeAutoScalingGroups -> Bool
$c/= :: DescribeAutoScalingGroups -> DescribeAutoScalingGroups -> Bool
== :: DescribeAutoScalingGroups -> DescribeAutoScalingGroups -> Bool
$c== :: DescribeAutoScalingGroups -> DescribeAutoScalingGroups -> Bool
Prelude.Eq, ReadPrec [DescribeAutoScalingGroups]
ReadPrec DescribeAutoScalingGroups
Int -> ReadS DescribeAutoScalingGroups
ReadS [DescribeAutoScalingGroups]
(Int -> ReadS DescribeAutoScalingGroups)
-> ReadS [DescribeAutoScalingGroups]
-> ReadPrec DescribeAutoScalingGroups
-> ReadPrec [DescribeAutoScalingGroups]
-> Read DescribeAutoScalingGroups
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeAutoScalingGroups]
$creadListPrec :: ReadPrec [DescribeAutoScalingGroups]
readPrec :: ReadPrec DescribeAutoScalingGroups
$creadPrec :: ReadPrec DescribeAutoScalingGroups
readList :: ReadS [DescribeAutoScalingGroups]
$creadList :: ReadS [DescribeAutoScalingGroups]
readsPrec :: Int -> ReadS DescribeAutoScalingGroups
$creadsPrec :: Int -> ReadS DescribeAutoScalingGroups
Prelude.Read, Int -> DescribeAutoScalingGroups -> ShowS
[DescribeAutoScalingGroups] -> ShowS
DescribeAutoScalingGroups -> String
(Int -> DescribeAutoScalingGroups -> ShowS)
-> (DescribeAutoScalingGroups -> String)
-> ([DescribeAutoScalingGroups] -> ShowS)
-> Show DescribeAutoScalingGroups
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeAutoScalingGroups] -> ShowS
$cshowList :: [DescribeAutoScalingGroups] -> ShowS
show :: DescribeAutoScalingGroups -> String
$cshow :: DescribeAutoScalingGroups -> String
showsPrec :: Int -> DescribeAutoScalingGroups -> ShowS
$cshowsPrec :: Int -> DescribeAutoScalingGroups -> ShowS
Prelude.Show, (forall x.
 DescribeAutoScalingGroups -> Rep DescribeAutoScalingGroups x)
-> (forall x.
    Rep DescribeAutoScalingGroups x -> DescribeAutoScalingGroups)
-> Generic DescribeAutoScalingGroups
forall x.
Rep DescribeAutoScalingGroups x -> DescribeAutoScalingGroups
forall x.
DescribeAutoScalingGroups -> Rep DescribeAutoScalingGroups x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeAutoScalingGroups x -> DescribeAutoScalingGroups
$cfrom :: forall x.
DescribeAutoScalingGroups -> Rep DescribeAutoScalingGroups x
Prelude.Generic)

-- |
-- Create a value of 'DescribeAutoScalingGroups' 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:
--
-- 'filters', 'describeAutoScalingGroups_filters' - One or more filters to limit the results based on specific tags.
--
-- 'autoScalingGroupNames', 'describeAutoScalingGroups_autoScalingGroupNames' - The names of the Auto Scaling groups. By default, you can only specify
-- up to 50 names. You can optionally increase this limit using the
-- @MaxRecords@ parameter.
--
-- If you omit this parameter, all Auto Scaling groups are described.
--
-- 'nextToken', 'describeAutoScalingGroups_nextToken' - The token for the next set of items to return. (You received this token
-- from a previous call.)
--
-- 'maxRecords', 'describeAutoScalingGroups_maxRecords' - The maximum number of items to return with this call. The default value
-- is @50@ and the maximum value is @100@.
newDescribeAutoScalingGroups ::
  DescribeAutoScalingGroups
newDescribeAutoScalingGroups :: DescribeAutoScalingGroups
newDescribeAutoScalingGroups =
  DescribeAutoScalingGroups' :: Maybe [Filter]
-> Maybe [Text]
-> Maybe Text
-> Maybe Int
-> DescribeAutoScalingGroups
DescribeAutoScalingGroups'
    { $sel:filters:DescribeAutoScalingGroups' :: Maybe [Filter]
filters =
        Maybe [Filter]
forall a. Maybe a
Prelude.Nothing,
      $sel:autoScalingGroupNames:DescribeAutoScalingGroups' :: Maybe [Text]
autoScalingGroupNames = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeAutoScalingGroups' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxRecords:DescribeAutoScalingGroups' :: Maybe Int
maxRecords = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | One or more filters to limit the results based on specific tags.
describeAutoScalingGroups_filters :: Lens.Lens' DescribeAutoScalingGroups (Prelude.Maybe [Filter])
describeAutoScalingGroups_filters :: (Maybe [Filter] -> f (Maybe [Filter]))
-> DescribeAutoScalingGroups -> f DescribeAutoScalingGroups
describeAutoScalingGroups_filters = (DescribeAutoScalingGroups -> Maybe [Filter])
-> (DescribeAutoScalingGroups
    -> Maybe [Filter] -> DescribeAutoScalingGroups)
-> Lens
     DescribeAutoScalingGroups
     DescribeAutoScalingGroups
     (Maybe [Filter])
     (Maybe [Filter])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAutoScalingGroups' {Maybe [Filter]
filters :: Maybe [Filter]
$sel:filters:DescribeAutoScalingGroups' :: DescribeAutoScalingGroups -> Maybe [Filter]
filters} -> Maybe [Filter]
filters) (\s :: DescribeAutoScalingGroups
s@DescribeAutoScalingGroups' {} Maybe [Filter]
a -> DescribeAutoScalingGroups
s {$sel:filters:DescribeAutoScalingGroups' :: Maybe [Filter]
filters = Maybe [Filter]
a} :: DescribeAutoScalingGroups) ((Maybe [Filter] -> f (Maybe [Filter]))
 -> DescribeAutoScalingGroups -> f DescribeAutoScalingGroups)
-> ((Maybe [Filter] -> f (Maybe [Filter]))
    -> Maybe [Filter] -> f (Maybe [Filter]))
-> (Maybe [Filter] -> f (Maybe [Filter]))
-> DescribeAutoScalingGroups
-> f DescribeAutoScalingGroups
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Filter] [Filter] [Filter] [Filter]
-> Iso
     (Maybe [Filter]) (Maybe [Filter]) (Maybe [Filter]) (Maybe [Filter])
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 [Filter] [Filter] [Filter] [Filter]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The names of the Auto Scaling groups. By default, you can only specify
-- up to 50 names. You can optionally increase this limit using the
-- @MaxRecords@ parameter.
--
-- If you omit this parameter, all Auto Scaling groups are described.
describeAutoScalingGroups_autoScalingGroupNames :: Lens.Lens' DescribeAutoScalingGroups (Prelude.Maybe [Prelude.Text])
describeAutoScalingGroups_autoScalingGroupNames :: (Maybe [Text] -> f (Maybe [Text]))
-> DescribeAutoScalingGroups -> f DescribeAutoScalingGroups
describeAutoScalingGroups_autoScalingGroupNames = (DescribeAutoScalingGroups -> Maybe [Text])
-> (DescribeAutoScalingGroups
    -> Maybe [Text] -> DescribeAutoScalingGroups)
-> Lens
     DescribeAutoScalingGroups
     DescribeAutoScalingGroups
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAutoScalingGroups' {Maybe [Text]
autoScalingGroupNames :: Maybe [Text]
$sel:autoScalingGroupNames:DescribeAutoScalingGroups' :: DescribeAutoScalingGroups -> Maybe [Text]
autoScalingGroupNames} -> Maybe [Text]
autoScalingGroupNames) (\s :: DescribeAutoScalingGroups
s@DescribeAutoScalingGroups' {} Maybe [Text]
a -> DescribeAutoScalingGroups
s {$sel:autoScalingGroupNames:DescribeAutoScalingGroups' :: Maybe [Text]
autoScalingGroupNames = Maybe [Text]
a} :: DescribeAutoScalingGroups) ((Maybe [Text] -> f (Maybe [Text]))
 -> DescribeAutoScalingGroups -> f DescribeAutoScalingGroups)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> DescribeAutoScalingGroups
-> f DescribeAutoScalingGroups
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 token for the next set of items to return. (You received this token
-- from a previous call.)
describeAutoScalingGroups_nextToken :: Lens.Lens' DescribeAutoScalingGroups (Prelude.Maybe Prelude.Text)
describeAutoScalingGroups_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeAutoScalingGroups -> f DescribeAutoScalingGroups
describeAutoScalingGroups_nextToken = (DescribeAutoScalingGroups -> Maybe Text)
-> (DescribeAutoScalingGroups
    -> Maybe Text -> DescribeAutoScalingGroups)
-> Lens
     DescribeAutoScalingGroups
     DescribeAutoScalingGroups
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAutoScalingGroups' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeAutoScalingGroups' :: DescribeAutoScalingGroups -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeAutoScalingGroups
s@DescribeAutoScalingGroups' {} Maybe Text
a -> DescribeAutoScalingGroups
s {$sel:nextToken:DescribeAutoScalingGroups' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeAutoScalingGroups)

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

instance Core.AWSPager DescribeAutoScalingGroups where
  page :: DescribeAutoScalingGroups
-> AWSResponse DescribeAutoScalingGroups
-> Maybe DescribeAutoScalingGroups
page DescribeAutoScalingGroups
rq AWSResponse DescribeAutoScalingGroups
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeAutoScalingGroups
DescribeAutoScalingGroupsResponse
rs
            DescribeAutoScalingGroupsResponse
-> Getting (First Text) DescribeAutoScalingGroupsResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeAutoScalingGroupsResponse
-> Const (First Text) DescribeAutoScalingGroupsResponse
Lens' DescribeAutoScalingGroupsResponse (Maybe Text)
describeAutoScalingGroupsResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeAutoScalingGroupsResponse
 -> Const (First Text) DescribeAutoScalingGroupsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeAutoScalingGroupsResponse 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 DescribeAutoScalingGroups
forall a. Maybe a
Prelude.Nothing
    | [AutoScalingGroup] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeAutoScalingGroups
DescribeAutoScalingGroupsResponse
rs
            DescribeAutoScalingGroupsResponse
-> Getting
     [AutoScalingGroup]
     DescribeAutoScalingGroupsResponse
     [AutoScalingGroup]
-> [AutoScalingGroup]
forall s a. s -> Getting a s a -> a
Lens.^. Getting
  [AutoScalingGroup]
  DescribeAutoScalingGroupsResponse
  [AutoScalingGroup]
Lens' DescribeAutoScalingGroupsResponse [AutoScalingGroup]
describeAutoScalingGroupsResponse_autoScalingGroups
        ) =
      Maybe DescribeAutoScalingGroups
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      DescribeAutoScalingGroups -> Maybe DescribeAutoScalingGroups
forall a. a -> Maybe a
Prelude.Just (DescribeAutoScalingGroups -> Maybe DescribeAutoScalingGroups)
-> DescribeAutoScalingGroups -> Maybe DescribeAutoScalingGroups
forall a b. (a -> b) -> a -> b
Prelude.$
        DescribeAutoScalingGroups
rq
          DescribeAutoScalingGroups
-> (DescribeAutoScalingGroups -> DescribeAutoScalingGroups)
-> DescribeAutoScalingGroups
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> DescribeAutoScalingGroups -> Identity DescribeAutoScalingGroups
Lens
  DescribeAutoScalingGroups
  DescribeAutoScalingGroups
  (Maybe Text)
  (Maybe Text)
describeAutoScalingGroups_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> DescribeAutoScalingGroups -> Identity DescribeAutoScalingGroups)
-> Maybe Text
-> DescribeAutoScalingGroups
-> DescribeAutoScalingGroups
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse DescribeAutoScalingGroups
DescribeAutoScalingGroupsResponse
rs
          DescribeAutoScalingGroupsResponse
-> Getting (First Text) DescribeAutoScalingGroupsResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeAutoScalingGroupsResponse
-> Const (First Text) DescribeAutoScalingGroupsResponse
Lens' DescribeAutoScalingGroupsResponse (Maybe Text)
describeAutoScalingGroupsResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeAutoScalingGroupsResponse
 -> Const (First Text) DescribeAutoScalingGroupsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeAutoScalingGroupsResponse 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 DescribeAutoScalingGroups where
  type
    AWSResponse DescribeAutoScalingGroups =
      DescribeAutoScalingGroupsResponse
  request :: DescribeAutoScalingGroups -> Request DescribeAutoScalingGroups
request = Service
-> DescribeAutoScalingGroups -> Request DescribeAutoScalingGroups
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeAutoScalingGroups
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeAutoScalingGroups)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse DescribeAutoScalingGroups))
-> Logger
-> Service
-> Proxy DescribeAutoScalingGroups
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeAutoScalingGroups)))
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
"DescribeAutoScalingGroupsResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe Text
-> Int -> [AutoScalingGroup] -> DescribeAutoScalingGroupsResponse
DescribeAutoScalingGroupsResponse'
            (Maybe Text
 -> Int -> [AutoScalingGroup] -> DescribeAutoScalingGroupsResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Int -> [AutoScalingGroup] -> DescribeAutoScalingGroupsResponse)
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 -> [AutoScalingGroup] -> DescribeAutoScalingGroupsResponse)
-> Either String Int
-> Either
     String ([AutoScalingGroup] -> DescribeAutoScalingGroupsResponse)
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 ([AutoScalingGroup] -> DescribeAutoScalingGroupsResponse)
-> Either String [AutoScalingGroup]
-> Either String DescribeAutoScalingGroupsResponse
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
"AutoScalingGroups"
                            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 [AutoScalingGroup])
-> Either String [AutoScalingGroup]
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= Text -> [Node] -> Either String [AutoScalingGroup]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member"
                        )
      )

instance Prelude.Hashable DescribeAutoScalingGroups

instance Prelude.NFData DescribeAutoScalingGroups

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

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

instance Core.ToQuery DescribeAutoScalingGroups where
  toQuery :: DescribeAutoScalingGroups -> QueryString
toQuery DescribeAutoScalingGroups' {Maybe Int
Maybe [Text]
Maybe [Filter]
Maybe Text
maxRecords :: Maybe Int
nextToken :: Maybe Text
autoScalingGroupNames :: Maybe [Text]
filters :: Maybe [Filter]
$sel:maxRecords:DescribeAutoScalingGroups' :: DescribeAutoScalingGroups -> Maybe Int
$sel:nextToken:DescribeAutoScalingGroups' :: DescribeAutoScalingGroups -> Maybe Text
$sel:autoScalingGroupNames:DescribeAutoScalingGroups' :: DescribeAutoScalingGroups -> Maybe [Text]
$sel:filters:DescribeAutoScalingGroups' :: DescribeAutoScalingGroups -> Maybe [Filter]
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"DescribeAutoScalingGroups" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2011-01-01" :: Prelude.ByteString),
        ByteString
"Filters"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            (ByteString -> [Filter] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" ([Filter] -> QueryString) -> Maybe [Filter] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Filter]
filters),
        ByteString
"AutoScalingGroupNames"
          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]
autoScalingGroupNames
            ),
        ByteString
"NextToken" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
nextToken,
        ByteString
"MaxRecords" ByteString -> Maybe Int -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Int
maxRecords
      ]

-- | /See:/ 'newDescribeAutoScalingGroupsResponse' smart constructor.
data DescribeAutoScalingGroupsResponse = DescribeAutoScalingGroupsResponse'
  { -- | 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.
    DescribeAutoScalingGroupsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DescribeAutoScalingGroupsResponse -> Int
httpStatus :: Prelude.Int,
    -- | The groups.
    DescribeAutoScalingGroupsResponse -> [AutoScalingGroup]
autoScalingGroups :: [AutoScalingGroup]
  }
  deriving (DescribeAutoScalingGroupsResponse
-> DescribeAutoScalingGroupsResponse -> Bool
(DescribeAutoScalingGroupsResponse
 -> DescribeAutoScalingGroupsResponse -> Bool)
-> (DescribeAutoScalingGroupsResponse
    -> DescribeAutoScalingGroupsResponse -> Bool)
-> Eq DescribeAutoScalingGroupsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeAutoScalingGroupsResponse
-> DescribeAutoScalingGroupsResponse -> Bool
$c/= :: DescribeAutoScalingGroupsResponse
-> DescribeAutoScalingGroupsResponse -> Bool
== :: DescribeAutoScalingGroupsResponse
-> DescribeAutoScalingGroupsResponse -> Bool
$c== :: DescribeAutoScalingGroupsResponse
-> DescribeAutoScalingGroupsResponse -> Bool
Prelude.Eq, ReadPrec [DescribeAutoScalingGroupsResponse]
ReadPrec DescribeAutoScalingGroupsResponse
Int -> ReadS DescribeAutoScalingGroupsResponse
ReadS [DescribeAutoScalingGroupsResponse]
(Int -> ReadS DescribeAutoScalingGroupsResponse)
-> ReadS [DescribeAutoScalingGroupsResponse]
-> ReadPrec DescribeAutoScalingGroupsResponse
-> ReadPrec [DescribeAutoScalingGroupsResponse]
-> Read DescribeAutoScalingGroupsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeAutoScalingGroupsResponse]
$creadListPrec :: ReadPrec [DescribeAutoScalingGroupsResponse]
readPrec :: ReadPrec DescribeAutoScalingGroupsResponse
$creadPrec :: ReadPrec DescribeAutoScalingGroupsResponse
readList :: ReadS [DescribeAutoScalingGroupsResponse]
$creadList :: ReadS [DescribeAutoScalingGroupsResponse]
readsPrec :: Int -> ReadS DescribeAutoScalingGroupsResponse
$creadsPrec :: Int -> ReadS DescribeAutoScalingGroupsResponse
Prelude.Read, Int -> DescribeAutoScalingGroupsResponse -> ShowS
[DescribeAutoScalingGroupsResponse] -> ShowS
DescribeAutoScalingGroupsResponse -> String
(Int -> DescribeAutoScalingGroupsResponse -> ShowS)
-> (DescribeAutoScalingGroupsResponse -> String)
-> ([DescribeAutoScalingGroupsResponse] -> ShowS)
-> Show DescribeAutoScalingGroupsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeAutoScalingGroupsResponse] -> ShowS
$cshowList :: [DescribeAutoScalingGroupsResponse] -> ShowS
show :: DescribeAutoScalingGroupsResponse -> String
$cshow :: DescribeAutoScalingGroupsResponse -> String
showsPrec :: Int -> DescribeAutoScalingGroupsResponse -> ShowS
$cshowsPrec :: Int -> DescribeAutoScalingGroupsResponse -> ShowS
Prelude.Show, (forall x.
 DescribeAutoScalingGroupsResponse
 -> Rep DescribeAutoScalingGroupsResponse x)
-> (forall x.
    Rep DescribeAutoScalingGroupsResponse x
    -> DescribeAutoScalingGroupsResponse)
-> Generic DescribeAutoScalingGroupsResponse
forall x.
Rep DescribeAutoScalingGroupsResponse x
-> DescribeAutoScalingGroupsResponse
forall x.
DescribeAutoScalingGroupsResponse
-> Rep DescribeAutoScalingGroupsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeAutoScalingGroupsResponse x
-> DescribeAutoScalingGroupsResponse
$cfrom :: forall x.
DescribeAutoScalingGroupsResponse
-> Rep DescribeAutoScalingGroupsResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeAutoScalingGroupsResponse' 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', 'describeAutoScalingGroupsResponse_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', 'describeAutoScalingGroupsResponse_httpStatus' - The response's http status code.
--
-- 'autoScalingGroups', 'describeAutoScalingGroupsResponse_autoScalingGroups' - The groups.
newDescribeAutoScalingGroupsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeAutoScalingGroupsResponse
newDescribeAutoScalingGroupsResponse :: Int -> DescribeAutoScalingGroupsResponse
newDescribeAutoScalingGroupsResponse Int
pHttpStatus_ =
  DescribeAutoScalingGroupsResponse' :: Maybe Text
-> Int -> [AutoScalingGroup] -> DescribeAutoScalingGroupsResponse
DescribeAutoScalingGroupsResponse'
    { $sel:nextToken:DescribeAutoScalingGroupsResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeAutoScalingGroupsResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:autoScalingGroups:DescribeAutoScalingGroupsResponse' :: [AutoScalingGroup]
autoScalingGroups = [AutoScalingGroup]
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.
describeAutoScalingGroupsResponse_nextToken :: Lens.Lens' DescribeAutoScalingGroupsResponse (Prelude.Maybe Prelude.Text)
describeAutoScalingGroupsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeAutoScalingGroupsResponse
-> f DescribeAutoScalingGroupsResponse
describeAutoScalingGroupsResponse_nextToken = (DescribeAutoScalingGroupsResponse -> Maybe Text)
-> (DescribeAutoScalingGroupsResponse
    -> Maybe Text -> DescribeAutoScalingGroupsResponse)
-> Lens' DescribeAutoScalingGroupsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAutoScalingGroupsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeAutoScalingGroupsResponse' :: DescribeAutoScalingGroupsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeAutoScalingGroupsResponse
s@DescribeAutoScalingGroupsResponse' {} Maybe Text
a -> DescribeAutoScalingGroupsResponse
s {$sel:nextToken:DescribeAutoScalingGroupsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeAutoScalingGroupsResponse)

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

-- | The groups.
describeAutoScalingGroupsResponse_autoScalingGroups :: Lens.Lens' DescribeAutoScalingGroupsResponse [AutoScalingGroup]
describeAutoScalingGroupsResponse_autoScalingGroups :: ([AutoScalingGroup] -> f [AutoScalingGroup])
-> DescribeAutoScalingGroupsResponse
-> f DescribeAutoScalingGroupsResponse
describeAutoScalingGroupsResponse_autoScalingGroups = (DescribeAutoScalingGroupsResponse -> [AutoScalingGroup])
-> (DescribeAutoScalingGroupsResponse
    -> [AutoScalingGroup] -> DescribeAutoScalingGroupsResponse)
-> Lens' DescribeAutoScalingGroupsResponse [AutoScalingGroup]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAutoScalingGroupsResponse' {[AutoScalingGroup]
autoScalingGroups :: [AutoScalingGroup]
$sel:autoScalingGroups:DescribeAutoScalingGroupsResponse' :: DescribeAutoScalingGroupsResponse -> [AutoScalingGroup]
autoScalingGroups} -> [AutoScalingGroup]
autoScalingGroups) (\s :: DescribeAutoScalingGroupsResponse
s@DescribeAutoScalingGroupsResponse' {} [AutoScalingGroup]
a -> DescribeAutoScalingGroupsResponse
s {$sel:autoScalingGroups:DescribeAutoScalingGroupsResponse' :: [AutoScalingGroup]
autoScalingGroups = [AutoScalingGroup]
a} :: DescribeAutoScalingGroupsResponse) (([AutoScalingGroup] -> f [AutoScalingGroup])
 -> DescribeAutoScalingGroupsResponse
 -> f DescribeAutoScalingGroupsResponse)
-> (([AutoScalingGroup] -> f [AutoScalingGroup])
    -> [AutoScalingGroup] -> f [AutoScalingGroup])
-> ([AutoScalingGroup] -> f [AutoScalingGroup])
-> DescribeAutoScalingGroupsResponse
-> f DescribeAutoScalingGroupsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([AutoScalingGroup] -> f [AutoScalingGroup])
-> [AutoScalingGroup] -> f [AutoScalingGroup]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance
  Prelude.NFData
    DescribeAutoScalingGroupsResponse