{-# 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.CreateOrganization
(
CreateOrganization (..),
newCreateOrganization,
createOrganization_featureSet,
CreateOrganizationResponse (..),
newCreateOrganizationResponse,
createOrganizationResponse_organization,
createOrganizationResponse_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 CreateOrganization = CreateOrganization'
{
CreateOrganization -> Maybe OrganizationFeatureSet
featureSet :: Prelude.Maybe OrganizationFeatureSet
}
deriving (CreateOrganization -> CreateOrganization -> Bool
(CreateOrganization -> CreateOrganization -> Bool)
-> (CreateOrganization -> CreateOrganization -> Bool)
-> Eq CreateOrganization
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateOrganization -> CreateOrganization -> Bool
$c/= :: CreateOrganization -> CreateOrganization -> Bool
== :: CreateOrganization -> CreateOrganization -> Bool
$c== :: CreateOrganization -> CreateOrganization -> Bool
Prelude.Eq, ReadPrec [CreateOrganization]
ReadPrec CreateOrganization
Int -> ReadS CreateOrganization
ReadS [CreateOrganization]
(Int -> ReadS CreateOrganization)
-> ReadS [CreateOrganization]
-> ReadPrec CreateOrganization
-> ReadPrec [CreateOrganization]
-> Read CreateOrganization
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateOrganization]
$creadListPrec :: ReadPrec [CreateOrganization]
readPrec :: ReadPrec CreateOrganization
$creadPrec :: ReadPrec CreateOrganization
readList :: ReadS [CreateOrganization]
$creadList :: ReadS [CreateOrganization]
readsPrec :: Int -> ReadS CreateOrganization
$creadsPrec :: Int -> ReadS CreateOrganization
Prelude.Read, Int -> CreateOrganization -> ShowS
[CreateOrganization] -> ShowS
CreateOrganization -> String
(Int -> CreateOrganization -> ShowS)
-> (CreateOrganization -> String)
-> ([CreateOrganization] -> ShowS)
-> Show CreateOrganization
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateOrganization] -> ShowS
$cshowList :: [CreateOrganization] -> ShowS
show :: CreateOrganization -> String
$cshow :: CreateOrganization -> String
showsPrec :: Int -> CreateOrganization -> ShowS
$cshowsPrec :: Int -> CreateOrganization -> ShowS
Prelude.Show, (forall x. CreateOrganization -> Rep CreateOrganization x)
-> (forall x. Rep CreateOrganization x -> CreateOrganization)
-> Generic CreateOrganization
forall x. Rep CreateOrganization x -> CreateOrganization
forall x. CreateOrganization -> Rep CreateOrganization x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateOrganization x -> CreateOrganization
$cfrom :: forall x. CreateOrganization -> Rep CreateOrganization x
Prelude.Generic)
newCreateOrganization ::
CreateOrganization
newCreateOrganization :: CreateOrganization
newCreateOrganization =
CreateOrganization' :: Maybe OrganizationFeatureSet -> CreateOrganization
CreateOrganization' {$sel:featureSet:CreateOrganization' :: Maybe OrganizationFeatureSet
featureSet = Maybe OrganizationFeatureSet
forall a. Maybe a
Prelude.Nothing}
createOrganization_featureSet :: Lens.Lens' CreateOrganization (Prelude.Maybe OrganizationFeatureSet)
createOrganization_featureSet :: (Maybe OrganizationFeatureSet -> f (Maybe OrganizationFeatureSet))
-> CreateOrganization -> f CreateOrganization
createOrganization_featureSet = (CreateOrganization -> Maybe OrganizationFeatureSet)
-> (CreateOrganization
-> Maybe OrganizationFeatureSet -> CreateOrganization)
-> Lens
CreateOrganization
CreateOrganization
(Maybe OrganizationFeatureSet)
(Maybe OrganizationFeatureSet)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateOrganization' {Maybe OrganizationFeatureSet
featureSet :: Maybe OrganizationFeatureSet
$sel:featureSet:CreateOrganization' :: CreateOrganization -> Maybe OrganizationFeatureSet
featureSet} -> Maybe OrganizationFeatureSet
featureSet) (\s :: CreateOrganization
s@CreateOrganization' {} Maybe OrganizationFeatureSet
a -> CreateOrganization
s {$sel:featureSet:CreateOrganization' :: Maybe OrganizationFeatureSet
featureSet = Maybe OrganizationFeatureSet
a} :: CreateOrganization)
instance Core.AWSRequest CreateOrganization where
type
AWSResponse CreateOrganization =
CreateOrganizationResponse
request :: CreateOrganization -> Request CreateOrganization
request = Service -> CreateOrganization -> Request CreateOrganization
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateOrganization
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse CreateOrganization)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateOrganization))
-> Logger
-> Service
-> Proxy CreateOrganization
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse CreateOrganization)))
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 Organization -> Int -> CreateOrganizationResponse
CreateOrganizationResponse'
(Maybe Organization -> Int -> CreateOrganizationResponse)
-> Either String (Maybe Organization)
-> Either String (Int -> CreateOrganizationResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Key -> Either String (Maybe Organization)
forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Core..?> Key
"Organization")
Either String (Int -> CreateOrganizationResponse)
-> Either String Int -> Either String CreateOrganizationResponse
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 CreateOrganization
instance Prelude.NFData CreateOrganization
instance Core.ToHeaders CreateOrganization where
toHeaders :: CreateOrganization -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateOrganization -> 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.CreateOrganization" ::
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 CreateOrganization where
toJSON :: CreateOrganization -> Value
toJSON CreateOrganization' {Maybe OrganizationFeatureSet
featureSet :: Maybe OrganizationFeatureSet
$sel:featureSet:CreateOrganization' :: CreateOrganization -> Maybe OrganizationFeatureSet
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[(Key
"FeatureSet" Key -> OrganizationFeatureSet -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Core..=) (OrganizationFeatureSet -> Pair)
-> Maybe OrganizationFeatureSet -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe OrganizationFeatureSet
featureSet]
)
instance Core.ToPath CreateOrganization where
toPath :: CreateOrganization -> ByteString
toPath = ByteString -> CreateOrganization -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery CreateOrganization where
toQuery :: CreateOrganization -> QueryString
toQuery = QueryString -> CreateOrganization -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateOrganizationResponse = CreateOrganizationResponse'
{
CreateOrganizationResponse -> Maybe Organization
organization :: Prelude.Maybe Organization,
CreateOrganizationResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateOrganizationResponse -> CreateOrganizationResponse -> Bool
(CreateOrganizationResponse -> CreateOrganizationResponse -> Bool)
-> (CreateOrganizationResponse
-> CreateOrganizationResponse -> Bool)
-> Eq CreateOrganizationResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateOrganizationResponse -> CreateOrganizationResponse -> Bool
$c/= :: CreateOrganizationResponse -> CreateOrganizationResponse -> Bool
== :: CreateOrganizationResponse -> CreateOrganizationResponse -> Bool
$c== :: CreateOrganizationResponse -> CreateOrganizationResponse -> Bool
Prelude.Eq, Int -> CreateOrganizationResponse -> ShowS
[CreateOrganizationResponse] -> ShowS
CreateOrganizationResponse -> String
(Int -> CreateOrganizationResponse -> ShowS)
-> (CreateOrganizationResponse -> String)
-> ([CreateOrganizationResponse] -> ShowS)
-> Show CreateOrganizationResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateOrganizationResponse] -> ShowS
$cshowList :: [CreateOrganizationResponse] -> ShowS
show :: CreateOrganizationResponse -> String
$cshow :: CreateOrganizationResponse -> String
showsPrec :: Int -> CreateOrganizationResponse -> ShowS
$cshowsPrec :: Int -> CreateOrganizationResponse -> ShowS
Prelude.Show, (forall x.
CreateOrganizationResponse -> Rep CreateOrganizationResponse x)
-> (forall x.
Rep CreateOrganizationResponse x -> CreateOrganizationResponse)
-> Generic CreateOrganizationResponse
forall x.
Rep CreateOrganizationResponse x -> CreateOrganizationResponse
forall x.
CreateOrganizationResponse -> Rep CreateOrganizationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateOrganizationResponse x -> CreateOrganizationResponse
$cfrom :: forall x.
CreateOrganizationResponse -> Rep CreateOrganizationResponse x
Prelude.Generic)
newCreateOrganizationResponse ::
Prelude.Int ->
CreateOrganizationResponse
newCreateOrganizationResponse :: Int -> CreateOrganizationResponse
newCreateOrganizationResponse Int
pHttpStatus_ =
CreateOrganizationResponse' :: Maybe Organization -> Int -> CreateOrganizationResponse
CreateOrganizationResponse'
{ $sel:organization:CreateOrganizationResponse' :: Maybe Organization
organization =
Maybe Organization
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateOrganizationResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createOrganizationResponse_organization :: Lens.Lens' CreateOrganizationResponse (Prelude.Maybe Organization)
createOrganizationResponse_organization :: (Maybe Organization -> f (Maybe Organization))
-> CreateOrganizationResponse -> f CreateOrganizationResponse
createOrganizationResponse_organization = (CreateOrganizationResponse -> Maybe Organization)
-> (CreateOrganizationResponse
-> Maybe Organization -> CreateOrganizationResponse)
-> Lens
CreateOrganizationResponse
CreateOrganizationResponse
(Maybe Organization)
(Maybe Organization)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateOrganizationResponse' {Maybe Organization
organization :: Maybe Organization
$sel:organization:CreateOrganizationResponse' :: CreateOrganizationResponse -> Maybe Organization
organization} -> Maybe Organization
organization) (\s :: CreateOrganizationResponse
s@CreateOrganizationResponse' {} Maybe Organization
a -> CreateOrganizationResponse
s {$sel:organization:CreateOrganizationResponse' :: Maybe Organization
organization = Maybe Organization
a} :: CreateOrganizationResponse)
createOrganizationResponse_httpStatus :: Lens.Lens' CreateOrganizationResponse Prelude.Int
createOrganizationResponse_httpStatus :: (Int -> f Int)
-> CreateOrganizationResponse -> f CreateOrganizationResponse
createOrganizationResponse_httpStatus = (CreateOrganizationResponse -> Int)
-> (CreateOrganizationResponse
-> Int -> CreateOrganizationResponse)
-> Lens
CreateOrganizationResponse CreateOrganizationResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateOrganizationResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateOrganizationResponse' :: CreateOrganizationResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateOrganizationResponse
s@CreateOrganizationResponse' {} Int
a -> CreateOrganizationResponse
s {$sel:httpStatus:CreateOrganizationResponse' :: Int
httpStatus = Int
a} :: CreateOrganizationResponse)
instance Prelude.NFData CreateOrganizationResponse