{-# 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.BatchGetAccountStatus
-- 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 the Amazon Inspector status of multiple Amazon Web Services
-- accounts within your environment.
module Amazonka.Inspector2.BatchGetAccountStatus
  ( -- * Creating a Request
    BatchGetAccountStatus (..),
    newBatchGetAccountStatus,

    -- * Request Lenses
    batchGetAccountStatus_accountIds,

    -- * Destructuring the Response
    BatchGetAccountStatusResponse (..),
    newBatchGetAccountStatusResponse,

    -- * Response Lenses
    batchGetAccountStatusResponse_failedAccounts,
    batchGetAccountStatusResponse_httpStatus,
    batchGetAccountStatusResponse_accounts,
  )
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:/ 'newBatchGetAccountStatus' smart constructor.
data BatchGetAccountStatus = BatchGetAccountStatus'
  { -- | The 12-digit Amazon Web Services account IDs of the accounts to retrieve
    -- Amazon Inspector status for.
    BatchGetAccountStatus -> Maybe [Text]
accountIds :: Prelude.Maybe [Prelude.Text]
  }
  deriving (BatchGetAccountStatus -> BatchGetAccountStatus -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchGetAccountStatus -> BatchGetAccountStatus -> Bool
$c/= :: BatchGetAccountStatus -> BatchGetAccountStatus -> Bool
== :: BatchGetAccountStatus -> BatchGetAccountStatus -> Bool
$c== :: BatchGetAccountStatus -> BatchGetAccountStatus -> Bool
Prelude.Eq, ReadPrec [BatchGetAccountStatus]
ReadPrec BatchGetAccountStatus
Int -> ReadS BatchGetAccountStatus
ReadS [BatchGetAccountStatus]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchGetAccountStatus]
$creadListPrec :: ReadPrec [BatchGetAccountStatus]
readPrec :: ReadPrec BatchGetAccountStatus
$creadPrec :: ReadPrec BatchGetAccountStatus
readList :: ReadS [BatchGetAccountStatus]
$creadList :: ReadS [BatchGetAccountStatus]
readsPrec :: Int -> ReadS BatchGetAccountStatus
$creadsPrec :: Int -> ReadS BatchGetAccountStatus
Prelude.Read, Int -> BatchGetAccountStatus -> ShowS
[BatchGetAccountStatus] -> ShowS
BatchGetAccountStatus -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchGetAccountStatus] -> ShowS
$cshowList :: [BatchGetAccountStatus] -> ShowS
show :: BatchGetAccountStatus -> String
$cshow :: BatchGetAccountStatus -> String
showsPrec :: Int -> BatchGetAccountStatus -> ShowS
$cshowsPrec :: Int -> BatchGetAccountStatus -> ShowS
Prelude.Show, forall x. Rep BatchGetAccountStatus x -> BatchGetAccountStatus
forall x. BatchGetAccountStatus -> Rep BatchGetAccountStatus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchGetAccountStatus x -> BatchGetAccountStatus
$cfrom :: forall x. BatchGetAccountStatus -> Rep BatchGetAccountStatus x
Prelude.Generic)

-- |
-- Create a value of 'BatchGetAccountStatus' 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:
--
-- 'accountIds', 'batchGetAccountStatus_accountIds' - The 12-digit Amazon Web Services account IDs of the accounts to retrieve
-- Amazon Inspector status for.
newBatchGetAccountStatus ::
  BatchGetAccountStatus
newBatchGetAccountStatus :: BatchGetAccountStatus
newBatchGetAccountStatus =
  BatchGetAccountStatus'
    { $sel:accountIds:BatchGetAccountStatus' :: Maybe [Text]
accountIds =
        forall a. Maybe a
Prelude.Nothing
    }

-- | The 12-digit Amazon Web Services account IDs of the accounts to retrieve
-- Amazon Inspector status for.
batchGetAccountStatus_accountIds :: Lens.Lens' BatchGetAccountStatus (Prelude.Maybe [Prelude.Text])
batchGetAccountStatus_accountIds :: Lens' BatchGetAccountStatus (Maybe [Text])
batchGetAccountStatus_accountIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetAccountStatus' {Maybe [Text]
accountIds :: Maybe [Text]
$sel:accountIds:BatchGetAccountStatus' :: BatchGetAccountStatus -> Maybe [Text]
accountIds} -> Maybe [Text]
accountIds) (\s :: BatchGetAccountStatus
s@BatchGetAccountStatus' {} Maybe [Text]
a -> BatchGetAccountStatus
s {$sel:accountIds:BatchGetAccountStatus' :: Maybe [Text]
accountIds = Maybe [Text]
a} :: BatchGetAccountStatus) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest BatchGetAccountStatus where
  type
    AWSResponse BatchGetAccountStatus =
      BatchGetAccountStatusResponse
  request :: (Service -> Service)
