{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- 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.Lens as Lens
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
(GetOrganizationAdminAccount
 -> GetOrganizationAdminAccount -> Bool)
-> (GetOrganizationAdminAccount
    -> GetOrganizationAdminAccount -> Bool)
-> Eq GetOrganizationAdminAccount
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]
(Int -> ReadS GetOrganizationAdminAccount)
-> ReadS [GetOrganizationAdminAccount]
-> ReadPrec GetOrganizationAdminAccount
-> ReadPrec [GetOrganizationAdminAccount]
-> Read 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
(Int -> GetOrganizationAdminAccount -> ShowS)
-> (GetOrganizationAdminAccount -> String)
-> ([GetOrganizationAdminAccount] -> ShowS)
-> Show GetOrganizationAdminAccount
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.
 GetOrganizationAdminAccount -> Rep GetOrganizationAdminAccount x)
-> (forall x.
    Rep GetOrganizationAdminAccount x -> GetOrganizationAdminAccount)
-> Generic GetOrganizationAdminAccount
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 :: GetOrganizationAdminAccount -> Request GetOrganizationAdminAccount
request = Service
-> GetOrganizationAdminAccount
-> Request GetOrganizationAdminAccount
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetOrganizationAdminAccount
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetOrganizationAdminAccount)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetOrganizationAdminAccount))
-> Logger
-> Service
-> Proxy GetOrganizationAdminAccount
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetOrganizationAdminAccount)))
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 Text
-> Maybe Text -> Int -> GetOrganizationAdminAccountResponse
GetOrganizationAdminAccountResponse'
            (Maybe Text
 -> Maybe Text -> Int -> GetOrganizationAdminAccountResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe Text -> Int -> GetOrganizationAdminAccountResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"adminAccountId")
            Either
  String (Maybe Text -> Int -> GetOrganizationAdminAccountResponse)
-> Either String (Maybe Text)
-> Either String (Int -> GetOrganizationAdminAccountResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"organizationId")
            Either String (Int -> GetOrganizationAdminAccountResponse)
-> Either String Int
-> Either String GetOrganizationAdminAccountResponse
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 GetOrganizationAdminAccount

instance Prelude.NFData GetOrganizationAdminAccount

instance Core.ToHeaders GetOrganizationAdminAccount where
  toHeaders :: GetOrganizationAdminAccount -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetOrganizationAdminAccount -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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.ToPath GetOrganizationAdminAccount where
  toPath :: GetOrganizationAdminAccount -> ByteString
toPath =
    ByteString -> GetOrganizationAdminAccount -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/account/organizationAdminAccount"

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

-- | /See:/ 'newGetOrganizationAdminAccountResponse' smart constructor.
data GetOrganizationAdminAccountResponse = GetOrganizationAdminAccountResponse'
  { -- | The identifier for the specified administrator account.
    GetOrganizationAdminAccountResponse -> Maybe Text
adminAccountId :: Prelude.Maybe Prelude.Text,
    -- | The identifier for the specified organization.
    GetOrganizationAdminAccountResponse -> Maybe Text
organizationId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    GetOrganizationAdminAccountResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetOrganizationAdminAccountResponse
-> GetOrganizationAdminAccountResponse -> Bool
(GetOrganizationAdminAccountResponse
 -> GetOrganizationAdminAccountResponse -> Bool)
-> (GetOrganizationAdminAccountResponse
    -> GetOrganizationAdminAccountResponse -> Bool)
-> Eq GetOrganizationAdminAccountResponse
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]
(Int -> ReadS GetOrganizationAdminAccountResponse)
-> ReadS [GetOrganizationAdminAccountResponse]
-> ReadPrec GetOrganizationAdminAccountResponse
-> ReadPrec [GetOrganizationAdminAccountResponse]
-> Read 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
(Int -> GetOrganizationAdminAccountResponse -> ShowS)
-> (GetOrganizationAdminAccountResponse -> String)
-> ([GetOrganizationAdminAccountResponse] -> ShowS)
-> Show GetOrganizationAdminAccountResponse
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.
 GetOrganizationAdminAccountResponse
 -> Rep GetOrganizationAdminAccountResponse x)
-> (forall x.
    Rep GetOrganizationAdminAccountResponse x
    -> GetOrganizationAdminAccountResponse)
-> Generic GetOrganizationAdminAccountResponse
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 specified administrator account.
--
-- 'organizationId', 'getOrganizationAdminAccountResponse_organizationId' - The identifier for the specified organization.
--
-- 'httpStatus', 'getOrganizationAdminAccountResponse_httpStatus' - The response's http status code.
newGetOrganizationAdminAccountResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetOrganizationAdminAccountResponse
newGetOrganizationAdminAccountResponse :: Int -> GetOrganizationAdminAccountResponse
newGetOrganizationAdminAccountResponse Int
pHttpStatus_ =
  GetOrganizationAdminAccountResponse' :: Maybe Text
-> Maybe Text -> Int -> GetOrganizationAdminAccountResponse
GetOrganizationAdminAccountResponse'
    { $sel:adminAccountId:GetOrganizationAdminAccountResponse' :: Maybe Text
adminAccountId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:organizationId:GetOrganizationAdminAccountResponse' :: Maybe Text
organizationId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetOrganizationAdminAccountResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The identifier for the specified administrator account.
getOrganizationAdminAccountResponse_adminAccountId :: Lens.Lens' GetOrganizationAdminAccountResponse (Prelude.Maybe Prelude.Text)
getOrganizationAdminAccountResponse_adminAccountId :: (Maybe Text -> f (Maybe Text))
-> GetOrganizationAdminAccountResponse
-> f GetOrganizationAdminAccountResponse
getOrganizationAdminAccountResponse_adminAccountId = (GetOrganizationAdminAccountResponse -> Maybe Text)
-> (GetOrganizationAdminAccountResponse
    -> Maybe Text -> GetOrganizationAdminAccountResponse)
-> Lens
     GetOrganizationAdminAccountResponse
     GetOrganizationAdminAccountResponse
     (Maybe Text)
     (Maybe Text)
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 specified organization.
getOrganizationAdminAccountResponse_organizationId :: Lens.Lens' GetOrganizationAdminAccountResponse (Prelude.Maybe Prelude.Text)
getOrganizationAdminAccountResponse_organizationId :: (Maybe Text -> f (Maybe Text))
-> GetOrganizationAdminAccountResponse
-> f GetOrganizationAdminAccountResponse
getOrganizationAdminAccountResponse_organizationId = (GetOrganizationAdminAccountResponse -> Maybe Text)
-> (GetOrganizationAdminAccountResponse
    -> Maybe Text -> GetOrganizationAdminAccountResponse)
-> Lens
     GetOrganizationAdminAccountResponse
     GetOrganizationAdminAccountResponse
     (Maybe Text)
     (Maybe Text)
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 :: (Int -> f Int)
-> GetOrganizationAdminAccountResponse
-> f GetOrganizationAdminAccountResponse
getOrganizationAdminAccountResponse_httpStatus = (GetOrganizationAdminAccountResponse -> Int)
-> (GetOrganizationAdminAccountResponse
    -> Int -> GetOrganizationAdminAccountResponse)
-> Lens
     GetOrganizationAdminAccountResponse
     GetOrganizationAdminAccountResponse
     Int
     Int
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