{-# 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.GameLift.DescribeScalingPolicies
-- 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)
--
-- Retrieves all scaling policies applied to a fleet.
--
-- To get a fleet\'s scaling policies, specify the fleet ID. You can filter
-- this request by policy status, such as to retrieve only active scaling
-- policies. Use the pagination parameters to retrieve results as a set of
-- sequential pages. If successful, set of ScalingPolicy objects is
-- returned for the fleet.
--
-- A fleet may have all of its scaling policies suspended
-- (StopFleetActions). This operation does not affect the status of the
-- scaling policies, which remains ACTIVE. To see whether a fleet\'s
-- scaling policies are in force or suspended, call DescribeFleetAttributes
-- and check the stopped actions.
--
-- __Related actions__
--
-- DescribeFleetCapacity | UpdateFleetCapacity | DescribeEC2InstanceLimits
-- | PutScalingPolicy | DescribeScalingPolicies | DeleteScalingPolicy |
-- StopFleetActions | StartFleetActions |
-- <https://docs.aws.amazon.com/gamelift/latest/developerguide/reference-awssdk.html#reference-awssdk-resources-fleets All APIs by task>
--
-- This operation returns paginated results.
module Amazonka.GameLift.DescribeScalingPolicies
  ( -- * Creating a Request
    DescribeScalingPolicies (..),
    newDescribeScalingPolicies,

    -- * Request Lenses
    describeScalingPolicies_location,
    describeScalingPolicies_nextToken,
    describeScalingPolicies_statusFilter,
    describeScalingPolicies_limit,
    describeScalingPolicies_fleetId,

    -- * Destructuring the Response
    DescribeScalingPoliciesResponse (..),
    newDescribeScalingPoliciesResponse,

    -- * Response Lenses
    describeScalingPoliciesResponse_nextToken,
    describeScalingPoliciesResponse_scalingPolicies,
    describeScalingPoliciesResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.GameLift.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | Represents the input for a request operation.
--
-- /See:/ 'newDescribeScalingPolicies' smart constructor.
data DescribeScalingPolicies = DescribeScalingPolicies'
  { -- | CONTENT TODO
    DescribeScalingPolicies -> Maybe Text
location :: Prelude.Maybe Prelude.Text,
    -- | A token that indicates the start of the next sequential page of results.
    -- Use the token that is returned with a previous call to this operation.
    -- To start at the beginning of the result set, do not specify a value.
    DescribeScalingPolicies -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | Scaling policy status to filter results on. A scaling policy is only in
    -- force when in an @ACTIVE@ status.
    --
    -- -   __ACTIVE__ -- The scaling policy is currently in force.
    --
    -- -   __UPDATEREQUESTED__ -- A request to update the scaling policy has
    --     been received.
    --
    -- -   __UPDATING__ -- A change is being made to the scaling policy.
    --
    -- -   __DELETEREQUESTED__ -- A request to delete the scaling policy has
    --     been received.
    --
    -- -   __DELETING__ -- The scaling policy is being deleted.
    --
    -- -   __DELETED__ -- The scaling policy has been deleted.
    --
    -- -   __ERROR__ -- An error occurred in creating the policy. It should be
    --     removed and recreated.
    DescribeScalingPolicies -> Maybe ScalingStatusType
statusFilter :: Prelude.Maybe ScalingStatusType,
    -- | The maximum number of results to return. Use this parameter with
    -- @NextToken@ to get results as a set of sequential pages.
    DescribeScalingPolicies -> Maybe Natural
limit :: Prelude.Maybe Prelude.Natural,
    -- | A unique identifier for the fleet to retrieve scaling policies for. You
    -- can use either the fleet ID or ARN value.
    DescribeScalingPolicies -> Text
fleetId :: Prelude.Text
  }
  deriving (DescribeScalingPolicies -> DescribeScalingPolicies -> Bool
(DescribeScalingPolicies -> DescribeScalingPolicies -> Bool)
-> (DescribeScalingPolicies -> DescribeScalingPolicies -> Bool)
-> Eq DescribeScalingPolicies
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeScalingPolicies -> DescribeScalingPolicies -> Bool
$c/= :: DescribeScalingPolicies -> DescribeScalingPolicies -> Bool
== :: DescribeScalingPolicies -> DescribeScalingPolicies -> Bool
$c== :: DescribeScalingPolicies -> DescribeScalingPolicies -> Bool
Prelude.Eq, ReadPrec [DescribeScalingPolicies]
ReadPrec DescribeScalingPolicies
Int -> ReadS DescribeScalingPolicies
ReadS [DescribeScalingPolicies]
(Int -> ReadS DescribeScalingPolicies)
-> ReadS [DescribeScalingPolicies]
-> ReadPrec DescribeScalingPolicies
-> ReadPrec [DescribeScalingPolicies]
-> Read DescribeScalingPolicies
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeScalingPolicies]
$creadListPrec :: ReadPrec [DescribeScalingPolicies]
readPrec :: ReadPrec DescribeScalingPolicies
$creadPrec :: ReadPrec DescribeScalingPolicies
readList :: ReadS [DescribeScalingPolicies]
$creadList :: ReadS [DescribeScalingPolicies]
readsPrec :: Int -> ReadS DescribeScalingPolicies
$creadsPrec :: Int -> ReadS DescribeScalingPolicies
Prelude.Read, Int -> DescribeScalingPolicies -> ShowS
[DescribeScalingPolicies] -> ShowS
DescribeScalingPolicies -> String
(Int -> DescribeScalingPolicies -> ShowS)
-> (DescribeScalingPolicies -> String)
-> ([DescribeScalingPolicies] -> ShowS)
-> Show DescribeScalingPolicies
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeScalingPolicies] -> ShowS
$cshowList :: [DescribeScalingPolicies] -> ShowS
show :: DescribeScalingPolicies -> String
$cshow :: DescribeScalingPolicies -> String
showsPrec :: Int -> DescribeScalingPolicies -> ShowS
$cshowsPrec :: Int -> DescribeScalingPolicies -> ShowS
Prelude.Show, (forall x.
 DescribeScalingPolicies -> Rep DescribeScalingPolicies x)
