{-# 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.DescribeInstances
-- 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 information about a fleet\'s instances, including instance
-- IDs, connection data, and status.
--
-- This operation can be used in the following ways:
--
-- -   To get information on all instances that are deployed to a fleet\'s
--     home Region, provide the fleet ID.
--
-- -   To get information on all instances that are deployed to a fleet\'s
--     remote location, provide the fleet ID and location name.
--
-- -   To get information on a specific instance in a fleet, provide the
--     fleet ID and instance ID.
--
-- Use the pagination parameters to retrieve results as a set of sequential
-- pages.
--
-- If successful, an @Instance@ object is returned for each requested
-- instance. Instances are not returned in any particular order.
--
-- __Learn more__
--
-- <https://docs.aws.amazon.com/gamelift/latest/developerguide/fleets-remote-access.html Remotely Access Fleet Instances>
--
-- <https://docs.aws.amazon.com/gamelift/latest/developerguide/fleets-creating-debug.html Debug Fleet Issues>
--
-- __Related actions__
--
-- DescribeInstances | GetInstanceAccess | DescribeEC2InstanceLimits |
-- <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.DescribeInstances
  ( -- * Creating a Request
    DescribeInstances (..),
    newDescribeInstances,

    -- * Request Lenses
    describeInstances_instanceId,
    describeInstances_location,
    describeInstances_nextToken,
    describeInstances_limit,
    describeInstances_fleetId,

    -- * Destructuring the Response
    DescribeInstancesResponse (..),
    newDescribeInstancesResponse,

    -- * Response Lenses
    describeInstancesResponse_nextToken,
    describeInstancesResponse_instances,
    describeInstancesResponse_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:/ 'newDescribeInstances' smart constructor.
data DescribeInstances = DescribeInstances'
  { -- | A unique identifier for an instance to retrieve. Specify an instance ID
    -- or leave blank to retrieve all instances in the fleet.
    DescribeInstances -> Maybe Text
instanceId :: Prelude.Maybe Prelude.Text,
    -- | The name of a location to retrieve instance information for, in the form
    -- of an AWS Region code such as @us-west-2@.
    DescribeInstances -> 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.
    DescribeInstances -> 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.
    DescribeInstances -> Maybe Natural
limit :: Prelude.Maybe Prelude.Natural,
    -- | A unique identifier for the fleet to retrieve instance information for.
    -- You can use either the fleet ID or ARN value.
    DescribeInstances -> Text
fleetId :: Prelude.Text
  }
  deriving (DescribeInstances -> DescribeInstances -> Bool
(DescribeInstances -> DescribeInstances -> Bool)
-> (DescribeInstances -> DescribeInstances -> Bool)
-> Eq DescribeInstances
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeInstances -> DescribeInstances -> Bool
$c/= :: DescribeInstances -> DescribeInstances -> Bool
== :: DescribeInstances -> DescribeInstances -> Bool
$c== :: DescribeInstances -> DescribeInstances -> Bool
Prelude.Eq, ReadPrec [DescribeInstances]
ReadPrec DescribeInstances
Int -> ReadS DescribeInstances
ReadS [DescribeInstances]
(Int -> ReadS DescribeInstances)
-> ReadS [DescribeInstances]
-> ReadPrec DescribeInstances
-> ReadPrec [DescribeInstances]
-> Read DescribeInstances
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeInstances]
$creadListPrec :: ReadPrec [DescribeInstances]
readPrec :: ReadPrec DescribeInstances
$creadPrec :: ReadPrec DescribeInstances
readList :: ReadS [DescribeInstances]
$creadList :: ReadS [DescribeInstances]
readsPrec :: Int -> ReadS DescribeInstances
$creadsPrec :: Int -> ReadS DescribeInstances
Prelude.Read, Int -> DescribeInstances -> ShowS
[DescribeInstances] -> ShowS
DescribeInstances -> String
(Int -> DescribeInstances -> ShowS)
-> (DescribeInstances -> String)
-> ([DescribeInstances] -> ShowS)
-> Show DescribeInstances
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeInstances] -> ShowS
$cshowList :: [DescribeInstances] -> ShowS
show :: DescribeInstances -> String
$cshow :: DescribeInstances -> String
showsPrec :: Int -> DescribeInstances -> ShowS
$cshowsPrec :: Int -> DescribeInstances -> ShowS
Prelude.Show, (forall x. DescribeInstances -> Rep DescribeInstances x)
-> (forall x. Rep DescribeInstances x -> DescribeInstances)
-> Generic DescribeInstances
forall x. Rep DescribeInstances x -> DescribeInstances
forall x. DescribeInstances -> Rep DescribeInstances x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeInstances x -> DescribeInstances
$cfrom :: forall x. DescribeInstances -> Rep DescribeInstances x
Prelude.Generic)

-- |
-- Create a value of 'DescribeInstances' 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:
--
-- 'instanceId', 'describeInstances_instanceId' - A unique identifier for an instance to retrieve. Specify an instance ID
-- or leave blank to retrieve all instances in the fleet.
--
-- 'location', 'describeInstances_location' - The name of a location to retrieve instance information for, in the form
-- of an AWS Region code such as @us-west-2@.
--
-- 'nextToken', 'describeInstances_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.
--
-- 'limit', 'describeInstances_limit' - The maximum number of results to return. Use this parameter with
-- @NextToken@ to get results as a set of sequential pages.
--
-- 'fleetId', 'describeInstances_fleetId' - A unique identifier for the fleet to retrieve instance information for.
-- You can use either the fleet ID or ARN value.
newDescribeInstances ::
  -- | 'fleetId'
  Prelude.Text ->
  DescribeInstances
newDescribeInstances :: Text -> DescribeInstances
newDescribeInstances Text
pFleetId_ =
  DescribeInstances' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Natural
-> Text
-> DescribeInstances
DescribeInstances'
    { $sel:instanceId:DescribeInstances' :: Maybe Text
instanceId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:location:DescribeInstances' :: Maybe Text
location = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeInstances' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:limit:DescribeInstances' :: Maybe Natural
limit = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:fleetId:DescribeInstances' :: Text
fleetId = Text
pFleetId_
    }

-- | A unique identifier for an instance to retrieve. Specify an instance ID
-- or leave blank to retrieve all instances in the fleet.
describeInstances_instanceId :: Lens.Lens' DescribeInstances (Prelude.Maybe Prelude.Text)
describeInstances_instanceId :: (Maybe Text -> f (Maybe Text))
-> DescribeInstances -> f DescribeInstances
describeInstances_instanceId = (DescribeInstances -> Maybe Text)
-> (DescribeInstances -> Maybe Text -> DescribeInstances)
-> Lens
     DescribeInstances DescribeInstances (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeInstances' {Maybe Text
instanceId :: Maybe Text
$sel:instanceId:DescribeInstances' :: DescribeInstances -> Maybe Text
instanceId} -> Maybe Text
instanceId) (\s :: DescribeInstances
s@DescribeInstances' {} Maybe Text
a -> DescribeInstances
s {$sel:instanceId:DescribeInstances' :: Maybe Text
instanceId = Maybe Text
a} :: DescribeInstances)

-- | The name of a location to retrieve instance information for, in the form
-- of an AWS Region code such as @us-west-2@.
describeInstances_location :: Lens.Lens' DescribeInstances (Prelude.Maybe Prelude.Text)
describeInstances_location :: (Maybe Text -> f (Maybe Text))
-> DescribeInstances -> f DescribeInstances
describeInstances_location = (DescribeInstances -> Maybe Text)
-> (DescribeInstances -> Maybe Text -> DescribeInstances)
-> Lens
     DescribeInstances DescribeInstances (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeInstances' {Maybe Text
location :: Maybe Text
$sel:location:DescribeInstances' :: DescribeInstances -> Maybe Text
location} -> Maybe Text
location) (\s :: DescribeInstances
s@DescribeInstances' {} Maybe Text
a -> DescribeInstances
s {$sel:location:DescribeInstances' :: Maybe Text
location = Maybe Text
a} :: DescribeInstances)

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

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

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

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

instance Prelude.NFData DescribeInstances

instance Core.ToHeaders DescribeInstances where
  toHeaders :: DescribeInstances -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeInstances -> 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.DescribeInstances" :: 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 DescribeInstances where
  toJSON :: DescribeInstances -> Value
