{-# 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.CreateDeployment
(
createDeployment
, CreateDeployment
, cdDeploymentId
, cdAmznClientToken
, cdDeploymentType
, cdGroupVersionId
, cdGroupId
, createDeploymentResponse
, CreateDeploymentResponse
, cdrsDeploymentId
, cdrsDeploymentARN
, cdrsResponseStatus
) 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 CreateDeployment = CreateDeployment'
{ _cdDeploymentId :: !(Maybe Text)
, _cdAmznClientToken :: !(Maybe Text)
, _cdDeploymentType :: !(Maybe DeploymentType)
, _cdGroupVersionId :: !(Maybe Text)
, _cdGroupId :: !Text
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createDeployment
:: Text
-> CreateDeployment
createDeployment pGroupId_ =
CreateDeployment'
{ _cdDeploymentId = Nothing
, _cdAmznClientToken = Nothing
, _cdDeploymentType = Nothing
, _cdGroupVersionId = Nothing
, _cdGroupId = pGroupId_
}
cdDeploymentId :: Lens' CreateDeployment (Maybe Text)
cdDeploymentId = lens _cdDeploymentId (\ s a -> s{_cdDeploymentId = a})
cdAmznClientToken :: Lens' CreateDeployment (Maybe Text)
cdAmznClientToken = lens _cdAmznClientToken (\ s a -> s{_cdAmznClientToken = a})
cdDeploymentType :: Lens' CreateDeployment (Maybe DeploymentType)
cdDeploymentType = lens _cdDeploymentType (\ s a -> s{_cdDeploymentType = a})
cdGroupVersionId :: Lens' CreateDeployment (Maybe Text)
cdGroupVersionId = lens _cdGroupVersionId (\ s a -> s{_cdGroupVersionId = a})
cdGroupId :: Lens' CreateDeployment Text
cdGroupId = lens _cdGroupId (\ s a -> s{_cdGroupId = a})
instance AWSRequest CreateDeployment where
type Rs CreateDeployment = CreateDeploymentResponse
request = postJSON greengrass
response
= receiveJSON
(\ s h x ->
CreateDeploymentResponse' <$>
(x .?> "DeploymentId") <*> (x .?> "DeploymentArn")
<*> (pure (fromEnum s)))
instance Hashable CreateDeployment where
instance NFData CreateDeployment where
instance ToHeaders CreateDeployment where
toHeaders CreateDeployment'{..}
= mconcat
["X-Amzn-Client-Token" =# _cdAmznClientToken,
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)]
instance ToJSON CreateDeployment where
toJSON CreateDeployment'{..}
= object
(catMaybes
[("DeploymentId" .=) <$> _cdDeploymentId,
("DeploymentType" .=) <$> _cdDeploymentType,
("GroupVersionId" .=) <$> _cdGroupVersionId])
instance ToPath CreateDeployment where
toPath CreateDeployment'{..}
= mconcat
["/greengrass/groups/", toBS _cdGroupId,
"/deployments"]
instance ToQuery CreateDeployment where
toQuery = const mempty
data CreateDeploymentResponse = CreateDeploymentResponse'
{ _cdrsDeploymentId :: !(Maybe Text)
, _cdrsDeploymentARN :: !(Maybe Text)
, _cdrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createDeploymentResponse
:: Int
-> CreateDeploymentResponse
createDeploymentResponse pResponseStatus_ =
CreateDeploymentResponse'
{ _cdrsDeploymentId = Nothing
, _cdrsDeploymentARN = Nothing
, _cdrsResponseStatus = pResponseStatus_
}
cdrsDeploymentId :: Lens' CreateDeploymentResponse (Maybe Text)
cdrsDeploymentId = lens _cdrsDeploymentId (\ s a -> s{_cdrsDeploymentId = a})
cdrsDeploymentARN :: Lens' CreateDeploymentResponse (Maybe Text)
cdrsDeploymentARN = lens _cdrsDeploymentARN (\ s a -> s{_cdrsDeploymentARN = a})
cdrsResponseStatus :: Lens' CreateDeploymentResponse Int
cdrsResponseStatus = lens _cdrsResponseStatus (\ s a -> s{_cdrsResponseStatus = a})
instance NFData CreateDeploymentResponse where