{-# 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-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)
--
-- 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.Lens as Lens
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
(GetAdministratorAccount -> GetAdministratorAccount -> Bool)
-> (GetAdministratorAccount -> GetAdministratorAccount -> Bool)
-> Eq GetAdministratorAccount
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]
(Int -> ReadS GetAdministratorAccount)
-> ReadS [GetAdministratorAccount]
-> ReadPrec GetAdministratorAccount
-> ReadPrec [GetAdministratorAccount]
-> Read 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
(Int -> GetAdministratorAccount -> ShowS)
-> (GetAdministratorAccount -> String)
-> ([GetAdministratorAccount] -> ShowS)
-> Show GetAdministratorAccount
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.
 GetAdministratorAccount -> Rep GetAdministratorAccount x)
-> (forall x.
    Rep GetAdministratorAccount x -> GetAdministratorAccount)
-> Generic GetAdministratorAccount
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 :: GetAdministratorAccount -> Request GetAdministratorAccount
request = Service
-> GetAdministratorAccount -> Request GetAdministratorAccount
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetAdministratorAccount
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetAdministratorAccount)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetAdministratorAccount))
-> Logger
-> Service
-> Proxy GetAdministratorAccount
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetAdministratorAccount)))
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 Invitation -> Int -> GetAdministratorAccountResponse
GetAdministratorAccountResponse'
            (Maybe Invitation -> Int -> GetAdministratorAccountResponse)
-> Either String (Maybe Invitation)
-> Either String (Int -> GetAdministratorAccountResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Key -> Either String (Maybe Invitation)
forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Core..?> Key
"administrator")
            Either String (Int -> GetAdministratorAccountResponse)
-> Either String Int
-> Either String GetAdministratorAccountResponse
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 GetAdministratorAccount

instance Prelude.NFData GetAdministratorAccount

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

instance Core.ToQuery GetAdministratorAccount where
  toQuery :: GetAdministratorAccount -> QueryString
toQuery = QueryString -> GetAdministratorAccount -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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 a 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
(GetAdministratorAccountResponse
 -> GetAdministratorAccountResponse -> Bool)
-> (GetAdministratorAccountResponse
    -> GetAdministratorAccountResponse -> Bool)
-> Eq GetAdministratorAccountResponse
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]
(Int -> ReadS GetAdministratorAccountResponse)
-> ReadS [GetAdministratorAccountResponse]
-> ReadPrec GetAdministratorAccountResponse
-> ReadPrec [GetAdministratorAccountResponse]
-> Read 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
(Int -> GetAdministratorAccountResponse -> ShowS)
-> (GetAdministratorAccountResponse -> String)
-> ([GetAdministratorAccountResponse] -> ShowS)
-> Show GetAdministratorAccountResponse
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.
 GetAdministratorAccountResponse
 -> Rep GetAdministratorAccountResponse x)
-> (forall x.
    Rep GetAdministratorAccountResponse x
    -> GetAdministratorAccountResponse)
-> Generic GetAdministratorAccountResponse
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 a 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' :: Maybe Invitation -> Int -> GetAdministratorAccountResponse
GetAdministratorAccountResponse'
    { $sel:administrator:GetAdministratorAccountResponse' :: Maybe Invitation
administrator =
        Maybe Invitation
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 a 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 :: (Maybe Invitation -> f (Maybe Invitation))
-> GetAdministratorAccountResponse
-> f GetAdministratorAccountResponse
getAdministratorAccountResponse_administrator = (GetAdministratorAccountResponse -> Maybe Invitation)
-> (GetAdministratorAccountResponse
    -> Maybe Invitation -> GetAdministratorAccountResponse)
-> Lens
     GetAdministratorAccountResponse
     GetAdministratorAccountResponse
     (Maybe Invitation)
     (Maybe Invitation)
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 :: (Int -> f Int)
-> GetAdministratorAccountResponse
-> f GetAdministratorAccountResponse
getAdministratorAccountResponse_httpStatus = (GetAdministratorAccountResponse -> Int)
-> (GetAdministratorAccountResponse
    -> Int -> GetAdministratorAccountResponse)
-> Lens
     GetAdministratorAccountResponse
     GetAdministratorAccountResponse
     Int
     Int
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