{-# 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.Route53.ListTrafficPolicyInstancesByHostedZone
-- 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)
--
-- Gets information about the traffic policy instances that you created in
-- a specified hosted zone.
--
-- After you submit an 'UpdateTrafficPolicyInstance' request, there\'s a
-- brief delay while Amazon Route 53 creates the resource record sets that
-- are specified in the traffic policy definition. For more information,
-- see the < State> response element.
--
-- To get information about the traffic policy instances that you created
-- in a specified hosted zone, send a 'GET' request to the
-- '\/Route 53 API version\/trafficpolicyinstance' resource and include the
-- ID of the hosted zone.
--
-- Amazon Route 53 returns a maximum of 100 items in each response. If you
-- have a lot of traffic policy instances, you can use the 'MaxItems'
-- parameter to list them in groups of up to 100.
--
-- The response includes four values that help you navigate from one group
-- of 'MaxItems' traffic policy instances to the next:
--
-- -   __IsTruncated__
-- -   __MaxItems__
-- -   __TrafficPolicyInstanceNameMarker__ and
--     __TrafficPolicyInstanceTypeMarker__
module Network.AWS.Route53.ListTrafficPolicyInstancesByHostedZone
    (
    -- * Creating a Request
      listTrafficPolicyInstancesByHostedZone
    , ListTrafficPolicyInstancesByHostedZone
    -- * Request Lenses
    , ltpibhzTrafficPolicyInstanceTypeMarker
    , ltpibhzMaxItems
    , ltpibhzTrafficPolicyInstanceNameMarker
    , ltpibhzHostedZoneId

    -- * Destructuring the Response
    , listTrafficPolicyInstancesByHostedZoneResponse
    , ListTrafficPolicyInstancesByHostedZoneResponse
    -- * Response Lenses
    , ltpibhzrsTrafficPolicyInstanceTypeMarker
    , ltpibhzrsTrafficPolicyInstanceNameMarker
    , ltpibhzrsResponseStatus
    , ltpibhzrsTrafficPolicyInstances
    , ltpibhzrsIsTruncated
    , ltpibhzrsMaxItems
    ) where

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

-- | A request for the traffic policy instances that you created in a
-- specified hosted zone.
--
-- /See:/ 'listTrafficPolicyInstancesByHostedZone' smart constructor.
data ListTrafficPolicyInstancesByHostedZone = ListTrafficPolicyInstancesByHostedZone'
    { _ltpibhzTrafficPolicyInstanceTypeMarker :: !(Maybe RecordType)
    , _ltpibhzMaxItems                        :: !(Maybe Text)
    , _ltpibhzTrafficPolicyInstanceNameMarker :: !(Maybe Text)
    , _ltpibhzHostedZoneId                    :: !Text
    } deriving (Eq,Read,Show,Data,Typeable,Generic)

-- | Creates a value of 'ListTrafficPolicyInstancesByHostedZone' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'ltpibhzTrafficPolicyInstanceTypeMarker'
--
-- * 'ltpibhzMaxItems'
--
-- * 'ltpibhzTrafficPolicyInstanceNameMarker'
--
-- * 'ltpibhzHostedZoneId'
listTrafficPolicyInstancesByHostedZone
    :: Text -- ^ 'ltpibhzHostedZoneId'
    -> ListTrafficPolicyInstancesByHostedZone
listTrafficPolicyInstancesByHostedZone pHostedZoneId_ =
    ListTrafficPolicyInstancesByHostedZone'
    { _ltpibhzTrafficPolicyInstanceTypeMarker = Nothing
    , _ltpibhzMaxItems = Nothing
    , _ltpibhzTrafficPolicyInstanceNameMarker = Nothing
    , _ltpibhzHostedZoneId = pHostedZoneId_
    }

-- | For the first request to 'ListTrafficPolicyInstancesByHostedZone', omit
-- this value.
--
-- If the value of 'IsTruncated' in the previous response was 'true',
-- 'TrafficPolicyInstanceTypeMarker' is the DNS type of the first traffic
-- policy instance in the next group of 'MaxItems' traffic policy
-- instances.
--
-- If the value of 'IsTruncated' in the previous response was 'false',
-- there are no more traffic policy instances to get for this hosted zone.
ltpibhzTrafficPolicyInstanceTypeMarker :: Lens' ListTrafficPolicyInstancesByHostedZone (Maybe RecordType)
ltpibhzTrafficPolicyInstanceTypeMarker = lens _ltpibhzTrafficPolicyInstanceTypeMarker (\ s a -> s{_ltpibhzTrafficPolicyInstanceTypeMarker = a});

