{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Amazonka.WorkDocs.GetDocument
(
GetDocument (..),
newGetDocument,
getDocument_authenticationToken,
getDocument_includeCustomMetadata,
getDocument_documentId,
GetDocumentResponse (..),
newGetDocumentResponse,
getDocumentResponse_customMetadata,
getDocumentResponse_metadata,
getDocumentResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.WorkDocs.Types
data GetDocument = GetDocument'
{
GetDocument -> Maybe (Sensitive Text)
authenticationToken :: Prelude.Maybe (Data.Sensitive Prelude.Text),
GetDocument -> Maybe Bool
includeCustomMetadata :: Prelude.Maybe Prelude.Bool,
GetDocument -> Text
documentId :: Prelude.Text
}
deriving (GetDocument -> GetDocument -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDocument -> GetDocument -> Bool
$c/= :: GetDocument -> GetDocument -> Bool
== :: GetDocument -> GetDocument -> Bool
$c== :: GetDocument -> GetDocument -> Bool
Prelude.Eq, Int -> GetDocument -> ShowS
[GetDocument] -> ShowS
GetDocument -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDocument] -> ShowS
$cshowList :: [GetDocument] -> ShowS
show :: GetDocument -> String
$cshow :: GetDocument -> String
showsPrec :: Int -> GetDocument -> ShowS
$cshowsPrec :: Int -> GetDocument -> ShowS
Prelude.Show, forall x. Rep GetDocument x -> GetDocument
forall x. GetDocument -> Rep GetDocument x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDocument x -> GetDocument
$cfrom :: forall x. GetDocument -> Rep GetDocument x
Prelude.Generic)
newGetDocument ::
Prelude.Text ->
GetDocument
newGetDocument :: Text -> GetDocument
newGetDocument Text
pDocumentId_ =
GetDocument'
{ $sel:authenticationToken:GetDocument' :: Maybe (Sensitive Text)
authenticationToken = forall a. Maybe a
Prelude.Nothing,
$sel:includeCustomMetadata:GetDocument' :: Maybe Bool
includeCustomMetadata = forall a. Maybe a
Prelude.Nothing,
$sel:documentId:GetDocument' :: Text
documentId = Text
pDocumentId_
}
getDocument_authenticationToken :: Lens.Lens' GetDocument (Prelude.Maybe Prelude.Text)
getDocument_authenticationToken :: Lens' GetDocument (Maybe Text)
getDocument_authenticationToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDocument' {Maybe (Sensitive Text)
authenticationToken :: Maybe (Sensitive Text)
$sel:authenticationToken:GetDocument' :: GetDocument -> Maybe (Sensitive Text)
authenticationToken} -> Maybe (Sensitive Text)
authenticationToken) (\s :: GetDocument
s@GetDocument' {} Maybe (Sensitive Text)
a -> GetDocument
s {$sel:authenticationToken:GetDocument' :: Maybe (Sensitive Text)
authenticationToken = Maybe (Sensitive Text)
a} :: GetDocument) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall a. Iso' (Sensitive a) a
Data._Sensitive
getDocument_includeCustomMetadata :: Lens.Lens' GetDocument (Prelude.Maybe Prelude.Bool)
getDocument_includeCustomMetadata :: Lens' GetDocument (Maybe Bool)
getDocument_includeCustomMetadata = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDocument' {Maybe Bool
includeCustomMetadata :: Maybe Bool
$sel:includeCustomMetadata:GetDocument' :: GetDocument -> Maybe Bool
includeCustomMetadata} -> Maybe Bool
includeCustomMetadata) (\s :: GetDocument
s@GetDocument' {} Maybe Bool
a -> GetDocument
s {$sel:includeCustomMetadata:GetDocument' :: Maybe Bool
includeCustomMetadata = Maybe Bool
a} :: GetDocument)
getDocument_documentId :: Lens.Lens' GetDocument Prelude.Text
getDocument_documentId :: Lens' GetDocument Text
getDocument_documentId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDocument' {Text
documentId :: Text
$sel:documentId:GetDocument' :: GetDocument -> Text
documentId} -> Text
documentId) (\s :: GetDocument
s@GetDocument' {} Text
a -> GetDocument
s {$sel:documentId:GetDocument' :: Text
documentId = Text
a} :: GetDocument)
instance Core.AWSRequest GetDocument where
type AWSResponse GetDocument = GetDocumentResponse
request :: (Service -> Service) -> GetDocument -> Request GetDocument
request Service -> Service
overrides =
forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetDocument
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetDocument)))
response =
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
( \Int
s ResponseHeaders
h Object
x ->
Maybe (HashMap Text Text)
-> Maybe DocumentMetadata -> Int -> GetDocumentResponse
GetDocumentResponse'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"CustomMetadata" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"Metadata")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
)
instance Prelude.Hashable GetDocument where
hashWithSalt :: Int -> GetDocument -> Int
hashWithSalt Int
_salt GetDocument' {Maybe Bool
Maybe (Sensitive Text)
Text
documentId :: Text
includeCustomMetadata :: Maybe Bool
authenticationToken :: Maybe (Sensitive Text)
$sel:documentId:GetDocument' :: GetDocument -> Text
$sel:includeCustomMetadata:GetDocument' :: GetDocument -> Maybe Bool
$sel:authenticationToken:GetDocument' :: GetDocument -> Maybe (Sensitive Text)
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Text)
authenticationToken
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
includeCustomMetadata
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
documentId
instance Prelude.NFData GetDocument where
rnf :: GetDocument -> ()
rnf GetDocument' {Maybe Bool
Maybe (Sensitive Text)
Text
documentId :: Text
includeCustomMetadata :: Maybe Bool
authenticationToken :: Maybe (Sensitive Text)
$sel:documentId:GetDocument' :: GetDocument -> Text
$sel:includeCustomMetadata:GetDocument' :: GetDocument -> Maybe Bool
$sel:authenticationToken:GetDocument' :: GetDocument -> Maybe (Sensitive Text)
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
authenticationToken
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
includeCustomMetadata
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
documentId
instance Data.ToHeaders GetDocument where
toHeaders :: GetDocument -> ResponseHeaders
toHeaders GetDocument' {Maybe Bool
Maybe (Sensitive Text)
Text
documentId :: Text
includeCustomMetadata :: Maybe Bool
authenticationToken :: Maybe (Sensitive Text)
$sel:documentId:GetDocument' :: GetDocument -> Text
$sel:includeCustomMetadata:GetDocument' :: GetDocument -> Maybe Bool
$sel:authenticationToken:GetDocument' :: GetDocument -> Maybe (Sensitive Text)
..} =
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"Authentication" forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# Maybe (Sensitive Text)
authenticationToken,
HeaderName
"Content-Type"
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# (ByteString
"application/x-amz-json-1.1" :: Prelude.ByteString)
]
instance Data.ToPath GetDocument where
toPath :: GetDocument -> ByteString
toPath GetDocument' {Maybe Bool
Maybe (Sensitive Text)
Text
documentId :: Text
includeCustomMetadata :: Maybe Bool
authenticationToken :: Maybe (Sensitive Text)
$sel:documentId:GetDocument' :: GetDocument -> Text
$sel:includeCustomMetadata:GetDocument' :: GetDocument -> Maybe Bool
$sel:authenticationToken:GetDocument' :: GetDocument -> Maybe (Sensitive Text)
..} =
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ByteString
"/api/v1/documents/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
documentId]
instance Data.ToQuery GetDocument where
toQuery :: GetDocument -> QueryString
toQuery GetDocument' {Maybe Bool
Maybe (Sensitive Text)
Text
documentId :: Text
includeCustomMetadata :: Maybe Bool
authenticationToken :: Maybe (Sensitive Text)
$sel:documentId:GetDocument' :: GetDocument -> Text
$sel:includeCustomMetadata:GetDocument' :: GetDocument -> Maybe Bool
$sel:authenticationToken:GetDocument' :: GetDocument -> Maybe (Sensitive Text)
..} =
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"includeCustomMetadata"
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Bool
includeCustomMetadata
]
data GetDocumentResponse = GetDocumentResponse'
{
GetDocumentResponse -> Maybe (HashMap Text Text)
customMetadata :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
GetDocumentResponse -> Maybe DocumentMetadata
metadata :: Prelude.Maybe DocumentMetadata,
GetDocumentResponse -> Int
httpStatus :: Prelude.Int
}
deriving (GetDocumentResponse -> GetDocumentResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDocumentResponse -> GetDocumentResponse -> Bool
$c/= :: GetDocumentResponse -> GetDocumentResponse -> Bool
== :: GetDocumentResponse -> GetDocumentResponse -> Bool
$c== :: GetDocumentResponse -> GetDocumentResponse -> Bool
Prelude.Eq, Int -> GetDocumentResponse -> ShowS
[GetDocumentResponse] -> ShowS
GetDocumentResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDocumentResponse] -> ShowS
$cshowList :: [GetDocumentResponse] -> ShowS
show :: GetDocumentResponse -> String
$cshow :: GetDocumentResponse -> String
showsPrec :: Int -> GetDocumentResponse -> ShowS
$cshowsPrec :: Int -> GetDocumentResponse -> ShowS
Prelude.Show, forall x. Rep GetDocumentResponse x -> GetDocumentResponse
forall x. GetDocumentResponse -> Rep GetDocumentResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDocumentResponse x -> GetDocumentResponse
$cfrom :: forall x. GetDocumentResponse -> Rep GetDocumentResponse x
Prelude.Generic)
newGetDocumentResponse ::
Prelude.Int ->
GetDocumentResponse
newGetDocumentResponse :: Int -> GetDocumentResponse
newGetDocumentResponse Int
pHttpStatus_ =
GetDocumentResponse'
{ $sel:customMetadata:GetDocumentResponse' :: Maybe (HashMap Text Text)
customMetadata =
forall a. Maybe a
Prelude.Nothing,
$sel:metadata:GetDocumentResponse' :: Maybe DocumentMetadata
metadata = forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:GetDocumentResponse' :: Int
httpStatus = Int
pHttpStatus_
}
getDocumentResponse_customMetadata :: Lens.Lens' GetDocumentResponse (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
getDocumentResponse_customMetadata :: Lens' GetDocumentResponse (Maybe (HashMap Text Text))
getDocumentResponse_customMetadata = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDocumentResponse' {Maybe (HashMap Text Text)
customMetadata :: Maybe (HashMap Text Text)
$sel:customMetadata:GetDocumentResponse' :: GetDocumentResponse -> Maybe (HashMap Text Text)
customMetadata} -> Maybe (HashMap Text Text)
customMetadata) (\s :: GetDocumentResponse
s@GetDocumentResponse' {} Maybe (HashMap Text Text)
a -> GetDocumentResponse
s {$sel:customMetadata:GetDocumentResponse' :: Maybe (HashMap Text Text)
customMetadata = Maybe (HashMap Text Text)
a} :: GetDocumentResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
getDocumentResponse_metadata :: Lens.Lens' GetDocumentResponse (Prelude.Maybe DocumentMetadata)
getDocumentResponse_metadata :: Lens' GetDocumentResponse (Maybe DocumentMetadata)
getDocumentResponse_metadata = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDocumentResponse' {Maybe DocumentMetadata
metadata :: Maybe DocumentMetadata
$sel:metadata:GetDocumentResponse' :: GetDocumentResponse -> Maybe DocumentMetadata
metadata} -> Maybe DocumentMetadata
metadata) (\s :: GetDocumentResponse
s@GetDocumentResponse' {} Maybe DocumentMetadata
a -> GetDocumentResponse
s {$sel:metadata:GetDocumentResponse' :: Maybe DocumentMetadata
metadata = Maybe DocumentMetadata
a} :: GetDocumentResponse)
getDocumentResponse_httpStatus :: Lens.Lens' GetDocumentResponse Prelude.Int
getDocumentResponse_httpStatus :: Lens' GetDocumentResponse Int
getDocumentResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDocumentResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetDocumentResponse' :: GetDocumentResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetDocumentResponse
s@GetDocumentResponse' {} Int
a -> GetDocumentResponse
s {$sel:httpStatus:GetDocumentResponse' :: Int
httpStatus = Int
a} :: GetDocumentResponse)
instance Prelude.NFData GetDocumentResponse where
rnf :: GetDocumentResponse -> ()
rnf GetDocumentResponse' {Int
Maybe (HashMap Text Text)
Maybe DocumentMetadata
httpStatus :: Int
metadata :: Maybe DocumentMetadata
customMetadata :: Maybe (HashMap Text Text)
$sel:httpStatus:GetDocumentResponse' :: GetDocumentResponse -> Int
$sel:metadata:GetDocumentResponse' :: GetDocumentResponse -> Maybe DocumentMetadata
$sel:customMetadata:GetDocumentResponse' :: GetDocumentResponse -> Maybe (HashMap Text Text)
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
customMetadata
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe DocumentMetadata
metadata
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus