{-# 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.UpdateFolder
-- 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)
--
-- Updates the specified attributes of the specified folder. The user must
-- have access to both the folder and its parent folder, if applicable.
module Amazonka.WorkDocs.UpdateFolder
  ( -- * Creating a Request
    UpdateFolder (..),
    newUpdateFolder,

    -- * Request Lenses
    updateFolder_parentFolderId,
    updateFolder_authenticationToken,
    updateFolder_name,
    updateFolder_resourceState,
    updateFolder_folderId,

    -- * Destructuring the Response
    UpdateFolderResponse (..),
    newUpdateFolderResponse,
  )
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:/ 'newUpdateFolder' smart constructor.
data UpdateFolder = UpdateFolder'
  { -- | The ID of the parent folder.
    UpdateFolder -> Maybe Text
parentFolderId :: Prelude.Maybe Prelude.Text,
    -- | Amazon WorkDocs authentication token. Not required when using AWS
    -- administrator credentials to access the API.
    UpdateFolder -> Maybe (Sensitive Text)
authenticationToken :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The name of the folder.
    UpdateFolder -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The resource state of the folder. Only ACTIVE and RECYCLED are accepted
    -- values from the API.
    UpdateFolder -> Maybe ResourceStateType
resourceState :: Prelude.Maybe ResourceStateType,
    -- | The ID of the folder.
    UpdateFolder -> Text
folderId :: Prelude.Text
  }
  deriving (UpdateFolder -> UpdateFolder -> Bool
(UpdateFolder -> UpdateFolder -> Bool)
-> (UpdateFolder -> UpdateFolder -> Bool) -> Eq UpdateFolder
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateFolder -> UpdateFolder -> Bool
$c/= :: UpdateFolder -> UpdateFolder -> Bool
== :: UpdateFolder -> UpdateFolder -> Bool
$c== :: UpdateFolder -> UpdateFolder -> Bool
Prelude.Eq, Int -> UpdateFolder -> ShowS
[UpdateFolder] -> ShowS
UpdateFolder -> String
(Int -> UpdateFolder -> ShowS)
-> (UpdateFolder -> String)
-> ([UpdateFolder] -> ShowS)
-> Show UpdateFolder
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateFolder] -> ShowS
$cshowList :: [UpdateFolder] -> ShowS
show :: UpdateFolder -> String
$cshow :: UpdateFolder -> String
showsPrec :: Int -> UpdateFolder -> ShowS
$cshowsPrec :: Int -> UpdateFolder -> ShowS
Prelude.Show, (forall x. UpdateFolder -> Rep UpdateFolder x)
-> (forall x. Rep UpdateFolder x -> UpdateFolder)
-> Generic UpdateFolder
forall x. Rep UpdateFolder x -> UpdateFolder
forall x. UpdateFolder -> Rep UpdateFolder x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateFolder x -> UpdateFolder
$cfrom :: forall x. UpdateFolder -> Rep UpdateFolder x
Prelude.Generic)

-- |
-- Create a value of 'UpdateFolder' 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:
--
-- 'parentFolderId', 'updateFolder_parentFolderId' - The ID of the parent folder.
--
-- 'authenticationToken', 'updateFolder_authenticationToken' - Amazon WorkDocs authentication token. Not required when using AWS
-- administrator credentials to access the API.
--
-- 'name', 'updateFolder_name' - The name of the folder.
--
-- 'resourceState', 'updateFolder_resourceState' - The resource state of the folder. Only ACTIVE and RECYCLED are accepted
-- values from the API.
--
-- 'folderId', 'updateFolder_folderId' - The ID of the folder.
newUpdateFolder ::
  -- | 'folderId'
  Prelude.Text ->
  UpdateFolder
newUpdateFolder :: Text -> UpdateFolder
newUpdateFolder Text
pFolderId_ =
  UpdateFolder' :: Maybe Text
-> Maybe (Sensitive Text)
-> Maybe Text
-> Maybe ResourceStateType
-> Text
-> UpdateFolder
UpdateFolder'
    { $sel:parentFolderId:UpdateFolder' :: Maybe Text
parentFolderId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:authenticationToken:UpdateFolder' :: Maybe (Sensitive Text)
authenticationToken = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:name:UpdateFolder' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceState:UpdateFolder' :: Maybe ResourceStateType
resourceState = Maybe ResourceStateType
forall a. Maybe a
Prelude.Nothing,
      $sel:folderId:UpdateFolder' :: Text
folderId = Text
pFolderId_
    }

-- | The ID of the parent folder.
updateFolder_parentFolderId :: Lens.Lens' UpdateFolder (Prelude.Maybe Prelude.Text)
updateFolder_parentFolderId :: (Maybe Text -> f (Maybe Text)) -> UpdateFolder -> f UpdateFolder
updateFolder_parentFolderId = (UpdateFolder -> Maybe Text)
-> (UpdateFolder -> Maybe Text -> UpdateFolder)
-> Lens UpdateFolder UpdateFolder (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateFolder' {Maybe Text
parentFolderId :: Maybe Text
$sel:parentFolderId:UpdateFolder' :: UpdateFolder -> Maybe Text
parentFolderId} -> Maybe Text
parentFolderId) (\s :: UpdateFolder
s@UpdateFolder' {} Maybe Text
a -> UpdateFolder
s {$sel:parentFolderId:UpdateFolder' :: Maybe Text
parentFolderId = Maybe Text
a} :: UpdateFolder)

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

