{-# 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.FraudDetector.DeleteRule
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes the rule. You cannot delete a rule if it is used by an @ACTIVE@
-- or @INACTIVE@ detector version.
--
-- When you delete a rule, Amazon Fraud Detector permanently deletes that
-- rule and the data is no longer stored in Amazon Fraud Detector.
module Amazonka.FraudDetector.DeleteRule
  ( -- * Creating a Request
    DeleteRule (..),
    newDeleteRule,

    -- * Request Lenses
    deleteRule_rule,

    -- * Destructuring the Response
    DeleteRuleResponse (..),
    newDeleteRuleResponse,

    -- * Response Lenses
    deleteRuleResponse_httpStatus,
  )
where

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

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

-- |
-- Create a value of 'DeleteRule' 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:
--
-- 'rule', 'deleteRule_rule' - Undocumented member.
newDeleteRule ::
  -- | 'rule'
  Rule ->
  DeleteRule
newDeleteRule :: Rule -> DeleteRule
newDeleteRule Rule
pRule_ = DeleteRule' {$sel:rule:DeleteRule' :: Rule
rule = Rule
pRule_}

-- | Undocumented member.
deleteRule_rule :: Lens.Lens' DeleteRule Rule
deleteRule_rule :: Lens' DeleteRule Rule
deleteRule_rule = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteRule' {Rule
rule :: Rule
$sel:rule:DeleteRule' :: DeleteRule -> Rule
rule} -> Rule
rule) (\s :: DeleteRule
s@DeleteRule' {} Rule
a -> DeleteRule
s {$sel:rule:DeleteRule' :: Rule
rule = Rule
a} :: DeleteRule)

instance Core.AWSRequest DeleteRule where
  type AWSResponse DeleteRule = DeleteRuleResponse
  request :: (Service -> Service) -> DeleteRule -> Request DeleteRule
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 DeleteRule
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteRule)))
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 -> DeleteRuleResponse
DeleteRuleResponse'
            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 DeleteRule where
  hashWithSalt :: Int -> DeleteRule -> Int
hashWithSalt Int
_salt DeleteRule' {Rule
rule :: Rule
$sel:rule:DeleteRule' :: DeleteRule -> Rule
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Rule
rule

instance Prelude.NFData DeleteRule where
  rnf :: DeleteRule -> ()
rnf DeleteRule' {Rule
rule :: Rule
$sel:rule:DeleteRule' :: DeleteRule -> Rule
..} = forall a. NFData a => a -> ()
Prelude.rnf Rule
rule

instance Data.ToHeaders DeleteRule where
  toHeaders :: DeleteRule -> 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
"AWSHawksNestServiceFacade.DeleteRule" ::
                          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 DeleteRule where
  toJSON :: DeleteRule -> Value
toJSON DeleteRule' {Rule
rule :: Rule
$sel:rule:DeleteRule' :: DeleteRule -> Rule
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"rule" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Rule
rule)]
      )

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

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

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

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

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

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