{-# 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.DescribeFleetUtilization
-- 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 utilization statistics for one or more fleets. Utilization
-- data provides a snapshot of how the fleet\'s hosting resources are
-- currently being used. For fleets with remote locations, this operation
-- retrieves data for the fleet\'s home Region only. See
-- DescribeFleetLocationUtilization to get utilization statistics for a
-- fleet\'s remote locations.
--
-- This operation can be used in the following ways:
--
-- -   To get utilization data for one or more specific fleets, provide a
--     list of fleet IDs or fleet ARNs.
--
-- -   To get utilization data for all fleets, do not provide a fleet
--     identifier.
--
-- When requesting multiple fleets, use the pagination parameters to
-- retrieve results as a set of sequential pages.
--
-- If successful, a FleetUtilization object is returned for each requested
-- fleet ID, unless the fleet identifier is not found. Each fleet
-- utilization object includes a @Location@ property, which is set to the
-- fleet\'s home Region.
--
-- Some API operations may limit the number of fleet IDs allowed in one
-- request. If a request exceeds this limit, the request fails and the
-- error message includes the maximum allowed.
--
-- __Learn more__
--
-- <https://docs.aws.amazon.com/gamelift/latest/developerguide/fleets-intro.html Setting up GameLift Fleets>
--
-- <https://docs.aws.amazon.com/gamelift/latest/developerguide/monitoring-cloudwatch.html#gamelift-metrics-fleet GameLift Metrics for Fleets>
--
-- __Related actions__
--
-- ListFleets | DescribeEC2InstanceLimits | DescribeFleetAttributes |
-- DescribeFleetCapacity | DescribeFleetEvents |
-- DescribeFleetLocationAttributes | DescribeFleetPortSettings |
-- DescribeFleetUtilization | DescribeRuntimeConfiguration |
-- DescribeScalingPolicies |
-- <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.DescribeFleetUtilization
  ( -- * Creating a Request
    DescribeFleetUtilization (..),
    newDescribeFleetUtilization,

    -- * Request Lenses
    describeFleetUtilization_nextToken,
    describeFleetUtilization_limit,
    describeFleetUtilization_fleetIds,

    -- * Destructuring the Response
    DescribeFleetUtilizationResponse (..),
    newDescribeFleetUtilizationResponse,

    -- * Response Lenses
    describeFleetUtilizationResponse_nextToken,
    describeFleetUtilizationResponse_fleetUtilization,
    describeFleetUtilizationResponse_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:/ 'newDescribeFleetUtilization' smart constructor.
data DescribeFleetUtilization = DescribeFleetUtilization'
  { -- | 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.
    -- This parameter is ignored when the request specifies one or a list of
    -- fleet IDs.
    DescribeFleetUtilization -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of results to return. Use this parameter with
    -- @NextToken@ to get results as a set of sequential pages. This parameter
    -- is ignored when the request specifies one or a list of fleet IDs.
    DescribeFleetUtilization -> Maybe Natural
limit :: Prelude.Maybe Prelude.Natural,
    -- | A unique identifier for the fleet(s) to retrieve utilization data for.
    -- You can use either the fleet ID or ARN value. To retrieve attributes for
    -- all current fleets, do not include this parameter.
    DescribeFleetUtilization -> Maybe (NonEmpty Text)
fleetIds :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text)
  }
  deriving (DescribeFleetUtilization -> DescribeFleetUtilization -> Bool
(DescribeFleetUtilization -> DescribeFleetUtilization -> Bool)
-> (DescribeFleetUtilization -> DescribeFleetUtilization -> Bool)
-> Eq DescribeFleetUtilization
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeFleetUtilization -> DescribeFleetUtilization -> Bool
$c/= :: DescribeFleetUtilization -> DescribeFleetUtilization -> Bool
== :: DescribeFleetUtilization -> DescribeFleetUtilization -> Bool
$c== :: DescribeFleetUtilization -> DescribeFleetUtilization -> Bool
Prelude.Eq, ReadPrec [DescribeFleetUtilization]
ReadPrec DescribeFleetUtilization
Int -> ReadS DescribeFleetUtilization
ReadS [DescribeFleetUtilization]
(Int -> ReadS DescribeFleetUtilization)
-> ReadS [DescribeFleetUtilization]
-> ReadPrec DescribeFleetUtilization
-> ReadPrec [DescribeFleetUtilization]
-> Read DescribeFleetUtilization
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeFleetUtilization]
$creadListPrec :: ReadPrec [DescribeFleetUtilization]
readPrec :: ReadPrec DescribeFleetUtilization
$creadPrec :: ReadPrec DescribeFleetUtilization
readList :: ReadS [DescribeFleetUtilization]
$creadList :: ReadS [DescribeFleetUtilization]
readsPrec :: Int -> ReadS DescribeFleetUtilization
$creadsPrec :: Int -> ReadS DescribeFleetUtilization
Prelude.Read, Int -> DescribeFleetUtilization -> ShowS
[DescribeFleetUtilization] -> ShowS
DescribeFleetUtilization -> String
(Int -> DescribeFleetUtilization -> ShowS)
-> (DescribeFleetUtilization -> String)
-> ([DescribeFleetUtilization] -> ShowS)
-> Show DescribeFleetUtilization
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeFleetUtilization] -> ShowS
$cshowList :: [DescribeFleetUtilization] -> ShowS
show :: DescribeFleetUtilization -> String
$cshow :: DescribeFleetUtilization -> String
showsPrec :: Int -> DescribeFleetUtilization -> ShowS
$cshowsPrec :: Int -> DescribeFleetUtilization -> ShowS
Prelude.Show, (forall x.
 DescribeFleetUtilization -> Rep DescribeFleetUtilization x)
