{-# 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.CloudTrail.DeregisterOrganizationDelegatedAdmin
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Removes CloudTrail delegated administrator permissions from a member
-- account in an organization.
module Amazonka.CloudTrail.DeregisterOrganizationDelegatedAdmin
  ( -- * Creating a Request
    DeregisterOrganizationDelegatedAdmin (..),
    newDeregisterOrganizationDelegatedAdmin,

    -- * Request Lenses
    deregisterOrganizationDelegatedAdmin_delegatedAdminAccountId,

    -- * Destructuring the Response
    DeregisterOrganizationDelegatedAdminResponse (..),
    newDeregisterOrganizationDelegatedAdminResponse,

    -- * Response Lenses
    deregisterOrganizationDelegatedAdminResponse_httpStatus,
  )
where

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

-- | Removes CloudTrail delegated administrator permissions from a specified
-- member account in an organization that is currently designated as a
-- delegated administrator.
--
-- /See:/ 'newDeregisterOrganizationDelegatedAdmin' smart constructor.
data DeregisterOrganizationDelegatedAdmin = DeregisterOrganizationDelegatedAdmin'
  { -- | A delegated administrator account ID. This is a member account in an
    -- organization that is currently designated as a delegated administrator.
    DeregisterOrganizationDelegatedAdmin -> Text
delegatedAdminAccountId :: Prelude.Text
  }
  deriving (DeregisterOrganizationDelegatedAdmin
-> DeregisterOrganizationDelegatedAdmin -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeregisterOrganizationDelegatedAdmin
-> DeregisterOrganizationDelegatedAdmin -> Bool
$c/= :: DeregisterOrganizationDelegatedAdmin
-> DeregisterOrganizationDelegatedAdmin -> Bool
== :: DeregisterOrganizationDelegatedAdmin
-> DeregisterOrganizationDelegatedAdmin -> Bool
$c== :: DeregisterOrganizationDelegatedAdmin
-> DeregisterOrganizationDelegatedAdmin -> Bool
Prelude.Eq, ReadPrec [DeregisterOrganizationDelegatedAdmin]
ReadPrec DeregisterOrganizationDelegatedAdmin
Int -> ReadS DeregisterOrganizationDelegatedAdmin
ReadS [DeregisterOrganizationDelegatedAdmin]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeregisterOrganizationDelegatedAdmin]
$creadListPrec :: ReadPrec [DeregisterOrganizationDelegatedAdmin]
readPrec :: ReadPrec DeregisterOrganizationDelegatedAdmin
$creadPrec :: ReadPrec DeregisterOrganizationDelegatedAdmin
readList :: ReadS [DeregisterOrganizationDelegatedAdmin]
$creadList :: ReadS [DeregisterOrganizationDelegatedAdmin]
readsPrec :: Int -> ReadS DeregisterOrganizationDelegatedAdmin
$creadsPrec :: Int -> ReadS DeregisterOrganizationDelegatedAdmin
Prelude.Read, Int -> DeregisterOrganizationDelegatedAdmin -> ShowS
[DeregisterOrganizationDelegatedAdmin] -> ShowS
DeregisterOrganizationDelegatedAdmin -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeregisterOrganizationDelegatedAdmin] -> ShowS
$cshowList :: [DeregisterOrganizationDelegatedAdmin] -> ShowS
show :: DeregisterOrganizationDelegatedAdmin -> String
$cshow :: DeregisterOrganizationDelegatedAdmin -> String
showsPrec :: Int -> DeregisterOrganizationDelegatedAdmin -> ShowS
$cshowsPrec :: Int -> DeregisterOrganizationDelegatedAdmin -> ShowS
Prelude.Show, forall x.
Rep DeregisterOrganizationDelegatedAdmin x
-> DeregisterOrganizationDelegatedAdmin
forall x.
DeregisterOrganizationDelegatedAdmin
-> Rep DeregisterOrganizationDelegatedAdmin x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeregisterOrganizationDelegatedAdmin x
-> DeregisterOrganizationDelegatedAdmin
$cfrom :: forall x.
DeregisterOrganizationDelegatedAdmin
-> Rep DeregisterOrganizationDelegatedAdmin x
Prelude.Generic)

-- |
-- Create a value of 'DeregisterOrganizationDelegatedAdmin' 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:
--
-- 'delegatedAdminAccountId', 'deregisterOrganizationDelegatedAdmin_delegatedAdminAccountId' - A delegated administrator account ID. This is a member account in an
-- organization that is currently designated as a delegated administrator.
newDeregisterOrganizationDelegatedAdmin ::
  -- | 'delegatedAdminAccountId'
  Prelude.Text ->
  DeregisterOrganizationDelegatedAdmin
newDeregisterOrganizationDelegatedAdmin :: Text -> DeregisterOrganizationDelegatedAdmin
newDeregisterOrganizationDelegatedAdmin
  Text
pDelegatedAdminAccountId_ =
    DeregisterOrganizationDelegatedAdmin'
      { $sel:delegatedAdminAccountId:DeregisterOrganizationDelegatedAdmin' :: Text
delegatedAdminAccountId =
          Text
pDelegatedAdminAccountId_
      }

-- | A delegated administrator account ID. This is a member account in an
-- organization that is currently designated as a delegated administrator.
deregisterOrganizationDelegatedAdmin_delegatedAdminAccountId :: Lens.Lens' DeregisterOrganizationDelegatedAdmin Prelude.Text
deregisterOrganizationDelegatedAdmin_delegatedAdminAccountId :: Lens' DeregisterOrganizationDelegatedAdmin Text
deregisterOrganizationDelegatedAdmin_delegatedAdminAccountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeregisterOrganizationDelegatedAdmin' {Text
delegatedAdminAccountId :: Text
$sel:delegatedAdminAccountId:DeregisterOrganizationDelegatedAdmin' :: DeregisterOrganizationDelegatedAdmin -> Text
delegatedAdminAccountId} -> Text
delegatedAdminAccountId) (\s :: DeregisterOrganizationDelegatedAdmin
s@DeregisterOrganizationDelegatedAdmin' {} Text
a -> DeregisterOrganizationDelegatedAdmin
s {$sel:delegatedAdminAccountId:DeregisterOrganizationDelegatedAdmin' :: Text
delegatedAdminAccountId = Text
a} :: DeregisterOrganizationDelegatedAdmin)

instance
  Core.AWSRequest
    DeregisterOrganizationDelegatedAdmin
  where
  type
    AWSResponse DeregisterOrganizationDelegatedAdmin =
      DeregisterOrganizationDelegatedAdminResponse
  request :: (Service -> Service)
-> DeregisterOrganizationDelegatedAdmin
-> Request DeregisterOrganizationDelegatedAdmin
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 DeregisterOrganizationDelegatedAdmin
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse
           (AWSResponse DeregisterOrganizationDelegatedAdmin)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DeregisterOrganizationDelegatedAdminResponse
DeregisterOrganizationDelegatedAdminResponse'
            forall (f :: * -> *) a b. Functor 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
    DeregisterOrganizationDelegatedAdmin
  where
  hashWithSalt :: Int -> DeregisterOrganizationDelegatedAdmin -> Int
hashWithSalt
    Int
_salt
    DeregisterOrganizationDelegatedAdmin' {Text
delegatedAdminAccountId :: Text
$sel:delegatedAdminAccountId:DeregisterOrganizationDelegatedAdmin' :: DeregisterOrganizationDelegatedAdmin -> Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
delegatedAdminAccountId

instance
  Prelude.NFData
    DeregisterOrganizationDelegatedAdmin
  where
  rnf :: DeregisterOrganizationDelegatedAdmin -> ()
rnf DeregisterOrganizationDelegatedAdmin' {Text
delegatedAdminAccountId :: Text
$sel:delegatedAdminAccountId:DeregisterOrganizationDelegatedAdmin' :: DeregisterOrganizationDelegatedAdmin -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
delegatedAdminAccountId

instance
  Data.ToHeaders
    DeregisterOrganizationDelegatedAdmin
  where
  toHeaders :: DeregisterOrganizationDelegatedAdmin -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"com.amazonaws.cloudtrail.v20131101.CloudTrail_20131101.DeregisterOrganizationDelegatedAdmin" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance
  Data.ToJSON
    DeregisterOrganizationDelegatedAdmin
  where
  toJSON :: DeregisterOrganizationDelegatedAdmin -> Value
toJSON DeregisterOrganizationDelegatedAdmin' {Text
delegatedAdminAccountId :: Text
$sel:delegatedAdminAccountId:DeregisterOrganizationDelegatedAdmin' :: DeregisterOrganizationDelegatedAdmin -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              ( Key
"DelegatedAdminAccountId"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
delegatedAdminAccountId
              )
          ]
      )

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

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

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

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

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

instance
  Prelude.NFData
    DeregisterOrganizationDelegatedAdminResponse
  where
  rnf :: DeregisterOrganizationDelegatedAdminResponse -> ()
rnf DeregisterOrganizationDelegatedAdminResponse' {Int
httpStatus :: Int
$sel:httpStatus:DeregisterOrganizationDelegatedAdminResponse' :: DeregisterOrganizationDelegatedAdminResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus