{-# 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.CreateCoreDefinitionVersion
(
createCoreDefinitionVersion
, CreateCoreDefinitionVersion
, ccdvAmznClientToken
, ccdvCores
, ccdvCoreDefinitionId
, createCoreDefinitionVersionResponse
, CreateCoreDefinitionVersionResponse
, ccdvrsARN
, ccdvrsCreationTimestamp
, ccdvrsVersion
, ccdvrsId
, ccdvrsResponseStatus
) 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 CreateCoreDefinitionVersion = CreateCoreDefinitionVersion'
{ _ccdvAmznClientToken :: !(Maybe Text)
, _ccdvCores :: !(Maybe [Core])
, _ccdvCoreDefinitionId :: !Text
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createCoreDefinitionVersion
:: Text
-> CreateCoreDefinitionVersion
createCoreDefinitionVersion pCoreDefinitionId_ =
CreateCoreDefinitionVersion'
{ _ccdvAmznClientToken = Nothing
, _ccdvCores = Nothing
, _ccdvCoreDefinitionId = pCoreDefinitionId_
}
ccdvAmznClientToken :: Lens' CreateCoreDefinitionVersion (Maybe Text)
ccdvAmznClientToken = lens _ccdvAmznClientToken (\ s a -> s{_ccdvAmznClientToken = a})
ccdvCores :: Lens' CreateCoreDefinitionVersion [Core]
ccdvCores = lens _ccdvCores (\ s a -> s{_ccdvCores = a}) . _Default . _Coerce
ccdvCoreDefinitionId :: Lens' CreateCoreDefinitionVersion Text
ccdvCoreDefinitionId = lens _ccdvCoreDefinitionId (\ s a -> s{_ccdvCoreDefinitionId = a})
instance AWSRequest CreateCoreDefinitionVersion where
type Rs CreateCoreDefinitionVersion =
CreateCoreDefinitionVersionResponse
request = postJSON greengrass
response
= receiveJSON
(\ s h x ->
CreateCoreDefinitionVersionResponse' <$>
(x .?> "Arn") <*> (x .?> "CreationTimestamp") <*>
(x .?> "Version")
<*> (x .?> "Id")
<*> (pure (fromEnum s)))
instance Hashable CreateCoreDefinitionVersion where
instance NFData CreateCoreDefinitionVersion where
instance ToHeaders CreateCoreDefinitionVersion where
toHeaders CreateCoreDefinitionVersion'{..}
= mconcat
["X-Amzn-Client-Token" =# _ccdvAmznClientToken,
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)]
instance ToJSON CreateCoreDefinitionVersion where
toJSON CreateCoreDefinitionVersion'{..}
= object (catMaybes [("Cores" .=) <$> _ccdvCores])
instance ToPath CreateCoreDefinitionVersion where
toPath CreateCoreDefinitionVersion'{..}
= mconcat
["/greengrass/definition/cores/",
toBS _ccdvCoreDefinitionId, "/versions"]
instance ToQuery CreateCoreDefinitionVersion where
toQuery = const mempty
data CreateCoreDefinitionVersionResponse = CreateCoreDefinitionVersionResponse'
{ _ccdvrsARN :: !(Maybe Text)
, _ccdvrsCreationTimestamp :: !(Maybe Text)
, _ccdvrsVersion :: !(Maybe Text)
, _ccdvrsId :: !(Maybe Text)
, _ccdvrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createCoreDefinitionVersionResponse
:: Int
-> CreateCoreDefinitionVersionResponse
createCoreDefinitionVersionResponse pResponseStatus_ =
CreateCoreDefinitionVersionResponse'
{ _ccdvrsARN = Nothing
, _ccdvrsCreationTimestamp = Nothing
, _ccdvrsVersion = Nothing
, _ccdvrsId = Nothing
, _ccdvrsResponseStatus = pResponseStatus_
}
ccdvrsARN :: Lens' CreateCoreDefinitionVersionResponse (Maybe Text)
ccdvrsARN = lens _ccdvrsARN (\ s a -> s{_ccdvrsARN = a})
ccdvrsCreationTimestamp :: Lens' CreateCoreDefinitionVersionResponse (Maybe Text)
ccdvrsCreationTimestamp = lens _ccdvrsCreationTimestamp (\ s a -> s{_ccdvrsCreationTimestamp = a})
ccdvrsVersion :: Lens' CreateCoreDefinitionVersionResponse (Maybe Text)
ccdvrsVersion = lens _ccdvrsVersion (\ s a -> s{_ccdvrsVersion = a})
ccdvrsId :: Lens' CreateCoreDefinitionVersionResponse (Maybe Text)
ccdvrsId = lens _ccdvrsId (\ s a -> s{_ccdvrsId = a})
ccdvrsResponseStatus :: Lens' CreateCoreDefinitionVersionResponse Int
ccdvrsResponseStatus = lens _ccdvrsResponseStatus (\ s a -> s{_ccdvrsResponseStatus = a})
instance NFData CreateCoreDefinitionVersionResponse
where