{-# 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.GetDocumentVersion
(
getDocumentVersion
, GetDocumentVersion
, gdvAuthenticationToken
, gdvIncludeCustomMetadata
, gdvFields
, gdvDocumentId
, gdvVersionId
, getDocumentVersionResponse
, GetDocumentVersionResponse
, gdvrsCustomMetadata
, gdvrsMetadata
, gdvrsResponseStatus
) 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 GetDocumentVersion = GetDocumentVersion'
{ _gdvAuthenticationToken :: !(Maybe (Sensitive Text))
, _gdvIncludeCustomMetadata :: !(Maybe Bool)
, _gdvFields :: !(Maybe Text)
, _gdvDocumentId :: !Text
, _gdvVersionId :: !Text
} deriving (Eq, Show, Data, Typeable, Generic)
getDocumentVersion
:: Text
-> Text
-> GetDocumentVersion
getDocumentVersion pDocumentId_ pVersionId_ =
GetDocumentVersion'
{ _gdvAuthenticationToken = Nothing
, _gdvIncludeCustomMetadata = Nothing
, _gdvFields = Nothing
, _gdvDocumentId = pDocumentId_
, _gdvVersionId = pVersionId_
}
gdvAuthenticationToken :: Lens' GetDocumentVersion (Maybe Text)
gdvAuthenticationToken = lens _gdvAuthenticationToken (\ s a -> s{_gdvAuthenticationToken = a}) . mapping _Sensitive
gdvIncludeCustomMetadata :: Lens' GetDocumentVersion (Maybe Bool)
gdvIncludeCustomMetadata = lens _gdvIncludeCustomMetadata (\ s a -> s{_gdvIncludeCustomMetadata = a})
gdvFields :: Lens' GetDocumentVersion (Maybe Text)
gdvFields = lens _gdvFields (\ s a -> s{_gdvFields = a})
gdvDocumentId :: Lens' GetDocumentVersion Text
gdvDocumentId = lens _gdvDocumentId (\ s a -> s{_gdvDocumentId = a})
gdvVersionId :: Lens' GetDocumentVersion Text
gdvVersionId = lens _gdvVersionId (\ s a -> s{_gdvVersionId = a})
instance AWSRequest GetDocumentVersion where
type Rs GetDocumentVersion =
GetDocumentVersionResponse
request = get workDocs
response
= receiveJSON
(\ s h x ->
GetDocumentVersionResponse' <$>
(x .?> "CustomMetadata" .!@ mempty) <*>
(x .?> "Metadata")
<*> (pure (fromEnum s)))
instance Hashable GetDocumentVersion where
instance NFData GetDocumentVersion where
instance ToHeaders GetDocumentVersion where
toHeaders GetDocumentVersion'{..}
= mconcat
["Authentication" =# _gdvAuthenticationToken,
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)]
instance ToPath GetDocumentVersion where
toPath GetDocumentVersion'{..}
= mconcat
["/api/v1/documents/", toBS _gdvDocumentId,
"/versions/", toBS _gdvVersionId]
instance ToQuery GetDocumentVersion where
toQuery GetDocumentVersion'{..}
= mconcat
["includeCustomMetadata" =:
_gdvIncludeCustomMetadata,
"fields" =: _gdvFields]
data GetDocumentVersionResponse = GetDocumentVersionResponse'
{ _gdvrsCustomMetadata :: !(Maybe (Map Text Text))
, _gdvrsMetadata :: !(Maybe DocumentVersionMetadata)
, _gdvrsResponseStatus :: !Int
} deriving (Eq, Show, Data, Typeable, Generic)
getDocumentVersionResponse
:: Int
-> GetDocumentVersionResponse
getDocumentVersionResponse pResponseStatus_ =
GetDocumentVersionResponse'
{ _gdvrsCustomMetadata = Nothing
, _gdvrsMetadata = Nothing
, _gdvrsResponseStatus = pResponseStatus_
}
gdvrsCustomMetadata :: Lens' GetDocumentVersionResponse (HashMap Text Text)
gdvrsCustomMetadata = lens _gdvrsCustomMetadata (\ s a -> s{_gdvrsCustomMetadata = a}) . _Default . _Map
gdvrsMetadata :: Lens' GetDocumentVersionResponse (Maybe DocumentVersionMetadata)
gdvrsMetadata = lens _gdvrsMetadata (\ s a -> s{_gdvrsMetadata = a})
gdvrsResponseStatus :: Lens' GetDocumentVersionResponse Int
gdvrsResponseStatus = lens _gdvrsResponseStatus (\ s a -> s{_gdvrsResponseStatus = a})
instance NFData GetDocumentVersionResponse where