module Network.AWS.ServiceCatalog.ListPortfoliosForProduct
    (
    
      listPortfoliosForProduct
    , ListPortfoliosForProduct
    
    , lisAcceptLanguage
    , lisPageToken
    , lisPageSize
    , lisProductId
    
    , listPortfoliosForProductResponse
    , ListPortfoliosForProductResponse
    
    , lpfprsNextPageToken
    , lpfprsPortfolioDetails
    , lpfprsResponseStatus
    ) where
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
import Network.AWS.ServiceCatalog.Types
import Network.AWS.ServiceCatalog.Types.Product
data ListPortfoliosForProduct = ListPortfoliosForProduct'
  { _lisAcceptLanguage :: !(Maybe Text)
  , _lisPageToken      :: !(Maybe Text)
  , _lisPageSize       :: !(Maybe Nat)
  , _lisProductId      :: !Text
  } deriving (Eq, Read, Show, Data, Typeable, Generic)
listPortfoliosForProduct
    :: Text 
    -> ListPortfoliosForProduct
listPortfoliosForProduct pProductId_ =
  ListPortfoliosForProduct'
  { _lisAcceptLanguage = Nothing
  , _lisPageToken = Nothing
  , _lisPageSize = Nothing
  , _lisProductId = pProductId_
  }
lisAcceptLanguage :: Lens' ListPortfoliosForProduct (Maybe Text)
lisAcceptLanguage = lens _lisAcceptLanguage (\ s a -> s{_lisAcceptLanguage = a});
lisPageToken :: Lens' ListPortfoliosForProduct (Maybe Text)
lisPageToken = lens _lisPageToken (\ s a -> s{_lisPageToken = a});
lisPageSize :: Lens' ListPortfoliosForProduct (Maybe Natural)
lisPageSize = lens _lisPageSize (\ s a -> s{_lisPageSize = a}) . mapping _Nat;
lisProductId :: Lens' ListPortfoliosForProduct Text
lisProductId = lens _lisProductId (\ s a -> s{_lisProductId = a});
instance AWSRequest ListPortfoliosForProduct where
        type Rs ListPortfoliosForProduct =
             ListPortfoliosForProductResponse
        request = postJSON serviceCatalog
        response
          = receiveJSON
              (\ s h x ->
                 ListPortfoliosForProductResponse' <$>
                   (x .?> "NextPageToken") <*>
                     (x .?> "PortfolioDetails" .!@ mempty)
                     <*> (pure (fromEnum s)))
instance Hashable ListPortfoliosForProduct where
instance NFData ListPortfoliosForProduct where
instance ToHeaders ListPortfoliosForProduct where
        toHeaders
          = const
              (mconcat
                 ["X-Amz-Target" =#
                    ("AWS242ServiceCatalogService.ListPortfoliosForProduct"
                       :: ByteString),
                  "Content-Type" =#
                    ("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON ListPortfoliosForProduct where
        toJSON ListPortfoliosForProduct'{..}
          = object
              (catMaybes
                 [("AcceptLanguage" .=) <$> _lisAcceptLanguage,
                  ("PageToken" .=) <$> _lisPageToken,
                  ("PageSize" .=) <$> _lisPageSize,
                  Just ("ProductId" .= _lisProductId)])
instance ToPath ListPortfoliosForProduct where
        toPath = const "/"
instance ToQuery ListPortfoliosForProduct where
        toQuery = const mempty
data ListPortfoliosForProductResponse = ListPortfoliosForProductResponse'
  { _lpfprsNextPageToken    :: !(Maybe Text)
  , _lpfprsPortfolioDetails :: !(Maybe [PortfolioDetail])
  , _lpfprsResponseStatus   :: !Int
  } deriving (Eq, Read, Show, Data, Typeable, Generic)
listPortfoliosForProductResponse
    :: Int 
    -> ListPortfoliosForProductResponse
listPortfoliosForProductResponse pResponseStatus_ =
  ListPortfoliosForProductResponse'
  { _lpfprsNextPageToken = Nothing
  , _lpfprsPortfolioDetails = Nothing
  , _lpfprsResponseStatus = pResponseStatus_
  }
lpfprsNextPageToken :: Lens' ListPortfoliosForProductResponse (Maybe Text)
lpfprsNextPageToken = lens _lpfprsNextPageToken (\ s a -> s{_lpfprsNextPageToken = a});
lpfprsPortfolioDetails :: Lens' ListPortfoliosForProductResponse [PortfolioDetail]
lpfprsPortfolioDetails = lens _lpfprsPortfolioDetails (\ s a -> s{_lpfprsPortfolioDetails = a}) . _Default . _Coerce;
lpfprsResponseStatus :: Lens' ListPortfoliosForProductResponse Int
lpfprsResponseStatus = lens _lpfprsResponseStatus (\ s a -> s{_lpfprsResponseStatus = a});
instance NFData ListPortfoliosForProductResponse
         where