{-# 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.DescribePolicies
-- 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 policies in the account and Region.
--
-- This operation returns paginated results.
module Amazonka.AutoScaling.DescribePolicies
  ( -- * Creating a Request
    DescribePolicies (..),
    newDescribePolicies,

    -- * Request Lenses
    describePolicies_policyNames,
    describePolicies_nextToken,
    describePolicies_autoScalingGroupName,
    describePolicies_maxRecords,
    describePolicies_policyTypes,

    -- * Destructuring the Response
    DescribePoliciesResponse (..),
    newDescribePoliciesResponse,

    -- * Response Lenses
    describePoliciesResponse_nextToken,
    describePoliciesResponse_scalingPolicies,
    describePoliciesResponse_httpStatus,
  )
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:/ 'newDescribePolicies' smart constructor.
data DescribePolicies = DescribePolicies'
  { -- | The names of one or more policies. If you omit this parameter, all
    -- policies are described. If a group name is provided, the results are
    -- limited to that group. If you specify an unknown policy name, it is
    -- ignored with no error.
    --
    -- Array Members: Maximum number of 50 items.
    DescribePolicies -> Maybe [Text]
policyNames :: Prelude.Maybe [Prelude.Text],
    -- | The token for the next set of items to return. (You received this token
    -- from a previous call.)
    DescribePolicies -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The name of the Auto Scaling group.
    DescribePolicies -> Maybe Text
autoScalingGroupName :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of items to be returned with each call. The default
    -- value is @50@ and the maximum value is @100@.
    DescribePolicies -> Maybe Int
maxRecords :: Prelude.Maybe Prelude.Int,
    -- | One or more policy types. The valid values are @SimpleScaling@,
    -- @StepScaling@, @TargetTrackingScaling@, and @PredictiveScaling@.
    DescribePolicies -> Maybe [Text]
policyTypes :: Prelude.Maybe [Prelude.Text]
  }
  deriving (DescribePolicies -> DescribePolicies -> Bool
(DescribePolicies -> DescribePolicies -> Bool)
-> (DescribePolicies -> DescribePolicies -> Bool)
-> Eq DescribePolicies
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribePolicies -> DescribePolicies -> Bool
$c/= :: DescribePolicies -> DescribePolicies -> Bool
== :: DescribePolicies -> DescribePolicies -> Bool
$c== :: DescribePolicies -> DescribePolicies -> Bool
Prelude.Eq, ReadPrec [DescribePolicies]
ReadPrec DescribePolicies
Int -> ReadS DescribePolicies
ReadS [DescribePolicies]
(Int -> ReadS DescribePolicies)
-> ReadS [DescribePolicies]
-> ReadPrec DescribePolicies
-> ReadPrec [DescribePolicies]
-> Read DescribePolicies
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribePolicies]
$creadListPrec :: ReadPrec [DescribePolicies]
readPrec :: ReadPrec DescribePolicies
$creadPrec :: ReadPrec DescribePolicies
readList :: ReadS [DescribePolicies]
$creadList :: ReadS [DescribePolicies]
readsPrec :: Int -> ReadS DescribePolicies
$creadsPrec :: Int -> ReadS DescribePolicies
Prelude.Read, Int -> DescribePolicies -> ShowS
[DescribePolicies] -> ShowS
DescribePolicies -> String
(Int -> DescribePolicies -> ShowS)
-> (DescribePolicies -> String)
-> ([DescribePolicies] -> ShowS)
-> Show DescribePolicies
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribePolicies] -> ShowS
$cshowList :: [DescribePolicies] -> ShowS
show :: DescribePolicies -> String
$cshow :: DescribePolicies -> String
showsPrec :: Int -> DescribePolicies -> ShowS
$cshowsPrec :: Int -> DescribePolicies -> ShowS
Prelude.Show, (forall x. DescribePolicies -> Rep DescribePolicies x)
-> (forall x. Rep DescribePolicies x -> DescribePolicies)
-> Generic DescribePolicies
forall x. Rep DescribePolicies x -> DescribePolicies
forall x. DescribePolicies -> Rep DescribePolicies x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribePolicies x -> DescribePolicies
$cfrom :: forall x. DescribePolicies -> Rep DescribePolicies x
Prelude.Generic)

-- |
-- Create a value of 'DescribePolicies' 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:
--
-- 'policyNames', 'describePolicies_policyNames' - The names of one or more policies. If you omit this parameter, all
-- policies are described. If a group name is provided, the results are
-- limited to that group. If you specify an unknown policy name, it is
-- ignored with no error.
--
-- Array Members: Maximum number of 50 items.
--
-- 'nextToken', 'describePolicies_nextToken' - The token for the next set of items to return. (You received this token
-- from a previous call.)
--
-- 'autoScalingGroupName', 'describePolicies_autoScalingGroupName' - The name of the Auto Scaling group.
--
-- 'maxRecords', 'describePolicies_maxRecords' - The maximum number of items to be returned with each call. The default
-- value is @50@ and the maximum value is @100@.
--
-- 'policyTypes', 'describePolicies_policyTypes' - One or more policy types. The valid values are @SimpleScaling@,
-- @StepScaling@, @TargetTrackingScaling@, and @PredictiveScaling@.
newDescribePolicies ::
  DescribePolicies
newDescribePolicies :: DescribePolicies
newDescribePolicies =
  DescribePolicies' :: Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe Int
-> Maybe [Text]
-> DescribePolicies
DescribePolicies'
    { $sel:policyNames:DescribePolicies' :: Maybe [Text]
policyNames = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribePolicies' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:autoScalingGroupName:DescribePolicies' :: Maybe Text
autoScalingGroupName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxRecords:DescribePolicies' :: Maybe Int
maxRecords = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:policyTypes:DescribePolicies' :: Maybe [Text]
policyTypes = Maybe [Text]
forall a. Maybe a
Prelude.Nothing
    }

-- | The names of one or more policies. If you omit this parameter, all
-- policies are described. If a group name is provided, the results are
-- limited to that group. If you specify an unknown policy name, it is
-- ignored with no error.
--
-- Array Members: Maximum number of 50 items.
describePolicies_policyNames :: Lens.Lens' DescribePolicies (Prelude.Maybe [Prelude.Text])
describePolicies_policyNames :: (Maybe [Text] -> f (Maybe [Text]))
-> DescribePolicies -> f DescribePolicies
describePolicies_policyNames = (DescribePolicies -> Maybe [Text])
-> (DescribePolicies -> Maybe [Text] -> DescribePolicies)
-> Lens
     DescribePolicies DescribePolicies (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribePolicies' {Maybe [Text]
policyNames :: Maybe [Text]
$sel:policyNames:DescribePolicies' :: DescribePolicies -> Maybe [Text]
policyNames} -> Maybe [Text]
policyNames) (\s :: DescribePolicies
s@DescribePolicies' {} Maybe [Text]
a -> DescribePolicies
s {$sel:policyNames:DescribePolicies' :: Maybe [Text]
policyNames = Maybe [Text]
a} :: DescribePolicies) ((Maybe [Text] -> f (Maybe [Text]))
 -> DescribePolicies -> f DescribePolicies)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> DescribePolicies
-> f DescribePolicies
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.)
describePolicies_nextToken :: Lens.Lens' DescribePolicies (Prelude.Maybe Prelude.Text)
describePolicies_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribePolicies -> f DescribePolicies
describePolicies_nextToken = (DescribePolicies -> Maybe Text)
-> (DescribePolicies -> Maybe Text -> DescribePolicies)
-> Lens DescribePolicies DescribePolicies (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribePolicies' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribePolicies' :: DescribePolicies -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribePolicies
s@DescribePolicies' {} Maybe Text
a -> DescribePolicies
s {$sel:nextToken:DescribePolicies' :: Maybe Text
nextToken = Maybe Text
a} :: DescribePolicies)

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

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

-- | One or more policy types. The valid values are @SimpleScaling@,
-- @StepScaling@, @TargetTrackingScaling@, and @PredictiveScaling@.
describePolicies_policyTypes :: Lens.Lens' DescribePolicies (Prelude.Maybe [Prelude.Text])
describePolicies_policyTypes :: (Maybe [Text] -> f (Maybe [Text]))
-> DescribePolicies -> f DescribePolicies
describePolicies_policyTypes = (DescribePolicies -> Maybe [Text])
-> (DescribePolicies -> Maybe [Text] -> DescribePolicies)
-> Lens
     DescribePolicies DescribePolicies (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribePolicies' {Maybe [Text]
policyTypes :: Maybe [Text]
$sel:policyTypes:DescribePolicies' :: DescribePolicies -> Maybe [Text]
policyTypes} -> Maybe [Text]
policyTypes) (\s :: DescribePolicies
s@DescribePolicies' {} Maybe [Text]
a -> DescribePolicies
s {$sel:policyTypes:DescribePolicies' :: Maybe [Text]
policyTypes = Maybe [Text]
a} :: DescribePolicies) ((Maybe [Text] -> f (Maybe [Text]))
 -> DescribePolicies -> f DescribePolicies)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> DescribePolicies
-> f DescribePolicies
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 DescribePolicies where
  page :: DescribePolicies
-> AWSResponse DescribePolicies -> Maybe DescribePolicies
page DescribePolicies
rq AWSResponse DescribePolicies
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribePolicies
DescribePoliciesResponse
rs
            DescribePoliciesResponse
