{-# 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 #-}
module Network.AWS.SSM.GetParameterHistory
(
getParameterHistory
, GetParameterHistory
, gphWithDecryption
, gphNextToken
, gphMaxResults
, gphName
, getParameterHistoryResponse
, GetParameterHistoryResponse
, gphrsNextToken
, gphrsParameters
, gphrsResponseStatus
) where
import Network.AWS.Lens
import Network.AWS.Pager
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
import Network.AWS.SSM.Types
import Network.AWS.SSM.Types.Product
data GetParameterHistory = GetParameterHistory'
{ _gphWithDecryption :: !(Maybe Bool)
, _gphNextToken :: !(Maybe Text)
, _gphMaxResults :: !(Maybe Nat)
, _gphName :: !Text
} deriving (Eq, Read, Show, Data, Typeable, Generic)
getParameterHistory
:: Text
-> GetParameterHistory
getParameterHistory pName_ =
GetParameterHistory'
{ _gphWithDecryption = Nothing
, _gphNextToken = Nothing
, _gphMaxResults = Nothing
, _gphName = pName_
}
gphWithDecryption :: Lens' GetParameterHistory (Maybe Bool)
gphWithDecryption = lens _gphWithDecryption (\ s a -> s{_gphWithDecryption = a})
gphNextToken :: Lens' GetParameterHistory (Maybe Text)
gphNextToken = lens _gphNextToken (\ s a -> s{_gphNextToken = a})
gphMaxResults :: Lens' GetParameterHistory (Maybe Natural)
gphMaxResults = lens _gphMaxResults (\ s a -> s{_gphMaxResults = a}) . mapping _Nat
gphName :: Lens' GetParameterHistory Text
gphName = lens _gphName (\ s a -> s{_gphName = a})
instance AWSPager GetParameterHistory where
page rq rs
| stop (rs ^. gphrsNextToken) = Nothing
| stop (rs ^. gphrsParameters) = Nothing
| otherwise =
Just $ rq & gphNextToken .~ rs ^. gphrsNextToken
instance AWSRequest GetParameterHistory where
type Rs GetParameterHistory =
GetParameterHistoryResponse
request = postJSON ssm
response
= receiveJSON
(\ s h x ->
GetParameterHistoryResponse' <$>
(x .?> "NextToken") <*>
(x .?> "Parameters" .!@ mempty)
<*> (pure (fromEnum s)))
instance Hashable GetParameterHistory where
instance NFData GetParameterHistory where
instance ToHeaders GetParameterHistory where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("AmazonSSM.GetParameterHistory" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON GetParameterHistory where
toJSON GetParameterHistory'{..}
= object
(catMaybes
[("WithDecryption" .=) <$> _gphWithDecryption,
("NextToken" .=) <$> _gphNextToken,
("MaxResults" .=) <$> _gphMaxResults,
Just ("Name" .= _gphName)])
instance ToPath GetParameterHistory where
toPath = const "/"
instance ToQuery GetParameterHistory where
toQuery = const mempty
data GetParameterHistoryResponse = GetParameterHistoryResponse'
{ _gphrsNextToken :: !(Maybe Text)
, _gphrsParameters :: !(Maybe [ParameterHistory])
, _gphrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
getParameterHistoryResponse
:: Int
-> GetParameterHistoryResponse
getParameterHistoryResponse pResponseStatus_ =
GetParameterHistoryResponse'
{ _gphrsNextToken = Nothing
, _gphrsParameters = Nothing
, _gphrsResponseStatus = pResponseStatus_
}
gphrsNextToken :: Lens' GetParameterHistoryResponse (Maybe Text)
gphrsNextToken = lens _gphrsNextToken (\ s a -> s{_gphrsNextToken = a})
gphrsParameters :: Lens' GetParameterHistoryResponse [ParameterHistory]
gphrsParameters = lens _gphrsParameters (\ s a -> s{_gphrsParameters = a}) . _Default . _Coerce
gphrsResponseStatus :: Lens' GetParameterHistoryResponse Int
gphrsResponseStatus = lens _gphrsResponseStatus (\ s a -> s{_gphrsResponseStatus = a})
instance NFData GetParameterHistoryResponse where