{-# 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.WorkMail.CreateResource
(
createResource
, CreateResource
, crOrganizationId
, crName
, crType
, createResourceResponse
, CreateResourceResponse
, crrsResourceId
, crrsResponseStatus
) where
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
import Network.AWS.WorkMail.Types
import Network.AWS.WorkMail.Types.Product
data CreateResource = CreateResource'
{ _crOrganizationId :: !Text
, _crName :: !Text
, _crType :: !ResourceType
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createResource
:: Text
-> Text
-> ResourceType
-> CreateResource
createResource pOrganizationId_ pName_ pType_ =
CreateResource'
{_crOrganizationId = pOrganizationId_, _crName = pName_, _crType = pType_}
crOrganizationId :: Lens' CreateResource Text
crOrganizationId = lens _crOrganizationId (\ s a -> s{_crOrganizationId = a})
crName :: Lens' CreateResource Text
crName = lens _crName (\ s a -> s{_crName = a})
crType :: Lens' CreateResource ResourceType
crType = lens _crType (\ s a -> s{_crType = a})
instance AWSRequest CreateResource where
type Rs CreateResource = CreateResourceResponse
request = postJSON workMail
response
= receiveJSON
(\ s h x ->
CreateResourceResponse' <$>
(x .?> "ResourceId") <*> (pure (fromEnum s)))
instance Hashable CreateResource where
instance NFData CreateResource where
instance ToHeaders CreateResource where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("WorkMailService.CreateResource" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON CreateResource where
toJSON CreateResource'{..}
= object
(catMaybes
[Just ("OrganizationId" .= _crOrganizationId),
Just ("Name" .= _crName), Just ("Type" .= _crType)])
instance ToPath CreateResource where
toPath = const "/"
instance ToQuery CreateResource where
toQuery = const mempty
data CreateResourceResponse = CreateResourceResponse'
{ _crrsResourceId :: !(Maybe Text)
, _crrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createResourceResponse
:: Int
-> CreateResourceResponse
createResourceResponse pResponseStatus_ =
CreateResourceResponse'
{_crrsResourceId = Nothing, _crrsResponseStatus = pResponseStatus_}
crrsResourceId :: Lens' CreateResourceResponse (Maybe Text)
crrsResourceId = lens _crrsResourceId (\ s a -> s{_crrsResourceId = a})
crrsResponseStatus :: Lens' CreateResourceResponse Int
crrsResponseStatus = lens _crrsResponseStatus (\ s a -> s{_crrsResponseStatus = a})
instance NFData CreateResourceResponse where