{-# 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.Greengrass.CreateFunctionDefinitionVersion
(
createFunctionDefinitionVersion
, CreateFunctionDefinitionVersion
, cfdvAmznClientToken
, cfdvFunctions
, cfdvFunctionDefinitionId
, createFunctionDefinitionVersionResponse
, CreateFunctionDefinitionVersionResponse
, cfdvrsARN
, cfdvrsCreationTimestamp
, cfdvrsVersion
, cfdvrsId
, cfdvrsResponseStatus
) where
import Network.AWS.Greengrass.Types
import Network.AWS.Greengrass.Types.Product
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data CreateFunctionDefinitionVersion = CreateFunctionDefinitionVersion'
{ _cfdvAmznClientToken :: !(Maybe Text)
, _cfdvFunctions :: !(Maybe [Function])
, _cfdvFunctionDefinitionId :: !Text
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createFunctionDefinitionVersion
:: Text
-> CreateFunctionDefinitionVersion
createFunctionDefinitionVersion pFunctionDefinitionId_ =
CreateFunctionDefinitionVersion'
{ _cfdvAmznClientToken = Nothing
, _cfdvFunctions = Nothing
, _cfdvFunctionDefinitionId = pFunctionDefinitionId_
}
cfdvAmznClientToken :: Lens' CreateFunctionDefinitionVersion (Maybe Text)
cfdvAmznClientToken = lens _cfdvAmznClientToken (\ s a -> s{_cfdvAmznClientToken = a})
cfdvFunctions :: Lens' CreateFunctionDefinitionVersion [Function]
cfdvFunctions = lens _cfdvFunctions (\ s a -> s{_cfdvFunctions = a}) . _Default . _Coerce
cfdvFunctionDefinitionId :: Lens' CreateFunctionDefinitionVersion Text
cfdvFunctionDefinitionId = lens _cfdvFunctionDefinitionId (\ s a -> s{_cfdvFunctionDefinitionId = a})
instance AWSRequest CreateFunctionDefinitionVersion
where
type Rs CreateFunctionDefinitionVersion =
CreateFunctionDefinitionVersionResponse
request = postJSON greengrass
response
= receiveJSON
(\ s h x ->
CreateFunctionDefinitionVersionResponse' <$>
(x .?> "Arn") <*> (x .?> "CreationTimestamp") <*>
(x .?> "Version")
<*> (x .?> "Id")
<*> (pure (fromEnum s)))
instance Hashable CreateFunctionDefinitionVersion
where
instance NFData CreateFunctionDefinitionVersion where
instance ToHeaders CreateFunctionDefinitionVersion
where
toHeaders CreateFunctionDefinitionVersion'{..}
= mconcat
["X-Amzn-Client-Token" =# _cfdvAmznClientToken,
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)]
instance ToJSON CreateFunctionDefinitionVersion where
toJSON CreateFunctionDefinitionVersion'{..}
= object
(catMaybes [("Functions" .=) <$> _cfdvFunctions])
instance ToPath CreateFunctionDefinitionVersion where
toPath CreateFunctionDefinitionVersion'{..}
= mconcat
["/greengrass/definition/functions/",
toBS _cfdvFunctionDefinitionId, "/versions"]
instance ToQuery CreateFunctionDefinitionVersion
where
toQuery = const mempty
data CreateFunctionDefinitionVersionResponse = CreateFunctionDefinitionVersionResponse'
{ _cfdvrsARN :: !(Maybe Text)
, _cfdvrsCreationTimestamp :: !(Maybe Text)
, _cfdvrsVersion :: !(Maybe Text)
, _cfdvrsId :: !(Maybe Text)
, _cfdvrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createFunctionDefinitionVersionResponse
:: Int
-> CreateFunctionDefinitionVersionResponse
createFunctionDefinitionVersionResponse pResponseStatus_ =
CreateFunctionDefinitionVersionResponse'
{ _cfdvrsARN = Nothing
, _cfdvrsCreationTimestamp = Nothing
, _cfdvrsVersion = Nothing
, _cfdvrsId = Nothing
, _cfdvrsResponseStatus = pResponseStatus_
}
cfdvrsARN :: Lens' CreateFunctionDefinitionVersionResponse (Maybe Text)
cfdvrsARN = lens _cfdvrsARN (\ s a -> s{_cfdvrsARN = a})
cfdvrsCreationTimestamp :: Lens' CreateFunctionDefinitionVersionResponse (Maybe Text)
cfdvrsCreationTimestamp = lens _cfdvrsCreationTimestamp (\ s a -> s{_cfdvrsCreationTimestamp = a})
cfdvrsVersion :: Lens' CreateFunctionDefinitionVersionResponse (Maybe Text)
cfdvrsVersion = lens _cfdvrsVersion (\ s a -> s{_cfdvrsVersion = a})
cfdvrsId :: Lens' CreateFunctionDefinitionVersionResponse (Maybe Text)
cfdvrsId = lens _cfdvrsId (\ s a -> s{_cfdvrsId = a})
cfdvrsResponseStatus :: Lens' CreateFunctionDefinitionVersionResponse Int
cfdvrsResponseStatus = lens _cfdvrsResponseStatus (\ s a -> s{_cfdvrsResponseStatus = a})
instance NFData
CreateFunctionDefinitionVersionResponse
where