-> Getting (First Text) DescribePoliciesResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribePoliciesResponse
-> Const (First Text) DescribePoliciesResponse
Lens' DescribePoliciesResponse (Maybe Text)
describePoliciesResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribePoliciesResponse
 -> Const (First Text) DescribePoliciesResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribePoliciesResponse 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 DescribePolicies
forall a. Maybe a
Prelude.Nothing
    | Maybe [ScalingPolicy] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribePolicies
DescribePoliciesResponse
rs
            DescribePoliciesResponse
-> Getting
     (First [ScalingPolicy]) DescribePoliciesResponse [ScalingPolicy]
-> Maybe [ScalingPolicy]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [ScalingPolicy]
 -> Const (First [ScalingPolicy]) (Maybe [ScalingPolicy]))
-> DescribePoliciesResponse
-> Const (First [ScalingPolicy]) DescribePoliciesResponse
Lens' DescribePoliciesResponse (Maybe [ScalingPolicy])
describePoliciesResponse_scalingPolicies
              ((Maybe [ScalingPolicy]
  -> Const (First [ScalingPolicy]) (Maybe [ScalingPolicy]))
 -> DescribePoliciesResponse
 -> Const (First [ScalingPolicy]) DescribePoliciesResponse)
-> (([ScalingPolicy]
     -> Const (First [ScalingPolicy]) [ScalingPolicy])
    -> Maybe [ScalingPolicy]
    -> Const (First [ScalingPolicy]) (Maybe [ScalingPolicy]))
-> Getting
     (First [ScalingPolicy]) DescribePoliciesResponse [ScalingPolicy]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([ScalingPolicy] -> Const (First [ScalingPolicy]) [ScalingPolicy])
-> Maybe [ScalingPolicy]
-> Const (First [ScalingPolicy]) (Maybe [ScalingPolicy])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe DescribePolicies
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      DescribePolicies -> Maybe DescribePolicies
forall a. a -> Maybe a
Prelude.Just (DescribePolicies -> Maybe DescribePolicies)
-> DescribePolicies -> Maybe DescribePolicies
forall a b. (a -> b) -> a -> b
Prelude.$
        DescribePolicies
rq
          DescribePolicies
-> (DescribePolicies -> DescribePolicies) -> DescribePolicies
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> DescribePolicies -> Identity DescribePolicies
Lens DescribePolicies DescribePolicies (Maybe Text) (Maybe Text)
describePolicies_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> DescribePolicies -> Identity DescribePolicies)
-> Maybe Text -> DescribePolicies -> DescribePolicies
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse DescribePolicies
DescribePoliciesResponse
rs
          DescribePoliciesResponse
-> Getting (First Text) DescribePoliciesResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribePoliciesResponse
-> Const (First Text) DescribePoliciesResponse
Lens' DescribePoliciesResponse (Maybe Text)
describePoliciesResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribePoliciesResponse
 -> Const (First Text) DescribePoliciesResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribePoliciesResponse 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 DescribePolicies where
  type
    AWSResponse DescribePolicies =
      DescribePoliciesResponse
  request :: DescribePolicies -> Request DescribePolicies
request = Service -> DescribePolicies -> Request DescribePolicies
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribePolicies
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribePolicies)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse DescribePolicies))
-> Logger
-> Service
-> Proxy DescribePolicies
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribePolicies)))
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
"DescribePoliciesResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe Text
-> Maybe [ScalingPolicy] -> Int -> DescribePoliciesResponse
DescribePoliciesResponse'
            (Maybe Text
 -> Maybe [ScalingPolicy] -> Int -> DescribePoliciesResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe [ScalingPolicy] -> Int -> DescribePoliciesResponse)
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 (Maybe [ScalingPolicy] -> Int -> DescribePoliciesResponse)
-> Either String (Maybe [ScalingPolicy])
-> Either String (Int -> DescribePoliciesResponse)
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
"ScalingPolicies" 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 (Maybe [ScalingPolicy]))
-> Either String (Maybe [ScalingPolicy])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [ScalingPolicy])
-> [Node] -> Either String (Maybe [ScalingPolicy])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [ScalingPolicy]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
                        )
            Either String (Int -> DescribePoliciesResponse)
-> Either String Int -> Either String DescribePoliciesResponse
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 DescribePolicies

instance Prelude.NFData DescribePolicies

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

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

instance Core.ToQuery DescribePolicies where
  toQuery :: DescribePolicies -> QueryString
toQuery DescribePolicies' {Maybe Int
Maybe [Text]
Maybe Text
policyTypes :: Maybe [Text]
maxRecords :: Maybe Int
autoScalingGroupName :: Maybe Text
nextToken :: Maybe Text
policyNames :: Maybe [Text]
$sel:policyTypes:DescribePolicies' :: DescribePolicies -> Maybe [Text]
$sel:maxRecords:DescribePolicies' :: DescribePolicies -> Maybe Int
$sel:autoScalingGroupName:DescribePolicies' :: DescribePolicies -> Maybe Text
$sel:nextToken:DescribePolicies' :: DescribePolicies -> Maybe Text
$sel:policyNames:DescribePolicies' :: DescribePolicies -> 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
"DescribePolicies" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2011-01-01" :: Prelude.ByteString),
        ByteString
"PolicyNames"
          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]
policyNames),
        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
"PolicyTypes"
          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]
policyTypes)
      ]

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

-- |
-- Create a value of 'DescribePoliciesResponse' 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', 'describePoliciesResponse_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.
--
-- 'scalingPolicies', 'describePoliciesResponse_scalingPolicies' - The scaling policies.
--
-- 'httpStatus', 'describePoliciesResponse_httpStatus' - The response's http status code.
newDescribePoliciesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribePoliciesResponse
newDescribePoliciesResponse :: Int -> DescribePoliciesResponse
newDescribePoliciesResponse Int
pHttpStatus_ =
  DescribePoliciesResponse' :: Maybe Text
-> Maybe [ScalingPolicy] -> Int -> DescribePoliciesResponse
DescribePoliciesResponse'
    { $sel:nextToken:DescribePoliciesResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:scalingPolicies:DescribePoliciesResponse' :: Maybe [ScalingPolicy]
scalingPolicies = Maybe [ScalingPolicy]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribePoliciesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | 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.
describePoliciesResponse_nextToken :: Lens.Lens' DescribePoliciesResponse (Prelude.Maybe Prelude.Text)
describePoliciesResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribePoliciesResponse -> f DescribePoliciesResponse
describePoliciesResponse_nextToken = (DescribePoliciesResponse -> Maybe Text)
-> (DescribePoliciesResponse
    -> Maybe Text -> DescribePoliciesResponse)
-> Lens' DescribePoliciesResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribePoliciesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribePoliciesResponse' :: DescribePoliciesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribePoliciesResponse
s@DescribePoliciesResponse' {} Maybe Text
a -> DescribePoliciesResponse
s {$sel:nextToken:DescribePoliciesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: DescribePoliciesResponse)

-- | The scaling policies.
describePoliciesResponse_scalingPolicies :: Lens.Lens' DescribePoliciesResponse (Prelude.Maybe [ScalingPolicy])
describePoliciesResponse_scalingPolicies :: (Maybe [ScalingPolicy] -> f (Maybe [ScalingPolicy]))
-> DescribePoliciesResponse -> f DescribePoliciesResponse
describePoliciesResponse_scalingPolicies = (DescribePoliciesResponse -> Maybe [ScalingPolicy])
-> (DescribePoliciesResponse
    -> Maybe [ScalingPolicy] -> DescribePoliciesResponse)
-> Lens' DescribePoliciesResponse (Maybe [ScalingPolicy])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribePoliciesResponse' {Maybe [ScalingPolicy]
scalingPolicies :: Maybe [ScalingPolicy]
$sel:scalingPolicies:DescribePoliciesResponse' :: DescribePoliciesResponse -> Maybe [ScalingPolicy]
scalingPolicies} -> Maybe [ScalingPolicy]
scalingPolicies) (\s :: DescribePoliciesResponse
s@DescribePoliciesResponse' {} Maybe [ScalingPolicy]
a -> DescribePoliciesResponse
s {$sel:scalingPolicies:DescribePoliciesResponse' :: Maybe [ScalingPolicy]
scalingPolicies = Maybe [ScalingPolicy]
a} :: DescribePoliciesResponse) ((Maybe [ScalingPolicy] -> f (Maybe [ScalingPolicy]))
 -> DescribePoliciesResponse -> f DescribePoliciesResponse)
-> ((Maybe [ScalingPolicy] -> f (Maybe [ScalingPolicy]))
    -> Maybe [ScalingPolicy] -> f (Maybe [ScalingPolicy]))
-> (Maybe [ScalingPolicy] -> f (Maybe [ScalingPolicy]))
-> DescribePoliciesResponse
-> f DescribePoliciesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ScalingPolicy] [ScalingPolicy] [ScalingPolicy] [ScalingPolicy]
-> Iso
     (Maybe [ScalingPolicy])
     (Maybe [ScalingPolicy])
     (Maybe [ScalingPolicy])
     (Maybe [ScalingPolicy])
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
  [ScalingPolicy] [ScalingPolicy] [ScalingPolicy] [ScalingPolicy]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData DescribePoliciesResponse