{-# 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.AutoScalingPlans.DescribeScalingPlans
-- 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)
--
-- Describes one or more of your scaling plans.
--
-- This operation returns paginated results.
module Amazonka.AutoScalingPlans.DescribeScalingPlans
  ( -- * Creating a Request
    DescribeScalingPlans (..),
    newDescribeScalingPlans,

    -- * Request Lenses
    describeScalingPlans_scalingPlanVersion,
    describeScalingPlans_scalingPlanNames,
    describeScalingPlans_nextToken,
    describeScalingPlans_applicationSources,
    describeScalingPlans_maxResults,

    -- * Destructuring the Response
    DescribeScalingPlansResponse (..),
    newDescribeScalingPlansResponse,

    -- * Response Lenses
    describeScalingPlansResponse_scalingPlans,
    describeScalingPlansResponse_nextToken,
    describeScalingPlansResponse_httpStatus,
  )
where

import Amazonka.AutoScalingPlans.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:/ 'newDescribeScalingPlans' smart constructor.
data DescribeScalingPlans = DescribeScalingPlans'
  { -- | The version number of the scaling plan. Currently, the only valid value
    -- is @1@.
    --
    -- If you specify a scaling plan version, you must also specify a scaling
    -- plan name.
    DescribeScalingPlans -> Maybe Integer
scalingPlanVersion :: Prelude.Maybe Prelude.Integer,
    -- | The names of the scaling plans (up to 10). If you specify application
    -- sources, you cannot specify scaling plan names.
    DescribeScalingPlans -> Maybe [Text]
scalingPlanNames :: Prelude.Maybe [Prelude.Text],
    -- | The token for the next set of results.
    DescribeScalingPlans -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The sources for the applications (up to 10). If you specify scaling plan
    -- names, you cannot specify application sources.
    DescribeScalingPlans -> Maybe [ApplicationSource]
applicationSources :: Prelude.Maybe [ApplicationSource],
    -- | The maximum number of scalable resources to return. This value can be
    -- between 1 and 50. The default value is 50.
    DescribeScalingPlans -> Maybe Int
maxResults :: Prelude.Maybe Prelude.Int
  }
  deriving (DescribeScalingPlans -> DescribeScalingPlans -> Bool
(DescribeScalingPlans -> DescribeScalingPlans -> Bool)
-> (DescribeScalingPlans -> DescribeScalingPlans -> Bool)
-> Eq DescribeScalingPlans
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeScalingPlans -> DescribeScalingPlans -> Bool
$c/= :: DescribeScalingPlans -> DescribeScalingPlans -> Bool
== :: DescribeScalingPlans -> DescribeScalingPlans -> Bool
$c== :: DescribeScalingPlans -> DescribeScalingPlans -> Bool
Prelude.Eq, ReadPrec [DescribeScalingPlans]
ReadPrec DescribeScalingPlans
Int -> ReadS DescribeScalingPlans
ReadS [DescribeScalingPlans]
(Int -> ReadS DescribeScalingPlans)
-> ReadS [DescribeScalingPlans]
-> ReadPrec DescribeScalingPlans
-> ReadPrec [DescribeScalingPlans]
-> Read DescribeScalingPlans
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeScalingPlans]
$creadListPrec :: ReadPrec [DescribeScalingPlans]
readPrec :: ReadPrec DescribeScalingPlans
$creadPrec :: ReadPrec DescribeScalingPlans
readList :: ReadS [DescribeScalingPlans]
$creadList :: ReadS [DescribeScalingPlans]
readsPrec :: Int -> ReadS DescribeScalingPlans
$creadsPrec :: Int -> ReadS DescribeScalingPlans
Prelude.Read, Int -> DescribeScalingPlans -> ShowS
[DescribeScalingPlans] -> ShowS
DescribeScalingPlans -> String
(Int -> DescribeScalingPlans -> ShowS)
-> (DescribeScalingPlans -> String)
-> ([DescribeScalingPlans] -> ShowS)
-> Show DescribeScalingPlans
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeScalingPlans] -> ShowS
$cshowList :: [DescribeScalingPlans] -> ShowS
show :: DescribeScalingPlans -> String
$cshow :: DescribeScalingPlans -> String
showsPrec :: Int -> DescribeScalingPlans -> ShowS
$cshowsPrec :: Int -> DescribeScalingPlans -> ShowS
Prelude.Show, (forall x. DescribeScalingPlans -> Rep DescribeScalingPlans x)
-> (forall x. Rep DescribeScalingPlans x -> DescribeScalingPlans)
-> Generic DescribeScalingPlans
forall x. Rep DescribeScalingPlans x -> DescribeScalingPlans
forall x. DescribeScalingPlans -> Rep DescribeScalingPlans x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeScalingPlans x -> DescribeScalingPlans
$cfrom :: forall x. DescribeScalingPlans -> Rep DescribeScalingPlans x
Prelude.Generic)