-> BatchGetAccountStatus -> Request BatchGetAccountStatus
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 BatchGetAccountStatus
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse BatchGetAccountStatus)))
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 [FailedAccount]
-> Int -> [AccountState] -> BatchGetAccountStatusResponse
BatchGetAccountStatusResponse'
            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
"failedAccounts" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            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))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"accounts" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable BatchGetAccountStatus where
  hashWithSalt :: Int -> BatchGetAccountStatus -> Int
hashWithSalt Int
_salt BatchGetAccountStatus' {Maybe [Text]
accountIds :: Maybe [Text]
$sel:accountIds:BatchGetAccountStatus' :: BatchGetAccountStatus -> Maybe [Text]
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
accountIds

instance Prelude.NFData BatchGetAccountStatus where
  rnf :: BatchGetAccountStatus -> ()
rnf BatchGetAccountStatus' {Maybe [Text]
accountIds :: Maybe [Text]
$sel:accountIds:BatchGetAccountStatus' :: BatchGetAccountStatus -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
accountIds

instance Data.ToHeaders BatchGetAccountStatus where
  toHeaders :: BatchGetAccountStatus -> 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 BatchGetAccountStatus where
  toJSON :: BatchGetAccountStatus -> Value
toJSON BatchGetAccountStatus' {Maybe [Text]
accountIds :: Maybe [Text]
$sel:accountIds:BatchGetAccountStatus' :: BatchGetAccountStatus -> Maybe [Text]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"accountIds" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
accountIds]
      )

instance Data.ToPath BatchGetAccountStatus where
  toPath :: BatchGetAccountStatus -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/status/batch/get"

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

-- | /See:/ 'newBatchGetAccountStatusResponse' smart constructor.
data BatchGetAccountStatusResponse = BatchGetAccountStatusResponse'
  { -- | An array of objects detailing any accounts that failed to enable Amazon
    -- Inspector and why.
    BatchGetAccountStatusResponse -> Maybe [FailedAccount]
failedAccounts :: Prelude.Maybe [FailedAccount],
    -- | The response's http status code.
    BatchGetAccountStatusResponse -> Int
httpStatus :: Prelude.Int,
    -- | An array of objects that provide details on the status of Amazon
    -- Inspector for each of the requested accounts.
    BatchGetAccountStatusResponse -> [AccountState]
accounts :: [AccountState]
  }
  deriving (BatchGetAccountStatusResponse
-> BatchGetAccountStatusResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchGetAccountStatusResponse
-> BatchGetAccountStatusResponse -> Bool
$c/= :: BatchGetAccountStatusResponse
-> BatchGetAccountStatusResponse -> Bool
== :: BatchGetAccountStatusResponse
-> BatchGetAccountStatusResponse -> Bool
$c== :: BatchGetAccountStatusResponse
-> BatchGetAccountStatusResponse -> Bool
Prelude.Eq, ReadPrec [BatchGetAccountStatusResponse]
ReadPrec BatchGetAccountStatusResponse
Int -> ReadS BatchGetAccountStatusResponse
ReadS [BatchGetAccountStatusResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchGetAccountStatusResponse]
$creadListPrec :: ReadPrec [BatchGetAccountStatusResponse]
readPrec :: ReadPrec BatchGetAccountStatusResponse
$creadPrec :: ReadPrec BatchGetAccountStatusResponse
readList :: ReadS [BatchGetAccountStatusResponse]
$creadList :: ReadS [BatchGetAccountStatusResponse]
readsPrec :: Int -> ReadS BatchGetAccountStatusResponse
$creadsPrec :: Int -> ReadS BatchGetAccountStatusResponse
Prelude.Read, Int -> BatchGetAccountStatusResponse -> ShowS
[BatchGetAccountStatusResponse] -> ShowS
BatchGetAccountStatusResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchGetAccountStatusResponse] -> ShowS
$cshowList :: [BatchGetAccountStatusResponse] -> ShowS
show :: BatchGetAccountStatusResponse -> String
$cshow :: BatchGetAccountStatusResponse -> String
showsPrec :: Int -> BatchGetAccountStatusResponse -> ShowS
$cshowsPrec :: Int -> BatchGetAccountStatusResponse -> ShowS
Prelude.Show, forall x.
Rep BatchGetAccountStatusResponse x
-> BatchGetAccountStatusResponse
forall x.
BatchGetAccountStatusResponse
-> Rep BatchGetAccountStatusResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BatchGetAccountStatusResponse x
-> BatchGetAccountStatusResponse
$cfrom :: forall x.
BatchGetAccountStatusResponse
-> Rep BatchGetAccountStatusResponse x
Prelude.Generic)