-> (forall x.
    Rep DescribeScalingPolicies x -> DescribeScalingPolicies)
-> Generic DescribeScalingPolicies
forall x. Rep DescribeScalingPolicies x -> DescribeScalingPolicies
forall x. DescribeScalingPolicies -> Rep DescribeScalingPolicies x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeScalingPolicies x -> DescribeScalingPolicies
$cfrom :: forall x. DescribeScalingPolicies -> Rep DescribeScalingPolicies x
Prelude.Generic)

-- |
-- Create a value of 'DescribeScalingPolicies' 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:
--
-- 'location', 'describeScalingPolicies_location' - CONTENT TODO
--
-- 'nextToken', 'describeScalingPolicies_nextToken' - A token that indicates the start of the next sequential page of results.
-- Use the token that is returned with a previous call to this operation.
-- To start at the beginning of the result set, do not specify a value.
--
-- 'statusFilter', 'describeScalingPolicies_statusFilter' - Scaling policy status to filter results on. A scaling policy is only in
-- force when in an @ACTIVE@ status.
--
-- -   __ACTIVE__ -- The scaling policy is currently in force.
--
-- -   __UPDATEREQUESTED__ -- A request to update the scaling policy has
--     been received.
--
-- -   __UPDATING__ -- A change is being made to the scaling policy.
--
-- -   __DELETEREQUESTED__ -- A request to delete the scaling policy has
--     been received.
--
-- -   __DELETING__ -- The scaling policy is being deleted.
--
-- -   __DELETED__ -- The scaling policy has been deleted.
--
-- -   __ERROR__ -- An error occurred in creating the policy. It should be
--     removed and recreated.
--
-- 'limit', 'describeScalingPolicies_limit' - The maximum number of results to return. Use this parameter with
-- @NextToken@ to get results as a set of sequential pages.
--
-- 'fleetId', 'describeScalingPolicies_fleetId' - A unique identifier for the fleet to retrieve scaling policies for. You
-- can use either the fleet ID or ARN value.
newDescribeScalingPolicies ::
  -- | 'fleetId'
  Prelude.Text ->
  DescribeScalingPolicies
newDescribeScalingPolicies :: Text -> DescribeScalingPolicies
newDescribeScalingPolicies Text
pFleetId_ =
  DescribeScalingPolicies' :: Maybe Text
-> Maybe Text
-> Maybe ScalingStatusType
-> Maybe Natural
-> Text
-> DescribeScalingPolicies
DescribeScalingPolicies'
    { $sel:location:DescribeScalingPolicies' :: Maybe Text
location =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeScalingPolicies' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:statusFilter:DescribeScalingPolicies' :: Maybe ScalingStatusType
statusFilter = Maybe ScalingStatusType
forall a. Maybe a
Prelude.Nothing,
      $sel:limit:DescribeScalingPolicies' :: Maybe Natural
limit = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:fleetId:DescribeScalingPolicies' :: Text
fleetId = Text
pFleetId_
    }

-- | CONTENT TODO
describeScalingPolicies_location :: Lens.Lens' DescribeScalingPolicies (Prelude.Maybe Prelude.Text)
describeScalingPolicies_location :: (Maybe Text -> f (Maybe Text))
-> DescribeScalingPolicies -> f DescribeScalingPolicies
describeScalingPolicies_location = (DescribeScalingPolicies -> Maybe Text)
-> (DescribeScalingPolicies
    -> Maybe Text -> DescribeScalingPolicies)
-> Lens
     DescribeScalingPolicies
     DescribeScalingPolicies
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeScalingPolicies' {Maybe Text
location :: Maybe Text
$sel:location:DescribeScalingPolicies' :: DescribeScalingPolicies -> Maybe Text
location} -> Maybe Text
location) (\s :: DescribeScalingPolicies
s@DescribeScalingPolicies' {} Maybe Text
a -> DescribeScalingPolicies
s {$sel:location:DescribeScalingPolicies' :: Maybe Text
location = Maybe Text
a} :: DescribeScalingPolicies)

-- | A token that indicates the start of the next sequential page of results.
-- Use the token that is returned with a previous call to this operation.
-- To start at the beginning of the result set, do not specify a value.
describeScalingPolicies_nextToken :: Lens.Lens' DescribeScalingPolicies (Prelude.Maybe Prelude.Text)
describeScalingPolicies_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeScalingPolicies -> f DescribeScalingPolicies
describeScalingPolicies_nextToken = (DescribeScalingPolicies -> Maybe Text)
-> (DescribeScalingPolicies
    -> Maybe Text -> DescribeScalingPolicies)
-> Lens
     DescribeScalingPolicies
     DescribeScalingPolicies
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeScalingPolicies' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeScalingPolicies' :: DescribeScalingPolicies -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeScalingPolicies
s@DescribeScalingPolicies' {} Maybe Text
a -> DescribeScalingPolicies
s {$sel:nextToken:DescribeScalingPolicies' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeScalingPolicies)

-- | Scaling policy status to filter results on. A scaling policy is only in
-- force when in an @ACTIVE@ status.
--
-- -   __ACTIVE__ -- The scaling policy is currently in force.
--
-- -   __UPDATEREQUESTED__ -- A request to update the scaling policy has
--     been received.
--
-- -   __UPDATING__ -- A change is being made to the scaling policy.
--
-- -   __DELETEREQUESTED__ -- A request to delete the scaling policy has
--     been received.
--
-- -   __DELETING__ -- The scaling policy is being deleted.
--
-- -   __DELETED__ -- The scaling policy has been deleted.
--
-- -   __ERROR__ -- An error occurred in creating the policy. It should be
--     removed and recreated.
describeScalingPolicies_statusFilter :: Lens.Lens' DescribeScalingPolicies (Prelude.Maybe ScalingStatusType)
describeScalingPolicies_statusFilter :: (Maybe ScalingStatusType -> f (Maybe ScalingStatusType))
-> DescribeScalingPolicies -> f DescribeScalingPolicies
describeScalingPolicies_statusFilter = (DescribeScalingPolicies -> Maybe ScalingStatusType)
-> (DescribeScalingPolicies
    -> Maybe ScalingStatusType -> DescribeScalingPolicies)
-> Lens
     DescribeScalingPolicies
     DescribeScalingPolicies
     (Maybe ScalingStatusType)
     (Maybe ScalingStatusType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeScalingPolicies' {Maybe ScalingStatusType
statusFilter :: Maybe ScalingStatusType
$sel:statusFilter:DescribeScalingPolicies' :: DescribeScalingPolicies -> Maybe ScalingStatusType
statusFilter} -> Maybe ScalingStatusType
statusFilter) (\s :: DescribeScalingPolicies
s@DescribeScalingPolicies' {} Maybe ScalingStatusType
a -> DescribeScalingPolicies
s {$sel:statusFilter:DescribeScalingPolicies' :: Maybe ScalingStatusType
statusFilter = Maybe ScalingStatusType
a} :: DescribeScalingPolicies)

-- | The maximum number of results to return. Use this parameter with
-- @NextToken@ to get results as a set of sequential pages.
describeScalingPolicies_limit :: Lens.Lens' DescribeScalingPolicies (Prelude.Maybe Prelude.Natural)
describeScalingPolicies_limit :: (Maybe Natural -> f (Maybe Natural))
-> DescribeScalingPolicies -> f DescribeScalingPolicies
describeScalingPolicies_limit = (DescribeScalingPolicies -> Maybe Natural)
-> (DescribeScalingPolicies
    -> Maybe Natural -> DescribeScalingPolicies)
-> Lens
     DescribeScalingPolicies
     DescribeScalingPolicies
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeScalingPolicies' {Maybe Natural
limit :: Maybe Natural
$sel:limit:DescribeScalingPolicies' :: DescribeScalingPolicies -> Maybe Natural
limit} -> Maybe Natural
limit) (\s :: DescribeScalingPolicies
s@DescribeScalingPolicies' {} Maybe Natural
a -> DescribeScalingPolicies
s {$sel:limit:DescribeScalingPolicies' :: Maybe Natural
limit = Maybe Natural
a} :: DescribeScalingPolicies)

-- | A unique identifier for the fleet to retrieve scaling policies for. You
-- can use either the fleet ID or ARN value.
describeScalingPolicies_fleetId :: Lens.Lens' DescribeScalingPolicies Prelude.Text
describeScalingPolicies_fleetId :: (Text -> f Text)
-> DescribeScalingPolicies -> f DescribeScalingPolicies
describeScalingPolicies_fleetId = (DescribeScalingPolicies -> Text)
-> (DescribeScalingPolicies -> Text -> DescribeScalingPolicies)
-> Lens DescribeScalingPolicies DescribeScalingPolicies Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeScalingPolicies' {Text
fleetId :: Text
$sel:fleetId:DescribeScalingPolicies' :: DescribeScalingPolicies -> Text
fleetId} -> Text
fleetId) (\s :: DescribeScalingPolicies
s@DescribeScalingPolicies' {} Text
a -> DescribeScalingPolicies
s {$sel:fleetId:DescribeScalingPolicies' :: Text
fleetId = Text
a} :: DescribeScalingPolicies)

instance Core.AWSPager DescribeScalingPolicies where
  page :: DescribeScalingPolicies
-> AWSResponse DescribeScalingPolicies
-> Maybe DescribeScalingPolicies
page DescribeScalingPolicies
rq AWSResponse DescribeScalingPolicies
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeScalingPolicies
DescribeScalingPoliciesResponse
rs
            DescribeScalingPoliciesResponse
