{-# 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.Organizations.DeregisterDelegatedAdministrator
-- 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 AWS account as a delegated administrator
-- for the specified AWS service.
--
-- Deregistering a delegated administrator can have unintended impacts on
-- the functionality of the enabled AWS service. See the documentation for
-- the enabled service before you deregister a delegated administrator so
-- that you understand any potential impacts.
--
-- You can run this action only for AWS services that support this feature.
-- For a current list of services that support it, see the column /Supports
-- Delegated Administrator/ in the table at
-- <https://docs.aws.amazon.com/organizations/latest/userguide/orgs_integrate_services_list.html AWS Services that you can use with AWS Organizations>
-- in the /AWS Organizations User Guide./
--
-- This operation can be called only from the organization\'s management
-- account.
module Amazonka.Organizations.DeregisterDelegatedAdministrator
  ( -- * Creating a Request
    DeregisterDelegatedAdministrator (..),
    newDeregisterDelegatedAdministrator,

    -- * Request Lenses
    deregisterDelegatedAdministrator_accountId,
    deregisterDelegatedAdministrator_servicePrincipal,

    -- * Destructuring the Response
    DeregisterDelegatedAdministratorResponse (..),
    newDeregisterDelegatedAdministratorResponse,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Organizations.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDeregisterDelegatedAdministrator' smart constructor.
data DeregisterDelegatedAdministrator = DeregisterDelegatedAdministrator'
  { -- | The account ID number of the member account in the organization that you
    -- want to deregister as a delegated administrator.
    DeregisterDelegatedAdministrator -> Text
accountId :: Prelude.Text,
    -- | The service principal name of an AWS service for which the account is a
    -- delegated administrator.
    --
    -- Delegated administrator privileges are revoked for only the specified
    -- AWS service from the member account. If the specified service is the
    -- only service for which the member account is a delegated administrator,
    -- the operation also revokes Organizations read action permissions.
    DeregisterDelegatedAdministrator -> Text
servicePrincipal :: Prelude.Text
  }
  deriving (DeregisterDelegatedAdministrator
-> DeregisterDelegatedAdministrator -> Bool
(DeregisterDelegatedAdministrator
 -> DeregisterDelegatedAdministrator -> Bool)
-> (DeregisterDelegatedAdministrator
    -> DeregisterDelegatedAdministrator -> Bool)
-> Eq DeregisterDelegatedAdministrator
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeregisterDelegatedAdministrator
-> DeregisterDelegatedAdministrator -> Bool
$c/= :: DeregisterDelegatedAdministrator
-> DeregisterDelegatedAdministrator -> Bool
== :: DeregisterDelegatedAdministrator
-> DeregisterDelegatedAdministrator -> Bool
$c== :: DeregisterDelegatedAdministrator
-> DeregisterDelegatedAdministrator -> Bool
Prelude.Eq, ReadPrec [DeregisterDelegatedAdministrator]
ReadPrec DeregisterDelegatedAdministrator
Int -> ReadS DeregisterDelegatedAdministrator
ReadS [DeregisterDelegatedAdministrator]
(Int -> ReadS DeregisterDelegatedAdministrator)
-> ReadS [DeregisterDelegatedAdministrator]
-> ReadPrec DeregisterDelegatedAdministrator
-> ReadPrec [DeregisterDelegatedAdministrator]
-> Read DeregisterDelegatedAdministrator
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeregisterDelegatedAdministrator]
$creadListPrec :: ReadPrec [DeregisterDelegatedAdministrator]
readPrec :: ReadPrec DeregisterDelegatedAdministrator
$creadPrec :: ReadPrec DeregisterDelegatedAdministrator
readList :: ReadS [DeregisterDelegatedAdministrator]
$creadList :: ReadS [DeregisterDelegatedAdministrator]
readsPrec :: Int -> ReadS DeregisterDelegatedAdministrator
$creadsPrec :: Int -> ReadS DeregisterDelegatedAdministrator
Prelude.Read, Int -> DeregisterDelegatedAdministrator -> ShowS
[DeregisterDelegatedAdministrator] -> ShowS
DeregisterDelegatedAdministrator -> String
(Int -> DeregisterDelegatedAdministrator -> ShowS)
-> (DeregisterDelegatedAdministrator -> String)
-> ([DeregisterDelegatedAdministrator] -> ShowS)
-> Show DeregisterDelegatedAdministrator
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeregisterDelegatedAdministrator] -> ShowS
$cshowList :: [DeregisterDelegatedAdministrator] -> ShowS
show :: DeregisterDelegatedAdministrator -> String
$cshow :: DeregisterDelegatedAdministrator -> String
showsPrec :: Int -> DeregisterDelegatedAdministrator -> ShowS
$cshowsPrec :: Int -> DeregisterDelegatedAdministrator -> ShowS
Prelude.Show, (forall x.
 DeregisterDelegatedAdministrator
 -> Rep DeregisterDelegatedAdministrator x)
-> (forall x.
    Rep DeregisterDelegatedAdministrator x
    -> DeregisterDelegatedAdministrator)
-> Generic DeregisterDelegatedAdministrator
forall x.
Rep DeregisterDelegatedAdministrator x
-> DeregisterDelegatedAdministrator
forall x.
DeregisterDelegatedAdministrator
-> Rep DeregisterDelegatedAdministrator x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeregisterDelegatedAdministrator x
-> DeregisterDelegatedAdministrator
$cfrom :: forall x.
DeregisterDelegatedAdministrator
-> Rep DeregisterDelegatedAdministrator x
Prelude.Generic)