-> (forall x.
    Rep DescribeFleetUtilization x -> DescribeFleetUtilization)
-> Generic DescribeFleetUtilization
forall x.
Rep DescribeFleetUtilization x -> DescribeFleetUtilization
forall x.
DescribeFleetUtilization -> Rep DescribeFleetUtilization x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeFleetUtilization x -> DescribeFleetUtilization
$cfrom :: forall x.
DescribeFleetUtilization -> Rep DescribeFleetUtilization x
Prelude.Generic)

-- |
-- Create a value of 'DescribeFleetUtilization' 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', 'describeFleetUtilization_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.
-- This parameter is ignored when the request specifies one or a list of
-- fleet IDs.
--
-- 'limit', 'describeFleetUtilization_limit' - The maximum number of results to return. Use this parameter with
-- @NextToken@ to get results as a set of sequential pages. This parameter
-- is ignored when the request specifies one or a list of fleet IDs.
--
-- 'fleetIds', 'describeFleetUtilization_fleetIds' - A unique identifier for the fleet(s) to retrieve utilization data for.
-- You can use either the fleet ID or ARN value. To retrieve attributes for
-- all current fleets, do not include this parameter.
newDescribeFleetUtilization ::
  DescribeFleetUtilization
newDescribeFleetUtilization :: DescribeFleetUtilization
newDescribeFleetUtilization =
  DescribeFleetUtilization' :: Maybe Text
-> Maybe Natural
-> Maybe (NonEmpty Text)
-> DescribeFleetUtilization
DescribeFleetUtilization'
    { $sel:nextToken:DescribeFleetUtilization' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:limit:DescribeFleetUtilization' :: Maybe Natural
limit = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:fleetIds:DescribeFleetUtilization' :: Maybe (NonEmpty Text)
fleetIds = Maybe (NonEmpty Text)
forall a. Maybe a
Prelude.Nothing
    }

-- | 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.
-- This parameter is ignored when the request specifies one or a list of
-- fleet IDs.
describeFleetUtilization_nextToken :: Lens.Lens' DescribeFleetUtilization (Prelude.Maybe Prelude.Text)
describeFleetUtilization_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeFleetUtilization -> f DescribeFleetUtilization
describeFleetUtilization_nextToken = (DescribeFleetUtilization -> Maybe Text)
-> (DescribeFleetUtilization
    -> Maybe Text -> DescribeFleetUtilization)
-> Lens
     DescribeFleetUtilization
     DescribeFleetUtilization
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeFleetUtilization' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeFleetUtilization' :: DescribeFleetUtilization -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeFleetUtilization
s@DescribeFleetUtilization' {} Maybe Text
a -> DescribeFleetUtilization
s {$sel:nextToken:DescribeFleetUtilization' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeFleetUtilization)

-- | The maximum number of results to return. Use this parameter with
-- @NextToken@ to get results as a set of sequential pages. This parameter
-- is ignored when the request specifies one or a list of fleet IDs.
describeFleetUtilization_limit :: Lens.Lens' DescribeFleetUtilization (Prelude.Maybe Prelude.Natural)
describeFleetUtilization_limit :: (Maybe Natural -> f (Maybe Natural))
-> DescribeFleetUtilization -> f DescribeFleetUtilization
describeFleetUtilization_limit = (DescribeFleetUtilization -> Maybe Natural)
-> (DescribeFleetUtilization
    -> Maybe Natural -> DescribeFleetUtilization)
-> Lens
     DescribeFleetUtilization
     DescribeFleetUtilization
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeFleetUtilization' {Maybe Natural
limit :: Maybe Natural
$sel:limit:DescribeFleetUtilization' :: DescribeFleetUtilization -> Maybe Natural
limit} -> Maybe Natural
limit) (\s :: DescribeFleetUtilization
s@DescribeFleetUtilization' {} Maybe Natural
a -> DescribeFleetUtilization
s {$sel:limit:DescribeFleetUtilization' :: Maybe Natural
limit = Maybe Natural
a} :: DescribeFleetUtilization)

-- | A unique identifier for the fleet(s) to retrieve utilization data for.
-- You can use either the fleet ID or ARN value. To retrieve attributes for
-- all current fleets, do not include this parameter.
describeFleetUtilization_fleetIds :: Lens.Lens' DescribeFleetUtilization (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
describeFleetUtilization_fleetIds :: (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> DescribeFleetUtilization -> f DescribeFleetUtilization
describeFleetUtilization_fleetIds = (DescribeFleetUtilization -> Maybe (NonEmpty Text))
-> (DescribeFleetUtilization
    -> Maybe (NonEmpty Text) -> DescribeFleetUtilization)
-> Lens
     DescribeFleetUtilization
     DescribeFleetUtilization
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeFleetUtilization' {Maybe (NonEmpty Text)
fleetIds :: Maybe (NonEmpty Text)
$sel:fleetIds:DescribeFleetUtilization' :: DescribeFleetUtilization -> Maybe (NonEmpty Text)
fleetIds} -> Maybe (NonEmpty Text)
fleetIds) (\s :: DescribeFleetUtilization
s@DescribeFleetUtilization' {} Maybe (NonEmpty Text)
a -> DescribeFleetUtilization
s {$sel:fleetIds:DescribeFleetUtilization' :: Maybe (NonEmpty Text)
fleetIds = Maybe (NonEmpty Text)
a} :: DescribeFleetUtilization) ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
 -> DescribeFleetUtilization -> f DescribeFleetUtilization)
-> ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
    -> Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> DescribeFleetUtilization
-> f DescribeFleetUtilization
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
-> Iso
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty 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
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData DescribeFleetUtilization

instance Core.ToHeaders DescribeFleetUtilization where
  toHeaders :: DescribeFleetUtilization -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeFleetUtilization -> 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.DescribeFleetUtilization" ::
                          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 DescribeFleetUtilization where
  toJSON :: DescribeFleetUtilization -> Value
toJSON DescribeFleetUtilization' {Maybe Natural
Maybe (NonEmpty Text)
Maybe Text
fleetIds :: Maybe (NonEmpty Text)
limit :: Maybe Natural
nextToken :: Maybe Text
$sel:fleetIds:DescribeFleetUtilization' :: DescribeFleetUtilization -> Maybe (NonEmpty Text)
$sel:limit:DescribeFleetUtilization' :: DescribeFleetUtilization -> Maybe Natural
$sel:nextToken:DescribeFleetUtilization' :: DescribeFleetUtilization -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (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
"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,
            (Text
"FleetIds" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty Text -> Pair) -> Maybe (NonEmpty Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Text)
fleetIds
          ]
      )

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

instance Core.ToQuery DescribeFleetUtilization where
  toQuery :: DescribeFleetUtilization -> QueryString
toQuery = QueryString -> DescribeFleetUtilization -> 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:/ 'newDescribeFleetUtilizationResponse' smart constructor.
data DescribeFleetUtilizationResponse = DescribeFleetUtilizationResponse'
  { -- | 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.
    DescribeFleetUtilizationResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | A collection of objects containing utilization information for each
    -- requested fleet ID. Utilization objects are returned only for fleets
    -- that currently exist.
    DescribeFleetUtilizationResponse -> Maybe [FleetUtilization]
fleetUtilization :: Prelude.Maybe [FleetUtilization],
    -- | The response's http status code.
    DescribeFleetUtilizationResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeFleetUtilizationResponse
-> DescribeFleetUtilizationResponse -> Bool
(DescribeFleetUtilizationResponse
 -> DescribeFleetUtilizationResponse -> Bool)
-> (DescribeFleetUtilizationResponse
    -> DescribeFleetUtilizationResponse -> Bool)
-> Eq DescribeFleetUtilizationResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeFleetUtilizationResponse
-> DescribeFleetUtilizationResponse -> Bool
$c/= :: DescribeFleetUtilizationResponse
-> DescribeFleetUtilizationResponse -> Bool
== :: DescribeFleetUtilizationResponse
-> DescribeFleetUtilizationResponse -> Bool
$c== :: DescribeFleetUtilizationResponse
-> DescribeFleetUtilizationResponse -> Bool
Prelude.Eq, ReadPrec [DescribeFleetUtilizationResponse]
ReadPrec DescribeFleetUtilizationResponse
Int -> ReadS DescribeFleetUtilizationResponse
ReadS [DescribeFleetUtilizationResponse]
(Int -> ReadS DescribeFleetUtilizationResponse)
-> ReadS [DescribeFleetUtilizationResponse]
-> ReadPrec DescribeFleetUtilizationResponse
-> ReadPrec [DescribeFleetUtilizationResponse]
-> Read DescribeFleetUtilizationResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeFleetUtilizationResponse]
$creadListPrec :: ReadPrec [DescribeFleetUtilizationResponse]
readPrec :: ReadPrec DescribeFleetUtilizationResponse
$creadPrec :: ReadPrec DescribeFleetUtilizationResponse
readList :: ReadS [DescribeFleetUtilizationResponse]
$creadList :: ReadS [DescribeFleetUtilizationResponse]
readsPrec :: Int -> ReadS DescribeFleetUtilizationResponse
$creadsPrec :: Int -> ReadS DescribeFleetUtilizationResponse
Prelude.Read, Int -> DescribeFleetUtilizationResponse -> ShowS
[DescribeFleetUtilizationResponse] -> ShowS
DescribeFleetUtilizationResponse -> String
(Int -> DescribeFleetUtilizationResponse -> ShowS)
-> (DescribeFleetUtilizationResponse -> String)
-> ([DescribeFleetUtilizationResponse] -> ShowS)
-> Show DescribeFleetUtilizationResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeFleetUtilizationResponse] -> ShowS
$cshowList :: [DescribeFleetUtilizationResponse] -> ShowS
show :: DescribeFleetUtilizationResponse -> String
$cshow :: DescribeFleetUtilizationResponse -> String
showsPrec :: Int -> DescribeFleetUtilizationResponse -> ShowS
$cshowsPrec :: Int -> DescribeFleetUtilizationResponse -> ShowS
Prelude.Show, (forall x.
 DescribeFleetUtilizationResponse
 -> Rep DescribeFleetUtilizationResponse x)
-> (forall x.
    Rep DescribeFleetUtilizationResponse x
    -> DescribeFleetUtilizationResponse)
-> Generic DescribeFleetUtilizationResponse
forall x.
Rep DescribeFleetUtilizationResponse x
-> DescribeFleetUtilizationResponse
forall x.
DescribeFleetUtilizationResponse
-> Rep DescribeFleetUtilizationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeFleetUtilizationResponse x
-> DescribeFleetUtilizationResponse
$cfrom :: forall x.
DescribeFleetUtilizationResponse
-> Rep DescribeFleetUtilizationResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeFleetUtilizationResponse' 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', 'describeFleetUtilizationResponse_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.
--
-- 'fleetUtilization', 'describeFleetUtilizationResponse_fleetUtilization' - A collection of objects containing utilization information for each
-- requested fleet ID. Utilization objects are returned only for fleets
-- that currently exist.
--
-- 'httpStatus', 'describeFleetUtilizationResponse_httpStatus' - The response's http status code.
newDescribeFleetUtilizationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeFleetUtilizationResponse
newDescribeFleetUtilizationResponse :: Int -> DescribeFleetUtilizationResponse
newDescribeFleetUtilizationResponse Int
pHttpStatus_ =
  DescribeFleetUtilizationResponse' :: Maybe Text
