{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.WorkDocs.DescribeDocumentVersions
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves the document versions for the specified document.
--
-- By default, only active versions are returned.
--
-- This operation returns paginated results.
module Amazonka.WorkDocs.DescribeDocumentVersions
  ( -- * Creating a Request
    DescribeDocumentVersions (..),
    newDescribeDocumentVersions,

    -- * Request Lenses
    describeDocumentVersions_include,
    describeDocumentVersions_authenticationToken,
    describeDocumentVersions_marker,
    describeDocumentVersions_limit,
    describeDocumentVersions_fields,
    describeDocumentVersions_documentId,

    -- * Destructuring the Response
    DescribeDocumentVersionsResponse (..),
    newDescribeDocumentVersionsResponse,

    -- * Response Lenses
    describeDocumentVersionsResponse_documentVersions,
    describeDocumentVersionsResponse_marker,
    describeDocumentVersionsResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.WorkDocs.Types

-- | /See:/ 'newDescribeDocumentVersions' smart constructor.
data DescribeDocumentVersions = DescribeDocumentVersions'
  { -- | A comma-separated list of values. Specify \"INITIALIZED\" to include
    -- incomplete versions.
    DescribeDocumentVersions -> Maybe Text
include :: Prelude.Maybe Prelude.Text,
    -- | Amazon WorkDocs authentication token. Not required when using AWS
    -- administrator credentials to access the API.
    DescribeDocumentVersions -> Maybe (Sensitive Text)
authenticationToken :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The marker for the next set of results. (You received this marker from a
    -- previous call.)
    DescribeDocumentVersions -> Maybe Text
marker :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of versions to return with this call.
    DescribeDocumentVersions -> Maybe Natural
limit :: Prelude.Maybe Prelude.Natural,
    -- | Specify \"SOURCE\" to include initialized versions and a URL for the
    -- source document.
    DescribeDocumentVersions -> Maybe Text
fields :: Prelude.Maybe Prelude.Text,
    -- | The ID of the document.
    DescribeDocumentVersions -> Text
documentId :: Prelude.Text
  }
  deriving (DescribeDocumentVersions -> DescribeDocumentVersions -> Bool
(DescribeDocumentVersions -> DescribeDocumentVersions -> Bool)
-> (DescribeDocumentVersions -> DescribeDocumentVersions -> Bool)
-> Eq DescribeDocumentVersions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeDocumentVersions -> DescribeDocumentVersions -> Bool
$c/= :: DescribeDocumentVersions -> DescribeDocumentVersions -> Bool
== :: DescribeDocumentVersions -> DescribeDocumentVersions -> Bool
$c== :: DescribeDocumentVersions -> DescribeDocumentVersions -> Bool
Prelude.Eq, Int -> DescribeDocumentVersions -> ShowS
[DescribeDocumentVersions] -> ShowS
DescribeDocumentVersions -> String
(Int -> DescribeDocumentVersions -> ShowS)
-> (DescribeDocumentVersions -> String)
-> ([DescribeDocumentVersions] -> ShowS)
-> Show DescribeDocumentVersions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeDocumentVersions] -> ShowS
$cshowList :: [DescribeDocumentVersions] -> ShowS
show :: DescribeDocumentVersions -> String
$cshow :: DescribeDocumentVersions -> String
showsPrec :: Int -> DescribeDocumentVersions -> ShowS
$cshowsPrec :: Int -> DescribeDocumentVersions -> ShowS
Prelude.Show, (forall x.
 DescribeDocumentVersions -> Rep DescribeDocumentVersions x)
-> (forall x.
    Rep DescribeDocumentVersions x -> DescribeDocumentVersions)
-> Generic DescribeDocumentVersions
forall x.
Rep DescribeDocumentVersions x -> DescribeDocumentVersions
forall x.
DescribeDocumentVersions -> Rep DescribeDocumentVersions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeDocumentVersions x -> DescribeDocumentVersions
$cfrom :: forall x.
DescribeDocumentVersions -> Rep DescribeDocumentVersions x
Prelude.Generic)

-- |
-- Create a value of 'DescribeDocumentVersions' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'include', 'describeDocumentVersions_include' - A comma-separated list of values. Specify \"INITIALIZED\" to include
-- incomplete versions.
--
-- 'authenticationToken', 'describeDocumentVersions_authenticationToken' - Amazon WorkDocs authentication token. Not required when using AWS
-- administrator credentials to access the API.
--
-- 'marker', 'describeDocumentVersions_marker' - The marker for the next set of results. (You received this marker from a
-- previous call.)
--
-- 'limit', 'describeDocumentVersions_limit' - The maximum number of versions to return with this call.
--
-- 'fields', 'describeDocumentVersions_fields' - Specify \"SOURCE\" to include initialized versions and a URL for the
-- source document.
--
-- 'documentId', 'describeDocumentVersions_documentId' - The ID of the document.
newDescribeDocumentVersions ::
  -- | 'documentId'
  Prelude.Text ->
  DescribeDocumentVersions
newDescribeDocumentVersions :: Text -> DescribeDocumentVersions
newDescribeDocumentVersions Text
pDocumentId_ =
  DescribeDocumentVersions' :: Maybe Text
-> Maybe (Sensitive Text)
-> Maybe Text
-> Maybe Natural
-> Maybe Text
-> Text
-> DescribeDocumentVersions
DescribeDocumentVersions'
    { $sel:include:DescribeDocumentVersions' :: Maybe Text
include =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:authenticationToken:DescribeDocumentVersions' :: Maybe (Sensitive Text)
authenticationToken = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:marker:DescribeDocumentVersions' :: Maybe Text
marker = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:limit:DescribeDocumentVersions' :: Maybe Natural
limit = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:fields:DescribeDocumentVersions' :: Maybe Text
fields = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:documentId:DescribeDocumentVersions' :: Text
documentId = Text
pDocumentId_
    }

-- | A comma-separated list of values. Specify \"INITIALIZED\" to include
-- incomplete versions.
describeDocumentVersions_include :: Lens.Lens' DescribeDocumentVersions (Prelude.Maybe Prelude.Text)
describeDocumentVersions_include :: (Maybe Text -> f (Maybe Text))
-> DescribeDocumentVersions -> f DescribeDocumentVersions
describeDocumentVersions_include = (DescribeDocumentVersions -> Maybe Text)
-> (DescribeDocumentVersions
    -> Maybe Text -> DescribeDocumentVersions)
-> Lens
     DescribeDocumentVersions
     DescribeDocumentVersions
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeDocumentVersions' {Maybe Text
include :: Maybe Text
$sel:include:DescribeDocumentVersions' :: DescribeDocumentVersions -> Maybe Text
include} -> Maybe Text
include) (\s :: DescribeDocumentVersions
s@DescribeDocumentVersions' {} Maybe Text
a -> DescribeDocumentVersions
s {$sel:include:DescribeDocumentVersions' :: Maybe Text
include = Maybe Text
a} :: DescribeDocumentVersions)

-- | Amazon WorkDocs authentication token. Not required when using AWS
-- administrator credentials to access the API.
describeDocumentVersions_authenticationToken :: Lens.Lens' DescribeDocumentVersions (Prelude.Maybe Prelude.Text)
describeDocumentVersions_authenticationToken :: (Maybe Text -> f (Maybe Text))
-> DescribeDocumentVersions -> f DescribeDocumentVersions
describeDocumentVersions_authenticationToken = (DescribeDocumentVersions -> Maybe (Sensitive Text))
-> (DescribeDocumentVersions
    -> Maybe (Sensitive Text) -> DescribeDocumentVersions)
-> Lens
     DescribeDocumentVersions
     DescribeDocumentVersions
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeDocumentVersions' {Maybe (Sensitive Text)
authenticationToken :: Maybe (Sensitive Text)
$sel:authenticationToken:DescribeDocumentVersions' :: DescribeDocumentVersions -> Maybe (Sensitive Text)
authenticationToken} -> Maybe (Sensitive Text)
authenticationToken) (\s :: DescribeDocumentVersions
s@DescribeDocumentVersions' {} Maybe (Sensitive Text)
a -> DescribeDocumentVersions
s {$sel:authenticationToken:DescribeDocumentVersions' :: Maybe (Sensitive Text)
authenticationToken = Maybe (Sensitive Text)
a} :: DescribeDocumentVersions) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> DescribeDocumentVersions -> f DescribeDocumentVersions)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> DescribeDocumentVersions
-> f DescribeDocumentVersions
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
     (Maybe Text)
     (Maybe Text)
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 AnIso (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The marker for the next set of results. (You received this marker from a
-- previous call.)
describeDocumentVersions_marker :: Lens.Lens' DescribeDocumentVersions (Prelude.Maybe Prelude.Text)
describeDocumentVersions_marker :: (Maybe Text -> f (Maybe Text))
-> DescribeDocumentVersions -> f DescribeDocumentVersions
describeDocumentVersions_marker = (DescribeDocumentVersions -> Maybe Text)
-> (DescribeDocumentVersions
    -> Maybe Text -> DescribeDocumentVersions)
-> Lens
     DescribeDocumentVersions
     DescribeDocumentVersions
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeDocumentVersions' {Maybe Text
marker :: Maybe Text
$sel:marker:DescribeDocumentVersions' :: DescribeDocumentVersions -> Maybe Text
marker} -> Maybe Text
marker) (\s :: DescribeDocumentVersions
s@DescribeDocumentVersions' {} Maybe Text
a -> DescribeDocumentVersions
s {$sel:marker:DescribeDocumentVersions' :: Maybe Text
marker = Maybe Text
a} :: DescribeDocumentVersions)