-- |
-- Create a value of 'DescribeScalingPlans' 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:
--
-- 'scalingPlanVersion', 'describeScalingPlans_scalingPlanVersion' - The version number of the scaling plan. Currently, the only valid value
-- is @1@.
--
-- If you specify a scaling plan version, you must also specify a scaling
-- plan name.
--
-- 'scalingPlanNames', 'describeScalingPlans_scalingPlanNames' - The names of the scaling plans (up to 10). If you specify application
-- sources, you cannot specify scaling plan names.
--
-- 'nextToken', 'describeScalingPlans_nextToken' - The token for the next set of results.
--
-- 'applicationSources', 'describeScalingPlans_applicationSources' - The sources for the applications (up to 10). If you specify scaling plan
-- names, you cannot specify application sources.
--
-- 'maxResults', 'describeScalingPlans_maxResults' - The maximum number of scalable resources to return. This value can be
-- between 1 and 50. The default value is 50.
newDescribeScalingPlans ::
  DescribeScalingPlans
newDescribeScalingPlans :: DescribeScalingPlans
newDescribeScalingPlans =
  DescribeScalingPlans' :: Maybe Integer
-> Maybe [Text]
-> Maybe Text
-> Maybe [ApplicationSource]
-> Maybe Int
-> DescribeScalingPlans
DescribeScalingPlans'
    { $sel:scalingPlanVersion:DescribeScalingPlans' :: Maybe Integer
scalingPlanVersion =
        Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:scalingPlanNames:DescribeScalingPlans' :: Maybe [Text]
scalingPlanNames = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeScalingPlans' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:applicationSources:DescribeScalingPlans' :: Maybe [ApplicationSource]
applicationSources = Maybe [ApplicationSource]
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:DescribeScalingPlans' :: Maybe Int
maxResults = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | The version number of the scaling plan. Currently, the only valid value
-- is @1@.
--
-- If you specify a scaling plan version, you must also specify a scaling
-- plan name.
describeScalingPlans_scalingPlanVersion :: Lens.Lens' DescribeScalingPlans (Prelude.Maybe Prelude.Integer)
describeScalingPlans_scalingPlanVersion :: (Maybe Integer -> f (Maybe Integer))
-> DescribeScalingPlans -> f DescribeScalingPlans
describeScalingPlans_scalingPlanVersion = (DescribeScalingPlans -> Maybe Integer)
-> (DescribeScalingPlans -> Maybe Integer -> DescribeScalingPlans)
-> Lens
     DescribeScalingPlans
     DescribeScalingPlans
     (Maybe Integer)
     (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeScalingPlans' {Maybe Integer
scalingPlanVersion :: Maybe Integer
$sel:scalingPlanVersion:DescribeScalingPlans' :: DescribeScalingPlans -> Maybe Integer
scalingPlanVersion} -> Maybe Integer
scalingPlanVersion) (\s :: DescribeScalingPlans
s@DescribeScalingPlans' {} Maybe Integer
a -> DescribeScalingPlans
s {$sel:scalingPlanVersion:DescribeScalingPlans' :: Maybe Integer
scalingPlanVersion = Maybe Integer
a} :: DescribeScalingPlans)

