{-# 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.Lightsail.GetInstancePortStates
(
getInstancePortStates
, GetInstancePortStates
, gipsInstanceName
, getInstancePortStatesResponse
, GetInstancePortStatesResponse
, gipsrsPortStates
, gipsrsResponseStatus
) where
import Network.AWS.Lens
import Network.AWS.Lightsail.Types
import Network.AWS.Lightsail.Types.Product
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
newtype GetInstancePortStates = GetInstancePortStates'
{ _gipsInstanceName :: Text
} deriving (Eq, Read, Show, Data, Typeable, Generic)
getInstancePortStates
:: Text
-> GetInstancePortStates
getInstancePortStates pInstanceName_ =
GetInstancePortStates' {_gipsInstanceName = pInstanceName_}
gipsInstanceName :: Lens' GetInstancePortStates Text
gipsInstanceName = lens _gipsInstanceName (\ s a -> s{_gipsInstanceName = a})
instance AWSRequest GetInstancePortStates where
type Rs GetInstancePortStates =
GetInstancePortStatesResponse
request = postJSON lightsail
response
= receiveJSON
(\ s h x ->
GetInstancePortStatesResponse' <$>
(x .?> "portStates" .!@ mempty) <*>
(pure (fromEnum s)))
instance Hashable GetInstancePortStates where
instance NFData GetInstancePortStates where
instance ToHeaders GetInstancePortStates where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("Lightsail_20161128.GetInstancePortStates" ::
ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON GetInstancePortStates where
toJSON GetInstancePortStates'{..}
= object
(catMaybes
[Just ("instanceName" .= _gipsInstanceName)])
instance ToPath GetInstancePortStates where
toPath = const "/"
instance ToQuery GetInstancePortStates where
toQuery = const mempty
data GetInstancePortStatesResponse = GetInstancePortStatesResponse'
{ _gipsrsPortStates :: !(Maybe [InstancePortState])
, _gipsrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
getInstancePortStatesResponse
:: Int
-> GetInstancePortStatesResponse
getInstancePortStatesResponse pResponseStatus_ =
GetInstancePortStatesResponse'
{_gipsrsPortStates = Nothing, _gipsrsResponseStatus = pResponseStatus_}
gipsrsPortStates :: Lens' GetInstancePortStatesResponse [InstancePortState]
gipsrsPortStates = lens _gipsrsPortStates (\ s a -> s{_gipsrsPortStates = a}) . _Default . _Coerce
gipsrsResponseStatus :: Lens' GetInstancePortStatesResponse Int
gipsrsResponseStatus = lens _gipsrsResponseStatus (\ s a -> s{_gipsrsResponseStatus = a})
instance NFData GetInstancePortStatesResponse where