-- | The maximum number of versions to return with this call.
describeDocumentVersions_limit :: Lens.Lens' DescribeDocumentVersions (Prelude.Maybe Prelude.Natural)
describeDocumentVersions_limit :: (Maybe Natural -> f (Maybe Natural))
-> DescribeDocumentVersions -> f DescribeDocumentVersions
describeDocumentVersions_limit = (DescribeDocumentVersions -> Maybe Natural)
-> (DescribeDocumentVersions
    -> Maybe Natural -> DescribeDocumentVersions)
-> Lens
     DescribeDocumentVersions
     DescribeDocumentVersions
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeDocumentVersions' {Maybe Natural
limit :: Maybe Natural
$sel:limit:DescribeDocumentVersions' :: DescribeDocumentVersions -> Maybe Natural
limit} -> Maybe Natural
limit) (\s :: DescribeDocumentVersions
s@DescribeDocumentVersions' {} Maybe Natural
a -> DescribeDocumentVersions
s {$sel:limit:DescribeDocumentVersions' :: Maybe Natural
limit = Maybe Natural
a} :: DescribeDocumentVersions)

-- | Specify \"SOURCE\" to include initialized versions and a URL for the
-- source document.
describeDocumentVersions_fields :: Lens.Lens' DescribeDocumentVersions (Prelude.Maybe Prelude.Text)
describeDocumentVersions_fields :: (Maybe Text -> f (Maybe Text))
-> DescribeDocumentVersions -> f DescribeDocumentVersions
describeDocumentVersions_fields = (DescribeDocumentVersions -> Maybe Text)
-> (DescribeDocumentVersions
    -> Maybe Text -> DescribeDocumentVersions)
-> Lens
     DescribeDocumentVersions
     DescribeDocumentVersions
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeDocumentVersions' {Maybe Text
fields :: Maybe Text
$sel:fields:DescribeDocumentVersions' :: DescribeDocumentVersions -> Maybe Text
fields} -> Maybe Text
fields) (\s :: DescribeDocumentVersions
s@DescribeDocumentVersions' {} Maybe Text
a -> DescribeDocumentVersions
s {$sel:fields:DescribeDocumentVersions' :: Maybe Text
fields = Maybe Text
a} :: DescribeDocumentVersions)

-- | The ID of the document.
describeDocumentVersions_documentId :: Lens.Lens' DescribeDocumentVersions Prelude.Text
describeDocumentVersions_documentId :: (Text -> f Text)
-> DescribeDocumentVersions -> f DescribeDocumentVersions
describeDocumentVersions_documentId = (DescribeDocumentVersions -> Text)
-> (DescribeDocumentVersions -> Text -> DescribeDocumentVersions)
-> Lens DescribeDocumentVersions DescribeDocumentVersions Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeDocumentVersions' {Text
documentId :: Text
$sel:documentId:DescribeDocumentVersions' :: DescribeDocumentVersions -> Text
documentId} -> Text
documentId) (\s :: DescribeDocumentVersions
s@DescribeDocumentVersions' {} Text
a -> DescribeDocumentVersions
s {$sel:documentId:DescribeDocumentVersions' :: Text
documentId = Text
a} :: DescribeDocumentVersions)

instance Core.AWSPager DescribeDocumentVersions where
  page :: DescribeDocumentVersions
-> AWSResponse DescribeDocumentVersions
-> Maybe DescribeDocumentVersions
page DescribeDocumentVersions
rq AWSResponse DescribeDocumentVersions
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeDocumentVersions
DescribeDocumentVersionsResponse
rs
            DescribeDocumentVersionsResponse
-> Getting (First Text) DescribeDocumentVersionsResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeDocumentVersionsResponse
-> Const (First Text) DescribeDocumentVersionsResponse
Lens' DescribeDocumentVersionsResponse (Maybe Text)
describeDocumentVersionsResponse_marker
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeDocumentVersionsResponse
 -> Const (First Text) DescribeDocumentVersionsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeDocumentVersionsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe DescribeDocumentVersions
forall a. Maybe a
Prelude.Nothing
    | Maybe [DocumentVersionMetadata] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeDocumentVersions
DescribeDocumentVersionsResponse
rs
            DescribeDocumentVersionsResponse
-> Getting
     (First [DocumentVersionMetadata])
     DescribeDocumentVersionsResponse
     [DocumentVersionMetadata]
-> Maybe [DocumentVersionMetadata]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [DocumentVersionMetadata]
 -> Const
      (First [DocumentVersionMetadata])
      (Maybe [DocumentVersionMetadata]))
-> DescribeDocumentVersionsResponse
-> Const
     (First [DocumentVersionMetadata]) DescribeDocumentVersionsResponse
Lens'
  DescribeDocumentVersionsResponse (Maybe [DocumentVersionMetadata])
describeDocumentVersionsResponse_documentVersions
              ((Maybe [DocumentVersionMetadata]
  -> Const
       (First [DocumentVersionMetadata])
       (Maybe [DocumentVersionMetadata]))
 -> DescribeDocumentVersionsResponse
 -> Const
      (First [DocumentVersionMetadata]) DescribeDocumentVersionsResponse)
-> (([DocumentVersionMetadata]
     -> Const
          (First [DocumentVersionMetadata]) [DocumentVersionMetadata])
    -> Maybe [DocumentVersionMetadata]
    -> Const
         (First [DocumentVersionMetadata])
         (Maybe [DocumentVersionMetadata]))
-> Getting
     (First [DocumentVersionMetadata])
     DescribeDocumentVersionsResponse
     [DocumentVersionMetadata]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([DocumentVersionMetadata]
 -> Const
      (First [DocumentVersionMetadata]) [DocumentVersionMetadata])
-> Maybe [DocumentVersionMetadata]
-> Const
     (First [DocumentVersionMetadata]) (Maybe [DocumentVersionMetadata])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe DescribeDocumentVersions
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      DescribeDocumentVersions -> Maybe DescribeDocumentVersions
forall a. a -> Maybe a
Prelude.Just (DescribeDocumentVersions -> Maybe DescribeDocumentVersions)
-> DescribeDocumentVersions -> Maybe DescribeDocumentVersions
forall a b. (a -> b) -> a -> b
Prelude.$
        DescribeDocumentVersions
