{-# 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.DeregisterOrganizationAdminAccount
-- 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)
--
-- Removes the specified member Amazon Web Services account as a delegated
-- administrator for Audit Manager.
--
-- When you remove a delegated administrator from your Audit Manager
-- settings, or when you deregister a delegated administrator from
-- Organizations, you continue to have access to the evidence that you
-- previously collected under that account. However, Audit Manager will
-- stop collecting and attaching evidence to that delegated administrator
-- account moving forward.
module Amazonka.AuditManager.DeregisterOrganizationAdminAccount
  ( -- * Creating a Request
    DeregisterOrganizationAdminAccount (..),
    newDeregisterOrganizationAdminAccount,

    -- * Request Lenses
    deregisterOrganizationAdminAccount_adminAccountId,

    -- * Destructuring the Response
    DeregisterOrganizationAdminAccountResponse (..),
    newDeregisterOrganizationAdminAccountResponse,

    -- * Response Lenses
    deregisterOrganizationAdminAccountResponse_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:/ 'newDeregisterOrganizationAdminAccount' smart constructor.
data DeregisterOrganizationAdminAccount = DeregisterOrganizationAdminAccount'
  { -- | The identifier for the specified administrator account.
    DeregisterOrganizationAdminAccount -> Maybe Text
adminAccountId :: Prelude.Maybe Prelude.Text
  }
  deriving (DeregisterOrganizationAdminAccount
-> DeregisterOrganizationAdminAccount -> Bool
(DeregisterOrganizationAdminAccount
 -> DeregisterOrganizationAdminAccount -> Bool)
-> (DeregisterOrganizationAdminAccount
    -> DeregisterOrganizationAdminAccount -> Bool)
-> Eq DeregisterOrganizationAdminAccount
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeregisterOrganizationAdminAccount
-> DeregisterOrganizationAdminAccount -> Bool
$c/= :: DeregisterOrganizationAdminAccount
-> DeregisterOrganizationAdminAccount -> Bool
== :: DeregisterOrganizationAdminAccount
-> DeregisterOrganizationAdminAccount -> Bool
$c== :: DeregisterOrganizationAdminAccount
-> DeregisterOrganizationAdminAccount -> Bool
Prelude.Eq, ReadPrec [DeregisterOrganizationAdminAccount]
ReadPrec DeregisterOrganizationAdminAccount
Int -> ReadS DeregisterOrganizationAdminAccount
ReadS [DeregisterOrganizationAdminAccount]
(Int -> ReadS DeregisterOrganizationAdminAccount)
-> ReadS [DeregisterOrganizationAdminAccount]
-> ReadPrec DeregisterOrganizationAdminAccount
-> ReadPrec [DeregisterOrganizationAdminAccount]
-> Read DeregisterOrganizationAdminAccount
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeregisterOrganizationAdminAccount]
$creadListPrec :: ReadPrec [DeregisterOrganizationAdminAccount]
readPrec :: ReadPrec DeregisterOrganizationAdminAccount
$creadPrec :: ReadPrec DeregisterOrganizationAdminAccount
readList :: ReadS [DeregisterOrganizationAdminAccount]
$creadList :: ReadS [DeregisterOrganizationAdminAccount]
readsPrec :: Int -> ReadS DeregisterOrganizationAdminAccount
$creadsPrec :: Int -> ReadS DeregisterOrganizationAdminAccount
Prelude.Read, Int -> DeregisterOrganizationAdminAccount -> ShowS
[DeregisterOrganizationAdminAccount] -> ShowS
DeregisterOrganizationAdminAccount -> String
(Int -> DeregisterOrganizationAdminAccount -> ShowS)
-> (DeregisterOrganizationAdminAccount -> String)
-> ([DeregisterOrganizationAdminAccount] -> ShowS)
-> Show DeregisterOrganizationAdminAccount
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeregisterOrganizationAdminAccount] -> ShowS
$cshowList :: [DeregisterOrganizationAdminAccount] -> ShowS
show :: DeregisterOrganizationAdminAccount -> String
$cshow :: DeregisterOrganizationAdminAccount -> String
showsPrec :: Int -> DeregisterOrganizationAdminAccount -> ShowS
$cshowsPrec :: Int -> DeregisterOrganizationAdminAccount -> ShowS
Prelude.Show, (forall x.
 DeregisterOrganizationAdminAccount
 -> Rep DeregisterOrganizationAdminAccount x)
-> (forall x.
    Rep DeregisterOrganizationAdminAccount x
    -> DeregisterOrganizationAdminAccount)
