{-# 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.DescribeFleetEvents
-- 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 entries from a fleet\'s event log. Fleet events are initiated
-- by changes in status, such as during fleet creation and termination,
-- changes in capacity, etc. If a fleet has multiple locations, events are
-- also initiated by changes to status and capacity in remote locations.
--
-- You can specify a time range to limit the result set. Use the pagination
-- parameters to retrieve results as a set of sequential pages.
--
-- If successful, a collection of event log entries matching the request
-- are returned.
--
-- __Learn more__
--
-- <https://docs.aws.amazon.com/gamelift/latest/developerguide/fleets-intro.html Setting up GameLift 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.DescribeFleetEvents
  ( -- * Creating a Request
    DescribeFleetEvents (..),
    newDescribeFleetEvents,

    -- * Request Lenses
    describeFleetEvents_startTime,
    describeFleetEvents_nextToken,
    describeFleetEvents_endTime,
    describeFleetEvents_limit,
    describeFleetEvents_fleetId,

    -- * Destructuring the Response
    DescribeFleetEventsResponse (..),
    newDescribeFleetEventsResponse,

    -- * Response Lenses
    describeFleetEventsResponse_nextToken,
    describeFleetEventsResponse_events,
    describeFleetEventsResponse_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:/ 'newDescribeFleetEvents' smart constructor.
data DescribeFleetEvents = DescribeFleetEvents'
  { -- | The earliest date to retrieve event logs for. If no start time is
    -- specified, this call returns entries starting from when the fleet was
    -- created to the specified end time. Format is a number expressed in Unix
    -- time as milliseconds (ex: \"1469498468.057\").
    DescribeFleetEvents -> Maybe POSIX
startTime :: Prelude.Maybe Core.POSIX,
    -- | 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.
    DescribeFleetEvents -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The most recent date to retrieve event logs for. If no end time is
    -- specified, this call returns entries from the specified start time up to
    -- the present. Format is a number expressed in Unix time as milliseconds
    -- (ex: \"1469498468.057\").
    DescribeFleetEvents -> Maybe POSIX
endTime :: Prelude.Maybe Core.POSIX,
    -- | The maximum number of results to return. Use this parameter with
    -- @NextToken@ to get results as a set of sequential pages.
    DescribeFleetEvents -> Maybe Natural
limit :: Prelude.Maybe Prelude.Natural,
    -- | A unique identifier for the fleet to get event logs for. You can use
    -- either the fleet ID or ARN value.
    DescribeFleetEvents -> Text
fleetId :: Prelude.Text
  }
  deriving (DescribeFleetEvents -> DescribeFleetEvents -> Bool
(DescribeFleetEvents -> DescribeFleetEvents -> Bool)
-> (DescribeFleetEvents -> DescribeFleetEvents -> Bool)
-> Eq DescribeFleetEvents
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeFleetEvents -> DescribeFleetEvents -> Bool
$c/= :: DescribeFleetEvents -> DescribeFleetEvents -> Bool
== :: DescribeFleetEvents -> DescribeFleetEvents -> Bool
$c== :: DescribeFleetEvents -> DescribeFleetEvents -> Bool
Prelude.Eq, ReadPrec [DescribeFleetEvents]
ReadPrec DescribeFleetEvents
Int -> ReadS DescribeFleetEvents
ReadS [DescribeFleetEvents]
(Int -> ReadS DescribeFleetEvents)
-> ReadS [DescribeFleetEvents]
-> ReadPrec DescribeFleetEvents
-> ReadPrec [DescribeFleetEvents]
-> Read DescribeFleetEvents
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeFleetEvents]
$creadListPrec :: ReadPrec [DescribeFleetEvents]
readPrec :: ReadPrec DescribeFleetEvents
$creadPrec :: ReadPrec DescribeFleetEvents
readList :: ReadS [DescribeFleetEvents]
$creadList :: ReadS [DescribeFleetEvents]
readsPrec :: Int -> ReadS DescribeFleetEvents
$creadsPrec :: Int -> ReadS DescribeFleetEvents
Prelude.Read, Int -> DescribeFleetEvents -> ShowS
[DescribeFleetEvents] -> ShowS
DescribeFleetEvents -> String
(Int -> DescribeFleetEvents -> ShowS)
-> (DescribeFleetEvents -> String)
-> ([DescribeFleetEvents] -> ShowS)
-> Show DescribeFleetEvents
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeFleetEvents] -> ShowS
$cshowList :: [DescribeFleetEvents] -> ShowS
show :: DescribeFleetEvents -> String
$cshow :: DescribeFleetEvents -> String
showsPrec :: Int -> DescribeFleetEvents -> ShowS
$cshowsPrec :: Int -> DescribeFleetEvents -> ShowS
Prelude.Show, (forall x. DescribeFleetEvents -> Rep DescribeFleetEvents x)
-> (forall x. Rep DescribeFleetEvents x -> DescribeFleetEvents)
-> Generic DescribeFleetEvents
forall x. Rep DescribeFleetEvents x -> DescribeFleetEvents
forall x. DescribeFleetEvents -> Rep DescribeFleetEvents x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeFleetEvents x -> DescribeFleetEvents
$cfrom :: forall x. DescribeFleetEvents -> Rep DescribeFleetEvents x
Prelude.Generic)

-- |
-- Create a value of 'DescribeFleetEvents' 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:
--
-- 'startTime', 'describeFleetEvents_startTime' - The earliest date to retrieve event logs for. If no start time is
-- specified, this call returns entries starting from when the fleet was
-- created to the specified end time. Format is a number expressed in Unix
-- time as milliseconds (ex: \"1469498468.057\").
--
-- 'nextToken', 'describeFleetEvents_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.
--
-- 'endTime', 'describeFleetEvents_endTime' - The most recent date to retrieve event logs for. If no end time is
-- specified, this call returns entries from the specified start time up to
-- the present. Format is a number expressed in Unix time as milliseconds
-- (ex: \"1469498468.057\").
--
-- 'limit', 'describeFleetEvents_limit' - The maximum number of results to return. Use this parameter with
-- @NextToken@ to get results as a set of sequential pages.
--
-- 'fleetId', 'describeFleetEvents_fleetId' - A unique identifier for the fleet to get event logs for. You can use
-- either the fleet ID or ARN value.
newDescribeFleetEvents ::
  -- | 'fleetId'
  Prelude.Text ->
  DescribeFleetEvents
newDescribeFleetEvents :: Text -> DescribeFleetEvents
newDescribeFleetEvents Text
pFleetId_ =
  DescribeFleetEvents' :: Maybe POSIX
-> Maybe Text
-> Maybe POSIX
-> Maybe Natural
-> Text
-> DescribeFleetEvents
DescribeFleetEvents'
    { $sel:startTime:DescribeFleetEvents' :: Maybe POSIX
startTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeFleetEvents' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:endTime:DescribeFleetEvents' :: Maybe POSIX
endTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:limit:DescribeFleetEvents' :: Maybe Natural
limit = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:fleetId:DescribeFleetEvents' :: Text
fleetId = Text
pFleetId_
    }

-- | The earliest date to retrieve event logs for. If no start time is
-- specified, this call returns entries starting from when the fleet was
-- created to the specified end time. Format is a number expressed in Unix
-- time as milliseconds (ex: \"1469498468.057\").
describeFleetEvents_startTime :: Lens.Lens' DescribeFleetEvents (Prelude.Maybe Prelude.UTCTime)
describeFleetEvents_startTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> DescribeFleetEvents -> f DescribeFleetEvents
describeFleetEvents_startTime = (DescribeFleetEvents -> Maybe POSIX)
-> (DescribeFleetEvents -> Maybe POSIX -> DescribeFleetEvents)
-> Lens
     DescribeFleetEvents DescribeFleetEvents (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeFleetEvents' {Maybe POSIX
startTime :: Maybe POSIX
$sel:startTime:DescribeFleetEvents' :: DescribeFleetEvents -> Maybe POSIX
startTime} -> Maybe POSIX
startTime) (\s :: DescribeFleetEvents
s@DescribeFleetEvents' {} Maybe POSIX
a -> DescribeFleetEvents
s {$sel:startTime:DescribeFleetEvents' :: Maybe POSIX
startTime = Maybe POSIX
a} :: DescribeFleetEvents) ((Maybe POSIX -> f (Maybe POSIX))
 -> DescribeFleetEvents -> f DescribeFleetEvents)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> DescribeFleetEvents
-> f DescribeFleetEvents
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

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

-- | The most recent date to retrieve event logs for. If no end time is
-- specified, this call returns entries from the specified start time up to
-- the present. Format is a number expressed in Unix time as milliseconds
-- (ex: \"1469498468.057\").
describeFleetEvents_endTime :: Lens.Lens' DescribeFleetEvents (Prelude.Maybe Prelude.UTCTime)
describeFleetEvents_endTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> DescribeFleetEvents -> f DescribeFleetEvents
describeFleetEvents_endTime = (DescribeFleetEvents -> Maybe POSIX)
-> (DescribeFleetEvents -> Maybe POSIX -> DescribeFleetEvents)
-> Lens
     DescribeFleetEvents DescribeFleetEvents (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeFleetEvents' {Maybe POSIX
endTime :: Maybe POSIX
$sel:endTime:DescribeFleetEvents' :: DescribeFleetEvents -> Maybe POSIX
endTime} -> Maybe POSIX
endTime) (\s :: DescribeFleetEvents
s@DescribeFleetEvents' {} Maybe POSIX
a -> DescribeFleetEvents
s {$sel:endTime:DescribeFleetEvents' :: Maybe POSIX
endTime = Maybe POSIX
a} :: DescribeFleetEvents) ((Maybe POSIX -> f (Maybe POSIX))
 -> DescribeFleetEvents -> f DescribeFleetEvents)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> DescribeFleetEvents
-> f DescribeFleetEvents
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

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

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

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

instance Prelude.NFData DescribeFleetEvents

instance Core.ToHeaders DescribeFleetEvents where
  toHeaders :: DescribeFleetEvents -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeFleetEvents -> 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.DescribeFleetEvents" ::
                          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 DescribeFleetEvents where
  toJSON :: DescribeFleetEvents -> Value
toJSON DescribeFleetEvents' {Maybe Natural
Maybe Text
Maybe POSIX
Text
fleetId :: Text
limit :: Maybe Natural
endTime :: Maybe POSIX
nextToken :: Maybe Text
startTime :: Maybe POSIX
$sel:fleetId:DescribeFleetEvents' :: DescribeFleetEvents -> Text
$sel:limit:DescribeFleetEvents' :: DescribeFleetEvents -> Maybe Natural
$sel:endTime:DescribeFleetEvents' :: DescribeFleetEvents -> Maybe POSIX
$sel:nextToken:DescribeFleetEvents' :: DescribeFleetEvents -> Maybe Text
$sel:startTime:DescribeFleetEvents' :: DescribeFleetEvents -> Maybe POSIX
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"StartTime" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (POSIX -> Pair) -> Maybe POSIX -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe POSIX
startTime,
            (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
"EndTime" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (POSIX -> Pair) -> Maybe POSIX -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe POSIX
endTime,
            (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 DescribeFleetEvents where
  toPath :: DescribeFleetEvents -> ByteString
toPath = ByteString -> DescribeFleetEvents -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery DescribeFleetEvents where
  toQuery :: DescribeFleetEvents -> QueryString
toQuery = QueryString -> DescribeFleetEvents -> 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:/ 'newDescribeFleetEventsResponse' smart constructor.
data DescribeFleetEventsResponse = DescribeFleetEventsResponse'
  { -- | 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.
    DescribeFleetEventsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | A collection of objects containing event log entries for the specified
    -- fleet.
    DescribeFleetEventsResponse -> Maybe [Event]
events :: Prelude.Maybe [Event],
    -- | The response's http status code.
    DescribeFleetEventsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeFleetEventsResponse -> DescribeFleetEventsResponse -> Bool
(DescribeFleetEventsResponse
 -> DescribeFleetEventsResponse -> Bool)
-> (DescribeFleetEventsResponse
    -> DescribeFleetEventsResponse -> Bool)
-> Eq DescribeFleetEventsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeFleetEventsResponse -> DescribeFleetEventsResponse -> Bool
$c/= :: DescribeFleetEventsResponse -> DescribeFleetEventsResponse -> Bool
== :: DescribeFleetEventsResponse -> DescribeFleetEventsResponse -> Bool
$c== :: DescribeFleetEventsResponse -> DescribeFleetEventsResponse -> Bool
Prelude.Eq, ReadPrec [DescribeFleetEventsResponse]
ReadPrec DescribeFleetEventsResponse
Int -> ReadS DescribeFleetEventsResponse
ReadS [DescribeFleetEventsResponse]
(Int -> ReadS DescribeFleetEventsResponse)
-> ReadS [DescribeFleetEventsResponse]
-> ReadPrec DescribeFleetEventsResponse
-> ReadPrec [DescribeFleetEventsResponse]
-> Read DescribeFleetEventsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeFleetEventsResponse]
$creadListPrec :: ReadPrec [DescribeFleetEventsResponse]
readPrec :: ReadPrec DescribeFleetEventsResponse
$creadPrec :: ReadPrec DescribeFleetEventsResponse
readList :: ReadS [DescribeFleetEventsResponse]
$creadList :: ReadS [DescribeFleetEventsResponse]
readsPrec :: Int -> ReadS DescribeFleetEventsResponse
$creadsPrec :: Int -> ReadS DescribeFleetEventsResponse
Prelude.Read, Int -> DescribeFleetEventsResponse -> ShowS
[DescribeFleetEventsResponse] -> ShowS
DescribeFleetEventsResponse -> String
(Int -> DescribeFleetEventsResponse -> ShowS)
-> (DescribeFleetEventsResponse -> String)
-> ([DescribeFleetEventsResponse] -> ShowS)
-> Show DescribeFleetEventsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeFleetEventsResponse] -> ShowS
$cshowList :: [DescribeFleetEventsResponse] -> ShowS
show :: DescribeFleetEventsResponse -> String
$cshow :: DescribeFleetEventsResponse -> String
showsPrec :: Int -> DescribeFleetEventsResponse -> ShowS
$cshowsPrec :: Int -> DescribeFleetEventsResponse -> ShowS
Prelude.Show, (forall x.
 DescribeFleetEventsResponse -> Rep DescribeFleetEventsResponse x)
-> (forall x.
    Rep DescribeFleetEventsResponse x -> DescribeFleetEventsResponse)
-> Generic DescribeFleetEventsResponse
forall x.
Rep DescribeFleetEventsResponse x -> DescribeFleetEventsResponse
forall x.
DescribeFleetEventsResponse -> Rep DescribeFleetEventsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeFleetEventsResponse x -> DescribeFleetEventsResponse
$cfrom :: forall x.
DescribeFleetEventsResponse -> Rep DescribeFleetEventsResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeFleetEventsResponse' 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', 'describeFleetEventsResponse_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.
--
-- 'events', 'describeFleetEventsResponse_events' - A collection of objects containing event log entries for the specified
-- fleet.
--
-- 'httpStatus', 'describeFleetEventsResponse_httpStatus' - The response's http status code.
newDescribeFleetEventsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeFleetEventsResponse
newDescribeFleetEventsResponse :: Int -> DescribeFleetEventsResponse
newDescribeFleetEventsResponse Int
pHttpStatus_ =
  DescribeFleetEventsResponse' :: Maybe Text -> Maybe [Event] -> Int -> DescribeFleetEventsResponse
DescribeFleetEventsResponse'
    { $sel:nextToken:DescribeFleetEventsResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:events:DescribeFleetEventsResponse' :: Maybe [Event]
events = Maybe [Event]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeFleetEventsResponse' :: 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.
describeFleetEventsResponse_nextToken :: Lens.Lens' DescribeFleetEventsResponse (Prelude.Maybe Prelude.Text)
describeFleetEventsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeFleetEventsResponse -> f DescribeFleetEventsResponse
describeFleetEventsResponse_nextToken = (DescribeFleetEventsResponse -> Maybe Text)
-> (DescribeFleetEventsResponse
    -> Maybe Text -> DescribeFleetEventsResponse)
-> Lens' DescribeFleetEventsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeFleetEventsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeFleetEventsResponse' :: DescribeFleetEventsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeFleetEventsResponse
s@DescribeFleetEventsResponse' {} Maybe Text
a -> DescribeFleetEventsResponse
s {$sel:nextToken:DescribeFleetEventsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeFleetEventsResponse)

-- | A collection of objects containing event log entries for the specified
-- fleet.
describeFleetEventsResponse_events :: Lens.Lens' DescribeFleetEventsResponse (Prelude.Maybe [Event])
describeFleetEventsResponse_events :: (Maybe [Event] -> f (Maybe [Event]))
-> DescribeFleetEventsResponse -> f DescribeFleetEventsResponse
describeFleetEventsResponse_events = (DescribeFleetEventsResponse -> Maybe [Event])
-> (DescribeFleetEventsResponse
    -> Maybe [Event] -> DescribeFleetEventsResponse)
-> Lens' DescribeFleetEventsResponse (Maybe [Event])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeFleetEventsResponse' {Maybe [Event]
events :: Maybe [Event]
$sel:events:DescribeFleetEventsResponse' :: DescribeFleetEventsResponse -> Maybe [Event]
events} -> Maybe [Event]
events) (\s :: DescribeFleetEventsResponse
s@DescribeFleetEventsResponse' {} Maybe [Event]
a -> DescribeFleetEventsResponse
s {$sel:events:DescribeFleetEventsResponse' :: Maybe [Event]
events = Maybe [Event]
a} :: DescribeFleetEventsResponse) ((Maybe [Event] -> f (Maybe [Event]))
 -> DescribeFleetEventsResponse -> f DescribeFleetEventsResponse)
-> ((Maybe [Event] -> f (Maybe [Event]))
    -> Maybe [Event] -> f (Maybe [Event]))
-> (Maybe [Event] -> f (Maybe [Event]))
-> DescribeFleetEventsResponse
-> f DescribeFleetEventsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Event] [Event] [Event] [Event]
-> Iso
     (Maybe [Event]) (Maybe [Event]) (Maybe [Event]) (Maybe [Event])
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 [Event] [Event] [Event] [Event]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData DescribeFleetEventsResponse