-- | The names of the scaling plans (up to 10). If you specify application
-- sources, you cannot specify scaling plan names.
describeScalingPlans_scalingPlanNames :: Lens.Lens' DescribeScalingPlans (Prelude.Maybe [Prelude.Text])
describeScalingPlans_scalingPlanNames :: (Maybe [Text] -> f (Maybe [Text]))
-> DescribeScalingPlans -> f DescribeScalingPlans
describeScalingPlans_scalingPlanNames = (DescribeScalingPlans -> Maybe [Text])
-> (DescribeScalingPlans -> Maybe [Text] -> DescribeScalingPlans)
-> Lens
     DescribeScalingPlans
     DescribeScalingPlans
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeScalingPlans' {Maybe [Text]
scalingPlanNames :: Maybe [Text]
$sel:scalingPlanNames:DescribeScalingPlans' :: DescribeScalingPlans -> Maybe [Text]
scalingPlanNames} -> Maybe [Text]
scalingPlanNames) (\s :: DescribeScalingPlans
s@DescribeScalingPlans' {} Maybe [Text]
a -> DescribeScalingPlans
s {$sel:scalingPlanNames:DescribeScalingPlans' :: Maybe [Text]
scalingPlanNames = Maybe [Text]
a} :: DescribeScalingPlans) ((Maybe [Text] -> f (Maybe [Text]))
 -> DescribeScalingPlans -> f DescribeScalingPlans)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> DescribeScalingPlans
-> f DescribeScalingPlans
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 results.
describeScalingPlans_nextToken :: Lens.Lens' DescribeScalingPlans (Prelude.Maybe Prelude.Text)
describeScalingPlans_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeScalingPlans -> f DescribeScalingPlans
describeScalingPlans_nextToken = (DescribeScalingPlans -> Maybe Text)
-> (DescribeScalingPlans -> Maybe Text -> DescribeScalingPlans)
-> Lens
     DescribeScalingPlans DescribeScalingPlans (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeScalingPlans' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeScalingPlans' :: DescribeScalingPlans -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeScalingPlans
s@DescribeScalingPlans' {} Maybe Text
a -> DescribeScalingPlans
s {$sel:nextToken:DescribeScalingPlans' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeScalingPlans)

-- | The sources for the applications (up to 10). If you specify scaling plan
-- names, you cannot specify application sources.
describeScalingPlans_applicationSources :: Lens.Lens' DescribeScalingPlans (Prelude.Maybe [ApplicationSource])
describeScalingPlans_applicationSources :: (Maybe [ApplicationSource] -> f (Maybe [ApplicationSource]))
-> DescribeScalingPlans -> f DescribeScalingPlans
describeScalingPlans_applicationSources = (DescribeScalingPlans -> Maybe [ApplicationSource])
-> (DescribeScalingPlans
    -> Maybe [ApplicationSource] -> DescribeScalingPlans)
-> Lens
     DescribeScalingPlans
     DescribeScalingPlans
     (Maybe [ApplicationSource])
     (Maybe [ApplicationSource])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeScalingPlans' {Maybe [ApplicationSource]
applicationSources :: Maybe [ApplicationSource]
$sel:applicationSources:DescribeScalingPlans' :: DescribeScalingPlans -> Maybe [ApplicationSource]
applicationSources} -> Maybe [ApplicationSource]
applicationSources) (\s :: DescribeScalingPlans
s@DescribeScalingPlans' {} Maybe [ApplicationSource]
a -> DescribeScalingPlans
s {$sel:applicationSources:DescribeScalingPlans' :: Maybe [ApplicationSource]
applicationSources = Maybe [ApplicationSource]
a} :: DescribeScalingPlans) ((Maybe [ApplicationSource] -> f (Maybe [ApplicationSource]))
 -> DescribeScalingPlans -> f DescribeScalingPlans)
-> ((Maybe [ApplicationSource] -> f (Maybe [ApplicationSource]))
    -> Maybe [ApplicationSource] -> f (Maybe [ApplicationSource]))
-> (Maybe [ApplicationSource] -> f (Maybe [ApplicationSource]))
-> DescribeScalingPlans
-> f DescribeScalingPlans
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ApplicationSource]
  [ApplicationSource]
  [ApplicationSource]
  [ApplicationSource]
-> Iso
     (Maybe [ApplicationSource])
     (Maybe [ApplicationSource])
     (Maybe [ApplicationSource])
     (Maybe [ApplicationSource])
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
  [ApplicationSource]
  [ApplicationSource]
  [ApplicationSource]
  [ApplicationSource]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The maximum number of scalable resources to return. This value can be
-- between 1 and 50. The default value is 50.
describeScalingPlans_maxResults :: Lens.Lens' DescribeScalingPlans (Prelude.Maybe Prelude.Int)
describeScalingPlans_maxResults :: (Maybe Int -> f (Maybe Int))
-> DescribeScalingPlans -> f DescribeScalingPlans
describeScalingPlans_maxResults = (DescribeScalingPlans -> Maybe Int)
-> (DescribeScalingPlans -> Maybe Int -> DescribeScalingPlans)
-> Lens
     DescribeScalingPlans DescribeScalingPlans (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeScalingPlans' {Maybe Int
maxResults :: Maybe Int
$sel:maxResults:DescribeScalingPlans' :: DescribeScalingPlans -> Maybe Int
maxResults} -> Maybe Int
maxResults) (\s :: DescribeScalingPlans
s@DescribeScalingPlans' {} Maybe Int
a -> DescribeScalingPlans
s {$sel:maxResults:DescribeScalingPlans' :: Maybe Int
maxResults = Maybe Int
a} :: DescribeScalingPlans)

instance Core.AWSPager DescribeScalingPlans where
  page :: DescribeScalingPlans
-> AWSResponse DescribeScalingPlans -> Maybe DescribeScalingPlans
page DescribeScalingPlans
rq AWSResponse DescribeScalingPlans
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeScalingPlans
DescribeScalingPlansResponse
rs
            DescribeScalingPlansResponse
-> Getting (First Text) DescribeScalingPlansResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeScalingPlansResponse
-> Const (First Text) DescribeScalingPlansResponse
Lens' DescribeScalingPlansResponse (Maybe Text)
describeScalingPlansResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeScalingPlansResponse
 -> Const (First Text) DescribeScalingPlansResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeScalingPlansResponse 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 DescribeScalingPlans
forall a. Maybe a
Prelude.Nothing
    | Maybe [ScalingPlan] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeScalingPlans
DescribeScalingPlansResponse
rs
            DescribeScalingPlansResponse
-> Getting
     (First [ScalingPlan]) DescribeScalingPlansResponse [ScalingPlan]
-> Maybe [ScalingPlan]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [ScalingPlan]
 -> Const (First [ScalingPlan]) (Maybe [ScalingPlan]))
-> DescribeScalingPlansResponse
-> Const (First [ScalingPlan]) DescribeScalingPlansResponse
Lens' DescribeScalingPlansResponse (Maybe [ScalingPlan])
describeScalingPlansResponse_scalingPlans
              ((Maybe [ScalingPlan]
  -> Const (First [ScalingPlan]) (Maybe [ScalingPlan]))
 -> DescribeScalingPlansResponse
 -> Const (First [ScalingPlan]) DescribeScalingPlansResponse)
-> (([ScalingPlan] -> Const (First [ScalingPlan]) [ScalingPlan])
    -> Maybe [ScalingPlan]
    -> Const (First [ScalingPlan]) (Maybe [ScalingPlan]))
-> Getting
     (First [ScalingPlan]) DescribeScalingPlansResponse [ScalingPlan]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([ScalingPlan] -> Const (First [ScalingPlan]) [ScalingPlan])
-> Maybe [ScalingPlan]
-> Const (First [ScalingPlan]) (Maybe [ScalingPlan])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe DescribeScalingPlans
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      DescribeScalingPlans -> Maybe DescribeScalingPlans
forall a. a -> Maybe a
Prelude.Just (DescribeScalingPlans -> Maybe DescribeScalingPlans)
-> DescribeScalingPlans -> Maybe DescribeScalingPlans
forall a b. (a -> b) -> a -> b
Prelude.$
        DescribeScalingPlans
rq
          DescribeScalingPlans
-> (DescribeScalingPlans -> DescribeScalingPlans)
-> DescribeScalingPlans
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> DescribeScalingPlans -> Identity DescribeScalingPlans
Lens
  DescribeScalingPlans DescribeScalingPlans (Maybe Text) (Maybe Text)
describeScalingPlans_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> DescribeScalingPlans -> Identity DescribeScalingPlans)
-> Maybe Text -> DescribeScalingPlans -> DescribeScalingPlans
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse DescribeScalingPlans
DescribeScalingPlansResponse
rs
          DescribeScalingPlansResponse
-> Getting (First Text) DescribeScalingPlansResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeScalingPlansResponse
-> Const (First Text) DescribeScalingPlansResponse
Lens' DescribeScalingPlansResponse (Maybe Text)
describeScalingPlansResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeScalingPlansResponse
 -> Const (First Text) DescribeScalingPlansResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeScalingPlansResponse 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 DescribeScalingPlans where
  type
    AWSResponse DescribeScalingPlans =
      DescribeScalingPlansResponse
  request :: DescribeScalingPlans -> Request DescribeScalingPlans
request = Service -> DescribeScalingPlans -> Request DescribeScalingPlans
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeScalingPlans
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeScalingPlans)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeScalingPlans))
-> Logger
-> Service
-> Proxy DescribeScalingPlans
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeScalingPlans)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [ScalingPlan]
-> Maybe Text -> Int -> DescribeScalingPlansResponse
DescribeScalingPlansResponse'
            (Maybe [ScalingPlan]
 -> Maybe Text -> Int -> DescribeScalingPlansResponse)
-> Either String (Maybe [ScalingPlan])
-> Either
     String (Maybe Text -> Int -> DescribeScalingPlansResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [ScalingPlan]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ScalingPlans" Either String (Maybe (Maybe [ScalingPlan]))
-> Maybe [ScalingPlan] -> Either String (Maybe [ScalingPlan])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [ScalingPlan]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Maybe Text -> Int -> DescribeScalingPlansResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DescribeScalingPlansResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"NextToken")
            Either String (Int -> DescribeScalingPlansResponse)
-> Either String Int -> Either String DescribeScalingPlansResponse
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))
      )

instance Prelude.Hashable DescribeScalingPlans

instance Prelude.NFData DescribeScalingPlans

instance Core.ToHeaders DescribeScalingPlans where
  toHeaders :: DescribeScalingPlans -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeScalingPlans -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AnyScaleScalingPlannerFrontendService.DescribeScalingPlans" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON DescribeScalingPlans where
  toJSON :: DescribeScalingPlans -> Value
