{-# 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.CreateFolder
(
CreateFolder (..),
newCreateFolder,
createFolder_authenticationToken,
createFolder_name,
createFolder_parentFolderId,
CreateFolderResponse (..),
newCreateFolderResponse,
createFolderResponse_metadata,
createFolderResponse_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
data CreateFolder = CreateFolder'
{
CreateFolder -> Maybe (Sensitive Text)
authenticationToken :: Prelude.Maybe (Core.Sensitive Prelude.Text),
CreateFolder -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
CreateFolder -> Text
parentFolderId :: Prelude.Text
}
deriving (CreateFolder -> CreateFolder -> Bool
(CreateFolder -> CreateFolder -> Bool)
-> (CreateFolder -> CreateFolder -> Bool) -> Eq CreateFolder
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateFolder -> CreateFolder -> Bool
$c/= :: CreateFolder -> CreateFolder -> Bool
== :: CreateFolder -> CreateFolder -> Bool
$c== :: CreateFolder -> CreateFolder -> Bool
Prelude.Eq, Int -> CreateFolder -> ShowS
[CreateFolder] -> ShowS
CreateFolder -> String
(Int -> CreateFolder -> ShowS)
-> (CreateFolder -> String)
-> ([CreateFolder] -> ShowS)
-> Show CreateFolder
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateFolder] -> ShowS
$cshowList :: [CreateFolder] -> ShowS
show :: CreateFolder -> String
$cshow :: CreateFolder -> String
showsPrec :: Int -> CreateFolder -> ShowS
$cshowsPrec :: Int -> CreateFolder -> ShowS
Prelude.Show, (forall x. CreateFolder -> Rep CreateFolder x)
-> (forall x. Rep CreateFolder x -> CreateFolder)
-> Generic CreateFolder
forall x. Rep CreateFolder x -> CreateFolder
forall x. CreateFolder -> Rep CreateFolder x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateFolder x -> CreateFolder
$cfrom :: forall x. CreateFolder -> Rep CreateFolder x
Prelude.Generic)
newCreateFolder ::
Prelude.Text ->
CreateFolder
newCreateFolder :: Text -> CreateFolder
newCreateFolder Text
pParentFolderId_ =
CreateFolder' :: Maybe (Sensitive Text) -> Maybe Text -> Text -> CreateFolder
CreateFolder'
{ $sel:authenticationToken:CreateFolder' :: Maybe (Sensitive Text)
authenticationToken =
Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
$sel:name:CreateFolder' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:parentFolderId:CreateFolder' :: Text
parentFolderId = Text
pParentFolderId_
}
createFolder_authenticationToken :: Lens.Lens' CreateFolder (Prelude.Maybe Prelude.Text)
createFolder_authenticationToken :: (Maybe Text -> f (Maybe Text)) -> CreateFolder -> f CreateFolder
createFolder_authenticationToken = (CreateFolder -> Maybe (Sensitive Text))
-> (CreateFolder -> Maybe (Sensitive Text) -> CreateFolder)
-> Lens
CreateFolder
CreateFolder
(Maybe (Sensitive Text))
(Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFolder' {Maybe (Sensitive Text)
authenticationToken :: Maybe (Sensitive Text)
$sel:authenticationToken:CreateFolder' :: CreateFolder -> Maybe (Sensitive Text)
authenticationToken} -> Maybe (Sensitive Text)
authenticationToken) (\s :: CreateFolder
s@CreateFolder' {} Maybe (Sensitive Text)
a -> CreateFolder
s {$sel:authenticationToken:CreateFolder' :: Maybe (Sensitive Text)
authenticationToken = Maybe (Sensitive Text)
a} :: CreateFolder) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> CreateFolder -> f CreateFolder)
-> ((Maybe Text -> f (Maybe Text))
-> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> CreateFolder
-> f CreateFolder
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
createFolder_name :: Lens.Lens' CreateFolder (Prelude.Maybe Prelude.Text)
createFolder_name :: (Maybe Text -> f (Maybe Text)) -> CreateFolder -> f CreateFolder
createFolder_name = (CreateFolder -> Maybe Text)
-> (CreateFolder -> Maybe Text -> CreateFolder)
-> Lens CreateFolder CreateFolder (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFolder' {Maybe Text
name :: Maybe Text
$sel:name:CreateFolder' :: CreateFolder -> Maybe Text
name} -> Maybe Text
name) (\s :: CreateFolder
s@CreateFolder' {} Maybe Text
a -> CreateFolder
s {$sel:name:CreateFolder' :: Maybe Text
name = Maybe Text
a} :: CreateFolder)
createFolder_parentFolderId :: Lens.Lens' CreateFolder Prelude.Text
createFolder_parentFolderId :: (Text -> f Text) -> CreateFolder -> f CreateFolder
createFolder_parentFolderId = (CreateFolder -> Text)
-> (CreateFolder -> Text -> CreateFolder)
-> Lens CreateFolder CreateFolder Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFolder' {Text
parentFolderId :: Text
$sel:parentFolderId:CreateFolder' :: CreateFolder -> Text
parentFolderId} -> Text
parentFolderId) (\s :: CreateFolder
s@CreateFolder' {} Text
a -> CreateFolder
s {$sel:parentFolderId:CreateFolder' :: Text
parentFolderId = Text
a} :: CreateFolder)
instance Core.AWSRequest CreateFolder where
type AWSResponse CreateFolder = CreateFolderResponse
request :: CreateFolder -> Request CreateFolder
request = Service -> CreateFolder -> Request CreateFolder
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateFolder
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateFolder)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateFolder))
-> Logger
-> Service
-> Proxy CreateFolder
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateFolder)))
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 FolderMetadata -> Int -> CreateFolderResponse
CreateFolderResponse'
(Maybe FolderMetadata -> Int -> CreateFolderResponse)
-> Either String (Maybe FolderMetadata)
-> Either String (Int -> CreateFolderResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe FolderMetadata)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Metadata")
Either String (Int -> CreateFolderResponse)
-> Either String Int -> Either String CreateFolderResponse
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 CreateFolder
instance Prelude.NFData CreateFolder
instance Core.ToHeaders CreateFolder where
toHeaders :: CreateFolder -> ResponseHeaders
toHeaders CreateFolder' {Maybe Text
Maybe (Sensitive Text)
Text
parentFolderId :: Text
name :: Maybe Text
authenticationToken :: Maybe (Sensitive Text)
$sel:parentFolderId:CreateFolder' :: CreateFolder -> Text
$sel:name:CreateFolder' :: CreateFolder -> Maybe Text
$sel:authenticationToken:CreateFolder' :: CreateFolder -> Maybe (Sensitive 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.ToJSON CreateFolder where
toJSON :: CreateFolder -> Value
toJSON CreateFolder' {Maybe Text
Maybe (Sensitive Text)
Text
parentFolderId :: Text
name :: Maybe Text
authenticationToken :: Maybe (Sensitive Text)
$sel:parentFolderId:CreateFolder' :: CreateFolder -> Text
$sel:name:CreateFolder' :: CreateFolder -> Maybe Text
$sel:authenticationToken:CreateFolder' :: CreateFolder -> Maybe (Sensitive Text)
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (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,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"ParentFolderId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
parentFolderId)
]
)
instance Core.ToPath CreateFolder where
toPath :: CreateFolder -> ByteString
toPath = ByteString -> CreateFolder -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/api/v1/folders"
instance Core.ToQuery CreateFolder where
toQuery :: CreateFolder -> QueryString
toQuery = QueryString -> CreateFolder -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateFolderResponse = CreateFolderResponse'
{
CreateFolderResponse -> Maybe FolderMetadata
metadata :: Prelude.Maybe FolderMetadata,
CreateFolderResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateFolderResponse -> CreateFolderResponse -> Bool
(CreateFolderResponse -> CreateFolderResponse -> Bool)
-> (CreateFolderResponse -> CreateFolderResponse -> Bool)
-> Eq CreateFolderResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateFolderResponse -> CreateFolderResponse -> Bool
$c/= :: CreateFolderResponse -> CreateFolderResponse -> Bool
== :: CreateFolderResponse -> CreateFolderResponse -> Bool
$c== :: CreateFolderResponse -> CreateFolderResponse -> Bool
Prelude.Eq, ReadPrec [CreateFolderResponse]
ReadPrec CreateFolderResponse
Int -> ReadS CreateFolderResponse
ReadS [CreateFolderResponse]
(Int -> ReadS CreateFolderResponse)
-> ReadS [CreateFolderResponse]
-> ReadPrec CreateFolderResponse
-> ReadPrec [CreateFolderResponse]
-> Read CreateFolderResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateFolderResponse]
$creadListPrec :: ReadPrec [CreateFolderResponse]
readPrec :: ReadPrec CreateFolderResponse
$creadPrec :: ReadPrec CreateFolderResponse
readList :: ReadS [CreateFolderResponse]
$creadList :: ReadS [CreateFolderResponse]
readsPrec :: Int -> ReadS CreateFolderResponse
$creadsPrec :: Int -> ReadS CreateFolderResponse
Prelude.Read, Int -> CreateFolderResponse -> ShowS
[CreateFolderResponse] -> ShowS
CreateFolderResponse -> String
(Int -> CreateFolderResponse -> ShowS)
-> (CreateFolderResponse -> String)
-> ([CreateFolderResponse] -> ShowS)
-> Show CreateFolderResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateFolderResponse] -> ShowS
$cshowList :: [CreateFolderResponse] -> ShowS
show :: CreateFolderResponse -> String
$cshow :: CreateFolderResponse -> String
showsPrec :: Int -> CreateFolderResponse -> ShowS
$cshowsPrec :: Int -> CreateFolderResponse -> ShowS
Prelude.Show, (forall x. CreateFolderResponse -> Rep CreateFolderResponse x)
-> (forall x. Rep CreateFolderResponse x -> CreateFolderResponse)
-> Generic CreateFolderResponse
forall x. Rep CreateFolderResponse x -> CreateFolderResponse
forall x. CreateFolderResponse -> Rep CreateFolderResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateFolderResponse x -> CreateFolderResponse
$cfrom :: forall x. CreateFolderResponse -> Rep CreateFolderResponse x
Prelude.Generic)
newCreateFolderResponse ::
Prelude.Int ->
CreateFolderResponse
newCreateFolderResponse :: Int -> CreateFolderResponse
newCreateFolderResponse Int
pHttpStatus_ =
CreateFolderResponse' :: Maybe FolderMetadata -> Int -> CreateFolderResponse
CreateFolderResponse'
{ $sel:metadata:CreateFolderResponse' :: Maybe FolderMetadata
metadata = Maybe FolderMetadata
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateFolderResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createFolderResponse_metadata :: Lens.Lens' CreateFolderResponse (Prelude.Maybe FolderMetadata)
createFolderResponse_metadata :: (Maybe FolderMetadata -> f (Maybe FolderMetadata))
-> CreateFolderResponse -> f CreateFolderResponse
createFolderResponse_metadata = (CreateFolderResponse -> Maybe FolderMetadata)
-> (CreateFolderResponse
-> Maybe FolderMetadata -> CreateFolderResponse)
-> Lens
CreateFolderResponse
CreateFolderResponse
(Maybe FolderMetadata)
(Maybe FolderMetadata)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFolderResponse' {Maybe FolderMetadata
metadata :: Maybe FolderMetadata
$sel:metadata:CreateFolderResponse' :: CreateFolderResponse -> Maybe FolderMetadata
metadata} -> Maybe FolderMetadata
metadata) (\s :: CreateFolderResponse
s@CreateFolderResponse' {} Maybe FolderMetadata
a -> CreateFolderResponse
s {$sel:metadata:CreateFolderResponse' :: Maybe FolderMetadata
metadata = Maybe FolderMetadata
a} :: CreateFolderResponse)
createFolderResponse_httpStatus :: Lens.Lens' CreateFolderResponse Prelude.Int
createFolderResponse_httpStatus :: (Int -> f Int) -> CreateFolderResponse -> f CreateFolderResponse
createFolderResponse_httpStatus = (CreateFolderResponse -> Int)
-> (CreateFolderResponse -> Int -> CreateFolderResponse)
-> Lens CreateFolderResponse CreateFolderResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFolderResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateFolderResponse' :: CreateFolderResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateFolderResponse
s@CreateFolderResponse' {} Int
a -> CreateFolderResponse
s {$sel:httpStatus:CreateFolderResponse' :: Int
httpStatus = Int
a} :: CreateFolderResponse)
instance Prelude.NFData CreateFolderResponse