{-# 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.StepFunctions.CreateStateMachine
(
createStateMachine
, CreateStateMachine
, csmName
, csmDefinition
, csmRoleARN
, createStateMachineResponse
, CreateStateMachineResponse
, csmrsResponseStatus
, csmrsStateMachineARN
, csmrsCreationDate
) where
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
import Network.AWS.StepFunctions.Types
import Network.AWS.StepFunctions.Types.Product
data CreateStateMachine = CreateStateMachine'
{ _csmName :: !Text
, _csmDefinition :: !Text
, _csmRoleARN :: !Text
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createStateMachine
:: Text
-> Text
-> Text
-> CreateStateMachine
createStateMachine pName_ pDefinition_ pRoleARN_ =
CreateStateMachine'
{_csmName = pName_, _csmDefinition = pDefinition_, _csmRoleARN = pRoleARN_}
csmName :: Lens' CreateStateMachine Text
csmName = lens _csmName (\ s a -> s{_csmName = a})
csmDefinition :: Lens' CreateStateMachine Text
csmDefinition = lens _csmDefinition (\ s a -> s{_csmDefinition = a})
csmRoleARN :: Lens' CreateStateMachine Text
csmRoleARN = lens _csmRoleARN (\ s a -> s{_csmRoleARN = a})
instance AWSRequest CreateStateMachine where
type Rs CreateStateMachine =
CreateStateMachineResponse
request = postJSON stepFunctions
response
= receiveJSON
(\ s h x ->
CreateStateMachineResponse' <$>
(pure (fromEnum s)) <*> (x .:> "stateMachineArn") <*>
(x .:> "creationDate"))
instance Hashable CreateStateMachine where
instance NFData CreateStateMachine where
instance ToHeaders CreateStateMachine where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("AWSStepFunctions.CreateStateMachine" ::
ByteString),
"Content-Type" =#
("application/x-amz-json-1.0" :: ByteString)])
instance ToJSON CreateStateMachine where
toJSON CreateStateMachine'{..}
= object
(catMaybes
[Just ("name" .= _csmName),
Just ("definition" .= _csmDefinition),
Just ("roleArn" .= _csmRoleARN)])
instance ToPath CreateStateMachine where
toPath = const "/"
instance ToQuery CreateStateMachine where
toQuery = const mempty
data CreateStateMachineResponse = CreateStateMachineResponse'
{ _csmrsResponseStatus :: !Int
, _csmrsStateMachineARN :: !Text
, _csmrsCreationDate :: !POSIX
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createStateMachineResponse
:: Int
-> Text
-> UTCTime
-> CreateStateMachineResponse
createStateMachineResponse pResponseStatus_ pStateMachineARN_ pCreationDate_ =
CreateStateMachineResponse'
{ _csmrsResponseStatus = pResponseStatus_
, _csmrsStateMachineARN = pStateMachineARN_
, _csmrsCreationDate = _Time # pCreationDate_
}
csmrsResponseStatus :: Lens' CreateStateMachineResponse Int
csmrsResponseStatus = lens _csmrsResponseStatus (\ s a -> s{_csmrsResponseStatus = a})
csmrsStateMachineARN :: Lens' CreateStateMachineResponse Text
csmrsStateMachineARN = lens _csmrsStateMachineARN (\ s a -> s{_csmrsStateMachineARN = a})
csmrsCreationDate :: Lens' CreateStateMachineResponse UTCTime
csmrsCreationDate = lens _csmrsCreationDate (\ s a -> s{_csmrsCreationDate = a}) . _Time
instance NFData CreateStateMachineResponse where