-> Getting (First Text) DescribeScalingPoliciesResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeScalingPoliciesResponse
-> Const (First Text) DescribeScalingPoliciesResponse
Lens' DescribeScalingPoliciesResponse (Maybe Text)
describeScalingPoliciesResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeScalingPoliciesResponse
 -> Const (First Text) DescribeScalingPoliciesResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeScalingPoliciesResponse 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 DescribeScalingPolicies
forall a. Maybe a
Prelude.Nothing
    | Maybe [ScalingPolicy] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeScalingPolicies
DescribeScalingPoliciesResponse
rs
            DescribeScalingPoliciesResponse
-> Getting
     (First [ScalingPolicy])
     DescribeScalingPoliciesResponse
     [ScalingPolicy]
-> Maybe [ScalingPolicy]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [ScalingPolicy]
 -> Const (First [ScalingPolicy]) (Maybe [ScalingPolicy]))
-> DescribeScalingPoliciesResponse
-> Const (First [ScalingPolicy]) DescribeScalingPoliciesResponse
Lens' DescribeScalingPoliciesResponse (Maybe [ScalingPolicy])
describeScalingPoliciesResponse_scalingPolicies
              ((Maybe [ScalingPolicy]
  -> Const (First [ScalingPolicy]) (Maybe [ScalingPolicy]))
 -> DescribeScalingPoliciesResponse
 -> Const (First [ScalingPolicy]) DescribeScalingPoliciesResponse)
-> (([ScalingPolicy]
     -> Const (First [ScalingPolicy]) [ScalingPolicy])
    -> Maybe [ScalingPolicy]
    -> Const (First [ScalingPolicy]) (Maybe [ScalingPolicy]))
-> Getting
     (First [ScalingPolicy])
     DescribeScalingPoliciesResponse
     [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 DescribeScalingPolicies
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      DescribeScalingPolicies -> Maybe DescribeScalingPolicies
forall a. a -> Maybe a
Prelude.Just (DescribeScalingPolicies -> Maybe DescribeScalingPolicies)
-> DescribeScalingPolicies -> Maybe DescribeScalingPolicies
forall a b. (a -> b) -> a -> b
Prelude.$
        DescribeScalingPolicies
rq
          DescribeScalingPolicies
-> (DescribeScalingPolicies -> DescribeScalingPolicies)
-> DescribeScalingPolicies
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> DescribeScalingPolicies -> Identity DescribeScalingPolicies
Lens
  DescribeScalingPolicies
  DescribeScalingPolicies
  (Maybe Text)
  (Maybe Text)
describeScalingPolicies_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> DescribeScalingPolicies -> Identity DescribeScalingPolicies)
-> Maybe Text -> DescribeScalingPolicies -> DescribeScalingPolicies
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse DescribeScalingPolicies
DescribeScalingPoliciesResponse
rs
          DescribeScalingPoliciesResponse
-> Getting (First Text) DescribeScalingPoliciesResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeScalingPoliciesResponse
-> Const (First Text) DescribeScalingPoliciesResponse
Lens' DescribeScalingPoliciesResponse (Maybe Text)
describeScalingPoliciesResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeScalingPoliciesResponse
 -> Const (First Text) DescribeScalingPoliciesResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeScalingPoliciesResponse 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 DescribeScalingPolicies where
  type
    AWSResponse DescribeScalingPolicies =
      DescribeScalingPoliciesResponse
  request :: DescribeScalingPolicies -> Request DescribeScalingPolicies
request = Service
-> DescribeScalingPolicies -> Request DescribeScalingPolicies
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeScalingPolicies
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeScalingPolicies)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeScalingPolicies))
-> Logger
-> Service
-> Proxy DescribeScalingPolicies
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeScalingPolicies)))
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 Text
-> Maybe [ScalingPolicy] -> Int -> DescribeScalingPoliciesResponse
DescribeScalingPoliciesResponse'
            (Maybe Text
 -> Maybe [ScalingPolicy] -> Int -> DescribeScalingPoliciesResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe [ScalingPolicy] -> Int -> DescribeScalingPoliciesResponse)
forall (f :: * -> *) a b. Functor 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
  (Maybe [ScalingPolicy] -> Int -> DescribeScalingPoliciesResponse)
-> Either String (Maybe [ScalingPolicy])
-> Either String (Int -> DescribeScalingPoliciesResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Either String (Maybe (Maybe [ScalingPolicy]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ScalingPolicies"
                            Either String (Maybe (Maybe [ScalingPolicy]))
-> Maybe [ScalingPolicy] -> Either String (Maybe [ScalingPolicy])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [ScalingPolicy]
forall a. Monoid a => a
Prelude.mempty
                        )
            Either String (Int -> DescribeScalingPoliciesResponse)
-> Either String Int
-> Either String DescribeScalingPoliciesResponse
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 DescribeScalingPolicies

instance Prelude.NFData DescribeScalingPolicies

instance Core.ToHeaders DescribeScalingPolicies where
  toHeaders :: DescribeScalingPolicies -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeScalingPolicies -> 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
"GameLift.DescribeScalingPolicies" ::
                          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 DescribeScalingPolicies where
  toJSON :: DescribeScalingPolicies -> Value
toJSON DescribeScalingPolicies' {Maybe Natural
Maybe Text
Maybe ScalingStatusType
Text
fleetId :: Text
limit :: Maybe Natural
statusFilter :: Maybe ScalingStatusType
nextToken :: Maybe Text
location :: Maybe Text
$sel:fleetId:DescribeScalingPolicies' :: DescribeScalingPolicies -> Text
$sel:limit:DescribeScalingPolicies' :: DescribeScalingPolicies -> Maybe Natural
$sel:statusFilter:DescribeScalingPolicies' :: DescribeScalingPolicies -> Maybe ScalingStatusType
$sel:nextToken:DescribeScalingPolicies' :: DescribeScalingPolicies -> Maybe Text
$sel:location:DescribeScalingPolicies' :: DescribeScalingPolicies -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Location" 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
location,
            (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
"StatusFilter" Text -> ScalingStatusType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ScalingStatusType -> Pair)
-> Maybe ScalingStatusType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ScalingStatusType
statusFilter,
            (Text
"Limit" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
limit,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"FleetId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
fleetId)
          ]
      )

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

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

-- | Represents the returned data in response to a request operation.
--
-- /See:/ 'newDescribeScalingPoliciesResponse' smart constructor.
data DescribeScalingPoliciesResponse = DescribeScalingPoliciesResponse'
  { -- | A token that indicates where to resume retrieving results on the next
    -- call to this operation. If no token is returned, these results represent
    -- the end of the list.
    DescribeScalingPoliciesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | A collection of objects containing the scaling policies matching the
    -- request.
    DescribeScalingPoliciesResponse -> Maybe [ScalingPolicy]
scalingPolicies :: Prelude.Maybe [ScalingPolicy],
    -- | The response's http status code.
    DescribeScalingPoliciesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeScalingPoliciesResponse
-> DescribeScalingPoliciesResponse -> Bool
(DescribeScalingPoliciesResponse
 -> DescribeScalingPoliciesResponse -> Bool)
-> (DescribeScalingPoliciesResponse
    -> DescribeScalingPoliciesResponse -> Bool)
-> Eq DescribeScalingPoliciesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeScalingPoliciesResponse
-> DescribeScalingPoliciesResponse -> Bool
$c/= :: DescribeScalingPoliciesResponse
-> DescribeScalingPoliciesResponse -> Bool
== :: DescribeScalingPoliciesResponse
-> DescribeScalingPoliciesResponse -> Bool
$c== :: DescribeScalingPoliciesResponse
-> DescribeScalingPoliciesResponse -> Bool
Prelude.Eq, ReadPrec [DescribeScalingPoliciesResponse]
ReadPrec DescribeScalingPoliciesResponse
Int -> ReadS DescribeScalingPoliciesResponse
ReadS [DescribeScalingPoliciesResponse]
(Int -> ReadS DescribeScalingPoliciesResponse)
-> ReadS [DescribeScalingPoliciesResponse]
-> ReadPrec DescribeScalingPoliciesResponse
-> ReadPrec [DescribeScalingPoliciesResponse]
-> Read DescribeScalingPoliciesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeScalingPoliciesResponse]
$creadListPrec :: ReadPrec [DescribeScalingPoliciesResponse]
readPrec :: ReadPrec DescribeScalingPoliciesResponse
$creadPrec :: ReadPrec DescribeScalingPoliciesResponse
readList :: ReadS [DescribeScalingPoliciesResponse]
$creadList :: ReadS [DescribeScalingPoliciesResponse]
readsPrec :: Int -> ReadS DescribeScalingPoliciesResponse
$creadsPrec :: Int -> ReadS DescribeScalingPoliciesResponse
Prelude.Read, Int -> DescribeScalingPoliciesResponse -> ShowS
[DescribeScalingPoliciesResponse] -> ShowS
DescribeScalingPoliciesResponse -> String
(Int -> DescribeScalingPoliciesResponse -> ShowS)
-> (DescribeScalingPoliciesResponse -> String)
-> ([DescribeScalingPoliciesResponse] -> ShowS)
-> Show DescribeScalingPoliciesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeScalingPoliciesResponse] -> ShowS
$cshowList :: [DescribeScalingPoliciesResponse] -> ShowS
show :: DescribeScalingPoliciesResponse -> String
$cshow :: DescribeScalingPoliciesResponse -> String
showsPrec :: Int -> DescribeScalingPoliciesResponse -> ShowS
$cshowsPrec :: Int -> DescribeScalingPoliciesResponse -> ShowS
Prelude.Show, (forall x.
 DescribeScalingPoliciesResponse
 -> Rep DescribeScalingPoliciesResponse x)
-> (forall x.
    Rep DescribeScalingPoliciesResponse x
    -> DescribeScalingPoliciesResponse)
-> Generic DescribeScalingPoliciesResponse
forall x.
Rep DescribeScalingPoliciesResponse x
-> DescribeScalingPoliciesResponse
forall x.
DescribeScalingPoliciesResponse
-> Rep DescribeScalingPoliciesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeScalingPoliciesResponse x
-> DescribeScalingPoliciesResponse
$cfrom :: forall x.
DescribeScalingPoliciesResponse
-> Rep DescribeScalingPoliciesResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeScalingPoliciesResponse' 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', 'describeScalingPoliciesResponse_nextToken' - A token that indicates where to resume retrieving results on the next
-- call to this operation. If no token is returned, these results represent
-- the end of the list.
--
-- 'scalingPolicies', 'describeScalingPoliciesResponse_scalingPolicies' - A collection of objects containing the scaling policies matching the
-- request.
--
-- 'httpStatus', 'describeScalingPoliciesResponse_httpStatus' - The response's http status code.
newDescribeScalingPoliciesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeScalingPoliciesResponse
newDescribeScalingPoliciesResponse :: Int -> DescribeScalingPoliciesResponse
newDescribeScalingPoliciesResponse Int
pHttpStatus_ =
  DescribeScalingPoliciesResponse' :: Maybe Text
-> Maybe [ScalingPolicy] -> Int -> DescribeScalingPoliciesResponse
DescribeScalingPoliciesResponse'
    { $sel:nextToken:DescribeScalingPoliciesResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:scalingPolicies:DescribeScalingPoliciesResponse' :: Maybe [ScalingPolicy]
scalingPolicies = Maybe [ScalingPolicy]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeScalingPoliciesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A token that indicates where to resume retrieving results on the next
-- call to this operation. If no token is returned, these results represent
-- the end of the list.
describeScalingPoliciesResponse_nextToken :: Lens.Lens' DescribeScalingPoliciesResponse (Prelude.Maybe Prelude.Text)
describeScalingPoliciesResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeScalingPoliciesResponse
-> f DescribeScalingPoliciesResponse
describeScalingPoliciesResponse_nextToken = (DescribeScalingPoliciesResponse -> Maybe Text)
-> (DescribeScalingPoliciesResponse
    -> Maybe Text -> DescribeScalingPoliciesResponse)
-> Lens' DescribeScalingPoliciesResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeScalingPoliciesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeScalingPoliciesResponse' :: DescribeScalingPoliciesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeScalingPoliciesResponse
s@DescribeScalingPoliciesResponse' {} Maybe Text
a -> DescribeScalingPoliciesResponse
s {$sel:nextToken:DescribeScalingPoliciesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeScalingPoliciesResponse)

-- | A collection of objects containing the scaling policies matching the
-- request.
describeScalingPoliciesResponse_scalingPolicies :: Lens.Lens' DescribeScalingPoliciesResponse (Prelude.Maybe [ScalingPolicy])
describeScalingPoliciesResponse_scalingPolicies :: (Maybe [ScalingPolicy] -> f (Maybe [ScalingPolicy]))
-> DescribeScalingPoliciesResponse
-> f DescribeScalingPoliciesResponse
describeScalingPoliciesResponse_scalingPolicies = (DescribeScalingPoliciesResponse -> Maybe [ScalingPolicy])
-> (DescribeScalingPoliciesResponse
    -> Maybe [ScalingPolicy] -> DescribeScalingPoliciesResponse)
-> Lens' DescribeScalingPoliciesResponse (Maybe [ScalingPolicy])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeScalingPoliciesResponse' {Maybe [ScalingPolicy]
scalingPolicies :: Maybe [ScalingPolicy]
$sel:scalingPolicies:DescribeScalingPoliciesResponse' :: DescribeScalingPoliciesResponse -> Maybe [ScalingPolicy]
scalingPolicies} -> Maybe [ScalingPolicy]
scalingPolicies) (\s :: DescribeScalingPoliciesResponse
s@DescribeScalingPoliciesResponse' {} Maybe [ScalingPolicy]
a -> DescribeScalingPoliciesResponse
s {$sel:scalingPolicies:DescribeScalingPoliciesResponse' :: Maybe [ScalingPolicy]
scalingPolicies = Maybe [ScalingPolicy]
a} :: DescribeScalingPoliciesResponse) ((Maybe [ScalingPolicy] -> f (Maybe [ScalingPolicy]))
 -> DescribeScalingPoliciesResponse
 -> f DescribeScalingPoliciesResponse)
-> ((Maybe [ScalingPolicy] -> f (Maybe [ScalingPolicy]))
    -> Maybe [ScalingPolicy] -> f (Maybe [ScalingPolicy]))
-> (Maybe [ScalingPolicy] -> f (Maybe [ScalingPolicy]))
-> DescribeScalingPoliciesResponse
-> f DescribeScalingPoliciesResponse
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.
describeScalingPoliciesResponse_httpStatus :: Lens.Lens' DescribeScalingPoliciesResponse Prelude.Int
describeScalingPoliciesResponse_httpStatus :: (Int -> f Int)
-> DescribeScalingPoliciesResponse
-> f DescribeScalingPoliciesResponse
describeScalingPoliciesResponse_httpStatus = (DescribeScalingPoliciesResponse -> Int)
-> (DescribeScalingPoliciesResponse
    -> Int -> DescribeScalingPoliciesResponse)
-> Lens
     DescribeScalingPoliciesResponse
     DescribeScalingPoliciesResponse
     Int
     Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeScalingPoliciesResponse' {Int
httpStatus :: Int
$sel:httpStatus:DescribeScalingPoliciesResponse' :: DescribeScalingPoliciesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DescribeScalingPoliciesResponse
s@DescribeScalingPoliciesResponse' {} Int
a -> DescribeScalingPoliciesResponse
s {$sel:httpStatus:DescribeScalingPoliciesResponse' :: Int
httpStatus = Int
a} :: DescribeScalingPoliciesResponse)

instance
  Prelude.NFData
    DescribeScalingPoliciesResponse