rq
          DescribeDocumentVersions
-> (DescribeDocumentVersions -> DescribeDocumentVersions)
-> DescribeDocumentVersions
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> DescribeDocumentVersions -> Identity DescribeDocumentVersions
Lens
  DescribeDocumentVersions
  DescribeDocumentVersions
  (Maybe Text)
  (Maybe Text)
describeDocumentVersions_marker
          ((Maybe Text -> Identity (Maybe Text))
 -> DescribeDocumentVersions -> Identity DescribeDocumentVersions)
-> Maybe Text
-> DescribeDocumentVersions
-> DescribeDocumentVersions
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse DescribeDocumentVersions
DescribeDocumentVersionsResponse
rs
          DescribeDocumentVersionsResponse
-> Getting (First Text) DescribeDocumentVersionsResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeDocumentVersionsResponse
-> Const (First Text) DescribeDocumentVersionsResponse
Lens' DescribeDocumentVersionsResponse (Maybe Text)
describeDocumentVersionsResponse_marker
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeDocumentVersionsResponse
 -> Const (First Text) DescribeDocumentVersionsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeDocumentVersionsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest DescribeDocumentVersions where
  type
    AWSResponse DescribeDocumentVersions =
      DescribeDocumentVersionsResponse
  request :: DescribeDocumentVersions -> Request DescribeDocumentVersions
request = Service
-> DescribeDocumentVersions -> Request DescribeDocumentVersions
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeDocumentVersions
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeDocumentVersions)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeDocumentVersions))
-> Logger
-> Service
-> Proxy DescribeDocumentVersions
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeDocumentVersions)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [DocumentVersionMetadata]
-> Maybe Text -> Int -> DescribeDocumentVersionsResponse
DescribeDocumentVersionsResponse'
            (Maybe [DocumentVersionMetadata]
 -> Maybe Text -> Int -> DescribeDocumentVersionsResponse)
-> Either String (Maybe [DocumentVersionMetadata])
-> Either
     String (Maybe Text -> Int -> DescribeDocumentVersionsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object
-> Text -> Either String (Maybe (Maybe [DocumentVersionMetadata]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"DocumentVersions"
                            Either String (Maybe (Maybe [DocumentVersionMetadata]))
-> Maybe [DocumentVersionMetadata]
-> Either String (Maybe [DocumentVersionMetadata])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [DocumentVersionMetadata]
forall a. Monoid a => a
Prelude.mempty
                        )
            Either
  String (Maybe Text -> Int -> DescribeDocumentVersionsResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DescribeDocumentVersionsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Marker")
            Either String (Int -> DescribeDocumentVersionsResponse)
-> Either String Int
-> Either String DescribeDocumentVersionsResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DescribeDocumentVersions

instance Prelude.NFData DescribeDocumentVersions

instance Core.ToHeaders DescribeDocumentVersions where
  toHeaders :: DescribeDocumentVersions -> ResponseHeaders
toHeaders DescribeDocumentVersions' {Maybe Natural
Maybe Text
Maybe (Sensitive Text)
Text
documentId :: Text
fields :: Maybe Text
limit :: Maybe Natural
marker :: Maybe Text
authenticationToken :: Maybe (Sensitive Text)
include :: Maybe Text
$sel:documentId:DescribeDocumentVersions' :: DescribeDocumentVersions -> Text
$sel:fields:DescribeDocumentVersions' :: DescribeDocumentVersions -> Maybe Text
$sel:limit:DescribeDocumentVersions' :: DescribeDocumentVersions -> Maybe Natural
$sel:marker:DescribeDocumentVersions' :: DescribeDocumentVersions -> Maybe Text
$sel:authenticationToken:DescribeDocumentVersions' :: DescribeDocumentVersions -> Maybe (Sensitive Text)
$sel:include:DescribeDocumentVersions' :: DescribeDocumentVersions -> Maybe Text
..} =
    [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ HeaderName
"Authentication" HeaderName -> Maybe (Sensitive Text) -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe (Sensitive Text)
authenticationToken,
        HeaderName
"Content-Type"
          HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# (ByteString
"application/x-amz-json-1.1" :: Prelude.ByteString)
      ]

instance Core.ToPath DescribeDocumentVersions where
  toPath :: DescribeDocumentVersions -> ByteString
toPath DescribeDocumentVersions' {Maybe Natural
Maybe Text
Maybe (Sensitive Text)
Text
documentId :: Text
fields :: Maybe Text
limit :: Maybe Natural
marker :: Maybe Text
authenticationToken :: Maybe (Sensitive Text)
include :: Maybe Text
$sel:documentId:DescribeDocumentVersions' :: DescribeDocumentVersions -> Text
$sel:fields:DescribeDocumentVersions' :: DescribeDocumentVersions -> Maybe Text
$sel:limit:DescribeDocumentVersions' :: DescribeDocumentVersions -> Maybe Natural
$sel:marker:DescribeDocumentVersions' :: DescribeDocumentVersions -> Maybe Text
$sel:authenticationToken:DescribeDocumentVersions' :: DescribeDocumentVersions -> Maybe (Sensitive Text)
$sel:include:DescribeDocumentVersions' :: DescribeDocumentVersions -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/api/v1/documents/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
documentId,
        ByteString
"/versions"
      ]

