{-# 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.WorkMail.CreateResource
(
CreateResource (..),
newCreateResource,
createResource_organizationId,
createResource_name,
createResource_type,
CreateResourceResponse (..),
newCreateResourceResponse,
createResourceResponse_resourceId,
createResourceResponse_httpStatus,
)
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.WorkMail.Types
data CreateResource = CreateResource'
{
CreateResource -> Text
organizationId :: Prelude.Text,
CreateResource -> Text
name :: Prelude.Text,
CreateResource -> ResourceType
type' :: ResourceType
}
deriving (CreateResource -> CreateResource -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateResource -> CreateResource -> Bool
$c/= :: CreateResource -> CreateResource -> Bool
== :: CreateResource -> CreateResource -> Bool
$c== :: CreateResource -> CreateResource -> Bool
Prelude.Eq, ReadPrec [CreateResource]
ReadPrec CreateResource
Int -> ReadS CreateResource
ReadS [CreateResource]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateResource]
$creadListPrec :: ReadPrec [CreateResource]
readPrec :: ReadPrec CreateResource
$creadPrec :: ReadPrec CreateResource
readList :: ReadS [CreateResource]
$creadList :: ReadS [CreateResource]
readsPrec :: Int -> ReadS CreateResource
$creadsPrec :: Int -> ReadS CreateResource
Prelude.Read, Int -> CreateResource -> ShowS
[CreateResource] -> ShowS
CreateResource -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateResource] -> ShowS
$cshowList :: [CreateResource] -> ShowS
show :: CreateResource -> String
$cshow :: CreateResource -> String
showsPrec :: Int -> CreateResource -> ShowS
$cshowsPrec :: Int -> CreateResource -> ShowS
Prelude.Show, forall x. Rep CreateResource x -> CreateResource
forall x. CreateResource -> Rep CreateResource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateResource x -> CreateResource
$cfrom :: forall x. CreateResource -> Rep CreateResource x
Prelude.Generic)
newCreateResource ::
Prelude.Text ->
Prelude.Text ->
ResourceType ->
CreateResource
newCreateResource :: Text -> Text -> ResourceType -> CreateResource
newCreateResource Text
pOrganizationId_ Text
pName_ ResourceType
pType_ =
CreateResource'
{ $sel:organizationId:CreateResource' :: Text
organizationId = Text
pOrganizationId_,
$sel:name:CreateResource' :: Text
name = Text
pName_,
$sel:type':CreateResource' :: ResourceType
type' = ResourceType
pType_
}
createResource_organizationId :: Lens.Lens' CreateResource Prelude.Text
createResource_organizationId :: Lens' CreateResource Text
createResource_organizationId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResource' {Text
organizationId :: Text
$sel:organizationId:CreateResource' :: CreateResource -> Text
organizationId} -> Text
organizationId) (\s :: CreateResource
s@CreateResource' {} Text
a -> CreateResource
s {$sel:organizationId:CreateResource' :: Text
organizationId = Text
a} :: CreateResource)
createResource_name :: Lens.Lens' CreateResource Prelude.Text
createResource_name :: Lens' CreateResource Text
createResource_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResource' {Text
name :: Text
$sel:name:CreateResource' :: CreateResource -> Text
name} -> Text
name) (\s :: CreateResource
s@CreateResource' {} Text
a -> CreateResource
s {$sel:name:CreateResource' :: Text
name = Text
a} :: CreateResource)
createResource_type :: Lens.Lens' CreateResource ResourceType
createResource_type :: Lens' CreateResource ResourceType
createResource_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResource' {ResourceType
type' :: ResourceType
$sel:type':CreateResource' :: CreateResource -> ResourceType
type'} -> ResourceType
type') (\s :: CreateResource
s@CreateResource' {} ResourceType
a -> CreateResource
s {$sel:type':CreateResource' :: ResourceType
type' = ResourceType
a} :: CreateResource)
instance Core.AWSRequest CreateResource where
type
AWSResponse CreateResource =
CreateResourceResponse
request :: (Service -> Service) -> CreateResource -> Request CreateResource
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 CreateResource
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateResource)))
response =
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
( \Int
s ResponseHeaders
h Object
x ->
Maybe Text -> Int -> CreateResourceResponse
CreateResourceResponse'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"ResourceId")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
)
instance Prelude.Hashable CreateResource where
hashWithSalt :: Int -> CreateResource -> Int
hashWithSalt Int
_salt CreateResource' {Text
ResourceType
type' :: ResourceType
name :: Text
organizationId :: Text
$sel:type':CreateResource' :: CreateResource -> ResourceType
$sel:name:CreateResource' :: CreateResource -> Text
$sel:organizationId:CreateResource' :: CreateResource -> Text
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
organizationId
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ResourceType
type'
instance Prelude.NFData CreateResource where
rnf :: CreateResource -> ()
rnf CreateResource' {Text
ResourceType
type' :: ResourceType
name :: Text
organizationId :: Text
$sel:type':CreateResource' :: CreateResource -> ResourceType
$sel:name:CreateResource' :: CreateResource -> Text
$sel:organizationId:CreateResource' :: CreateResource -> Text
..} =
forall a. NFData a => a -> ()
Prelude.rnf Text
organizationId
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ResourceType
type'
instance Data.ToHeaders CreateResource where
toHeaders :: CreateResource -> ResponseHeaders
toHeaders =
forall a b. a -> b -> a
Prelude.const
( forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"X-Amz-Target"
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"WorkMailService.CreateResource" ::
Prelude.ByteString
),
HeaderName
"Content-Type"
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Data.ToJSON CreateResource where
toJSON :: CreateResource -> Value
toJSON CreateResource' {Text
ResourceType
type' :: ResourceType
name :: Text
organizationId :: Text
$sel:type':CreateResource' :: CreateResource -> ResourceType
$sel:name:CreateResource' :: CreateResource -> Text
$sel:organizationId:CreateResource' :: CreateResource -> Text
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ forall a. a -> Maybe a
Prelude.Just
(Key
"OrganizationId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
organizationId),
forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
forall a. a -> Maybe a
Prelude.Just (Key
"Type" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ResourceType
type')
]
)
instance Data.ToPath CreateResource where
toPath :: CreateResource -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Data.ToQuery CreateResource where
toQuery :: CreateResource -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty
data CreateResourceResponse = CreateResourceResponse'
{
CreateResourceResponse -> Maybe Text
resourceId :: Prelude.Maybe Prelude.Text,
CreateResourceResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateResourceResponse -> CreateResourceResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateResourceResponse -> CreateResourceResponse -> Bool
$c/= :: CreateResourceResponse -> CreateResourceResponse -> Bool
== :: CreateResourceResponse -> CreateResourceResponse -> Bool
$c== :: CreateResourceResponse -> CreateResourceResponse -> Bool
Prelude.Eq, ReadPrec [CreateResourceResponse]
ReadPrec CreateResourceResponse
Int -> ReadS CreateResourceResponse
ReadS [CreateResourceResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateResourceResponse]
$creadListPrec :: ReadPrec [CreateResourceResponse]
readPrec :: ReadPrec CreateResourceResponse
$creadPrec :: ReadPrec CreateResourceResponse
readList :: ReadS [CreateResourceResponse]
$creadList :: ReadS [CreateResourceResponse]
readsPrec :: Int -> ReadS CreateResourceResponse
$creadsPrec :: Int -> ReadS CreateResourceResponse
Prelude.Read, Int -> CreateResourceResponse -> ShowS
[CreateResourceResponse] -> ShowS
CreateResourceResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateResourceResponse] -> ShowS
$cshowList :: [CreateResourceResponse] -> ShowS
show :: CreateResourceResponse -> String
$cshow :: CreateResourceResponse -> String
showsPrec :: Int -> CreateResourceResponse -> ShowS
$cshowsPrec :: Int -> CreateResourceResponse -> ShowS
Prelude.Show, forall x. Rep CreateResourceResponse x -> CreateResourceResponse
forall x. CreateResourceResponse -> Rep CreateResourceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateResourceResponse x -> CreateResourceResponse
$cfrom :: forall x. CreateResourceResponse -> Rep CreateResourceResponse x
Prelude.Generic)
newCreateResourceResponse ::
Prelude.Int ->
CreateResourceResponse
newCreateResourceResponse :: Int -> CreateResourceResponse
newCreateResourceResponse Int
pHttpStatus_ =
CreateResourceResponse'
{ $sel:resourceId:CreateResourceResponse' :: Maybe Text
resourceId =
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateResourceResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createResourceResponse_resourceId :: Lens.Lens' CreateResourceResponse (Prelude.Maybe Prelude.Text)
createResourceResponse_resourceId :: Lens' CreateResourceResponse (Maybe Text)
createResourceResponse_resourceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResourceResponse' {Maybe Text
resourceId :: Maybe Text
$sel:resourceId:CreateResourceResponse' :: CreateResourceResponse -> Maybe Text
resourceId} -> Maybe Text
resourceId) (\s :: CreateResourceResponse
s@CreateResourceResponse' {} Maybe Text
a -> CreateResourceResponse
s {$sel:resourceId:CreateResourceResponse' :: Maybe Text
resourceId = Maybe Text
a} :: CreateResourceResponse)
createResourceResponse_httpStatus :: Lens.Lens' CreateResourceResponse Prelude.Int
createResourceResponse_httpStatus :: Lens' CreateResourceResponse Int
createResourceResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResourceResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateResourceResponse' :: CreateResourceResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateResourceResponse
s@CreateResourceResponse' {} Int
a -> CreateResourceResponse
s {$sel:httpStatus:CreateResourceResponse' :: Int
httpStatus = Int
a} :: CreateResourceResponse)
instance Prelude.NFData CreateResourceResponse where
rnf :: CreateResourceResponse -> ()
rnf CreateResourceResponse' {Int
Maybe Text
httpStatus :: Int
resourceId :: Maybe Text
$sel:httpStatus:CreateResourceResponse' :: CreateResourceResponse -> Int
$sel:resourceId:CreateResourceResponse' :: CreateResourceResponse -> Maybe Text
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
resourceId
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus