{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.AuditManager.GetOrganizationAdminAccount
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns the name of the delegated Amazon Web Services administrator
-- account for the organization.
module Amazonka.AuditManager.GetOrganizationAdminAccount
  ( -- * Creating a Request
    GetOrganizationAdminAccount (..),
    newGetOrganizationAdminAccount,

    -- * Destructuring the Response
    GetOrganizationAdminAccountResponse (..),
    newGetOrganizationAdminAccountResponse,

    -- * Response Lenses
    getOrganizationAdminAccountResponse_adminAccountId,
    getOrganizationAdminAccountResponse_organizationId,
    getOrganizationAdminAccountResponse_httpStatus,
  )
where

import Amazonka.AuditManager.Types
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

-- | /See:/ 'newGetOrganizationAdminAccount' smart constructor.
data GetOrganizationAdminAccount = GetOrganizationAdminAccount'
  {
  }
  deriving (GetOrganizationAdminAccount -> GetOrganizationAdminAccount -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetOrganizationAdminAccount -> GetOrganizationAdminAccount -> Bool
$c/= :: GetOrganizationAdminAccount -> GetOrganizationAdminAccount -> Bool
== :: GetOrganizationAdminAccount -> GetOrganizationAdminAccount -> Bool
$c== :: GetOrganizationAdminAccount -> GetOrganizationAdminAccount -> Bool
Prelude.Eq, ReadPrec [GetOrganizationAdminAccount]
ReadPrec GetOrganizationAdminAccount
Int -> ReadS GetOrganizationAdminAccount
ReadS [GetOrganizationAdminAccount]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetOrganizationAdminAccount]
$creadListPrec :: ReadPrec [GetOrganizationAdminAccount]
readPrec :: ReadPrec GetOrganizationAdminAccount
$creadPrec :: ReadPrec GetOrganizationAdminAccount
readList :: ReadS [GetOrganizationAdminAccount]
$creadList :: ReadS [GetOrganizationAdminAccount]
readsPrec :: Int -> ReadS GetOrganizationAdminAccount
$creadsPrec :: Int -> ReadS GetOrganizationAdminAccount
Prelude.Read, Int -> GetOrganizationAdminAccount -> ShowS
[GetOrganizationAdminAccount] -> ShowS
GetOrganizationAdminAccount -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetOrganizationAdminAccount] -> ShowS
$cshowList :: [GetOrganizationAdminAccount] -> ShowS
show :: GetOrganizationAdminAccount -> String
$cshow :: GetOrganizationAdminAccount -> String
showsPrec :: Int -> GetOrganizationAdminAccount -> ShowS
$cshowsPrec :: Int -> GetOrganizationAdminAccount -> ShowS
Prelude.Show, forall x.
Rep GetOrganizationAdminAccount x -> GetOrganizationAdminAccount
forall x.
GetOrganizationAdminAccount -> Rep GetOrganizationAdminAccount x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetOrganizationAdminAccount x -> GetOrganizationAdminAccount
$cfrom :: forall x.
GetOrganizationAdminAccount -> Rep GetOrganizationAdminAccount x
Prelude.Generic)

-- |
-- Create a value of 'GetOrganizationAdminAccount' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
newGetOrganizationAdminAccount ::
  GetOrganizationAdminAccount
newGetOrganizationAdminAccount :: GetOrganizationAdminAccount
newGetOrganizationAdminAccount =
  GetOrganizationAdminAccount
GetOrganizationAdminAccount'

instance Core.AWSRequest GetOrganizationAdminAccount where
  type
    AWSResponse GetOrganizationAdminAccount =
      GetOrganizationAdminAccountResponse
  request :: (Service -> Service)
-> GetOrganizationAdminAccount
-> Request GetOrganizationAdminAccount
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetOrganizationAdminAccount
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetOrganizationAdminAccount)))
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
-> Maybe Text -> Int -> GetOrganizationAdminAccountResponse
GetOrganizationAdminAccountResponse'
            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
"adminAccountId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"organizationId")
            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 GetOrganizationAdminAccount where
  hashWithSalt :: Int -> GetOrganizationAdminAccount -> Int
