{-# 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.DeleteDocumentVersion
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes a version of an Amazon WorkDocs document. Use the
-- @DeletePriorVersions@ parameter to delete prior versions.
module Amazonka.WorkDocs.DeleteDocumentVersion
  ( -- * Creating a Request
    DeleteDocumentVersion (..),
    newDeleteDocumentVersion,

    -- * Request Lenses
    deleteDocumentVersion_authenticationToken,
    deleteDocumentVersion_documentId,
    deleteDocumentVersion_versionId,
    deleteDocumentVersion_deletePriorVersions,

    -- * Destructuring the Response
    DeleteDocumentVersionResponse (..),
    newDeleteDocumentVersionResponse,
  )
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

-- | /See:/ 'newDeleteDocumentVersion' smart constructor.
data DeleteDocumentVersion = DeleteDocumentVersion'
  { -- | Amazon WorkDocs authentication token. Not required when using AWS
    -- administrator credentials to access the API.
    DeleteDocumentVersion -> Maybe (Sensitive Text)
authenticationToken :: Prelude.Maybe (Data.Sensitive Prelude.Text),
    -- | The ID of a document.
    DeleteDocumentVersion -> Text
documentId :: Prelude.Text,
    -- | The version ID of a document.
    DeleteDocumentVersion -> Text
versionId :: Prelude.Text,
    -- | When set to @TRUE@, deletes the specified version and /all prior
    -- versions/ of a document.
    DeleteDocumentVersion -> Bool
deletePriorVersions :: Prelude.Bool
  }
  deriving (DeleteDocumentVersion -> DeleteDocumentVersion -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteDocumentVersion -> DeleteDocumentVersion -> Bool
$c/= :: DeleteDocumentVersion -> DeleteDocumentVersion -> Bool
== :: DeleteDocumentVersion -> DeleteDocumentVersion -> Bool
$c== :: DeleteDocumentVersion -> DeleteDocumentVersion -> Bool
Prelude.Eq, Int -> DeleteDocumentVersion -> ShowS
[DeleteDocumentVersion] -> ShowS
DeleteDocumentVersion -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteDocumentVersion] -> ShowS
$cshowList :: [DeleteDocumentVersion] -> ShowS
show :: DeleteDocumentVersion -> String
$cshow :: DeleteDocumentVersion -> String
showsPrec :: Int -> DeleteDocumentVersion -> ShowS
$cshowsPrec :: Int -> DeleteDocumentVersion -> ShowS
Prelude.Show, forall x. Rep DeleteDocumentVersion x -> DeleteDocumentVersion
forall x. DeleteDocumentVersion -> Rep DeleteDocumentVersion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteDocumentVersion x -> DeleteDocumentVersion
$cfrom :: forall x. DeleteDocumentVersion -> Rep DeleteDocumentVersion x
Prelude.Generic)

-- |
-- Create a value of 'DeleteDocumentVersion' 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:
--
-- 'authenticationToken', 'deleteDocumentVersion_authenticationToken' - Amazon WorkDocs authentication token. Not required when using AWS
-- administrator credentials to access the API.
--
-- 'documentId', 'deleteDocumentVersion_documentId' - The ID of a document.
--
-- 'versionId', 'deleteDocumentVersion_versionId' - The version ID of a document.
--
-- 'deletePriorVersions', 'deleteDocumentVersion_deletePriorVersions' - When set to @TRUE@, deletes the specified version and /all prior
-- versions/ of a document.
newDeleteDocumentVersion ::
  -- | 'documentId'
  Prelude.Text ->
  -- | 'versionId'
  Prelude.Text ->
  -- | 'deletePriorVersions'
  Prelude.Bool ->
  DeleteDocumentVersion
newDeleteDocumentVersion :: Text -> Text -> Bool -> DeleteDocumentVersion
newDeleteDocumentVersion
  Text
pDocumentId_
  Text
pVersionId_
  Bool
pDeletePriorVersions_ =
    DeleteDocumentVersion'
      { $sel:authenticationToken:DeleteDocumentVersion' :: Maybe (Sensitive Text)
authenticationToken =
          forall a. Maybe a
Prelude.Nothing,
        $sel:documentId:DeleteDocumentVersion' :: Text
documentId = Text
pDocumentId_,
        $sel:versionId:DeleteDocumentVersion' :: Text
versionId = Text
pVersionId_,
        $sel:deletePriorVersions:DeleteDocumentVersion' :: Bool
deletePriorVersions = Bool
pDeletePriorVersions_
      }

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

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