toJSON DescribeScalingPlans' {Maybe Int
Maybe Integer
Maybe [Text]
Maybe [ApplicationSource]
Maybe Text
maxResults :: Maybe Int
applicationSources :: Maybe [ApplicationSource]
nextToken :: Maybe Text
scalingPlanNames :: Maybe [Text]
scalingPlanVersion :: Maybe Integer
$sel:maxResults:DescribeScalingPlans' :: DescribeScalingPlans -> Maybe Int
$sel:applicationSources:DescribeScalingPlans' :: DescribeScalingPlans -> Maybe [ApplicationSource]
$sel:nextToken:DescribeScalingPlans' :: DescribeScalingPlans -> Maybe Text
$sel:scalingPlanNames:DescribeScalingPlans' :: DescribeScalingPlans -> Maybe [Text]
$sel:scalingPlanVersion:DescribeScalingPlans' :: DescribeScalingPlans -> Maybe Integer
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ScalingPlanVersion" Text -> Integer -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Integer -> Pair) -> Maybe Integer -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Integer
scalingPlanVersion,
            (Text
"ScalingPlanNames" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
scalingPlanNames,
            (Text
"NextToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken,
            (Text
"ApplicationSources" Text -> [ApplicationSource] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([ApplicationSource] -> Pair)
-> Maybe [ApplicationSource] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [ApplicationSource]
applicationSources,
            (Text
"MaxResults" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
maxResults
          ]
      )

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

instance Core.ToQuery DescribeScalingPlans where
  toQuery :: DescribeScalingPlans -> QueryString
toQuery = QueryString -> DescribeScalingPlans -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newDescribeScalingPlansResponse' smart constructor.
data DescribeScalingPlansResponse = DescribeScalingPlansResponse'
  { -- | Information about the scaling plans.
    DescribeScalingPlansResponse -> Maybe [ScalingPlan]
scalingPlans :: Prelude.Maybe [ScalingPlan],
    -- | The token required to get the next set of results. This value is @null@
    -- if there are no more results to return.
    DescribeScalingPlansResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DescribeScalingPlansResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeScalingPlansResponse
-> DescribeScalingPlansResponse -> Bool
(DescribeScalingPlansResponse
 -> DescribeScalingPlansResponse -> Bool)
-> (DescribeScalingPlansResponse
    -> DescribeScalingPlansResponse -> Bool)
-> Eq DescribeScalingPlansResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeScalingPlansResponse
-> DescribeScalingPlansResponse -> Bool
$c/= :: DescribeScalingPlansResponse
-> DescribeScalingPlansResponse -> Bool
== :: DescribeScalingPlansResponse
-> DescribeScalingPlansResponse -> Bool
$c== :: DescribeScalingPlansResponse
-> DescribeScalingPlansResponse -> Bool
Prelude.Eq, ReadPrec [DescribeScalingPlansResponse]
ReadPrec DescribeScalingPlansResponse
Int -> ReadS DescribeScalingPlansResponse
ReadS [DescribeScalingPlansResponse]
(Int -> ReadS DescribeScalingPlansResponse)
-> ReadS [DescribeScalingPlansResponse]
-> ReadPrec DescribeScalingPlansResponse
-> ReadPrec [DescribeScalingPlansResponse]
-> Read DescribeScalingPlansResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeScalingPlansResponse]
$creadListPrec :: ReadPrec [DescribeScalingPlansResponse]
readPrec :: ReadPrec DescribeScalingPlansResponse
$creadPrec :: ReadPrec DescribeScalingPlansResponse
readList :: ReadS [DescribeScalingPlansResponse]
$creadList :: ReadS [DescribeScalingPlansResponse]
readsPrec :: Int -> ReadS DescribeScalingPlansResponse
$creadsPrec :: Int -> ReadS DescribeScalingPlansResponse
Prelude.Read, Int -> DescribeScalingPlansResponse -> ShowS
[DescribeScalingPlansResponse] -> ShowS
DescribeScalingPlansResponse -> String
(Int -> DescribeScalingPlansResponse -> ShowS)
-> (DescribeScalingPlansResponse -> String)
-> ([DescribeScalingPlansResponse] -> ShowS)
-> Show DescribeScalingPlansResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeScalingPlansResponse] -> ShowS
$cshowList :: [DescribeScalingPlansResponse] -> ShowS
show :: DescribeScalingPlansResponse -> String
$cshow :: DescribeScalingPlansResponse -> String
showsPrec :: Int -> DescribeScalingPlansResponse -> ShowS
$cshowsPrec :: Int -> DescribeScalingPlansResponse -> ShowS
Prelude.Show, (forall x.
 DescribeScalingPlansResponse -> Rep DescribeScalingPlansResponse x)
-> (forall x.
    Rep DescribeScalingPlansResponse x -> DescribeScalingPlansResponse)
-> Generic DescribeScalingPlansResponse
forall x.
Rep DescribeScalingPlansResponse x -> DescribeScalingPlansResponse
forall x.
DescribeScalingPlansResponse -> Rep DescribeScalingPlansResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeScalingPlansResponse x -> DescribeScalingPlansResponse
$cfrom :: forall x.
DescribeScalingPlansResponse -> Rep DescribeScalingPlansResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeScalingPlansResponse' 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:
--
-- 'scalingPlans', 'describeScalingPlansResponse_scalingPlans' - Information about the scaling plans.
--
-- 'nextToken', 'describeScalingPlansResponse_nextToken' - The token required to get the next set of results. This value is @null@
-- if there are no more results to return.
--
-- 'httpStatus', 'describeScalingPlansResponse_httpStatus' - The response's http status code.
newDescribeScalingPlansResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeScalingPlansResponse
newDescribeScalingPlansResponse :: Int -> DescribeScalingPlansResponse
newDescribeScalingPlansResponse Int
pHttpStatus_ =
  DescribeScalingPlansResponse' :: Maybe [ScalingPlan]
-> Maybe Text -> Int -> DescribeScalingPlansResponse
DescribeScalingPlansResponse'
    { $sel:scalingPlans:DescribeScalingPlansResponse' :: Maybe [ScalingPlan]
scalingPlans =
        Maybe [ScalingPlan]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeScalingPlansResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeScalingPlansResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the scaling plans.
describeScalingPlansResponse_scalingPlans :: Lens.Lens' DescribeScalingPlansResponse (Prelude.Maybe [ScalingPlan])
describeScalingPlansResponse_scalingPlans :: (Maybe [ScalingPlan] -> f (Maybe [ScalingPlan]))
-> DescribeScalingPlansResponse -> f DescribeScalingPlansResponse
describeScalingPlansResponse_scalingPlans = (DescribeScalingPlansResponse -> Maybe [ScalingPlan])
-> (DescribeScalingPlansResponse
    -> Maybe [ScalingPlan] -> DescribeScalingPlansResponse)
-> Lens' DescribeScalingPlansResponse (Maybe [ScalingPlan])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeScalingPlansResponse' {Maybe [ScalingPlan]
scalingPlans :: Maybe [ScalingPlan]
$sel:scalingPlans:DescribeScalingPlansResponse' :: DescribeScalingPlansResponse -> Maybe [ScalingPlan]
scalingPlans} -> Maybe [ScalingPlan]
scalingPlans) (\s :: DescribeScalingPlansResponse
s@DescribeScalingPlansResponse' {} Maybe [ScalingPlan]
a -> DescribeScalingPlansResponse
s {$sel:scalingPlans:DescribeScalingPlansResponse' :: Maybe [ScalingPlan]
scalingPlans = Maybe [ScalingPlan]
a} :: DescribeScalingPlansResponse) ((Maybe [ScalingPlan] -> f (Maybe [ScalingPlan]))
 -> DescribeScalingPlansResponse -> f DescribeScalingPlansResponse)
-> ((Maybe [ScalingPlan] -> f (Maybe [ScalingPlan]))
    -> Maybe [ScalingPlan] -> f (Maybe [ScalingPlan]))
-> (Maybe [ScalingPlan] -> f (Maybe [ScalingPlan]))
-> DescribeScalingPlansResponse
-> f DescribeScalingPlansResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [ScalingPlan] [ScalingPlan] [ScalingPlan] [ScalingPlan]
-> Iso
     (Maybe [ScalingPlan])
     (Maybe [ScalingPlan])
     (Maybe [ScalingPlan])
     (Maybe [ScalingPlan])
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 [ScalingPlan] [ScalingPlan] [ScalingPlan] [ScalingPlan]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The token required to get the next set of results. This value is @null@
-- if there are no more results to return.
describeScalingPlansResponse_nextToken :: Lens.Lens' DescribeScalingPlansResponse (Prelude.Maybe Prelude.Text)
describeScalingPlansResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeScalingPlansResponse -> f DescribeScalingPlansResponse
describeScalingPlansResponse_nextToken = (DescribeScalingPlansResponse -> Maybe Text)
-> (DescribeScalingPlansResponse
    -> Maybe Text -> DescribeScalingPlansResponse)
-> Lens' DescribeScalingPlansResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeScalingPlansResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeScalingPlansResponse' :: DescribeScalingPlansResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeScalingPlansResponse
s@DescribeScalingPlansResponse' {} Maybe Text
a -> DescribeScalingPlansResponse
s {$sel:nextToken:DescribeScalingPlansResponse' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeScalingPlansResponse)

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

instance Prelude.NFData DescribeScalingPlansResponse