{-# 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.RestoreDocumentVersions
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Recovers a deleted version of an Amazon WorkDocs document.
module Amazonka.WorkDocs.RestoreDocumentVersions
  ( -- * Creating a Request
    RestoreDocumentVersions (..),
    newRestoreDocumentVersions,

    -- * Request Lenses
    restoreDocumentVersions_authenticationToken,
    restoreDocumentVersions_documentId,

    -- * Destructuring the Response
    RestoreDocumentVersionsResponse (..),
    newRestoreDocumentVersionsResponse,
  )
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:/ 'newRestoreDocumentVersions' smart constructor.
data RestoreDocumentVersions = RestoreDocumentVersions'
  { -- | Amazon WorkDocs authentication token. Not required when using AWS
    -- administrator credentials to access the API.
    RestoreDocumentVersions -> Maybe (Sensitive Text)
authenticationToken :: Prelude.Maybe (Data.Sensitive Prelude.Text),
    -- | The ID of the document.
    RestoreDocumentVersions -> Text
documentId :: Prelude.Text
  }
  deriving (RestoreDocumentVersions -> RestoreDocumentVersions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RestoreDocumentVersions -> RestoreDocumentVersions -> Bool
$c/= :: RestoreDocumentVersions -> RestoreDocumentVersions -> Bool
== :: RestoreDocumentVersions -> RestoreDocumentVersions -> Bool
$c== :: RestoreDocumentVersions -> RestoreDocumentVersions -> Bool
Prelude.Eq, Int -> RestoreDocumentVersions -> ShowS
[RestoreDocumentVersions] -> ShowS
RestoreDocumentVersions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RestoreDocumentVersions] -> ShowS
$cshowList :: [RestoreDocumentVersions] -> ShowS
show :: RestoreDocumentVersions -> String
$cshow :: RestoreDocumentVersions -> String
showsPrec :: Int -> RestoreDocumentVersions -> ShowS
$cshowsPrec :: Int -> RestoreDocumentVersions -> ShowS
Prelude.Show, forall x. Rep RestoreDocumentVersions x -> RestoreDocumentVersions
forall x. RestoreDocumentVersions -> Rep RestoreDocumentVersions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RestoreDocumentVersions x -> RestoreDocumentVersions
$cfrom :: forall x. RestoreDocumentVersions -> Rep RestoreDocumentVersions x
Prelude.Generic)

-- |
-- Create a value of 'RestoreDocumentVersions' 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', 'restoreDocumentVersions_authenticationToken' - Amazon WorkDocs authentication token. Not required when using AWS
-- administrator credentials to access the API.
--
-- 'documentId', 'restoreDocumentVersions_documentId' - The ID of the document.
newRestoreDocumentVersions ::
  -- | 'documentId'
  Prelude.Text ->
  RestoreDocumentVersions
newRestoreDocumentVersions :: Text -> RestoreDocumentVersions
newRestoreDocumentVersions Text
pDocumentId_ =
  RestoreDocumentVersions'
    { $sel:authenticationToken:RestoreDocumentVersions' :: Maybe (Sensitive Text)
authenticationToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:documentId:RestoreDocumentVersions' :: Text
documentId = Text
pDocumentId_
    }

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

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

instance Prelude.Hashable RestoreDocumentVersions where
  hashWithSalt :: Int -> RestoreDocumentVersions -> Int
hashWithSalt Int
_salt RestoreDocumentVersions' {Maybe (Sensitive Text)
Text
documentId :: Text
authenticationToken :: Maybe (Sensitive Text)
$sel:documentId:RestoreDocumentVersions' :: RestoreDocumentVersions -> Text
$sel:authenticationToken:RestoreDocumentVersions' :: RestoreDocumentVersions -> 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

instance Prelude.NFData RestoreDocumentVersions where
  rnf :: RestoreDocumentVersions -> ()
rnf RestoreDocumentVersions' {Maybe (Sensitive Text)
Text
documentId :: Text
authenticationToken :: Maybe (Sensitive Text)
$sel:documentId:RestoreDocumentVersions' :: RestoreDocumentVersions -> Text
$sel:authenticationToken:RestoreDocumentVersions' :: RestoreDocumentVersions -> 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

instance Data.ToHeaders RestoreDocumentVersions where
  toHeaders :: RestoreDocumentVersions -> [Header]
toHeaders RestoreDocumentVersions' {Maybe (Sensitive Text)
Text
documentId :: Text
authenticationToken :: Maybe (Sensitive Text)
$sel:documentId:RestoreDocumentVersions' :: RestoreDocumentVersions -> Text
$sel:authenticationToken:RestoreDocumentVersions' :: RestoreDocumentVersions -> 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.ToJSON RestoreDocumentVersions where
  toJSON :: RestoreDocumentVersions -> Value
toJSON = forall a b. a -> b -> a
Prelude.const (Object -> Value
Data.Object forall a. Monoid a => a
Prelude.mempty)

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

instance Data.ToQuery RestoreDocumentVersions where
  toQuery :: RestoreDocumentVersions -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

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

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

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