-- | The version ID of a document.
deleteDocumentVersion_versionId :: Lens.Lens' DeleteDocumentVersion Prelude.Text
deleteDocumentVersion_versionId :: Lens' DeleteDocumentVersion Text
deleteDocumentVersion_versionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteDocumentVersion' {Text
versionId :: Text
$sel:versionId:DeleteDocumentVersion' :: DeleteDocumentVersion -> Text
versionId} -> Text
versionId) (\s :: DeleteDocumentVersion
s@DeleteDocumentVersion' {} Text
a -> DeleteDocumentVersion
s {$sel:versionId:DeleteDocumentVersion' :: Text
versionId = Text
a} :: DeleteDocumentVersion)

-- | When set to @TRUE@, deletes the specified version and /all prior
-- versions/ of a document.
deleteDocumentVersion_deletePriorVersions :: Lens.Lens' DeleteDocumentVersion Prelude.Bool
deleteDocumentVersion_deletePriorVersions :: Lens' DeleteDocumentVersion Bool
deleteDocumentVersion_deletePriorVersions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteDocumentVersion' {Bool
deletePriorVersions :: Bool
$sel:deletePriorVersions:DeleteDocumentVersion' :: DeleteDocumentVersion -> Bool
deletePriorVersions} -> Bool
deletePriorVersions) (\s :: DeleteDocumentVersion
s@DeleteDocumentVersion' {} Bool
a -> DeleteDocumentVersion
s {$sel:deletePriorVersions:DeleteDocumentVersion' :: Bool
deletePriorVersions = Bool
a} :: DeleteDocumentVersion)

instance Core.AWSRequest DeleteDocumentVersion where
  type
    AWSResponse DeleteDocumentVersion =
      DeleteDocumentVersionResponse
  request :: (Service -> Service)
-> DeleteDocumentVersion -> Request DeleteDocumentVersion
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.delete (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DeleteDocumentVersion
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteDocumentVersion)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull DeleteDocumentVersionResponse
DeleteDocumentVersionResponse'

instance Prelude.Hashable DeleteDocumentVersion where
  hashWithSalt :: Int -> DeleteDocumentVersion -> Int
hashWithSalt Int
_salt DeleteDocumentVersion' {Bool
Maybe (Sensitive Text)
Text
deletePriorVersions :: Bool
versionId :: Text
documentId :: Text
authenticationToken :: Maybe (Sensitive Text)
$sel:deletePriorVersions:DeleteDocumentVersion' :: DeleteDocumentVersion -> Bool
$sel:versionId:DeleteDocumentVersion' :: DeleteDocumentVersion -> Text
$sel:documentId:DeleteDocumentVersion' :: DeleteDocumentVersion -> Text
$sel:authenticationToken:DeleteDocumentVersion' :: DeleteDocumentVersion -> 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` Text
documentId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
versionId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Bool
deletePriorVersions

instance Prelude.NFData DeleteDocumentVersion where
  rnf :: DeleteDocumentVersion -> ()
rnf DeleteDocumentVersion' {Bool
Maybe (Sensitive Text)
Text
deletePriorVersions :: Bool
versionId :: Text
documentId :: Text
authenticationToken :: Maybe (Sensitive Text)
$sel:deletePriorVersions:DeleteDocumentVersion' :: DeleteDocumentVersion -> Bool
$sel:versionId:DeleteDocumentVersion' :: DeleteDocumentVersion -> Text
$sel:documentId:DeleteDocumentVersion' :: DeleteDocumentVersion -> Text
$sel:authenticationToken:DeleteDocumentVersion' :: DeleteDocumentVersion -> 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 Text
documentId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
versionId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Bool
deletePriorVersions

instance Data.ToHeaders DeleteDocumentVersion where
  toHeaders :: DeleteDocumentVersion -> [Header]
toHeaders DeleteDocumentVersion' {Bool
Maybe (Sensitive Text)
Text
deletePriorVersions :: Bool
versionId :: Text
documentId :: Text
authenticationToken :: Maybe (Sensitive Text)
$sel:deletePriorVersions:DeleteDocumentVersion' :: DeleteDocumentVersion -> Bool
$sel:versionId:DeleteDocumentVersion' :: DeleteDocumentVersion -> Text
$sel:documentId:DeleteDocumentVersion' :: DeleteDocumentVersion -> Text
$sel:authenticationToken:DeleteDocumentVersion' :: DeleteDocumentVersion -> Maybe (Sensitive Text)
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ HeaderName
"Authentication" forall a. ToHeader a => HeaderName -> a -> [Header]
Data.=# Maybe (Sensitive Text)
authenticationToken,
        HeaderName
"Content-Type"
          forall a. ToHeader a => HeaderName -> a -> [Header]
Data.=# (ByteString
"application/x-amz-json-1.1" :: Prelude.ByteString)
      ]

instance Data.ToPath DeleteDocumentVersion where
  toPath :: DeleteDocumentVersion -> ByteString
toPath DeleteDocumentVersion' {Bool
Maybe (Sensitive Text)
Text
deletePriorVersions :: Bool
versionId :: Text
documentId :: Text
authenticationToken :: Maybe (Sensitive Text)
$sel:deletePriorVersions:DeleteDocumentVersion' :: DeleteDocumentVersion -> Bool
$sel:versionId:DeleteDocumentVersion' :: DeleteDocumentVersion -> Text
$sel:documentId:DeleteDocumentVersion' :: DeleteDocumentVersion -> Text
$sel:authenticationToken:DeleteDocumentVersion' :: DeleteDocumentVersion -> Maybe (Sensitive Text)
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/api/v1/documentVersions/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
documentId,
        ByteString
"/versions/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
versionId
      ]

instance Data.ToQuery DeleteDocumentVersion where
  toQuery :: DeleteDocumentVersion -> QueryString
toQuery DeleteDocumentVersion' {Bool
Maybe (Sensitive Text)
Text
deletePriorVersions :: Bool
versionId :: Text
documentId :: Text
authenticationToken :: Maybe (Sensitive Text)
$sel:deletePriorVersions:DeleteDocumentVersion' :: DeleteDocumentVersion -> Bool
$sel:versionId:DeleteDocumentVersion' :: DeleteDocumentVersion -> Text
$sel:documentId:DeleteDocumentVersion' :: DeleteDocumentVersion -> Text
$sel:authenticationToken:DeleteDocumentVersion' :: DeleteDocumentVersion -> Maybe (Sensitive Text)
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"deletePriorVersions" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Bool
deletePriorVersions]

-- | /See:/ 'newDeleteDocumentVersionResponse' smart constructor.
data DeleteDocumentVersionResponse = DeleteDocumentVersionResponse'
  {
  }
  deriving (DeleteDocumentVersionResponse
-> DeleteDocumentVersionResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteDocumentVersionResponse
-> DeleteDocumentVersionResponse -> Bool
$c/= :: DeleteDocumentVersionResponse
-> DeleteDocumentVersionResponse -> Bool
== :: DeleteDocumentVersionResponse
-> DeleteDocumentVersionResponse -> Bool
$c== :: DeleteDocumentVersionResponse
-> DeleteDocumentVersionResponse -> Bool
Prelude.Eq, ReadPrec [DeleteDocumentVersionResponse]
ReadPrec DeleteDocumentVersionResponse
Int -> ReadS DeleteDocumentVersionResponse
ReadS [DeleteDocumentVersionResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteDocumentVersionResponse]
$creadListPrec :: ReadPrec [DeleteDocumentVersionResponse]
readPrec :: ReadPrec DeleteDocumentVersionResponse
$creadPrec :: ReadPrec DeleteDocumentVersionResponse
readList :: ReadS [DeleteDocumentVersionResponse]
$creadList :: ReadS [DeleteDocumentVersionResponse]
readsPrec :: Int -> ReadS DeleteDocumentVersionResponse
$creadsPrec :: Int -> ReadS DeleteDocumentVersionResponse
Prelude.Read, Int -> DeleteDocumentVersionResponse -> ShowS
[DeleteDocumentVersionResponse] -> ShowS
DeleteDocumentVersionResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteDocumentVersionResponse] -> ShowS
$cshowList :: [DeleteDocumentVersionResponse] -> ShowS
show :: DeleteDocumentVersionResponse -> String
$cshow :: DeleteDocumentVersionResponse -> String
showsPrec :: Int -> DeleteDocumentVersionResponse -> ShowS
$cshowsPrec :: Int -> DeleteDocumentVersionResponse -> ShowS
Prelude.Show, forall x.
Rep DeleteDocumentVersionResponse x
-> DeleteDocumentVersionResponse
forall x.
DeleteDocumentVersionResponse
-> Rep DeleteDocumentVersionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteDocumentVersionResponse x
-> DeleteDocumentVersionResponse
$cfrom :: forall x.
DeleteDocumentVersionResponse
-> Rep DeleteDocumentVersionResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteDocumentVersionResponse' 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.
newDeleteDocumentVersionResponse ::
  DeleteDocumentVersionResponse
newDeleteDocumentVersionResponse :: DeleteDocumentVersionResponse
newDeleteDocumentVersionResponse =
  DeleteDocumentVersionResponse
DeleteDocumentVersionResponse'

instance Prelude.NFData DeleteDocumentVersionResponse where
  rnf :: DeleteDocumentVersionResponse -> ()
rnf DeleteDocumentVersionResponse
_ = ()