-> Maybe [FleetUtilization]
-> Int
-> DescribeFleetUtilizationResponse
DescribeFleetUtilizationResponse'
    { $sel:nextToken:DescribeFleetUtilizationResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:fleetUtilization:DescribeFleetUtilizationResponse' :: Maybe [FleetUtilization]
fleetUtilization = Maybe [FleetUtilization]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeFleetUtilizationResponse' :: 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.
describeFleetUtilizationResponse_nextToken :: Lens.Lens' DescribeFleetUtilizationResponse (Prelude.Maybe Prelude.Text)
describeFleetUtilizationResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeFleetUtilizationResponse
-> f DescribeFleetUtilizationResponse
describeFleetUtilizationResponse_nextToken = (DescribeFleetUtilizationResponse -> Maybe Text)
-> (DescribeFleetUtilizationResponse
    -> Maybe Text -> DescribeFleetUtilizationResponse)
-> Lens' DescribeFleetUtilizationResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeFleetUtilizationResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeFleetUtilizationResponse' :: DescribeFleetUtilizationResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeFleetUtilizationResponse
s@DescribeFleetUtilizationResponse' {} Maybe Text
a -> DescribeFleetUtilizationResponse
s {$sel:nextToken:DescribeFleetUtilizationResponse' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeFleetUtilizationResponse)

-- | A collection of objects containing utilization information for each
-- requested fleet ID. Utilization objects are returned only for fleets
-- that currently exist.
describeFleetUtilizationResponse_fleetUtilization :: Lens.Lens' DescribeFleetUtilizationResponse (Prelude.Maybe [FleetUtilization])
describeFleetUtilizationResponse_fleetUtilization :: (Maybe [FleetUtilization] -> f (Maybe [FleetUtilization]))
-> DescribeFleetUtilizationResponse
-> f DescribeFleetUtilizationResponse
describeFleetUtilizationResponse_fleetUtilization = (DescribeFleetUtilizationResponse -> Maybe [FleetUtilization])
-> (DescribeFleetUtilizationResponse
    -> Maybe [FleetUtilization] -> DescribeFleetUtilizationResponse)
-> Lens'
     DescribeFleetUtilizationResponse (Maybe [FleetUtilization])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeFleetUtilizationResponse' {Maybe [FleetUtilization]
fleetUtilization :: Maybe [FleetUtilization]
$sel:fleetUtilization:DescribeFleetUtilizationResponse' :: DescribeFleetUtilizationResponse -> Maybe [FleetUtilization]
fleetUtilization} -> Maybe [FleetUtilization]
fleetUtilization) (\s :: DescribeFleetUtilizationResponse
s@DescribeFleetUtilizationResponse' {} Maybe [FleetUtilization]
a -> DescribeFleetUtilizationResponse
s {$sel:fleetUtilization:DescribeFleetUtilizationResponse' :: Maybe [FleetUtilization]
fleetUtilization = Maybe [FleetUtilization]
a} :: DescribeFleetUtilizationResponse) ((Maybe [FleetUtilization] -> f (Maybe [FleetUtilization]))
 -> DescribeFleetUtilizationResponse
 -> f DescribeFleetUtilizationResponse)
-> ((Maybe [FleetUtilization] -> f (Maybe [FleetUtilization]))
    -> Maybe [FleetUtilization] -> f (Maybe [FleetUtilization]))
-> (Maybe [FleetUtilization] -> f (Maybe [FleetUtilization]))
-> DescribeFleetUtilizationResponse
-> f DescribeFleetUtilizationResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [FleetUtilization]
  [FleetUtilization]
  [FleetUtilization]
  [FleetUtilization]
-> Iso
     (Maybe [FleetUtilization])
     (Maybe [FleetUtilization])
     (Maybe [FleetUtilization])
     (Maybe [FleetUtilization])
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
  [FleetUtilization]
  [FleetUtilization]
  [FleetUtilization]
  [FleetUtilization]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance
  Prelude.NFData
    DescribeFleetUtilizationResponse