-> Generic DeregisterOrganizationAdminAccount
forall x.
Rep DeregisterOrganizationAdminAccount x
-> DeregisterOrganizationAdminAccount
forall x.
DeregisterOrganizationAdminAccount
-> Rep DeregisterOrganizationAdminAccount x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeregisterOrganizationAdminAccount x
-> DeregisterOrganizationAdminAccount
$cfrom :: forall x.
DeregisterOrganizationAdminAccount
-> Rep DeregisterOrganizationAdminAccount x
Prelude.Generic)

-- |
-- Create a value of 'DeregisterOrganizationAdminAccount' 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:
--
-- 'adminAccountId', 'deregisterOrganizationAdminAccount_adminAccountId' - The identifier for the specified administrator account.
newDeregisterOrganizationAdminAccount ::
  DeregisterOrganizationAdminAccount
newDeregisterOrganizationAdminAccount :: DeregisterOrganizationAdminAccount
newDeregisterOrganizationAdminAccount =
  DeregisterOrganizationAdminAccount' :: Maybe Text -> DeregisterOrganizationAdminAccount
DeregisterOrganizationAdminAccount'
    { $sel:adminAccountId:DeregisterOrganizationAdminAccount' :: Maybe Text
adminAccountId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The identifier for the specified administrator account.
deregisterOrganizationAdminAccount_adminAccountId :: Lens.Lens' DeregisterOrganizationAdminAccount (Prelude.Maybe Prelude.Text)
deregisterOrganizationAdminAccount_adminAccountId :: (Maybe Text -> f (Maybe Text))
-> DeregisterOrganizationAdminAccount
-> f DeregisterOrganizationAdminAccount
deregisterOrganizationAdminAccount_adminAccountId = (DeregisterOrganizationAdminAccount -> Maybe Text)
-> (DeregisterOrganizationAdminAccount
    -> Maybe Text -> DeregisterOrganizationAdminAccount)
-> Lens
     DeregisterOrganizationAdminAccount
     DeregisterOrganizationAdminAccount
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeregisterOrganizationAdminAccount' {Maybe Text
adminAccountId :: Maybe Text
$sel:adminAccountId:DeregisterOrganizationAdminAccount' :: DeregisterOrganizationAdminAccount -> Maybe Text
adminAccountId} -> Maybe Text
adminAccountId) (\s :: DeregisterOrganizationAdminAccount
s@DeregisterOrganizationAdminAccount' {} Maybe Text
a -> DeregisterOrganizationAdminAccount
s {$sel:adminAccountId:DeregisterOrganizationAdminAccount' :: Maybe Text
adminAccountId = Maybe Text
a} :: DeregisterOrganizationAdminAccount)

instance
  Core.AWSRequest
    DeregisterOrganizationAdminAccount
  where
  type
    AWSResponse DeregisterOrganizationAdminAccount =
      DeregisterOrganizationAdminAccountResponse
  request :: DeregisterOrganizationAdminAccount
-> Request DeregisterOrganizationAdminAccount
request = Service
-> DeregisterOrganizationAdminAccount
-> Request DeregisterOrganizationAdminAccount
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeregisterOrganizationAdminAccount
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse DeregisterOrganizationAdminAccount)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeregisterOrganizationAdminAccount))
-> Logger
-> Service
-> Proxy DeregisterOrganizationAdminAccount
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse DeregisterOrganizationAdminAccount)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DeregisterOrganizationAdminAccountResponse
DeregisterOrganizationAdminAccountResponse'
            (Int -> DeregisterOrganizationAdminAccountResponse)
-> Either String Int
-> Either String DeregisterOrganizationAdminAccountResponse
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))
      )

instance
  Prelude.Hashable
    DeregisterOrganizationAdminAccount

instance
  Prelude.NFData
    DeregisterOrganizationAdminAccount

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

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

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

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

-- |
-- Create a value of 'DeregisterOrganizationAdminAccountResponse' 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', 'deregisterOrganizationAdminAccountResponse_httpStatus' - The response's http status code.
newDeregisterOrganizationAdminAccountResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeregisterOrganizationAdminAccountResponse
newDeregisterOrganizationAdminAccountResponse :: Int -> DeregisterOrganizationAdminAccountResponse
newDeregisterOrganizationAdminAccountResponse
  Int
pHttpStatus_ =
    DeregisterOrganizationAdminAccountResponse' :: Int -> DeregisterOrganizationAdminAccountResponse
DeregisterOrganizationAdminAccountResponse'
      { $sel:httpStatus:DeregisterOrganizationAdminAccountResponse' :: Int
httpStatus =
          Int
pHttpStatus_
      }

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

instance
  Prelude.NFData
    DeregisterOrganizationAdminAccountResponse