-- | The resource state of the folder. Only ACTIVE and RECYCLED are accepted
-- values from the API.
updateFolder_resourceState :: Lens.Lens' UpdateFolder (Prelude.Maybe ResourceStateType)
updateFolder_resourceState :: (Maybe ResourceStateType -> f (Maybe ResourceStateType))
-> UpdateFolder -> f UpdateFolder
updateFolder_resourceState = (UpdateFolder -> Maybe ResourceStateType)
-> (UpdateFolder -> Maybe ResourceStateType -> UpdateFolder)
-> Lens
     UpdateFolder
     UpdateFolder
     (Maybe ResourceStateType)
     (Maybe ResourceStateType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateFolder' {Maybe ResourceStateType
resourceState :: Maybe ResourceStateType
$sel:resourceState:UpdateFolder' :: UpdateFolder -> Maybe ResourceStateType
resourceState} -> Maybe ResourceStateType
resourceState) (\s :: UpdateFolder
s@UpdateFolder' {} Maybe ResourceStateType
a -> UpdateFolder
s {$sel:resourceState:UpdateFolder' :: Maybe ResourceStateType
resourceState = Maybe ResourceStateType
a} :: UpdateFolder)

-- | The ID of the folder.
updateFolder_folderId :: Lens.Lens' UpdateFolder Prelude.Text
updateFolder_folderId :: (Text -> f Text) -> UpdateFolder -> f UpdateFolder
updateFolder_folderId = (UpdateFolder -> Text)
-> (UpdateFolder -> Text -> UpdateFolder)
-> Lens UpdateFolder UpdateFolder Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateFolder' {Text
folderId :: Text
$sel:folderId:UpdateFolder' :: UpdateFolder -> Text
folderId} -> Text
folderId) (\s :: UpdateFolder
s@UpdateFolder' {} Text
a -> UpdateFolder
s {$sel:folderId:UpdateFolder' :: Text
folderId = Text
a} :: UpdateFolder)

instance Core.AWSRequest UpdateFolder where
  type AWSResponse UpdateFolder = UpdateFolderResponse
  request :: UpdateFolder -> Request UpdateFolder
request = Service -> UpdateFolder -> Request UpdateFolder
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.patchJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateFolder
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateFolder)))
response = AWSResponse UpdateFolder
-> Logger
-> Service
-> Proxy UpdateFolder
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateFolder)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse UpdateFolder
UpdateFolderResponse
UpdateFolderResponse'

instance Prelude.Hashable UpdateFolder

instance Prelude.NFData UpdateFolder

instance Core.ToHeaders UpdateFolder where
  toHeaders :: UpdateFolder -> [Header]
toHeaders UpdateFolder' {Maybe Text
Maybe (Sensitive Text)
Maybe ResourceStateType
Text
folderId :: Text
resourceState :: Maybe ResourceStateType
name :: Maybe Text
authenticationToken :: Maybe (Sensitive Text)
parentFolderId :: Maybe Text
$sel:folderId:UpdateFolder' :: UpdateFolder -> Text
$sel:resourceState:UpdateFolder' :: UpdateFolder -> Maybe ResourceStateType
$sel:name:UpdateFolder' :: UpdateFolder -> Maybe Text
$sel:authenticationToken:UpdateFolder' :: UpdateFolder -> Maybe (Sensitive Text)
$sel:parentFolderId:UpdateFolder' :: UpdateFolder -> Maybe Text
..} =
    [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ HeaderName
"Authentication" HeaderName -> Maybe (Sensitive Text) -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# Maybe (Sensitive Text)
authenticationToken,
        HeaderName
"Content-Type"
          HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# (ByteString
"application/x-amz-json-1.1" :: Prelude.ByteString)
      ]

instance Core.ToJSON UpdateFolder where
  toJSON :: UpdateFolder -> Value
toJSON UpdateFolder' {Maybe Text
Maybe (Sensitive Text)
Maybe ResourceStateType
Text
folderId :: Text
resourceState :: Maybe ResourceStateType
name :: Maybe Text
authenticationToken :: Maybe (Sensitive Text)
parentFolderId :: Maybe Text
$sel:folderId:UpdateFolder' :: UpdateFolder -> Text
$sel:resourceState:UpdateFolder' :: UpdateFolder -> Maybe ResourceStateType
$sel:name:UpdateFolder' :: UpdateFolder -> Maybe Text
$sel:authenticationToken:UpdateFolder' :: UpdateFolder -> Maybe (Sensitive Text)
$sel:parentFolderId:UpdateFolder' :: UpdateFolder -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ParentFolderId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
parentFolderId,
            (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
name,
            (Text
"ResourceState" Text -> ResourceStateType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ResourceStateType -> Pair)
-> Maybe ResourceStateType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ResourceStateType
resourceState
          ]
      )

instance Core.ToPath UpdateFolder where
  toPath :: UpdateFolder -> ByteString
toPath UpdateFolder' {Maybe Text
Maybe (Sensitive Text)
Maybe ResourceStateType
Text
folderId :: Text
resourceState :: Maybe ResourceStateType
name :: Maybe Text
authenticationToken :: Maybe (Sensitive Text)
parentFolderId :: Maybe Text
$sel:folderId:UpdateFolder' :: UpdateFolder -> Text
$sel:resourceState:UpdateFolder' :: UpdateFolder -> Maybe ResourceStateType
$sel:name:UpdateFolder' :: UpdateFolder -> Maybe Text
$sel:authenticationToken:UpdateFolder' :: UpdateFolder -> Maybe (Sensitive Text)
$sel:parentFolderId:UpdateFolder' :: UpdateFolder -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/api/v1/folders/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
folderId]

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

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

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

instance Prelude.NFData UpdateFolderResponse