{-# 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.Config.DeleteOrganizationConfigRule
-- 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)
--
-- Deletes the specified organization config rule and all of its evaluation
-- results from all member accounts in that organization.
--
-- Only a master account and a delegated administrator account can delete
-- an organization config rule. When calling this API with a delegated
-- administrator, you must ensure Organizations
-- @ListDelegatedAdministrator@ permissions are added.
--
-- Config sets the state of a rule to DELETE_IN_PROGRESS until the deletion
-- is complete. You cannot update a rule while it is in this state.
module Amazonka.Config.DeleteOrganizationConfigRule
  ( -- * Creating a Request
    DeleteOrganizationConfigRule (..),
    newDeleteOrganizationConfigRule,

    -- * Request Lenses
    deleteOrganizationConfigRule_organizationConfigRuleName,

    -- * Destructuring the Response
    DeleteOrganizationConfigRuleResponse (..),
    newDeleteOrganizationConfigRuleResponse,
  )
where

import Amazonka.Config.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:/ 'newDeleteOrganizationConfigRule' smart constructor.
data DeleteOrganizationConfigRule = DeleteOrganizationConfigRule'
  { -- | The name of organization config rule that you want to delete.
    DeleteOrganizationConfigRule -> Text
organizationConfigRuleName :: Prelude.Text
  }
  deriving (DeleteOrganizationConfigRule
-> DeleteOrganizationConfigRule -> Bool
(DeleteOrganizationConfigRule
 -> DeleteOrganizationConfigRule -> Bool)
-> (DeleteOrganizationConfigRule
    -> DeleteOrganizationConfigRule -> Bool)
-> Eq DeleteOrganizationConfigRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteOrganizationConfigRule
-> DeleteOrganizationConfigRule -> Bool
$c/= :: DeleteOrganizationConfigRule
-> DeleteOrganizationConfigRule -> Bool
== :: DeleteOrganizationConfigRule
-> DeleteOrganizationConfigRule -> Bool
$c== :: DeleteOrganizationConfigRule
-> DeleteOrganizationConfigRule -> Bool
Prelude.Eq, ReadPrec [DeleteOrganizationConfigRule]
ReadPrec DeleteOrganizationConfigRule
Int -> ReadS DeleteOrganizationConfigRule
ReadS [DeleteOrganizationConfigRule]
(Int -> ReadS DeleteOrganizationConfigRule)
-> ReadS [DeleteOrganizationConfigRule]
-> ReadPrec DeleteOrganizationConfigRule
-> ReadPrec [DeleteOrganizationConfigRule]
-> Read DeleteOrganizationConfigRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteOrganizationConfigRule]
$creadListPrec :: ReadPrec [DeleteOrganizationConfigRule]
readPrec :: ReadPrec DeleteOrganizationConfigRule
$creadPrec :: ReadPrec DeleteOrganizationConfigRule
readList :: ReadS [DeleteOrganizationConfigRule]
$creadList :: ReadS [DeleteOrganizationConfigRule]
readsPrec :: Int -> ReadS DeleteOrganizationConfigRule
$creadsPrec :: Int -> ReadS DeleteOrganizationConfigRule
Prelude.Read, Int -> DeleteOrganizationConfigRule -> ShowS
[DeleteOrganizationConfigRule] -> ShowS
DeleteOrganizationConfigRule -> String
(Int -> DeleteOrganizationConfigRule -> ShowS)
-> (DeleteOrganizationConfigRule -> String)
-> ([DeleteOrganizationConfigRule] -> ShowS)
-> Show DeleteOrganizationConfigRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteOrganizationConfigRule] -> ShowS
$cshowList :: [DeleteOrganizationConfigRule] -> ShowS
show :: DeleteOrganizationConfigRule -> String
$cshow :: DeleteOrganizationConfigRule -> String
showsPrec :: Int -> DeleteOrganizationConfigRule -> ShowS
$cshowsPrec :: Int -> DeleteOrganizationConfigRule -> ShowS
Prelude.Show, (forall x.
 DeleteOrganizationConfigRule -> Rep DeleteOrganizationConfigRule x)
-> (forall x.
    Rep DeleteOrganizationConfigRule x -> DeleteOrganizationConfigRule)
-> Generic DeleteOrganizationConfigRule
forall x.
Rep DeleteOrganizationConfigRule x -> DeleteOrganizationConfigRule
forall x.
DeleteOrganizationConfigRule -> Rep DeleteOrganizationConfigRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteOrganizationConfigRule x -> DeleteOrganizationConfigRule
$cfrom :: forall x.
DeleteOrganizationConfigRule -> Rep DeleteOrganizationConfigRule x
Prelude.Generic)

-- |
-- Create a value of 'DeleteOrganizationConfigRule' 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:
--
-- 'organizationConfigRuleName', 'deleteOrganizationConfigRule_organizationConfigRuleName' - The name of organization config rule that you want to delete.
newDeleteOrganizationConfigRule ::
  -- | 'organizationConfigRuleName'
  Prelude.Text ->
  DeleteOrganizationConfigRule
newDeleteOrganizationConfigRule :: Text -> DeleteOrganizationConfigRule
newDeleteOrganizationConfigRule
  Text
pOrganizationConfigRuleName_ =
    DeleteOrganizationConfigRule' :: Text -> DeleteOrganizationConfigRule
DeleteOrganizationConfigRule'
      { $sel:organizationConfigRuleName:DeleteOrganizationConfigRule' :: Text
organizationConfigRuleName =
          Text
pOrganizationConfigRuleName_
      }

-- | The name of organization config rule that you want to delete.
deleteOrganizationConfigRule_organizationConfigRuleName :: Lens.Lens' DeleteOrganizationConfigRule Prelude.Text
deleteOrganizationConfigRule_organizationConfigRuleName :: (Text -> f Text)
-> DeleteOrganizationConfigRule -> f DeleteOrganizationConfigRule
deleteOrganizationConfigRule_organizationConfigRuleName = (DeleteOrganizationConfigRule -> Text)
-> (DeleteOrganizationConfigRule
    -> Text -> DeleteOrganizationConfigRule)
-> Lens
     DeleteOrganizationConfigRule DeleteOrganizationConfigRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteOrganizationConfigRule' {Text
organizationConfigRuleName :: Text
$sel:organizationConfigRuleName:DeleteOrganizationConfigRule' :: DeleteOrganizationConfigRule -> Text
organizationConfigRuleName} -> Text
organizationConfigRuleName) (\s :: DeleteOrganizationConfigRule
s@DeleteOrganizationConfigRule' {} Text
a -> DeleteOrganizationConfigRule
s {$sel:organizationConfigRuleName:DeleteOrganizationConfigRule' :: Text
organizationConfigRuleName = Text
a} :: DeleteOrganizationConfigRule)

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

instance
  Prelude.Hashable
    DeleteOrganizationConfigRule

instance Prelude.NFData DeleteOrganizationConfigRule

instance Core.ToHeaders DeleteOrganizationConfigRule where
  toHeaders :: DeleteOrganizationConfigRule -> [Header]
toHeaders =
    [Header] -> DeleteOrganizationConfigRule -> [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
"StarlingDoveService.DeleteOrganizationConfigRule" ::
                          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 DeleteOrganizationConfigRule where
  toJSON :: DeleteOrganizationConfigRule -> Value
toJSON DeleteOrganizationConfigRule' {Text
organizationConfigRuleName :: Text
$sel:organizationConfigRuleName:DeleteOrganizationConfigRule' :: DeleteOrganizationConfigRule -> 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
"OrganizationConfigRuleName"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
organizationConfigRuleName
              )
          ]
      )

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

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

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

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

instance
  Prelude.NFData
    DeleteOrganizationConfigRuleResponse