{-# 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.DeregisterAccount
-- 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)
--
-- Deregisters an account in Audit Manager.
module Amazonka.AuditManager.DeregisterAccount
  ( -- * Creating a Request
    DeregisterAccount (..),
    newDeregisterAccount,

    -- * Destructuring the Response
    DeregisterAccountResponse (..),
    newDeregisterAccountResponse,

    -- * Response Lenses
    deregisterAccountResponse_status,
    deregisterAccountResponse_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:/ 'newDeregisterAccount' smart constructor.
data DeregisterAccount = DeregisterAccount'
  {
  }
  deriving (DeregisterAccount -> DeregisterAccount -> Bool
(DeregisterAccount -> DeregisterAccount -> Bool)
-> (DeregisterAccount -> DeregisterAccount -> Bool)
-> Eq DeregisterAccount
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeregisterAccount -> DeregisterAccount -> Bool
$c/= :: DeregisterAccount -> DeregisterAccount -> Bool
== :: DeregisterAccount -> DeregisterAccount -> Bool
$c== :: DeregisterAccount -> DeregisterAccount -> Bool
Prelude.Eq, ReadPrec [DeregisterAccount]
ReadPrec DeregisterAccount
Int -> ReadS DeregisterAccount
ReadS [DeregisterAccount]
(Int -> ReadS DeregisterAccount)
-> ReadS [DeregisterAccount]
-> ReadPrec DeregisterAccount
-> ReadPrec [DeregisterAccount]
-> Read DeregisterAccount
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeregisterAccount]
$creadListPrec :: ReadPrec [DeregisterAccount]
readPrec :: ReadPrec DeregisterAccount
$creadPrec :: ReadPrec DeregisterAccount
readList :: ReadS [DeregisterAccount]
$creadList :: ReadS [DeregisterAccount]
readsPrec :: Int -> ReadS DeregisterAccount
$creadsPrec :: Int -> ReadS DeregisterAccount
Prelude.Read, Int -> DeregisterAccount -> ShowS
[DeregisterAccount] -> ShowS
DeregisterAccount -> String
(Int -> DeregisterAccount -> ShowS)
-> (DeregisterAccount -> String)
-> ([DeregisterAccount] -> ShowS)
-> Show DeregisterAccount
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeregisterAccount] -> ShowS
$cshowList :: [DeregisterAccount] -> ShowS
show :: DeregisterAccount -> String
$cshow :: DeregisterAccount -> String
showsPrec :: Int -> DeregisterAccount -> ShowS
$cshowsPrec :: Int -> DeregisterAccount -> ShowS
Prelude.Show, (forall x. DeregisterAccount -> Rep DeregisterAccount x)
-> (forall x. Rep DeregisterAccount x -> DeregisterAccount)
-> Generic DeregisterAccount
forall x. Rep DeregisterAccount x -> DeregisterAccount
forall x. DeregisterAccount -> Rep DeregisterAccount x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeregisterAccount x -> DeregisterAccount
$cfrom :: forall x. DeregisterAccount -> Rep DeregisterAccount x
Prelude.Generic)

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

instance Core.AWSRequest DeregisterAccount where
  type
    AWSResponse DeregisterAccount =
      DeregisterAccountResponse
  request :: DeregisterAccount -> Request DeregisterAccount
request = Service -> DeregisterAccount -> Request DeregisterAccount
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeregisterAccount
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeregisterAccount)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeregisterAccount))
-> Logger
-> Service
-> Proxy DeregisterAccount
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeregisterAccount)))
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 -> DeregisterAccountResponse
DeregisterAccountResponse'
            (Maybe AccountStatus -> Int -> DeregisterAccountResponse)
-> Either String (Maybe AccountStatus)
-> Either String (Int -> DeregisterAccountResponse)
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 -> DeregisterAccountResponse)
-> Either String Int -> Either String DeregisterAccountResponse
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 DeregisterAccount

instance Prelude.NFData DeregisterAccount

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

instance Core.ToPath DeregisterAccount where
  toPath :: DeregisterAccount -> ByteString
toPath = ByteString -> DeregisterAccount -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/account/deregisterAccount"

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

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

-- |
-- Create a value of 'DeregisterAccountResponse' 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', 'deregisterAccountResponse_status' - The registration status of the account.
--
-- 'httpStatus', 'deregisterAccountResponse_httpStatus' - The response's http status code.
newDeregisterAccountResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeregisterAccountResponse
newDeregisterAccountResponse :: Int -> DeregisterAccountResponse
newDeregisterAccountResponse Int
pHttpStatus_ =
  DeregisterAccountResponse' :: Maybe AccountStatus -> Int -> DeregisterAccountResponse
DeregisterAccountResponse'
    { $sel:status:DeregisterAccountResponse' :: Maybe AccountStatus
status =
        Maybe AccountStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeregisterAccountResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The registration status of the account.
deregisterAccountResponse_status :: Lens.Lens' DeregisterAccountResponse (Prelude.Maybe AccountStatus)
deregisterAccountResponse_status :: (Maybe AccountStatus -> f (Maybe AccountStatus))
-> DeregisterAccountResponse -> f DeregisterAccountResponse
deregisterAccountResponse_status = (DeregisterAccountResponse -> Maybe AccountStatus)
-> (DeregisterAccountResponse
    -> Maybe AccountStatus -> DeregisterAccountResponse)
-> Lens
     DeregisterAccountResponse
     DeregisterAccountResponse
     (Maybe AccountStatus)
     (Maybe AccountStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeregisterAccountResponse' {Maybe AccountStatus
status :: Maybe AccountStatus
$sel:status:DeregisterAccountResponse' :: DeregisterAccountResponse -> Maybe AccountStatus
status} -> Maybe AccountStatus
status) (\s :: DeregisterAccountResponse
s@DeregisterAccountResponse' {} Maybe AccountStatus
a -> DeregisterAccountResponse
s {$sel:status:DeregisterAccountResponse' :: Maybe AccountStatus
status = Maybe AccountStatus
a} :: DeregisterAccountResponse)

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

instance Prelude.NFData DeregisterAccountResponse