-- | The maximum number of traffic policy instances to be included in the
-- response body for this request. If you have more than 'MaxItems' traffic
-- policy instances, the value of the 'IsTruncated' element in the response
-- is 'true', and the values of 'HostedZoneIdMarker',
-- 'TrafficPolicyInstanceNameMarker', and 'TrafficPolicyInstanceTypeMarker'
-- represent the first traffic policy instance in the next group of
-- 'MaxItems' traffic policy instances.
ltpibhzMaxItems :: Lens' ListTrafficPolicyInstancesByHostedZone (Maybe Text)
ltpibhzMaxItems = lens _ltpibhzMaxItems (\ s a -> s{_ltpibhzMaxItems = a});

-- | For the first request to 'ListTrafficPolicyInstancesByHostedZone', omit
-- this value.
--
-- If the value of 'IsTruncated' in the previous response was 'true',
-- 'TrafficPolicyInstanceNameMarker' is the name of the first traffic
-- policy instance in the next group of 'MaxItems' traffic policy
-- instances.
--
-- If the value of 'IsTruncated' in the previous response was 'false',
-- there are no more traffic policy instances to get for this hosted zone.
--
-- If the value of 'IsTruncated' in the previous response was 'false', omit
-- this value.
ltpibhzTrafficPolicyInstanceNameMarker :: Lens' ListTrafficPolicyInstancesByHostedZone (Maybe Text)
ltpibhzTrafficPolicyInstanceNameMarker = lens _ltpibhzTrafficPolicyInstanceNameMarker (\ s a -> s{_ltpibhzTrafficPolicyInstanceNameMarker = a});

-- | The ID of the hosted zone for which you want to list traffic policy
-- instances.
ltpibhzHostedZoneId :: Lens' ListTrafficPolicyInstancesByHostedZone Text
ltpibhzHostedZoneId = lens _ltpibhzHostedZoneId (\ s a -> s{_ltpibhzHostedZoneId = a});

instance AWSRequest
         ListTrafficPolicyInstancesByHostedZone where
        type Rs ListTrafficPolicyInstancesByHostedZone =
             ListTrafficPolicyInstancesByHostedZoneResponse
        request = get route53
        response
          = receiveXML
              (\ s h x ->
                 ListTrafficPolicyInstancesByHostedZoneResponse' <$>
                   (x .@? "TrafficPolicyInstanceTypeMarker") <*>
                     (x .@? "TrafficPolicyInstanceNameMarker")
                     <*> (pure (fromEnum s))
                     <*>
                     (x .@? "TrafficPolicyInstances" .!@ mempty >>=
                        parseXMLList "TrafficPolicyInstance")
                     <*> (x .@ "IsTruncated")
                     <*> (x .@ "MaxItems"))

instance Hashable
         ListTrafficPolicyInstancesByHostedZone

instance NFData
         ListTrafficPolicyInstancesByHostedZone

instance ToHeaders
         ListTrafficPolicyInstancesByHostedZone where
        toHeaders = const mempty

instance ToPath
         ListTrafficPolicyInstancesByHostedZone where
        toPath
          = const
              "/2013-04-01/trafficpolicyinstances/hostedzone"

instance ToQuery
         ListTrafficPolicyInstancesByHostedZone where
        toQuery ListTrafficPolicyInstancesByHostedZone'{..}
          = mconcat
              ["trafficpolicyinstancetype" =:
                 _ltpibhzTrafficPolicyInstanceTypeMarker,
               "maxitems" =: _ltpibhzMaxItems,
               "trafficpolicyinstancename" =:
                 _ltpibhzTrafficPolicyInstanceNameMarker,
               "id" =: _ltpibhzHostedZoneId]

-- | A complex type that contains the response information for the request.
--
-- /See:/ 'listTrafficPolicyInstancesByHostedZoneResponse' smart constructor.
data ListTrafficPolicyInstancesByHostedZoneResponse = ListTrafficPolicyInstancesByHostedZoneResponse'
    { _ltpibhzrsTrafficPolicyInstanceTypeMarker :: !(Maybe RecordType)
    , _ltpibhzrsTrafficPolicyInstanceNameMarker :: !(Maybe Text)
    , _ltpibhzrsResponseStatus                  :: !Int
    , _ltpibhzrsTrafficPolicyInstances          :: ![TrafficPolicyInstance]
    , _ltpibhzrsIsTruncated                     :: !Bool
    , _ltpibhzrsMaxItems                        :: !Text
    } deriving (Eq,Read,Show,Data,Typeable,Generic)

-- | Creates a value of 'ListTrafficPolicyInstancesByHostedZoneResponse' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'ltpibhzrsTrafficPolicyInstanceTypeMarker'
--
-- * 'ltpibhzrsTrafficPolicyInstanceNameMarker'
--
-- * 'ltpibhzrsResponseStatus'
--
-- * 'ltpibhzrsTrafficPolicyInstances'
--
-- * 'ltpibhzrsIsTruncated'
--
-- * 'ltpibhzrsMaxItems'
listTrafficPolicyInstancesByHostedZoneResponse
    :: Int -- ^ 'ltpibhzrsResponseStatus'
    -> Bool -- ^ 'ltpibhzrsIsTruncated'
    -> Text -- ^ 'ltpibhzrsMaxItems'
    -> ListTrafficPolicyInstancesByHostedZoneResponse
listTrafficPolicyInstancesByHostedZoneResponse pResponseStatus_ pIsTruncated_ pMaxItems_ =
    ListTrafficPolicyInstancesByHostedZoneResponse'
    { _ltpibhzrsTrafficPolicyInstanceTypeMarker = Nothing
    , _ltpibhzrsTrafficPolicyInstanceNameMarker = Nothing
    , _ltpibhzrsResponseStatus = pResponseStatus_
    , _ltpibhzrsTrafficPolicyInstances = mempty
    , _ltpibhzrsIsTruncated = pIsTruncated_
    , _ltpibhzrsMaxItems = pMaxItems_
    }

-- | If 'IsTruncated' is true, 'TrafficPolicyInstanceTypeMarker' is the DNS
-- type of the resource record sets that are associated with the first
-- traffic policy instance in the next group of 'MaxItems' traffic policy
-- instances.
ltpibhzrsTrafficPolicyInstanceTypeMarker :: Lens' ListTrafficPolicyInstancesByHostedZoneResponse (Maybe RecordType)
ltpibhzrsTrafficPolicyInstanceTypeMarker = lens _ltpibhzrsTrafficPolicyInstanceTypeMarker (\ s a -> s{_ltpibhzrsTrafficPolicyInstanceTypeMarker = a});

-- | If 'IsTruncated' is 'true', 'TrafficPolicyInstanceNameMarker' is the
-- name of the first traffic policy instance in the next group of
-- 'MaxItems' traffic policy instances.
ltpibhzrsTrafficPolicyInstanceNameMarker :: Lens' ListTrafficPolicyInstancesByHostedZoneResponse (Maybe Text)
ltpibhzrsTrafficPolicyInstanceNameMarker = lens _ltpibhzrsTrafficPolicyInstanceNameMarker (\ s a -> s{_ltpibhzrsTrafficPolicyInstanceNameMarker = a});

-- | The response status code.
ltpibhzrsResponseStatus :: Lens' ListTrafficPolicyInstancesByHostedZoneResponse Int
ltpibhzrsResponseStatus = lens _ltpibhzrsResponseStatus (\ s a -> s{_ltpibhzrsResponseStatus = a});

-- | A list that contains one 'TrafficPolicyInstance' element for each
-- traffic policy instance that matches the elements in the request.
ltpibhzrsTrafficPolicyInstances :: Lens' ListTrafficPolicyInstancesByHostedZoneResponse [TrafficPolicyInstance]
ltpibhzrsTrafficPolicyInstances = lens _ltpibhzrsTrafficPolicyInstances (\ s a -> s{_ltpibhzrsTrafficPolicyInstances = a}) . _Coerce;

-- | A flag that indicates whether there are more traffic policy instances to
-- be listed. If the response was truncated, you can get the next group of
-- 'MaxItems' traffic policy instances by calling
-- 'ListTrafficPolicyInstancesByHostedZone' again and specifying the values
-- of the 'HostedZoneIdMarker', 'TrafficPolicyInstanceNameMarker', and
-- 'TrafficPolicyInstanceTypeMarker' elements in the corresponding request
-- parameters.
--
-- Valid Values: 'true' | 'false'
ltpibhzrsIsTruncated :: Lens' ListTrafficPolicyInstancesByHostedZoneResponse Bool
ltpibhzrsIsTruncated = lens _ltpibhzrsIsTruncated (\ s a -> s{_ltpibhzrsIsTruncated = a});

-- | The value that you specified for the 'MaxItems' parameter in the call to
-- 'ListTrafficPolicyInstancesByHostedZone' that produced the current
-- response.
ltpibhzrsMaxItems :: Lens' ListTrafficPolicyInstancesByHostedZoneResponse Text
ltpibhzrsMaxItems = lens _ltpibhzrsMaxItems (\ s a -> s{_ltpibhzrsMaxItems = a});

instance NFData
         ListTrafficPolicyInstancesByHostedZoneResponse