-- |
-- Create a value of 'DeregisterDelegatedAdministrator' 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:
--
-- 'accountId', 'deregisterDelegatedAdministrator_accountId' - The account ID number of the member account in the organization that you
-- want to deregister as a delegated administrator.
--
-- 'servicePrincipal', 'deregisterDelegatedAdministrator_servicePrincipal' - The service principal name of an AWS service for which the account is a
-- delegated administrator.
--
-- Delegated administrator privileges are revoked for only the specified
-- AWS service from the member account. If the specified service is the
-- only service for which the member account is a delegated administrator,
-- the operation also revokes Organizations read action permissions.
newDeregisterDelegatedAdministrator ::
  -- | 'accountId'
  Prelude.Text ->
  -- | 'servicePrincipal'
  Prelude.Text ->
  DeregisterDelegatedAdministrator
newDeregisterDelegatedAdministrator :: Text -> Text -> DeregisterDelegatedAdministrator
newDeregisterDelegatedAdministrator
  Text
pAccountId_
  Text
pServicePrincipal_ =
    DeregisterDelegatedAdministrator' :: Text -> Text -> DeregisterDelegatedAdministrator
DeregisterDelegatedAdministrator'
      { $sel:accountId:DeregisterDelegatedAdministrator' :: Text
accountId =
          Text
pAccountId_,
        $sel:servicePrincipal:DeregisterDelegatedAdministrator' :: Text
servicePrincipal = Text
pServicePrincipal_
      }

-- | The account ID number of the member account in the organization that you
-- want to deregister as a delegated administrator.
deregisterDelegatedAdministrator_accountId :: Lens.Lens' DeregisterDelegatedAdministrator Prelude.Text
deregisterDelegatedAdministrator_accountId :: (Text -> f Text)
-> DeregisterDelegatedAdministrator
-> f DeregisterDelegatedAdministrator
deregisterDelegatedAdministrator_accountId = (DeregisterDelegatedAdministrator -> Text)
-> (DeregisterDelegatedAdministrator
    -> Text -> DeregisterDelegatedAdministrator)