toJSON DescribeInstances' {Maybe Natural
Maybe Text
Text
fleetId :: Text
limit :: Maybe Natural
nextToken :: Maybe Text
location :: Maybe Text
instanceId :: Maybe Text
$sel:fleetId:DescribeInstances' :: DescribeInstances -> Text
$sel:limit:DescribeInstances' :: DescribeInstances -> Maybe Natural
$sel:nextToken:DescribeInstances' :: DescribeInstances -> Maybe Text
$sel:location:DescribeInstances' :: DescribeInstances -> Maybe Text
$sel:instanceId:DescribeInstances' :: DescribeInstances -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"InstanceId" 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
instanceId,
            (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
"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 DescribeInstances where
  toPath :: DescribeInstances -> ByteString
toPath = ByteString -> DescribeInstances -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- |
-- Create a value of 'DescribeInstancesResponse' 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', 'describeInstancesResponse_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.
--
-- 'instances', 'describeInstancesResponse_instances' - A collection of objects containing properties for each instance
-- returned.
--
-- 'httpStatus', 'describeInstancesResponse_httpStatus' - The response's http status code.
newDescribeInstancesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeInstancesResponse
newDescribeInstancesResponse :: Int -> DescribeInstancesResponse
newDescribeInstancesResponse Int
pHttpStatus_ =
  DescribeInstancesResponse' :: Maybe Text -> Maybe [Instance] -> Int -> DescribeInstancesResponse
DescribeInstancesResponse'
    { $sel:nextToken:DescribeInstancesResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:instances:DescribeInstancesResponse' :: Maybe [Instance]
instances = Maybe [Instance]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeInstancesResponse' :: 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.
describeInstancesResponse_nextToken :: Lens.Lens' DescribeInstancesResponse (Prelude.Maybe Prelude.Text)
describeInstancesResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeInstancesResponse -> f DescribeInstancesResponse
describeInstancesResponse_nextToken = (DescribeInstancesResponse -> Maybe Text)
-> (DescribeInstancesResponse
    -> Maybe Text -> DescribeInstancesResponse)
-> Lens' DescribeInstancesResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeInstancesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeInstancesResponse' :: DescribeInstancesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeInstancesResponse
s@DescribeInstancesResponse' {} Maybe Text
a -> DescribeInstancesResponse
s {$sel:nextToken:DescribeInstancesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeInstancesResponse)

-- | A collection of objects containing properties for each instance
-- returned.
describeInstancesResponse_instances :: Lens.Lens' DescribeInstancesResponse (Prelude.Maybe [Instance])
describeInstancesResponse_instances :: (Maybe [Instance] -> f (Maybe [Instance]))
-> DescribeInstancesResponse -> f DescribeInstancesResponse
describeInstancesResponse_instances = (DescribeInstancesResponse -> Maybe [Instance])
-> (DescribeInstancesResponse
    -> Maybe [Instance] -> DescribeInstancesResponse)
-> Lens' DescribeInstancesResponse (Maybe [Instance])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeInstancesResponse' {Maybe [Instance]
instances :: Maybe [Instance]
$sel:instances:DescribeInstancesResponse' :: DescribeInstancesResponse -> Maybe [Instance]
instances} -> Maybe [Instance]
instances) (\s :: DescribeInstancesResponse
s@DescribeInstancesResponse' {} Maybe [Instance]
a -> DescribeInstancesResponse
s {$sel:instances:DescribeInstancesResponse' :: Maybe [Instance]
instances = Maybe [Instance]
a} :: DescribeInstancesResponse) ((Maybe [Instance] -> f (Maybe [Instance]))
 -> DescribeInstancesResponse -> f DescribeInstancesResponse)
-> ((Maybe [Instance] -> f (Maybe [Instance]))
    -> Maybe [Instance] -> f (Maybe [Instance]))
-> (Maybe [Instance] -> f (Maybe [Instance]))
-> DescribeInstancesResponse
-> f DescribeInstancesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Instance] [Instance] [Instance] [Instance]
-> Iso
     (Maybe [Instance])
     (Maybe [Instance])
     (Maybe [Instance])
     (Maybe [Instance])
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 [Instance] [Instance] [Instance] [Instance]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData DescribeInstancesResponse