{-# 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.Organizations.CreateOrganizationalUnit
(
CreateOrganizationalUnit (..),
newCreateOrganizationalUnit,
createOrganizationalUnit_tags,
createOrganizationalUnit_parentId,
createOrganizationalUnit_name,
CreateOrganizationalUnitResponse (..),
newCreateOrganizationalUnitResponse,
createOrganizationalUnitResponse_organizationalUnit,
createOrganizationalUnitResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Organizations.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data CreateOrganizationalUnit = CreateOrganizationalUnit'
{
CreateOrganizationalUnit -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
CreateOrganizationalUnit -> Text
parentId :: Prelude.Text,
CreateOrganizationalUnit -> Text
name :: Prelude.Text
}
deriving (CreateOrganizationalUnit -> CreateOrganizationalUnit -> Bool
(CreateOrganizationalUnit -> CreateOrganizationalUnit -> Bool)
-> (CreateOrganizationalUnit -> CreateOrganizationalUnit -> Bool)
-> Eq CreateOrganizationalUnit
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateOrganizationalUnit -> CreateOrganizationalUnit -> Bool
$c/= :: CreateOrganizationalUnit -> CreateOrganizationalUnit -> Bool
== :: CreateOrganizationalUnit -> CreateOrganizationalUnit -> Bool
$c== :: CreateOrganizationalUnit -> CreateOrganizationalUnit -> Bool
Prelude.Eq, ReadPrec [CreateOrganizationalUnit]
ReadPrec CreateOrganizationalUnit
Int -> ReadS CreateOrganizationalUnit
ReadS [CreateOrganizationalUnit]
(Int -> ReadS CreateOrganizationalUnit)
-> ReadS [CreateOrganizationalUnit]
-> ReadPrec CreateOrganizationalUnit
-> ReadPrec [CreateOrganizationalUnit]
-> Read CreateOrganizationalUnit
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateOrganizationalUnit]
$creadListPrec :: ReadPrec [CreateOrganizationalUnit]
readPrec :: ReadPrec CreateOrganizationalUnit
$creadPrec :: ReadPrec CreateOrganizationalUnit
readList :: ReadS [CreateOrganizationalUnit]
$creadList :: ReadS [CreateOrganizationalUnit]
readsPrec :: Int -> ReadS CreateOrganizationalUnit
$creadsPrec :: Int -> ReadS CreateOrganizationalUnit
Prelude.Read, Int -> CreateOrganizationalUnit -> ShowS
[CreateOrganizationalUnit] -> ShowS
CreateOrganizationalUnit -> String
(Int -> CreateOrganizationalUnit -> ShowS)
-> (CreateOrganizationalUnit -> String)
-> ([CreateOrganizationalUnit] -> ShowS)
-> Show CreateOrganizationalUnit
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateOrganizationalUnit] -> ShowS
$cshowList :: [CreateOrganizationalUnit] -> ShowS
show :: CreateOrganizationalUnit -> String
$cshow :: CreateOrganizationalUnit -> String
showsPrec :: Int -> CreateOrganizationalUnit -> ShowS
$cshowsPrec :: Int -> CreateOrganizationalUnit -> ShowS
Prelude.Show, (forall x.
CreateOrganizationalUnit -> Rep CreateOrganizationalUnit x)
-> (forall x.
Rep CreateOrganizationalUnit x -> CreateOrganizationalUnit)
-> Generic CreateOrganizationalUnit
forall x.
Rep CreateOrganizationalUnit x -> CreateOrganizationalUnit
forall x.
CreateOrganizationalUnit -> Rep CreateOrganizationalUnit x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateOrganizationalUnit x -> CreateOrganizationalUnit
$cfrom :: forall x.
CreateOrganizationalUnit -> Rep CreateOrganizationalUnit x
Prelude.Generic)
newCreateOrganizationalUnit ::
Prelude.Text ->
Prelude.Text ->
CreateOrganizationalUnit
newCreateOrganizationalUnit :: Text -> Text -> CreateOrganizationalUnit
newCreateOrganizationalUnit Text
pParentId_ Text
pName_ =
CreateOrganizationalUnit' :: Maybe [Tag] -> Text -> Text -> CreateOrganizationalUnit
CreateOrganizationalUnit'
{ $sel:tags:CreateOrganizationalUnit' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
$sel:parentId:CreateOrganizationalUnit' :: Text
parentId = Text
pParentId_,
$sel:name:CreateOrganizationalUnit' :: Text
name = Text
pName_
}
createOrganizationalUnit_tags :: Lens.Lens' CreateOrganizationalUnit (Prelude.Maybe [Tag])
createOrganizationalUnit_tags :: (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateOrganizationalUnit -> f CreateOrganizationalUnit
createOrganizationalUnit_tags = (CreateOrganizationalUnit -> Maybe [Tag])
-> (CreateOrganizationalUnit
-> Maybe [Tag] -> CreateOrganizationalUnit)
-> Lens
CreateOrganizationalUnit
CreateOrganizationalUnit
(Maybe [Tag])
(Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateOrganizationalUnit' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreateOrganizationalUnit' :: CreateOrganizationalUnit -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreateOrganizationalUnit
s@CreateOrganizationalUnit' {} Maybe [Tag]
a -> CreateOrganizationalUnit
s {$sel:tags:CreateOrganizationalUnit' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreateOrganizationalUnit) ((Maybe [Tag] -> f (Maybe [Tag]))
-> CreateOrganizationalUnit -> f CreateOrganizationalUnit)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
-> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateOrganizationalUnit
-> f CreateOrganizationalUnit
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
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 [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
createOrganizationalUnit_parentId :: Lens.Lens' CreateOrganizationalUnit Prelude.Text
createOrganizationalUnit_parentId :: (Text -> f Text)
-> CreateOrganizationalUnit -> f CreateOrganizationalUnit
createOrganizationalUnit_parentId = (CreateOrganizationalUnit -> Text)
-> (CreateOrganizationalUnit -> Text -> CreateOrganizationalUnit)
-> Lens CreateOrganizationalUnit CreateOrganizationalUnit Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateOrganizationalUnit' {Text
parentId :: Text
$sel:parentId:CreateOrganizationalUnit' :: CreateOrganizationalUnit -> Text
parentId} -> Text
parentId) (\s :: CreateOrganizationalUnit
s@CreateOrganizationalUnit' {} Text
a -> CreateOrganizationalUnit
s {$sel:parentId:CreateOrganizationalUnit' :: Text
parentId = Text
a} :: CreateOrganizationalUnit)
createOrganizationalUnit_name :: Lens.Lens' CreateOrganizationalUnit Prelude.Text
createOrganizationalUnit_name :: (Text -> f Text)
-> CreateOrganizationalUnit -> f CreateOrganizationalUnit
createOrganizationalUnit_name = (CreateOrganizationalUnit -> Text)
-> (CreateOrganizationalUnit -> Text -> CreateOrganizationalUnit)
-> Lens CreateOrganizationalUnit CreateOrganizationalUnit Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateOrganizationalUnit' {Text
name :: Text
$sel:name:CreateOrganizationalUnit' :: CreateOrganizationalUnit -> Text
name} -> Text
name) (\s :: CreateOrganizationalUnit
s@CreateOrganizationalUnit' {} Text
a -> CreateOrganizationalUnit
s {$sel:name:CreateOrganizationalUnit' :: Text
name = Text
a} :: CreateOrganizationalUnit)
instance Core.AWSRequest CreateOrganizationalUnit where
type
AWSResponse CreateOrganizationalUnit =
CreateOrganizationalUnitResponse
request :: CreateOrganizationalUnit -> Request CreateOrganizationalUnit
request = Service
-> CreateOrganizationalUnit -> Request CreateOrganizationalUnit
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateOrganizationalUnit
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse CreateOrganizationalUnit)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateOrganizationalUnit))
-> Logger
-> Service
-> Proxy CreateOrganizationalUnit
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse CreateOrganizationalUnit)))
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 OrganizationalUnit -> Int -> CreateOrganizationalUnitResponse
CreateOrganizationalUnitResponse'
(Maybe OrganizationalUnit
-> Int -> CreateOrganizationalUnitResponse)
-> Either String (Maybe OrganizationalUnit)
-> Either String (Int -> CreateOrganizationalUnitResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe OrganizationalUnit)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"OrganizationalUnit")
Either String (Int -> CreateOrganizationalUnitResponse)
-> Either String Int
-> Either String CreateOrganizationalUnitResponse
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 CreateOrganizationalUnit
instance Prelude.NFData CreateOrganizationalUnit
instance Core.ToHeaders CreateOrganizationalUnit where
toHeaders :: CreateOrganizationalUnit -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateOrganizationalUnit -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"X-Amz-Target"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AWSOrganizationsV20161128.CreateOrganizationalUnit" ::
Prelude.ByteString
),
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 CreateOrganizationalUnit where
toJSON :: CreateOrganizationalUnit -> Value
toJSON CreateOrganizationalUnit' {Maybe [Tag]
Text
name :: Text
parentId :: Text
tags :: Maybe [Tag]
$sel:name:CreateOrganizationalUnit' :: CreateOrganizationalUnit -> Text
$sel:parentId:CreateOrganizationalUnit' :: CreateOrganizationalUnit -> Text
$sel:tags:CreateOrganizationalUnit' :: CreateOrganizationalUnit -> Maybe [Tag]
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"Tags" Text -> [Tag] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Tag] -> Pair) -> Maybe [Tag] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ParentId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
parentId),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name)
]
)
instance Core.ToPath CreateOrganizationalUnit where
toPath :: CreateOrganizationalUnit -> ByteString
toPath = ByteString -> CreateOrganizationalUnit -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery CreateOrganizationalUnit where
toQuery :: CreateOrganizationalUnit -> QueryString
toQuery = QueryString -> CreateOrganizationalUnit -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateOrganizationalUnitResponse = CreateOrganizationalUnitResponse'
{
CreateOrganizationalUnitResponse -> Maybe OrganizationalUnit
organizationalUnit :: Prelude.Maybe OrganizationalUnit,
CreateOrganizationalUnitResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateOrganizationalUnitResponse
-> CreateOrganizationalUnitResponse -> Bool
(CreateOrganizationalUnitResponse
-> CreateOrganizationalUnitResponse -> Bool)
-> (CreateOrganizationalUnitResponse
-> CreateOrganizationalUnitResponse -> Bool)
-> Eq CreateOrganizationalUnitResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateOrganizationalUnitResponse
-> CreateOrganizationalUnitResponse -> Bool
$c/= :: CreateOrganizationalUnitResponse
-> CreateOrganizationalUnitResponse -> Bool
== :: CreateOrganizationalUnitResponse
-> CreateOrganizationalUnitResponse -> Bool
$c== :: CreateOrganizationalUnitResponse
-> CreateOrganizationalUnitResponse -> Bool
Prelude.Eq, ReadPrec [CreateOrganizationalUnitResponse]
ReadPrec CreateOrganizationalUnitResponse
Int -> ReadS CreateOrganizationalUnitResponse
ReadS [CreateOrganizationalUnitResponse]
(Int -> ReadS CreateOrganizationalUnitResponse)
-> ReadS [CreateOrganizationalUnitResponse]
-> ReadPrec CreateOrganizationalUnitResponse
-> ReadPrec [CreateOrganizationalUnitResponse]
-> Read CreateOrganizationalUnitResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateOrganizationalUnitResponse]
$creadListPrec :: ReadPrec [CreateOrganizationalUnitResponse]
readPrec :: ReadPrec CreateOrganizationalUnitResponse
$creadPrec :: ReadPrec CreateOrganizationalUnitResponse
readList :: ReadS [CreateOrganizationalUnitResponse]
$creadList :: ReadS [CreateOrganizationalUnitResponse]
readsPrec :: Int -> ReadS CreateOrganizationalUnitResponse
$creadsPrec :: Int -> ReadS CreateOrganizationalUnitResponse
Prelude.Read, Int -> CreateOrganizationalUnitResponse -> ShowS
[CreateOrganizationalUnitResponse] -> ShowS
CreateOrganizationalUnitResponse -> String
(Int -> CreateOrganizationalUnitResponse -> ShowS)
-> (CreateOrganizationalUnitResponse -> String)
-> ([CreateOrganizationalUnitResponse] -> ShowS)
-> Show CreateOrganizationalUnitResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateOrganizationalUnitResponse] -> ShowS
$cshowList :: [CreateOrganizationalUnitResponse] -> ShowS
show :: CreateOrganizationalUnitResponse -> String
$cshow :: CreateOrganizationalUnitResponse -> String
showsPrec :: Int -> CreateOrganizationalUnitResponse -> ShowS
$cshowsPrec :: Int -> CreateOrganizationalUnitResponse -> ShowS
Prelude.Show, (forall x.
CreateOrganizationalUnitResponse
-> Rep CreateOrganizationalUnitResponse x)
-> (forall x.
Rep CreateOrganizationalUnitResponse x
-> CreateOrganizationalUnitResponse)
-> Generic CreateOrganizationalUnitResponse
forall x.
Rep CreateOrganizationalUnitResponse x
-> CreateOrganizationalUnitResponse
forall x.
CreateOrganizationalUnitResponse
-> Rep CreateOrganizationalUnitResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateOrganizationalUnitResponse x
-> CreateOrganizationalUnitResponse
$cfrom :: forall x.
CreateOrganizationalUnitResponse
-> Rep CreateOrganizationalUnitResponse x
Prelude.Generic)
newCreateOrganizationalUnitResponse ::
Prelude.Int ->
CreateOrganizationalUnitResponse
newCreateOrganizationalUnitResponse :: Int -> CreateOrganizationalUnitResponse
newCreateOrganizationalUnitResponse Int
pHttpStatus_ =
CreateOrganizationalUnitResponse' :: Maybe OrganizationalUnit -> Int -> CreateOrganizationalUnitResponse
CreateOrganizationalUnitResponse'
{ $sel:organizationalUnit:CreateOrganizationalUnitResponse' :: Maybe OrganizationalUnit
organizationalUnit =
Maybe OrganizationalUnit
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateOrganizationalUnitResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createOrganizationalUnitResponse_organizationalUnit :: Lens.Lens' CreateOrganizationalUnitResponse (Prelude.Maybe OrganizationalUnit)
createOrganizationalUnitResponse_organizationalUnit :: (Maybe OrganizationalUnit -> f (Maybe OrganizationalUnit))
-> CreateOrganizationalUnitResponse
-> f CreateOrganizationalUnitResponse
createOrganizationalUnitResponse_organizationalUnit = (CreateOrganizationalUnitResponse -> Maybe OrganizationalUnit)
-> (CreateOrganizationalUnitResponse
-> Maybe OrganizationalUnit -> CreateOrganizationalUnitResponse)
-> Lens
CreateOrganizationalUnitResponse
CreateOrganizationalUnitResponse
(Maybe OrganizationalUnit)
(Maybe OrganizationalUnit)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateOrganizationalUnitResponse' {Maybe OrganizationalUnit
organizationalUnit :: Maybe OrganizationalUnit
$sel:organizationalUnit:CreateOrganizationalUnitResponse' :: CreateOrganizationalUnitResponse -> Maybe OrganizationalUnit
organizationalUnit} -> Maybe OrganizationalUnit
organizationalUnit) (\s :: CreateOrganizationalUnitResponse
s@CreateOrganizationalUnitResponse' {} Maybe OrganizationalUnit
a -> CreateOrganizationalUnitResponse
s {$sel:organizationalUnit:CreateOrganizationalUnitResponse' :: Maybe OrganizationalUnit
organizationalUnit = Maybe OrganizationalUnit
a} :: CreateOrganizationalUnitResponse)
createOrganizationalUnitResponse_httpStatus :: Lens.Lens' CreateOrganizationalUnitResponse Prelude.Int
createOrganizationalUnitResponse_httpStatus :: (Int -> f Int)
-> CreateOrganizationalUnitResponse
-> f CreateOrganizationalUnitResponse
createOrganizationalUnitResponse_httpStatus = (CreateOrganizationalUnitResponse -> Int)
-> (CreateOrganizationalUnitResponse
-> Int -> CreateOrganizationalUnitResponse)
-> Lens
CreateOrganizationalUnitResponse
CreateOrganizationalUnitResponse
Int
Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateOrganizationalUnitResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateOrganizationalUnitResponse' :: CreateOrganizationalUnitResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateOrganizationalUnitResponse
s@CreateOrganizationalUnitResponse' {} Int
a -> CreateOrganizationalUnitResponse
s {$sel:httpStatus:CreateOrganizationalUnitResponse' :: Int
httpStatus = Int
a} :: CreateOrganizationalUnitResponse)
instance
Prelude.NFData
CreateOrganizationalUnitResponse