{-# 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.AuditManager.GetAccountStatus
-- 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)
--
-- Returns the registration status of an account in Audit Manager.
module Amazonka.AuditManager.GetAccountStatus
  ( -- * Creating a Request
    GetAccountStatus (..),
    newGetAccountStatus,

    -- * Destructuring the Response
    GetAccountStatusResponse (..),
    newGetAccountStatusResponse,

    -- * Response Lenses
    getAccountStatusResponse_status,
    getAccountStatusResponse_httpStatus,
  )
where

import Amazonka.AuditManager.Types
import qualified Amazonka.Core as Core
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:/ 'newGetAccountStatus' smart constructor.
data GetAccountStatus = GetAccountStatus'
  {
  }
  deriving (GetAccountStatus -> GetAccountStatus -> Bool
(GetAccountStatus -> GetAccountStatus -> Bool)
-> (GetAccountStatus -> GetAccountStatus -> Bool)
-> Eq GetAccountStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetAccountStatus -> GetAccountStatus -> Bool
$c/= :: GetAccountStatus -> GetAccountStatus -> Bool
== :: GetAccountStatus -> GetAccountStatus -> Bool
$c== :: GetAccountStatus -> GetAccountStatus -> Bool
Prelude.Eq, ReadPrec [GetAccountStatus]
ReadPrec GetAccountStatus
Int -> ReadS GetAccountStatus
ReadS [GetAccountStatus]
(Int -> ReadS GetAccountStatus)
-> ReadS [GetAccountStatus]
-> ReadPrec GetAccountStatus
-> ReadPrec [GetAccountStatus]
-> Read GetAccountStatus
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetAccountStatus]
$creadListPrec :: ReadPrec [GetAccountStatus]
readPrec :: ReadPrec GetAccountStatus
$creadPrec :: ReadPrec GetAccountStatus
readList :: ReadS [GetAccountStatus]
$creadList :: ReadS [GetAccountStatus]
readsPrec :: Int -> ReadS GetAccountStatus
$creadsPrec :: Int -> ReadS GetAccountStatus
Prelude.Read, Int -> GetAccountStatus -> ShowS
[GetAccountStatus] -> ShowS
GetAccountStatus -> String
(Int -> GetAccountStatus -> ShowS)
-> (GetAccountStatus -> String)
-> ([GetAccountStatus] -> ShowS)
-> Show GetAccountStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetAccountStatus] -> ShowS
$cshowList :: [GetAccountStatus] -> ShowS
show :: GetAccountStatus -> String
$cshow :: GetAccountStatus -> String
showsPrec :: Int -> GetAccountStatus -> ShowS
$cshowsPrec :: Int -> GetAccountStatus -> ShowS
Prelude.Show, (forall x. GetAccountStatus -> Rep GetAccountStatus x)
-> (forall x. Rep GetAccountStatus x -> GetAccountStatus)
-> Generic GetAccountStatus
forall x. Rep GetAccountStatus x -> GetAccountStatus
forall x. GetAccountStatus -> Rep GetAccountStatus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetAccountStatus x -> GetAccountStatus
$cfrom :: forall x. GetAccountStatus -> Rep GetAccountStatus x
Prelude.Generic)

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

instance Core.AWSRequest GetAccountStatus where
  type
    AWSResponse GetAccountStatus =
      GetAccountStatusResponse
  request :: GetAccountStatus -> Request GetAccountStatus
request = Service -> GetAccountStatus -> Request GetAccountStatus
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetAccountStatus
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetAccountStatus)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetAccountStatus))
-> Logger
-> Service
-> Proxy GetAccountStatus
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetAccountStatus)))
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 AccountStatus -> Int -> GetAccountStatusResponse
GetAccountStatusResponse'
            (Maybe AccountStatus -> Int -> GetAccountStatusResponse)
-> Either String (Maybe AccountStatus)
-> Either String (Int -> GetAccountStatusResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Key -> Either String (Maybe AccountStatus)
forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Core..?> Key
"status")
            Either String (Int -> GetAccountStatusResponse)
-> Either String Int -> Either String GetAccountStatusResponse
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 GetAccountStatus

instance Prelude.NFData GetAccountStatus

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

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

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

-- |
-- Create a value of 'GetAccountStatusResponse' 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:
--
-- 'status', 'getAccountStatusResponse_status' - The status of the specified Amazon Web Services account.
--
-- 'httpStatus', 'getAccountStatusResponse_httpStatus' - The response's http status code.
newGetAccountStatusResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetAccountStatusResponse
newGetAccountStatusResponse :: Int -> GetAccountStatusResponse
newGetAccountStatusResponse Int
pHttpStatus_ =
  GetAccountStatusResponse' :: Maybe AccountStatus -> Int -> GetAccountStatusResponse
GetAccountStatusResponse'
    { $sel:status:GetAccountStatusResponse' :: Maybe AccountStatus
status = Maybe AccountStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetAccountStatusResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The status of the specified Amazon Web Services account.
getAccountStatusResponse_status :: Lens.Lens' GetAccountStatusResponse (Prelude.Maybe AccountStatus)
getAccountStatusResponse_status :: (Maybe AccountStatus -> f (Maybe AccountStatus))
-> GetAccountStatusResponse -> f GetAccountStatusResponse
getAccountStatusResponse_status = (GetAccountStatusResponse -> Maybe AccountStatus)
-> (GetAccountStatusResponse
    -> Maybe AccountStatus -> GetAccountStatusResponse)
-> Lens
     GetAccountStatusResponse
     GetAccountStatusResponse
     (Maybe AccountStatus)
     (Maybe AccountStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAccountStatusResponse' {Maybe AccountStatus
status :: Maybe AccountStatus
$sel:status:GetAccountStatusResponse' :: GetAccountStatusResponse -> Maybe AccountStatus
status} -> Maybe AccountStatus
status) (\s :: GetAccountStatusResponse
s@GetAccountStatusResponse' {} Maybe AccountStatus
a -> GetAccountStatusResponse
s {$sel:status:GetAccountStatusResponse' :: Maybe AccountStatus
status = Maybe AccountStatus
a} :: GetAccountStatusResponse)

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

instance Prelude.NFData GetAccountStatusResponse