hashWithSalt Int
_salt GetOrganizationAdminAccount
_ =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ()

instance Prelude.NFData GetOrganizationAdminAccount where
  rnf :: GetOrganizationAdminAccount -> ()
rnf GetOrganizationAdminAccount
_ = ()

instance Data.ToHeaders GetOrganizationAdminAccount where
  toHeaders :: GetOrganizationAdminAccount -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToPath GetOrganizationAdminAccount where
  toPath :: GetOrganizationAdminAccount -> ByteString
toPath =
    forall a b. a -> b -> a
Prelude.const ByteString
"/account/organizationAdminAccount"

instance Data.ToQuery GetOrganizationAdminAccount where
  toQuery :: GetOrganizationAdminAccount -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newGetOrganizationAdminAccountResponse' smart constructor.
data GetOrganizationAdminAccountResponse = GetOrganizationAdminAccountResponse'
  { -- | The identifier for the administrator account.
    GetOrganizationAdminAccountResponse -> Maybe Text
adminAccountId :: Prelude.Maybe Prelude.Text,
    -- | The identifier for the organization.
    GetOrganizationAdminAccountResponse -> Maybe Text
organizationId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    GetOrganizationAdminAccountResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetOrganizationAdminAccountResponse
-> GetOrganizationAdminAccountResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetOrganizationAdminAccountResponse
-> GetOrganizationAdminAccountResponse -> Bool
$c/= :: GetOrganizationAdminAccountResponse
-> GetOrganizationAdminAccountResponse -> Bool
== :: GetOrganizationAdminAccountResponse
-> GetOrganizationAdminAccountResponse -> Bool
$c== :: GetOrganizationAdminAccountResponse
-> GetOrganizationAdminAccountResponse -> Bool
Prelude.Eq, ReadPrec [GetOrganizationAdminAccountResponse]
ReadPrec GetOrganizationAdminAccountResponse
Int -> ReadS GetOrganizationAdminAccountResponse
ReadS [GetOrganizationAdminAccountResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetOrganizationAdminAccountResponse]
$creadListPrec :: ReadPrec [GetOrganizationAdminAccountResponse]
readPrec :: ReadPrec GetOrganizationAdminAccountResponse
$creadPrec :: ReadPrec GetOrganizationAdminAccountResponse
readList :: ReadS [GetOrganizationAdminAccountResponse]
$creadList :: ReadS [GetOrganizationAdminAccountResponse]
readsPrec :: Int -> ReadS GetOrganizationAdminAccountResponse
$creadsPrec :: Int -> ReadS GetOrganizationAdminAccountResponse
Prelude.Read, Int -> GetOrganizationAdminAccountResponse -> ShowS
[GetOrganizationAdminAccountResponse] -> ShowS
GetOrganizationAdminAccountResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetOrganizationAdminAccountResponse] -> ShowS
$cshowList :: [GetOrganizationAdminAccountResponse] -> ShowS
show :: GetOrganizationAdminAccountResponse -> String
$cshow :: GetOrganizationAdminAccountResponse -> String
showsPrec :: Int -> GetOrganizationAdminAccountResponse -> ShowS
$cshowsPrec :: Int -> GetOrganizationAdminAccountResponse -> ShowS
Prelude.Show, forall x.
Rep GetOrganizationAdminAccountResponse x
-> GetOrganizationAdminAccountResponse
forall x.
GetOrganizationAdminAccountResponse
-> Rep GetOrganizationAdminAccountResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetOrganizationAdminAccountResponse x
-> GetOrganizationAdminAccountResponse
$cfrom :: forall x.
GetOrganizationAdminAccountResponse
-> Rep GetOrganizationAdminAccountResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetOrganizationAdminAccountResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'adminAccountId', 'getOrganizationAdminAccountResponse_adminAccountId' - The identifier for the administrator account.
--
-- 'organizationId', 'getOrganizationAdminAccountResponse_organizationId' - The identifier for the organization.
--
-- 'httpStatus', 'getOrganizationAdminAccountResponse_httpStatus' - The response's http status code.
newGetOrganizationAdminAccountResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetOrganizationAdminAccountResponse
newGetOrganizationAdminAccountResponse :: Int -> GetOrganizationAdminAccountResponse
newGetOrganizationAdminAccountResponse Int
pHttpStatus_ =
  GetOrganizationAdminAccountResponse'
    { $sel:adminAccountId:GetOrganizationAdminAccountResponse' :: Maybe Text
adminAccountId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:organizationId:GetOrganizationAdminAccountResponse' :: Maybe Text
organizationId = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetOrganizationAdminAccountResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The identifier for the administrator account.
getOrganizationAdminAccountResponse_adminAccountId :: Lens.Lens' GetOrganizationAdminAccountResponse (Prelude.Maybe Prelude.Text)
getOrganizationAdminAccountResponse_adminAccountId :: Lens' GetOrganizationAdminAccountResponse (Maybe Text)
getOrganizationAdminAccountResponse_adminAccountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetOrganizationAdminAccountResponse' {Maybe Text
adminAccountId :: Maybe Text
$sel:adminAccountId:GetOrganizationAdminAccountResponse' :: GetOrganizationAdminAccountResponse -> Maybe Text
adminAccountId} -> Maybe Text
adminAccountId) (\s :: GetOrganizationAdminAccountResponse
s@GetOrganizationAdminAccountResponse' {} Maybe Text
a -> GetOrganizationAdminAccountResponse
s {$sel:adminAccountId:GetOrganizationAdminAccountResponse' :: Maybe Text
adminAccountId = Maybe Text
a} :: GetOrganizationAdminAccountResponse)

-- | The identifier for the organization.
getOrganizationAdminAccountResponse_organizationId :: Lens.Lens' GetOrganizationAdminAccountResponse (Prelude.Maybe Prelude.Text)
getOrganizationAdminAccountResponse_organizationId :: Lens' GetOrganizationAdminAccountResponse (Maybe Text)
getOrganizationAdminAccountResponse_organizationId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetOrganizationAdminAccountResponse' {Maybe Text
organizationId :: Maybe Text
$sel:organizationId:GetOrganizationAdminAccountResponse' :: GetOrganizationAdminAccountResponse -> Maybe Text
organizationId} -> Maybe Text
organizationId) (\s :: GetOrganizationAdminAccountResponse
s@GetOrganizationAdminAccountResponse' {} Maybe Text
a -> GetOrganizationAdminAccountResponse
s {$sel:organizationId:GetOrganizationAdminAccountResponse' :: Maybe Text
organizationId = Maybe Text
a} :: GetOrganizationAdminAccountResponse)

-- | The response's http status code.
getOrganizationAdminAccountResponse_httpStatus :: Lens.Lens' GetOrganizationAdminAccountResponse Prelude.Int
getOrganizationAdminAccountResponse_httpStatus :: Lens' GetOrganizationAdminAccountResponse Int
getOrganizationAdminAccountResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetOrganizationAdminAccountResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetOrganizationAdminAccountResponse' :: GetOrganizationAdminAccountResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetOrganizationAdminAccountResponse
s@GetOrganizationAdminAccountResponse' {} Int
a -> GetOrganizationAdminAccountResponse
s {$sel:httpStatus:GetOrganizationAdminAccountResponse' :: Int
httpStatus = Int
a} :: GetOrganizationAdminAccountResponse)

instance
  Prelude.NFData
    GetOrganizationAdminAccountResponse
  where
  rnf :: GetOrganizationAdminAccountResponse -> ()
rnf GetOrganizationAdminAccountResponse' {Int
Maybe Text
httpStatus :: Int
organizationId :: Maybe Text
adminAccountId :: Maybe Text
$sel:httpStatus:GetOrganizationAdminAccountResponse' :: GetOrganizationAdminAccountResponse -> Int
$sel:organizationId:GetOrganizationAdminAccountResponse' :: GetOrganizationAdminAccountResponse -> Maybe Text
$sel:adminAccountId:GetOrganizationAdminAccountResponse' :: GetOrganizationAdminAccountResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
adminAccountId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
organizationId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus