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

    -- * Request Lenses
    getMasterAccount_detectorId,

    -- * Destructuring the Response
    GetMasterAccountResponse (..),
    newGetMasterAccountResponse,

    -- * Response Lenses
    getMasterAccountResponse_httpStatus,
    getMasterAccountResponse_master,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.GuardDuty.Types
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:/ 'newGetMasterAccount' smart constructor.
data GetMasterAccount = GetMasterAccount'
  { -- | The unique ID of the detector of the GuardDuty member account.
    GetMasterAccount -> Text
detectorId :: Prelude.Text
  }
  deriving (GetMasterAccount -> GetMasterAccount -> Bool
(GetMasterAccount -> GetMasterAccount -> Bool)
-> (GetMasterAccount -> GetMasterAccount -> Bool)
-> Eq GetMasterAccount
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetMasterAccount -> GetMasterAccount -> Bool
$c/= :: GetMasterAccount -> GetMasterAccount -> Bool
== :: GetMasterAccount -> GetMasterAccount -> Bool
$c== :: GetMasterAccount -> GetMasterAccount -> Bool
Prelude.Eq, ReadPrec [GetMasterAccount]
ReadPrec GetMasterAccount
Int -> ReadS GetMasterAccount
ReadS [GetMasterAccount]
(Int -> ReadS GetMasterAccount)
-> ReadS [GetMasterAccount]
-> ReadPrec GetMasterAccount
-> ReadPrec [GetMasterAccount]
-> Read GetMasterAccount
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetMasterAccount]
$creadListPrec :: ReadPrec [GetMasterAccount]
readPrec :: ReadPrec GetMasterAccount
$creadPrec :: ReadPrec GetMasterAccount
readList :: ReadS [GetMasterAccount]
$creadList :: ReadS [GetMasterAccount]
readsPrec :: Int -> ReadS GetMasterAccount
$creadsPrec :: Int -> ReadS GetMasterAccount
Prelude.Read, Int -> GetMasterAccount -> ShowS
[GetMasterAccount] -> ShowS
GetMasterAccount -> String
(Int -> GetMasterAccount -> ShowS)
-> (GetMasterAccount -> String)
-> ([GetMasterAccount] -> ShowS)
-> Show GetMasterAccount
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetMasterAccount] -> ShowS
$cshowList :: [GetMasterAccount] -> ShowS
show :: GetMasterAccount -> String
$cshow :: GetMasterAccount -> String
showsPrec :: Int -> GetMasterAccount -> ShowS
$cshowsPrec :: Int -> GetMasterAccount -> ShowS
Prelude.Show, (forall x. GetMasterAccount -> Rep GetMasterAccount x)
-> (forall x. Rep GetMasterAccount x -> GetMasterAccount)
-> Generic GetMasterAccount
forall x. Rep GetMasterAccount x -> GetMasterAccount
forall x. GetMasterAccount -> Rep GetMasterAccount x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetMasterAccount x -> GetMasterAccount
$cfrom :: forall x. GetMasterAccount -> Rep GetMasterAccount x
Prelude.Generic)

-- |
-- Create a value of 'GetMasterAccount' 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', 'getMasterAccount_detectorId' - The unique ID of the detector of the GuardDuty member account.
newGetMasterAccount ::
  -- | 'detectorId'
  Prelude.Text ->
  GetMasterAccount
newGetMasterAccount :: Text -> GetMasterAccount
newGetMasterAccount Text
pDetectorId_ =
  GetMasterAccount' :: Text -> GetMasterAccount
GetMasterAccount' {$sel:detectorId:GetMasterAccount' :: Text
detectorId = Text
pDetectorId_}

-- | The unique ID of the detector of the GuardDuty member account.
getMasterAccount_detectorId :: Lens.Lens' GetMasterAccount Prelude.Text
getMasterAccount_detectorId :: (Text -> f Text) -> GetMasterAccount -> f GetMasterAccount
getMasterAccount_detectorId = (GetMasterAccount -> Text)
-> (GetMasterAccount -> Text -> GetMasterAccount)
-> Lens GetMasterAccount GetMasterAccount Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMasterAccount' {Text
detectorId :: Text
$sel:detectorId:GetMasterAccount' :: GetMasterAccount -> Text
detectorId} -> Text
detectorId) (\s :: GetMasterAccount
s@GetMasterAccount' {} Text
a -> GetMasterAccount
s {$sel:detectorId:GetMasterAccount' :: Text
detectorId = Text
a} :: GetMasterAccount)

instance Core.AWSRequest GetMasterAccount where
  type
    AWSResponse GetMasterAccount =
      GetMasterAccountResponse
  request :: GetMasterAccount -> Request GetMasterAccount
request = Service -> GetMasterAccount -> Request GetMasterAccount
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetMasterAccount
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetMasterAccount)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetMasterAccount))
-> Logger
-> Service
-> Proxy GetMasterAccount
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetMasterAccount)))
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 ->
          Int -> Master -> GetMasterAccountResponse
GetMasterAccountResponse'
            (Int -> Master -> GetMasterAccountResponse)
-> Either String Int
-> Either String (Master -> GetMasterAccountResponse)
forall (f :: * -> *) a b. Functor 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))
            Either String (Master -> GetMasterAccountResponse)
-> Either String Master -> Either String GetMasterAccountResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Master
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"master")
      )

instance Prelude.Hashable GetMasterAccount

instance Prelude.NFData GetMasterAccount

instance Core.ToHeaders GetMasterAccount where
  toHeaders :: GetMasterAccount -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetMasterAccount -> 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 GetMasterAccount where
  toPath :: GetMasterAccount -> ByteString
toPath GetMasterAccount' {Text
detectorId :: Text
$sel:detectorId:GetMasterAccount' :: GetMasterAccount -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/detector/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
detectorId, ByteString
"/master"]

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

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

-- |
-- Create a value of 'GetMasterAccountResponse' 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', 'getMasterAccountResponse_httpStatus' - The response's http status code.
--
-- 'master', 'getMasterAccountResponse_master' - The administrator account details.
newGetMasterAccountResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'master'
  Master ->
  GetMasterAccountResponse
newGetMasterAccountResponse :: Int -> Master -> GetMasterAccountResponse
newGetMasterAccountResponse Int
pHttpStatus_ Master
pMaster_ =
  GetMasterAccountResponse' :: Int -> Master -> GetMasterAccountResponse
GetMasterAccountResponse'
    { $sel:httpStatus:GetMasterAccountResponse' :: Int
httpStatus =
        Int
pHttpStatus_,
      $sel:master:GetMasterAccountResponse' :: Master
master = Master
pMaster_
    }

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

-- | The administrator account details.
getMasterAccountResponse_master :: Lens.Lens' GetMasterAccountResponse Master
getMasterAccountResponse_master :: (Master -> f Master)
-> GetMasterAccountResponse -> f GetMasterAccountResponse
getMasterAccountResponse_master = (GetMasterAccountResponse -> Master)
-> (GetMasterAccountResponse -> Master -> GetMasterAccountResponse)
-> Lens
     GetMasterAccountResponse GetMasterAccountResponse Master Master
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMasterAccountResponse' {Master
master :: Master
$sel:master:GetMasterAccountResponse' :: GetMasterAccountResponse -> Master
master} -> Master
master) (\s :: GetMasterAccountResponse
s@GetMasterAccountResponse' {} Master
a -> GetMasterAccountResponse
s {$sel:master:GetMasterAccountResponse' :: Master
master = Master
a} :: GetMasterAccountResponse)

instance Prelude.NFData GetMasterAccountResponse