{-# 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.Inspector2.GetDelegatedAdminAccount
-- 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 Inspector delegated administrator
-- for your organization.
module Amazonka.Inspector2.GetDelegatedAdminAccount
  ( -- * Creating a Request
    GetDelegatedAdminAccount (..),
    newGetDelegatedAdminAccount,

    -- * Destructuring the Response
    GetDelegatedAdminAccountResponse (..),
    newGetDelegatedAdminAccountResponse,

    -- * Response Lenses
    getDelegatedAdminAccountResponse_delegatedAdmin,
    getDelegatedAdminAccountResponse_httpStatus,
  )
where

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

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

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

instance Core.AWSRequest GetDelegatedAdminAccount where
  type
    AWSResponse GetDelegatedAdminAccount =
      GetDelegatedAdminAccountResponse
  request :: (Service -> Service)
-> GetDelegatedAdminAccount -> Request GetDelegatedAdminAccount
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetDelegatedAdminAccount
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetDelegatedAdminAccount)))
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 DelegatedAdmin -> Int -> GetDelegatedAdminAccountResponse
GetDelegatedAdminAccountResponse'
            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
"delegatedAdmin")
            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 GetDelegatedAdminAccount where
  hashWithSalt :: Int -> GetDelegatedAdminAccount -> Int
hashWithSalt Int
_salt GetDelegatedAdminAccount
_ =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ()

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

instance Data.ToHeaders GetDelegatedAdminAccount where
  toHeaders :: GetDelegatedAdminAccount -> 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.ToJSON GetDelegatedAdminAccount where
  toJSON :: GetDelegatedAdminAccount -> Value
toJSON = forall a b. a -> b -> a
Prelude.const (Object -> Value
Data.Object forall a. Monoid a => a
Prelude.mempty)

instance Data.ToPath GetDelegatedAdminAccount where
  toPath :: GetDelegatedAdminAccount -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/delegatedadminaccounts/get"

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

-- | /See:/ 'newGetDelegatedAdminAccountResponse' smart constructor.
data GetDelegatedAdminAccountResponse = GetDelegatedAdminAccountResponse'
  { -- | The Amazon Web Services account ID of the Amazon Inspector delegated
    -- administrator.
    GetDelegatedAdminAccountResponse -> Maybe DelegatedAdmin
delegatedAdmin :: Prelude.Maybe DelegatedAdmin,
    -- | The response's http status code.
    GetDelegatedAdminAccountResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetDelegatedAdminAccountResponse
-> GetDelegatedAdminAccountResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDelegatedAdminAccountResponse
-> GetDelegatedAdminAccountResponse -> Bool
$c/= :: GetDelegatedAdminAccountResponse
-> GetDelegatedAdminAccountResponse -> Bool
== :: GetDelegatedAdminAccountResponse
-> GetDelegatedAdminAccountResponse -> Bool
$c== :: GetDelegatedAdminAccountResponse
-> GetDelegatedAdminAccountResponse -> Bool
Prelude.Eq, ReadPrec [GetDelegatedAdminAccountResponse]
ReadPrec GetDelegatedAdminAccountResponse
Int -> ReadS GetDelegatedAdminAccountResponse
ReadS [GetDelegatedAdminAccountResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDelegatedAdminAccountResponse]
$creadListPrec :: ReadPrec [GetDelegatedAdminAccountResponse]
readPrec :: ReadPrec GetDelegatedAdminAccountResponse
$creadPrec :: ReadPrec GetDelegatedAdminAccountResponse
readList :: ReadS [GetDelegatedAdminAccountResponse]
$creadList :: ReadS [GetDelegatedAdminAccountResponse]
readsPrec :: Int -> ReadS GetDelegatedAdminAccountResponse
$creadsPrec :: Int -> ReadS GetDelegatedAdminAccountResponse
Prelude.Read, Int -> GetDelegatedAdminAccountResponse -> ShowS
[GetDelegatedAdminAccountResponse] -> ShowS
GetDelegatedAdminAccountResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDelegatedAdminAccountResponse] -> ShowS
$cshowList :: [GetDelegatedAdminAccountResponse] -> ShowS
show :: GetDelegatedAdminAccountResponse -> String
$cshow :: GetDelegatedAdminAccountResponse -> String
showsPrec :: Int -> GetDelegatedAdminAccountResponse -> ShowS
$cshowsPrec :: Int -> GetDelegatedAdminAccountResponse -> ShowS
Prelude.Show, forall x.
Rep GetDelegatedAdminAccountResponse x
-> GetDelegatedAdminAccountResponse
forall x.
GetDelegatedAdminAccountResponse
-> Rep GetDelegatedAdminAccountResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetDelegatedAdminAccountResponse x
-> GetDelegatedAdminAccountResponse
$cfrom :: forall x.
GetDelegatedAdminAccountResponse
-> Rep GetDelegatedAdminAccountResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetDelegatedAdminAccountResponse' 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:
--
-- 'delegatedAdmin', 'getDelegatedAdminAccountResponse_delegatedAdmin' - The Amazon Web Services account ID of the Amazon Inspector delegated
-- administrator.
--
-- 'httpStatus', 'getDelegatedAdminAccountResponse_httpStatus' - The response's http status code.
newGetDelegatedAdminAccountResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetDelegatedAdminAccountResponse
newGetDelegatedAdminAccountResponse :: Int -> GetDelegatedAdminAccountResponse
newGetDelegatedAdminAccountResponse Int
pHttpStatus_ =
  GetDelegatedAdminAccountResponse'
    { $sel:delegatedAdmin:GetDelegatedAdminAccountResponse' :: Maybe DelegatedAdmin
delegatedAdmin =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetDelegatedAdminAccountResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon Web Services account ID of the Amazon Inspector delegated
-- administrator.
getDelegatedAdminAccountResponse_delegatedAdmin :: Lens.Lens' GetDelegatedAdminAccountResponse (Prelude.Maybe DelegatedAdmin)
getDelegatedAdminAccountResponse_delegatedAdmin :: Lens' GetDelegatedAdminAccountResponse (Maybe DelegatedAdmin)
getDelegatedAdminAccountResponse_delegatedAdmin = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDelegatedAdminAccountResponse' {Maybe DelegatedAdmin
delegatedAdmin :: Maybe DelegatedAdmin
$sel:delegatedAdmin:GetDelegatedAdminAccountResponse' :: GetDelegatedAdminAccountResponse -> Maybe DelegatedAdmin
delegatedAdmin} -> Maybe DelegatedAdmin
delegatedAdmin) (\s :: GetDelegatedAdminAccountResponse
s@GetDelegatedAdminAccountResponse' {} Maybe DelegatedAdmin
a -> GetDelegatedAdminAccountResponse
s {$sel:delegatedAdmin:GetDelegatedAdminAccountResponse' :: Maybe DelegatedAdmin
delegatedAdmin = Maybe DelegatedAdmin
a} :: GetDelegatedAdminAccountResponse)

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

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