-> Lens
     DeregisterDelegatedAdministrator
     DeregisterDelegatedAdministrator
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeregisterDelegatedAdministrator' {Text
accountId :: Text
$sel:accountId:DeregisterDelegatedAdministrator' :: DeregisterDelegatedAdministrator -> Text
accountId} -> Text
accountId) (\s :: DeregisterDelegatedAdministrator
s@DeregisterDelegatedAdministrator' {} Text
a -> DeregisterDelegatedAdministrator
s {$sel:accountId:DeregisterDelegatedAdministrator' :: Text
accountId = Text
a} :: DeregisterDelegatedAdministrator)

-- | The service principal name of an AWS service for which the account is a
-- delegated administrator.
--
-- Delegated administrator privileges are revoked for only the specified
-- AWS service from the member account. If the specified service is the
-- only service for which the member account is a delegated administrator,
-- the operation also revokes Organizations read action permissions.
deregisterDelegatedAdministrator_servicePrincipal :: Lens.Lens' DeregisterDelegatedAdministrator Prelude.Text
deregisterDelegatedAdministrator_servicePrincipal :: (Text -> f Text)
-> DeregisterDelegatedAdministrator
-> f DeregisterDelegatedAdministrator
deregisterDelegatedAdministrator_servicePrincipal = (DeregisterDelegatedAdministrator -> Text)
-> (DeregisterDelegatedAdministrator
    -> Text -> DeregisterDelegatedAdministrator)
-> Lens
     DeregisterDelegatedAdministrator
     DeregisterDelegatedAdministrator
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeregisterDelegatedAdministrator' {Text
servicePrincipal :: Text
$sel:servicePrincipal:DeregisterDelegatedAdministrator' :: DeregisterDelegatedAdministrator -> Text
servicePrincipal} -> Text
servicePrincipal) (\s :: DeregisterDelegatedAdministrator
s@DeregisterDelegatedAdministrator' {} Text
a -> DeregisterDelegatedAdministrator
s {$sel:servicePrincipal:DeregisterDelegatedAdministrator' :: Text
servicePrincipal = Text
a} :: DeregisterDelegatedAdministrator)

instance
  Core.AWSRequest
    DeregisterDelegatedAdministrator
  where
  type
    AWSResponse DeregisterDelegatedAdministrator =
      DeregisterDelegatedAdministratorResponse
  request :: DeregisterDelegatedAdministrator
-> Request DeregisterDelegatedAdministrator
request = Service
-> DeregisterDelegatedAdministrator
-> Request DeregisterDelegatedAdministrator
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeregisterDelegatedAdministrator
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse DeregisterDelegatedAdministrator)))
response =
    AWSResponse DeregisterDelegatedAdministrator
-> Logger
-> Service
-> Proxy DeregisterDelegatedAdministrator
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse DeregisterDelegatedAdministrator)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull
      AWSResponse DeregisterDelegatedAdministrator
DeregisterDelegatedAdministratorResponse
DeregisterDelegatedAdministratorResponse'

instance
  Prelude.Hashable
    DeregisterDelegatedAdministrator

instance
  Prelude.NFData
    DeregisterDelegatedAdministrator

instance
  Core.ToHeaders
    DeregisterDelegatedAdministrator
  where
  toHeaders :: DeregisterDelegatedAdministrator -> [Header]
toHeaders =
    [Header] -> DeregisterDelegatedAdministrator -> [Header]
forall a b. a -> b -> a
Prelude.const
      ( [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"AWSOrganizationsV20161128.DeregisterDelegatedAdministrator" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON DeregisterDelegatedAdministrator where
  toJSON :: DeregisterDelegatedAdministrator -> Value
toJSON DeregisterDelegatedAdministrator' {Text
servicePrincipal :: Text
accountId :: Text
$sel:servicePrincipal:DeregisterDelegatedAdministrator' :: DeregisterDelegatedAdministrator -> Text
$sel:accountId:DeregisterDelegatedAdministrator' :: DeregisterDelegatedAdministrator -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"AccountId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
accountId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ServicePrincipal" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
servicePrincipal)
          ]
      )

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

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

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

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

instance
  Prelude.NFData
    DeregisterDelegatedAdministratorResponse