instance Core.ToQuery DescribeDocumentVersions where
  toQuery :: DescribeDocumentVersions -> QueryString
toQuery DescribeDocumentVersions' {Maybe Natural
Maybe Text
Maybe (Sensitive Text)
Text
documentId :: Text
fields :: Maybe Text
limit :: Maybe Natural
marker :: Maybe Text
authenticationToken :: Maybe (Sensitive Text)
include :: Maybe Text
$sel:documentId:DescribeDocumentVersions' :: DescribeDocumentVersions -> Text
$sel:fields:DescribeDocumentVersions' :: DescribeDocumentVersions -> Maybe Text
$sel:limit:DescribeDocumentVersions' :: DescribeDocumentVersions -> Maybe Natural
$sel:marker:DescribeDocumentVersions' :: DescribeDocumentVersions -> Maybe Text
$sel:authenticationToken:DescribeDocumentVersions' :: DescribeDocumentVersions -> Maybe (Sensitive Text)
$sel:include:DescribeDocumentVersions' :: DescribeDocumentVersions -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"include" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
include,
        ByteString
"marker" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
marker,
        ByteString
"limit" ByteString -> Maybe Natural -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Natural
limit,
        ByteString
"fields" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
fields
      ]

-- | /See:/ 'newDescribeDocumentVersionsResponse' smart constructor.
data DescribeDocumentVersionsResponse = DescribeDocumentVersionsResponse'
  { -- | The document versions.
    DescribeDocumentVersionsResponse -> Maybe [DocumentVersionMetadata]
documentVersions :: Prelude.Maybe [DocumentVersionMetadata],
    -- | The marker to use when requesting the next set of results. If there are
    -- no additional results, the string is empty.
    DescribeDocumentVersionsResponse -> Maybe Text
marker :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DescribeDocumentVersionsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeDocumentVersionsResponse
-> DescribeDocumentVersionsResponse -> Bool
(DescribeDocumentVersionsResponse
 -> DescribeDocumentVersionsResponse -> Bool)
-> (DescribeDocumentVersionsResponse
    -> DescribeDocumentVersionsResponse -> Bool)
-> Eq DescribeDocumentVersionsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeDocumentVersionsResponse
-> DescribeDocumentVersionsResponse -> Bool
$c/= :: DescribeDocumentVersionsResponse
-> DescribeDocumentVersionsResponse -> Bool
== :: DescribeDocumentVersionsResponse
-> DescribeDocumentVersionsResponse -> Bool
$c== :: DescribeDocumentVersionsResponse
-> DescribeDocumentVersionsResponse -> Bool
Prelude.Eq, Int -> DescribeDocumentVersionsResponse -> ShowS
[DescribeDocumentVersionsResponse] -> ShowS
DescribeDocumentVersionsResponse -> String
(Int -> DescribeDocumentVersionsResponse -> ShowS)
-> (DescribeDocumentVersionsResponse -> String)
-> ([DescribeDocumentVersionsResponse] -> ShowS)
-> Show DescribeDocumentVersionsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeDocumentVersionsResponse] -> ShowS
$cshowList :: [DescribeDocumentVersionsResponse] -> ShowS
show :: DescribeDocumentVersionsResponse -> String
$cshow :: DescribeDocumentVersionsResponse -> String
showsPrec :: Int -> DescribeDocumentVersionsResponse -> ShowS
$cshowsPrec :: Int -> DescribeDocumentVersionsResponse -> ShowS
Prelude.Show, (forall x.
 DescribeDocumentVersionsResponse
 -> Rep DescribeDocumentVersionsResponse x)
