{-# 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.MacieV2.GetAdministratorAccount
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves information about the Amazon Macie administrator account for
-- an account.
module Amazonka.MacieV2.GetAdministratorAccount
  ( -- * Creating a Request
    GetAdministratorAccount (..),
    newGetAdministratorAccount,

    -- * Destructuring the Response
    GetAdministratorAccountResponse (..),
    newGetAdministratorAccountResponse,

    -- * Response Lenses
    getAdministratorAccountResponse_administrator,
    getAdministratorAccountResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MacieV2.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

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

-- |
-- Create a value of 'GetAdministratorAccount' 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.
newGetAdministratorAccount ::
  GetAdministratorAccount
newGetAdministratorAccount :: GetAdministratorAccount
newGetAdministratorAccount = GetAdministratorAccount
GetAdministratorAccount'

instance Core.AWSRequest GetAdministratorAccount where
  type
    AWSResponse GetAdministratorAccount =
      GetAdministratorAccountResponse
  request :: (Service -> Service)
-> GetAdministratorAccount -> Request GetAdministratorAccount
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 GetAdministratorAccount
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetAdministratorAccount)))
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 Invitation -> Int -> GetAdministratorAccountResponse
GetAdministratorAccountResponse'
            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
"administrator")
            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 GetAdministratorAccount where
  hashWithSalt :: Int -> GetAdministratorAccount -> Int
hashWithSalt Int
_salt GetAdministratorAccount
_ =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ()

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

instance Data.ToHeaders GetAdministratorAccount where
  toHeaders :: GetAdministratorAccount -> 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 GetAdministratorAccount where
  toPath :: GetAdministratorAccount -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/administrator"

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

-- | /See:/ 'newGetAdministratorAccountResponse' smart constructor.
data GetAdministratorAccountResponse = GetAdministratorAccountResponse'
  { -- | The Amazon Web Services account ID for the administrator account. If the
    -- accounts are associated by an Amazon Macie membership invitation, this
    -- object also provides details about the invitation that was sent to
    -- establish the relationship between the accounts.
    GetAdministratorAccountResponse -> Maybe Invitation
administrator :: Prelude.Maybe Invitation,
    -- | The response's http status code.
    GetAdministratorAccountResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetAdministratorAccountResponse
-> GetAdministratorAccountResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetAdministratorAccountResponse
-> GetAdministratorAccountResponse -> Bool
$c/= :: GetAdministratorAccountResponse
-> GetAdministratorAccountResponse -> Bool
== :: GetAdministratorAccountResponse
-> GetAdministratorAccountResponse -> Bool
$c== :: GetAdministratorAccountResponse
-> GetAdministratorAccountResponse -> Bool
Prelude.Eq, ReadPrec [GetAdministratorAccountResponse]
ReadPrec GetAdministratorAccountResponse
Int -> ReadS GetAdministratorAccountResponse
ReadS [GetAdministratorAccountResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetAdministratorAccountResponse]
$creadListPrec :: ReadPrec [GetAdministratorAccountResponse]
readPrec :: ReadPrec GetAdministratorAccountResponse
$creadPrec :: ReadPrec GetAdministratorAccountResponse
readList :: ReadS [GetAdministratorAccountResponse]
$creadList :: ReadS [GetAdministratorAccountResponse]
readsPrec :: Int -> ReadS GetAdministratorAccountResponse
$creadsPrec :: Int -> ReadS GetAdministratorAccountResponse
Prelude.Read, Int -> GetAdministratorAccountResponse -> ShowS
[GetAdministratorAccountResponse] -> ShowS
GetAdministratorAccountResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetAdministratorAccountResponse] -> ShowS
$cshowList :: [GetAdministratorAccountResponse] -> ShowS
show :: GetAdministratorAccountResponse -> String
$cshow :: GetAdministratorAccountResponse -> String
showsPrec :: Int -> GetAdministratorAccountResponse -> ShowS
$cshowsPrec :: Int -> GetAdministratorAccountResponse -> ShowS
Prelude.Show, forall x.
Rep GetAdministratorAccountResponse x
-> GetAdministratorAccountResponse
forall x.
GetAdministratorAccountResponse
-> Rep GetAdministratorAccountResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetAdministratorAccountResponse x
-> GetAdministratorAccountResponse
$cfrom :: forall x.
GetAdministratorAccountResponse
-> Rep GetAdministratorAccountResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetAdministratorAccountResponse' 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:
--
-- 'administrator', 'getAdministratorAccountResponse_administrator' - The Amazon Web Services account ID for the administrator account. If the
-- accounts are associated by an Amazon Macie membership invitation, this
-- object also provides details about the invitation that was sent to
-- establish the relationship between the accounts.
--
-- 'httpStatus', 'getAdministratorAccountResponse_httpStatus' - The response's http status code.
newGetAdministratorAccountResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetAdministratorAccountResponse
newGetAdministratorAccountResponse :: Int -> GetAdministratorAccountResponse
newGetAdministratorAccountResponse Int
pHttpStatus_ =
  GetAdministratorAccountResponse'
    { $sel:administrator:GetAdministratorAccountResponse' :: Maybe Invitation
administrator =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetAdministratorAccountResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon Web Services account ID for the administrator account. If the
-- accounts are associated by an Amazon Macie membership invitation, this
-- object also provides details about the invitation that was sent to
-- establish the relationship between the accounts.
getAdministratorAccountResponse_administrator :: Lens.Lens' GetAdministratorAccountResponse (Prelude.Maybe Invitation)
getAdministratorAccountResponse_administrator :: Lens' GetAdministratorAccountResponse (Maybe Invitation)
getAdministratorAccountResponse_administrator = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAdministratorAccountResponse' {Maybe Invitation
administrator :: Maybe Invitation
$sel:administrator:GetAdministratorAccountResponse' :: GetAdministratorAccountResponse -> Maybe Invitation
administrator} -> Maybe Invitation
administrator) (\s :: GetAdministratorAccountResponse
s@GetAdministratorAccountResponse' {} Maybe Invitation
a -> GetAdministratorAccountResponse
s {$sel:administrator:GetAdministratorAccountResponse' :: Maybe Invitation
administrator = Maybe Invitation
a} :: GetAdministratorAccountResponse)

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

instance
  Prelude.NFData
    GetAdministratorAccountResponse
  where
  rnf :: GetAdministratorAccountResponse -> ()
rnf GetAdministratorAccountResponse' {Int
Maybe Invitation
httpStatus :: Int
administrator :: Maybe Invitation
$sel:httpStatus:GetAdministratorAccountResponse' :: GetAdministratorAccountResponse -> Int
$sel:administrator:GetAdministratorAccountResponse' :: GetAdministratorAccountResponse -> Maybe Invitation
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Invitation
administrator
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus