{-# 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.IoT.DescribeEndpoint
-- Copyright   : (c) 2013-2015 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)
--
-- Returns a unique URL specific to the AWS account making the call. The
-- URL points to the AWS IoT data plane endpoint. The customer-specific
-- endpoint should be provided to all data plane operations.
--
-- /See:/ <https://aws.amazon.com/iot#DescribeEndpoint.html AWS API Reference> for DescribeEndpoint.
module Network.AWS.IoT.DescribeEndpoint
    (
    -- * Creating a Request
      describeEndpoint
    , DescribeEndpoint

    -- * Destructuring the Response
    , describeEndpointResponse
    , DescribeEndpointResponse
    -- * Response Lenses
    , dersEndpointAddress
    , dersResponseStatus
    ) where

import           Network.AWS.IoT.Types
import           Network.AWS.IoT.Types.Product
import           Network.AWS.Prelude
import           Network.AWS.Request
import           Network.AWS.Response

-- | The input for the DescribeEndpoint operation.
--
-- /See:/ 'describeEndpoint' smart constructor.
data DescribeEndpoint =
    DescribeEndpoint'
    deriving (Eq,Read,Show,Data,Typeable,Generic)

-- | Creates a value of 'DescribeEndpoint' with the minimum fields required to make a request.
--
describeEndpoint
    :: DescribeEndpoint
describeEndpoint = DescribeEndpoint'

instance AWSRequest DescribeEndpoint where
        type Rs DescribeEndpoint = DescribeEndpointResponse
        request = get ioT
        response
          = receiveJSON
              (\ s h x ->
                 DescribeEndpointResponse' <$>
                   (x .?> "endpointAddress") <*> (pure (fromEnum s)))

instance ToHeaders DescribeEndpoint where
        toHeaders = const mempty

instance ToPath DescribeEndpoint where
        toPath = const "/endpoint"

instance ToQuery DescribeEndpoint where
        toQuery = const mempty

-- | The output from the DescribeEndpoint operation.
--
-- /See:/ 'describeEndpointResponse' smart constructor.
data DescribeEndpointResponse = DescribeEndpointResponse'
    { _dersEndpointAddress :: !(Maybe Text)
    , _dersResponseStatus  :: !Int
    } deriving (Eq,Read,Show,Data,Typeable,Generic)

-- | Creates a value of 'DescribeEndpointResponse' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'dersEndpointAddress'
--
-- * 'dersResponseStatus'
describeEndpointResponse
    :: Int -- ^ 'dersResponseStatus'
    -> DescribeEndpointResponse
describeEndpointResponse pResponseStatus_ =
    DescribeEndpointResponse'
    { _dersEndpointAddress = Nothing
    , _dersResponseStatus = pResponseStatus_
    }

-- | The address.
dersEndpointAddress :: Lens' DescribeEndpointResponse (Maybe Text)
dersEndpointAddress = lens _dersEndpointAddress (\ s a -> s{_dersEndpointAddress = a});

-- | The response status code.
dersResponseStatus :: Lens' DescribeEndpointResponse Int
dersResponseStatus = lens _dersResponseStatus (\ s a -> s{_dersResponseStatus = a});