{-# 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.GuardDuty.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)
--
-- Provides the details for the GuardDuty administrator account associated
-- with the current GuardDuty member account.
module Amazonka.GuardDuty.GetAdministratorAccount
  ( -- * Creating a Request
    GetAdministratorAccount (..),
    newGetAdministratorAccount,

    -- * Request Lenses
    getAdministratorAccount_detectorId,

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

    -- * Response Lenses
    getAdministratorAccountResponse_httpStatus,
    getAdministratorAccountResponse_administrator,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.GuardDuty.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'
  { -- | The unique ID of the detector of the GuardDuty member account.
    GetAdministratorAccount -> Text
detectorId :: Prelude.Text
  }
  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.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'detectorId', 'getAdministratorAccount_detectorId' - The unique ID of the detector of the GuardDuty member account.
newGetAdministratorAccount ::
  -- | 'detectorId'
  Prelude.Text ->
  GetAdministratorAccount
newGetAdministratorAccount :: Text -> GetAdministratorAccount
newGetAdministratorAccount Text
pDetectorId_ =
  GetAdministratorAccount' {$sel:detectorId:GetAdministratorAccount' :: Text
detectorId = Text
pDetectorId_}

-- | The unique ID of the detector of the GuardDuty member account.
getAdministratorAccount_detectorId :: Lens.Lens' GetAdministratorAccount Prelude.Text
getAdministratorAccount_detectorId :: Lens' GetAdministratorAccount Text
getAdministratorAccount_detectorId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAdministratorAccount' {Text
detectorId :: Text
$sel:detectorId:GetAdministratorAccount' :: GetAdministratorAccount -> Text
detectorId} -> Text
detectorId) (\s :: GetAdministratorAccount
s@GetAdministratorAccount' {} Text
a -> GetAdministratorAccount
s {$sel:detectorId:GetAdministratorAccount' :: Text
detectorId = Text
a} :: 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 ->
          Int -> Administrator -> GetAdministratorAccountResponse
GetAdministratorAccountResponse'
            forall (f :: * -> *) a b. Functor 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))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"administrator")
      )

instance Prelude.Hashable GetAdministratorAccount where
  hashWithSalt :: Int -> GetAdministratorAccount -> Int
hashWithSalt Int
_salt GetAdministratorAccount' {Text
detectorId :: Text
$sel:detectorId:GetAdministratorAccount' :: GetAdministratorAccount -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
detectorId

instance Prelude.NFData GetAdministratorAccount where
  rnf :: GetAdministratorAccount -> ()
rnf GetAdministratorAccount' {Text
detectorId :: Text
$sel:detectorId:GetAdministratorAccount' :: GetAdministratorAccount -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
detectorId

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 GetAdministratorAccount' {Text
detectorId :: Text
$sel:detectorId:GetAdministratorAccount' :: GetAdministratorAccount -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/detector/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
detectorId,
        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 response's http status code.
    GetAdministratorAccountResponse -> Int
httpStatus :: Prelude.Int,
    -- | The administrator account details.
    GetAdministratorAccountResponse -> Administrator
administrator :: Administrator
  }
  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:
--
-- 'httpStatus', 'getAdministratorAccountResponse_httpStatus' - The response's http status code.
--
-- 'administrator', 'getAdministratorAccountResponse_administrator' - The administrator account details.
newGetAdministratorAccountResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'administrator'
  Administrator ->
  GetAdministratorAccountResponse
newGetAdministratorAccountResponse :: Int -> Administrator -> GetAdministratorAccountResponse
newGetAdministratorAccountResponse
  Int
pHttpStatus_
  Administrator
pAdministrator_ =
    GetAdministratorAccountResponse'
      { $sel:httpStatus:GetAdministratorAccountResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:administrator:GetAdministratorAccountResponse' :: Administrator
administrator = Administrator
pAdministrator_
      }

-- | 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)

-- | The administrator account details.
getAdministratorAccountResponse_administrator :: Lens.Lens' GetAdministratorAccountResponse Administrator
getAdministratorAccountResponse_administrator :: Lens' GetAdministratorAccountResponse Administrator
getAdministratorAccountResponse_administrator = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAdministratorAccountResponse' {Administrator
administrator :: Administrator
$sel:administrator:GetAdministratorAccountResponse' :: GetAdministratorAccountResponse -> Administrator
administrator} -> Administrator
administrator) (\s :: GetAdministratorAccountResponse
s@GetAdministratorAccountResponse' {} Administrator
a -> GetAdministratorAccountResponse
s {$sel:administrator:GetAdministratorAccountResponse' :: Administrator
administrator = Administrator
a} :: GetAdministratorAccountResponse)

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