-- |
-- Create a value of 'BatchGetAccountStatusResponse' 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:
--
-- 'failedAccounts', 'batchGetAccountStatusResponse_failedAccounts' - An array of objects detailing any accounts that failed to enable Amazon
-- Inspector and why.
--
-- 'httpStatus', 'batchGetAccountStatusResponse_httpStatus' - The response's http status code.
--
-- 'accounts', 'batchGetAccountStatusResponse_accounts' - An array of objects that provide details on the status of Amazon
-- Inspector for each of the requested accounts.
newBatchGetAccountStatusResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  BatchGetAccountStatusResponse
newBatchGetAccountStatusResponse :: Int -> BatchGetAccountStatusResponse
newBatchGetAccountStatusResponse Int
pHttpStatus_ =
  BatchGetAccountStatusResponse'
    { $sel:failedAccounts:BatchGetAccountStatusResponse' :: Maybe [FailedAccount]
failedAccounts =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:BatchGetAccountStatusResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:accounts:BatchGetAccountStatusResponse' :: [AccountState]
accounts = forall a. Monoid a => a
Prelude.mempty
    }

-- | An array of objects detailing any accounts that failed to enable Amazon
-- Inspector and why.
batchGetAccountStatusResponse_failedAccounts :: Lens.Lens' BatchGetAccountStatusResponse (Prelude.Maybe [FailedAccount])
batchGetAccountStatusResponse_failedAccounts :: Lens' BatchGetAccountStatusResponse (Maybe [FailedAccount])
batchGetAccountStatusResponse_failedAccounts = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetAccountStatusResponse' {Maybe [FailedAccount]
failedAccounts :: Maybe [FailedAccount]
$sel:failedAccounts:BatchGetAccountStatusResponse' :: BatchGetAccountStatusResponse -> Maybe [FailedAccount]
failedAccounts} -> Maybe [FailedAccount]
failedAccounts) (\s :: BatchGetAccountStatusResponse
s@BatchGetAccountStatusResponse' {} Maybe [FailedAccount]
a -> BatchGetAccountStatusResponse
s {$sel:failedAccounts:BatchGetAccountStatusResponse' :: Maybe [FailedAccount]
failedAccounts = Maybe [FailedAccount]
a} :: BatchGetAccountStatusResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

-- | An array of objects that provide details on the status of Amazon
-- Inspector for each of the requested accounts.
batchGetAccountStatusResponse_accounts :: Lens.Lens' BatchGetAccountStatusResponse [AccountState]
batchGetAccountStatusResponse_accounts :: Lens' BatchGetAccountStatusResponse [AccountState]
batchGetAccountStatusResponse_accounts = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetAccountStatusResponse' {[AccountState]
accounts :: [AccountState]
$sel:accounts:BatchGetAccountStatusResponse' :: BatchGetAccountStatusResponse -> [AccountState]
accounts} -> [AccountState]
accounts) (\s :: BatchGetAccountStatusResponse
s@BatchGetAccountStatusResponse' {} [AccountState]
a -> BatchGetAccountStatusResponse
s {$sel:accounts:BatchGetAccountStatusResponse' :: [AccountState]
accounts = [AccountState]
a} :: BatchGetAccountStatusResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.NFData BatchGetAccountStatusResponse where
  rnf :: BatchGetAccountStatusResponse -> ()
rnf BatchGetAccountStatusResponse' {Int
[AccountState]
Maybe [FailedAccount]
accounts :: [AccountState]
httpStatus :: Int
failedAccounts :: Maybe [FailedAccount]
$sel:accounts:BatchGetAccountStatusResponse' :: BatchGetAccountStatusResponse -> [AccountState]
$sel:httpStatus:BatchGetAccountStatusResponse' :: BatchGetAccountStatusResponse -> Int
$sel:failedAccounts:BatchGetAccountStatusResponse' :: BatchGetAccountStatusResponse -> Maybe [FailedAccount]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [FailedAccount]
failedAccounts
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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 [AccountState]
accounts