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