{-# 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.GetInventory
(
getInventory
, GetInventory
, giAggregators
, giFilters
, giResultAttributes
, giNextToken
, giMaxResults
, getInventoryResponse
, GetInventoryResponse
, girsEntities
, girsNextToken
, girsResponseStatus
) where
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
import Network.AWS.SSM.Types
import Network.AWS.SSM.Types.Product
data GetInventory = GetInventory'
{ _giAggregators :: !(Maybe (List1 InventoryAggregator))
, _giFilters :: !(Maybe (List1 InventoryFilter))
, _giResultAttributes :: !(Maybe (List1 ResultAttribute))
, _giNextToken :: !(Maybe Text)
, _giMaxResults :: !(Maybe Nat)
} deriving (Eq, Read, Show, Data, Typeable, Generic)
getInventory
:: GetInventory
getInventory =
GetInventory'
{ _giAggregators = Nothing
, _giFilters = Nothing
, _giResultAttributes = Nothing
, _giNextToken = Nothing
, _giMaxResults = Nothing
}
giAggregators :: Lens' GetInventory (Maybe (NonEmpty InventoryAggregator))
giAggregators = lens _giAggregators (\ s a -> s{_giAggregators = a}) . mapping _List1
giFilters :: Lens' GetInventory (Maybe (NonEmpty InventoryFilter))
giFilters = lens _giFilters (\ s a -> s{_giFilters = a}) . mapping _List1
giResultAttributes :: Lens' GetInventory (Maybe (NonEmpty ResultAttribute))
giResultAttributes = lens _giResultAttributes (\ s a -> s{_giResultAttributes = a}) . mapping _List1
giNextToken :: Lens' GetInventory (Maybe Text)
giNextToken = lens _giNextToken (\ s a -> s{_giNextToken = a})
giMaxResults :: Lens' GetInventory (Maybe Natural)
giMaxResults = lens _giMaxResults (\ s a -> s{_giMaxResults = a}) . mapping _Nat
instance AWSRequest GetInventory where
type Rs GetInventory = GetInventoryResponse
request = postJSON ssm
response
= receiveJSON
(\ s h x ->
GetInventoryResponse' <$>
(x .?> "Entities" .!@ mempty) <*> (x .?> "NextToken")
<*> (pure (fromEnum s)))
instance Hashable GetInventory where
instance NFData GetInventory where
instance ToHeaders GetInventory where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("AmazonSSM.GetInventory" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON GetInventory where
toJSON GetInventory'{..}
= object
(catMaybes
[("Aggregators" .=) <$> _giAggregators,
("Filters" .=) <$> _giFilters,
("ResultAttributes" .=) <$> _giResultAttributes,
("NextToken" .=) <$> _giNextToken,
("MaxResults" .=) <$> _giMaxResults])
instance ToPath GetInventory where
toPath = const "/"
instance ToQuery GetInventory where
toQuery = const mempty
data GetInventoryResponse = GetInventoryResponse'
{ _girsEntities :: !(Maybe [InventoryResultEntity])
, _girsNextToken :: !(Maybe Text)
, _girsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
getInventoryResponse
:: Int
-> GetInventoryResponse
getInventoryResponse pResponseStatus_ =
GetInventoryResponse'
{ _girsEntities = Nothing
, _girsNextToken = Nothing
, _girsResponseStatus = pResponseStatus_
}
girsEntities :: Lens' GetInventoryResponse [InventoryResultEntity]
girsEntities = lens _girsEntities (\ s a -> s{_girsEntities = a}) . _Default . _Coerce
girsNextToken :: Lens' GetInventoryResponse (Maybe Text)
girsNextToken = lens _girsNextToken (\ s a -> s{_girsNextToken = a})
girsResponseStatus :: Lens' GetInventoryResponse Int
girsResponseStatus = lens _girsResponseStatus (\ s a -> s{_girsResponseStatus = a})
instance NFData GetInventoryResponse where