-> (forall x.
    Rep DescribeDocumentVersionsResponse x
    -> DescribeDocumentVersionsResponse)
-> Generic DescribeDocumentVersionsResponse
forall x.
Rep DescribeDocumentVersionsResponse x
-> DescribeDocumentVersionsResponse
forall x.
DescribeDocumentVersionsResponse
-> Rep DescribeDocumentVersionsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeDocumentVersionsResponse x
-> DescribeDocumentVersionsResponse
$cfrom :: forall x.
DescribeDocumentVersionsResponse
-> Rep DescribeDocumentVersionsResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeDocumentVersionsResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'documentVersions', 'describeDocumentVersionsResponse_documentVersions' - The document versions.
--
-- 'marker', 'describeDocumentVersionsResponse_marker' - The marker to use when requesting the next set of results. If there are
-- no additional results, the string is empty.
--
-- 'httpStatus', 'describeDocumentVersionsResponse_httpStatus' - The response's http status code.
newDescribeDocumentVersionsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeDocumentVersionsResponse
newDescribeDocumentVersionsResponse :: Int -> DescribeDocumentVersionsResponse
newDescribeDocumentVersionsResponse Int
pHttpStatus_ =
  DescribeDocumentVersionsResponse' :: Maybe [DocumentVersionMetadata]
-> Maybe Text -> Int -> DescribeDocumentVersionsResponse
DescribeDocumentVersionsResponse'
    { $sel:documentVersions:DescribeDocumentVersionsResponse' :: Maybe [DocumentVersionMetadata]
documentVersions =
        Maybe [DocumentVersionMetadata]
forall a. Maybe a
Prelude.Nothing,
      $sel:marker:DescribeDocumentVersionsResponse' :: Maybe Text
marker = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeDocumentVersionsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The document versions.
describeDocumentVersionsResponse_documentVersions :: Lens.Lens' DescribeDocumentVersionsResponse (Prelude.Maybe [DocumentVersionMetadata])
describeDocumentVersionsResponse_documentVersions :: (Maybe [DocumentVersionMetadata]
 -> f (Maybe [DocumentVersionMetadata]))
-> DescribeDocumentVersionsResponse
-> f DescribeDocumentVersionsResponse
describeDocumentVersionsResponse_documentVersions = (DescribeDocumentVersionsResponse
 -> Maybe [DocumentVersionMetadata])
-> (DescribeDocumentVersionsResponse
    -> Maybe [DocumentVersionMetadata]
    -> DescribeDocumentVersionsResponse)
-> Lens'
     DescribeDocumentVersionsResponse (Maybe [DocumentVersionMetadata])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeDocumentVersionsResponse' {Maybe [DocumentVersionMetadata]
documentVersions :: Maybe [DocumentVersionMetadata]
$sel:documentVersions:DescribeDocumentVersionsResponse' :: DescribeDocumentVersionsResponse -> Maybe [DocumentVersionMetadata]
documentVersions} -> Maybe [DocumentVersionMetadata]
documentVersions) (\s :: DescribeDocumentVersionsResponse
s@DescribeDocumentVersionsResponse' {} Maybe [DocumentVersionMetadata]
a -> DescribeDocumentVersionsResponse
s {$sel:documentVersions:DescribeDocumentVersionsResponse' :: Maybe [DocumentVersionMetadata]
documentVersions = Maybe [DocumentVersionMetadata]
a} :: DescribeDocumentVersionsResponse) ((Maybe [DocumentVersionMetadata]
  -> f (Maybe [DocumentVersionMetadata]))
 -> DescribeDocumentVersionsResponse
 -> f DescribeDocumentVersionsResponse)
