{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric      #-}
{-# LANGUAGE OverloadedStrings  #-}
{-# LANGUAGE RecordWildCards    #-}
{-# LANGUAGE TypeFamilies       #-}

{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-binds   #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Network.AWS.GameLift.DescribeGameSessionDetails
-- Copyright   : (c) 2013-2016 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves properties, including the protection policy in force, for one
-- or more game sessions. This action can be used in several ways: (1)
-- provide a /GameSessionId/ to request details for a specific game
-- session; (2) provide either a /FleetId/ or an /AliasId/ to request
-- properties for all game sessions running on a fleet.
--
-- To get game session record(s), specify just one of the following: game
-- session ID, fleet ID, or alias ID. You can filter this request by game
-- session status. Use the pagination parameters to retrieve results as a
-- set of sequential pages. If successful, a < GameSessionDetail> object is
-- returned for each session matching the request.
module Network.AWS.GameLift.DescribeGameSessionDetails
    (
    -- * Creating a Request
      describeGameSessionDetails
    , DescribeGameSessionDetails
    -- * Request Lenses
    , dgsdGameSessionId
    , dgsdAliasId
    , dgsdNextToken
    , dgsdStatusFilter
    , dgsdLimit
    , dgsdFleetId

    -- * Destructuring the Response
    , describeGameSessionDetailsResponse
    , DescribeGameSessionDetailsResponse
    -- * Response Lenses
    , dgsdrsGameSessionDetails
    , dgsdrsNextToken
    , dgsdrsResponseStatus
    ) where

import           Network.AWS.GameLift.Types
import           Network.AWS.GameLift.Types.Product
import           Network.AWS.Lens
import           Network.AWS.Prelude
import           Network.AWS.Request
import           Network.AWS.Response

-- | Represents the input for a request action.
--
-- /See:/ 'describeGameSessionDetails' smart constructor.
data DescribeGameSessionDetails = DescribeGameSessionDetails'
    { _dgsdGameSessionId :: !(Maybe Text)
    , _dgsdAliasId       :: !(Maybe Text)
    , _dgsdNextToken     :: !(Maybe Text)
    , _dgsdStatusFilter  :: !(Maybe Text)
    , _dgsdLimit         :: !(Maybe Nat)
    , _dgsdFleetId       :: !(Maybe Text)
    } deriving (Eq,Read,Show,Data,Typeable,Generic)

-- | Creates a value of 'DescribeGameSessionDetails' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'dgsdGameSessionId'
--
-- * 'dgsdAliasId'
--
-- * 'dgsdNextToken'
--
-- * 'dgsdStatusFilter'
--
-- * 'dgsdLimit'
--
-- * 'dgsdFleetId'
describeGameSessionDetails
    :: DescribeGameSessionDetails
describeGameSessionDetails =
    DescribeGameSessionDetails'
    { _dgsdGameSessionId = Nothing
    , _dgsdAliasId = Nothing
    , _dgsdNextToken = Nothing
    , _dgsdStatusFilter = Nothing
    , _dgsdLimit = Nothing
    , _dgsdFleetId = Nothing
    }

-- | Unique identifier for a game session. Specify the game session to
-- retrieve information on.
dgsdGameSessionId :: Lens' DescribeGameSessionDetails (Maybe Text)
dgsdGameSessionId = lens _dgsdGameSessionId (\ s a -> s{_dgsdGameSessionId = a});

-- | Unique identifier for a fleet alias. Specify an alias to retrieve
-- information on all game sessions active on the fleet.
dgsdAliasId :: Lens' DescribeGameSessionDetails (Maybe Text)
dgsdAliasId = lens _dgsdAliasId (\ s a -> s{_dgsdAliasId = a});

-- | Token indicating the start of the next sequential page of results. Use
-- the token that is returned with a previous call to this action. To
-- specify the start of the result set, do not specify a value.
dgsdNextToken :: Lens' DescribeGameSessionDetails (Maybe Text)
dgsdNextToken = lens _dgsdNextToken (\ s a -> s{_dgsdNextToken = a});

-- | Game session status to filter results on. Possible game session states
-- include ACTIVE, TERMINATED, ACTIVATING and TERMINATING (the last two are
-- transitory).
dgsdStatusFilter :: Lens' DescribeGameSessionDetails (Maybe Text)
dgsdStatusFilter = lens _dgsdStatusFilter (\ s a -> s{_dgsdStatusFilter = a});

-- | Maximum number of results to return. You can use this parameter with
-- /NextToken/ to get results as a set of sequential pages.
dgsdLimit :: Lens' DescribeGameSessionDetails (Maybe Natural)
dgsdLimit = lens _dgsdLimit (\ s a -> s{_dgsdLimit = a}) . mapping _Nat;

-- | Unique identifier for a fleet. Specify a fleet to retrieve information
-- on all game sessions active on the fleet.
dgsdFleetId :: Lens' DescribeGameSessionDetails (Maybe Text)
dgsdFleetId = lens _dgsdFleetId (\ s a -> s{_dgsdFleetId = a});

instance AWSRequest DescribeGameSessionDetails where
        type Rs DescribeGameSessionDetails =
             DescribeGameSessionDetailsResponse
        request = postJSON gameLift
        response
          = receiveJSON
              (\ s h x ->
                 DescribeGameSessionDetailsResponse' <$>
                   (x .?> "GameSessionDetails" .!@ mempty) <*>
                     (x .?> "NextToken")
                     <*> (pure (fromEnum s)))

instance Hashable DescribeGameSessionDetails

instance NFData DescribeGameSessionDetails

instance ToHeaders DescribeGameSessionDetails where
        toHeaders
          = const
              (mconcat
                 ["X-Amz-Target" =#
                    ("GameLift.DescribeGameSessionDetails" ::
                       ByteString),
                  "Content-Type" =#
                    ("application/x-amz-json-1.1" :: ByteString)])

instance ToJSON DescribeGameSessionDetails where
        toJSON DescribeGameSessionDetails'{..}
          = object
              (catMaybes
                 [("GameSessionId" .=) <$> _dgsdGameSessionId,
                  ("AliasId" .=) <$> _dgsdAliasId,
                  ("NextToken" .=) <$> _dgsdNextToken,
                  ("StatusFilter" .=) <$> _dgsdStatusFilter,
                  ("Limit" .=) <$> _dgsdLimit,
                  ("FleetId" .=) <$> _dgsdFleetId])

instance ToPath DescribeGameSessionDetails where
        toPath = const "/"

instance ToQuery DescribeGameSessionDetails where
        toQuery = const mempty

-- | Represents the returned data in response to a request action.
--
-- /See:/ 'describeGameSessionDetailsResponse' smart constructor.
data DescribeGameSessionDetailsResponse = DescribeGameSessionDetailsResponse'
    { _dgsdrsGameSessionDetails :: !(Maybe [GameSessionDetail])
    , _dgsdrsNextToken          :: !(Maybe Text)
    , _dgsdrsResponseStatus     :: !Int
    } deriving (Eq,Read,Show,Data,Typeable,Generic)

-- | Creates a value of 'DescribeGameSessionDetailsResponse' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'dgsdrsGameSessionDetails'
--
-- * 'dgsdrsNextToken'
--
-- * 'dgsdrsResponseStatus'
describeGameSessionDetailsResponse
    :: Int -- ^ 'dgsdrsResponseStatus'
    -> DescribeGameSessionDetailsResponse
describeGameSessionDetailsResponse pResponseStatus_ =
    DescribeGameSessionDetailsResponse'
    { _dgsdrsGameSessionDetails = Nothing
    , _dgsdrsNextToken = Nothing
    , _dgsdrsResponseStatus = pResponseStatus_
    }

-- | Collection of objects containing game session properties and the
-- protection policy currently in force for each session matching the
-- request.
dgsdrsGameSessionDetails :: Lens' DescribeGameSessionDetailsResponse [GameSessionDetail]
dgsdrsGameSessionDetails = lens _dgsdrsGameSessionDetails (\ s a -> s{_dgsdrsGameSessionDetails = a}) . _Default . _Coerce;

-- | Token indicating where to resume retrieving results on the next call to
-- this action. If no token is returned, these results represent the end of
-- the list.
--
-- If a request has a limit that exactly matches the number of remaining
-- results, a token is returned even though there are no more results to
-- retrieve.
dgsdrsNextToken :: Lens' DescribeGameSessionDetailsResponse (Maybe Text)
dgsdrsNextToken = lens _dgsdrsNextToken (\ s a -> s{_dgsdrsNextToken = a});

-- | The response status code.
dgsdrsResponseStatus :: Lens' DescribeGameSessionDetailsResponse Int
dgsdrsResponseStatus = lens _dgsdrsResponseStatus (\ s a -> s{_dgsdrsResponseStatus = a});

instance NFData DescribeGameSessionDetailsResponse