{-# 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.WorkDocs.CreateComment
(
createComment
, CreateComment
, ccNotifyCollaborators
, ccAuthenticationToken
, ccVisibility
, ccThreadId
, ccParentId
, ccDocumentId
, ccVersionId
, ccText
, createCommentResponse
, CreateCommentResponse
, ccrsComment
, ccrsResponseStatus
) where
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
import Network.AWS.WorkDocs.Types
import Network.AWS.WorkDocs.Types.Product
data CreateComment = CreateComment'
{ _ccNotifyCollaborators :: !(Maybe Bool)
, _ccAuthenticationToken :: !(Maybe (Sensitive Text))
, _ccVisibility :: !(Maybe CommentVisibilityType)
, _ccThreadId :: !(Maybe Text)
, _ccParentId :: !(Maybe Text)
, _ccDocumentId :: !Text
, _ccVersionId :: !Text
, _ccText :: !(Sensitive Text)
} deriving (Eq, Show, Data, Typeable, Generic)
createComment
:: Text
-> Text
-> Text
-> CreateComment
createComment pDocumentId_ pVersionId_ pText_ =
CreateComment'
{ _ccNotifyCollaborators = Nothing
, _ccAuthenticationToken = Nothing
, _ccVisibility = Nothing
, _ccThreadId = Nothing
, _ccParentId = Nothing
, _ccDocumentId = pDocumentId_
, _ccVersionId = pVersionId_
, _ccText = _Sensitive # pText_
}
ccNotifyCollaborators :: Lens' CreateComment (Maybe Bool)
ccNotifyCollaborators = lens _ccNotifyCollaborators (\ s a -> s{_ccNotifyCollaborators = a})
ccAuthenticationToken :: Lens' CreateComment (Maybe Text)
ccAuthenticationToken = lens _ccAuthenticationToken (\ s a -> s{_ccAuthenticationToken = a}) . mapping _Sensitive
ccVisibility :: Lens' CreateComment (Maybe CommentVisibilityType)
ccVisibility = lens _ccVisibility (\ s a -> s{_ccVisibility = a})
ccThreadId :: Lens' CreateComment (Maybe Text)
ccThreadId = lens _ccThreadId (\ s a -> s{_ccThreadId = a})
ccParentId :: Lens' CreateComment (Maybe Text)
ccParentId = lens _ccParentId (\ s a -> s{_ccParentId = a})
ccDocumentId :: Lens' CreateComment Text
ccDocumentId = lens _ccDocumentId (\ s a -> s{_ccDocumentId = a})
ccVersionId :: Lens' CreateComment Text
ccVersionId = lens _ccVersionId (\ s a -> s{_ccVersionId = a})
ccText :: Lens' CreateComment Text
ccText = lens _ccText (\ s a -> s{_ccText = a}) . _Sensitive
instance AWSRequest CreateComment where
type Rs CreateComment = CreateCommentResponse
request = postJSON workDocs
response
= receiveJSON
(\ s h x ->
CreateCommentResponse' <$>
(x .?> "Comment") <*> (pure (fromEnum s)))
instance Hashable CreateComment where
instance NFData CreateComment where
instance ToHeaders CreateComment where
toHeaders CreateComment'{..}
= mconcat
["Authentication" =# _ccAuthenticationToken,
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)]
instance ToJSON CreateComment where
toJSON CreateComment'{..}
= object
(catMaybes
[("NotifyCollaborators" .=) <$>
_ccNotifyCollaborators,
("Visibility" .=) <$> _ccVisibility,
("ThreadId" .=) <$> _ccThreadId,
("ParentId" .=) <$> _ccParentId,
Just ("Text" .= _ccText)])
instance ToPath CreateComment where
toPath CreateComment'{..}
= mconcat
["/api/v1/documents/", toBS _ccDocumentId,
"/versions/", toBS _ccVersionId, "/comment"]
instance ToQuery CreateComment where
toQuery = const mempty
data CreateCommentResponse = CreateCommentResponse'
{ _ccrsComment :: !(Maybe Comment)
, _ccrsResponseStatus :: !Int
} deriving (Eq, Show, Data, Typeable, Generic)
createCommentResponse
:: Int
-> CreateCommentResponse
createCommentResponse pResponseStatus_ =
CreateCommentResponse'
{_ccrsComment = Nothing, _ccrsResponseStatus = pResponseStatus_}
ccrsComment :: Lens' CreateCommentResponse (Maybe Comment)
ccrsComment = lens _ccrsComment (\ s a -> s{_ccrsComment = a})
ccrsResponseStatus :: Lens' CreateCommentResponse Int
ccrsResponseStatus = lens _ccrsResponseStatus (\ s a -> s{_ccrsResponseStatus = a})
instance NFData CreateCommentResponse where