-> ((Maybe [DocumentVersionMetadata]
     -> f (Maybe [DocumentVersionMetadata]))
    -> Maybe [DocumentVersionMetadata]
    -> f (Maybe [DocumentVersionMetadata]))
-> (Maybe [DocumentVersionMetadata]
    -> f (Maybe [DocumentVersionMetadata]))
-> DescribeDocumentVersionsResponse
-> f DescribeDocumentVersionsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [DocumentVersionMetadata]
  [DocumentVersionMetadata]
  [DocumentVersionMetadata]
  [DocumentVersionMetadata]
-> Iso
     (Maybe [DocumentVersionMetadata])
     (Maybe [DocumentVersionMetadata])
     (Maybe [DocumentVersionMetadata])
     (Maybe [DocumentVersionMetadata])
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 AnIso
  [DocumentVersionMetadata]
  [DocumentVersionMetadata]
  [DocumentVersionMetadata]
  [DocumentVersionMetadata]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The marker to use when requesting the next set of results. If there are
-- no additional results, the string is empty.
describeDocumentVersionsResponse_marker :: Lens.Lens' DescribeDocumentVersionsResponse (Prelude.Maybe Prelude.Text)
describeDocumentVersionsResponse_marker :: (Maybe Text -> f (Maybe Text))
-> DescribeDocumentVersionsResponse
-> f DescribeDocumentVersionsResponse
describeDocumentVersionsResponse_marker = (DescribeDocumentVersionsResponse -> Maybe Text)
-> (DescribeDocumentVersionsResponse
    -> Maybe Text -> DescribeDocumentVersionsResponse)
-> Lens' DescribeDocumentVersionsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeDocumentVersionsResponse' {Maybe Text
marker :: Maybe Text
$sel:marker:DescribeDocumentVersionsResponse' :: DescribeDocumentVersionsResponse -> Maybe Text
marker} -> Maybe Text
marker) (\s :: DescribeDocumentVersionsResponse
s@DescribeDocumentVersionsResponse' {} Maybe Text
a -> DescribeDocumentVersionsResponse
s {$sel:marker:DescribeDocumentVersionsResponse' :: Maybe Text
marker = Maybe Text
a} :: DescribeDocumentVersionsResponse)

-- | The response's http status code.
describeDocumentVersionsResponse_httpStatus :: Lens.Lens' DescribeDocumentVersionsResponse Prelude.Int
describeDocumentVersionsResponse_httpStatus :: (Int -> f Int)
-> DescribeDocumentVersionsResponse
-> f DescribeDocumentVersionsResponse
describeDocumentVersionsResponse_httpStatus = (DescribeDocumentVersionsResponse -> Int)
-> (DescribeDocumentVersionsResponse
    -> Int -> DescribeDocumentVersionsResponse)
-> Lens
     DescribeDocumentVersionsResponse
     DescribeDocumentVersionsResponse
     Int
     Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeDocumentVersionsResponse' {Int
httpStatus :: Int
$sel:httpStatus:DescribeDocumentVersionsResponse' :: DescribeDocumentVersionsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DescribeDocumentVersionsResponse
s@DescribeDocumentVersionsResponse' {} Int
a -> DescribeDocumentVersionsResponse
s {$sel:httpStatus:DescribeDocumentVersionsResponse' :: Int
httpStatus = Int
a} :: DescribeDocumentVersionsResponse)

instance
  Prelude.NFData
    DescribeDocumentVersionsResponse