{-# 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.UpdateRuleMetadata
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Updates a rule\'s metadata. The description attribute can be updated.
module Amazonka.FraudDetector.UpdateRuleMetadata
  ( -- * Creating a Request
    UpdateRuleMetadata (..),
    newUpdateRuleMetadata,

    -- * Request Lenses
    updateRuleMetadata_rule,
    updateRuleMetadata_description,

    -- * Destructuring the Response
    UpdateRuleMetadataResponse (..),
    newUpdateRuleMetadataResponse,

    -- * Response Lenses
    updateRuleMetadataResponse_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:/ 'newUpdateRuleMetadata' smart constructor.
data UpdateRuleMetadata = UpdateRuleMetadata'
  { -- | The rule to update.
    UpdateRuleMetadata -> Rule
rule :: Rule,
    -- | The rule description.
    UpdateRuleMetadata -> Text
description :: Prelude.Text
  }
  deriving (UpdateRuleMetadata -> UpdateRuleMetadata -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateRuleMetadata -> UpdateRuleMetadata -> Bool
$c/= :: UpdateRuleMetadata -> UpdateRuleMetadata -> Bool
== :: UpdateRuleMetadata -> UpdateRuleMetadata -> Bool
$c== :: UpdateRuleMetadata -> UpdateRuleMetadata -> Bool
Prelude.Eq, ReadPrec [UpdateRuleMetadata]
ReadPrec UpdateRuleMetadata
Int -> ReadS UpdateRuleMetadata
ReadS [UpdateRuleMetadata]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateRuleMetadata]
$creadListPrec :: ReadPrec [UpdateRuleMetadata]
readPrec :: ReadPrec UpdateRuleMetadata
$creadPrec :: ReadPrec UpdateRuleMetadata
readList :: ReadS [UpdateRuleMetadata]
$creadList :: ReadS [UpdateRuleMetadata]
readsPrec :: Int -> ReadS UpdateRuleMetadata
$creadsPrec :: Int -> ReadS UpdateRuleMetadata
Prelude.Read, Int -> UpdateRuleMetadata -> ShowS
[UpdateRuleMetadata] -> ShowS
UpdateRuleMetadata -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateRuleMetadata] -> ShowS
$cshowList :: [UpdateRuleMetadata] -> ShowS
show :: UpdateRuleMetadata -> String
$cshow :: UpdateRuleMetadata -> String
showsPrec :: Int -> UpdateRuleMetadata -> ShowS
$cshowsPrec :: Int -> UpdateRuleMetadata -> ShowS
Prelude.Show, forall x. Rep UpdateRuleMetadata x -> UpdateRuleMetadata
forall x. UpdateRuleMetadata -> Rep UpdateRuleMetadata x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateRuleMetadata x -> UpdateRuleMetadata
$cfrom :: forall x. UpdateRuleMetadata -> Rep UpdateRuleMetadata x
Prelude.Generic)

-- |
-- Create a value of 'UpdateRuleMetadata' 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', 'updateRuleMetadata_rule' - The rule to update.
--
-- 'description', 'updateRuleMetadata_description' - The rule description.
newUpdateRuleMetadata ::
  -- | 'rule'
  Rule ->
  -- | 'description'
  Prelude.Text ->
  UpdateRuleMetadata
newUpdateRuleMetadata :: Rule -> Text -> UpdateRuleMetadata
newUpdateRuleMetadata Rule
pRule_ Text
pDescription_ =
  UpdateRuleMetadata'
    { $sel:rule:UpdateRuleMetadata' :: Rule
rule = Rule
pRule_,
      $sel:description:UpdateRuleMetadata' :: Text
description = Text
pDescription_
    }

-- | The rule to update.
updateRuleMetadata_rule :: Lens.Lens' UpdateRuleMetadata Rule
updateRuleMetadata_rule :: Lens' UpdateRuleMetadata Rule
updateRuleMetadata_rule = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRuleMetadata' {Rule
rule :: Rule
$sel:rule:UpdateRuleMetadata' :: UpdateRuleMetadata -> Rule
rule} -> Rule
rule) (\s :: UpdateRuleMetadata
s@UpdateRuleMetadata' {} Rule
a -> UpdateRuleMetadata
s {$sel:rule:UpdateRuleMetadata' :: Rule
rule = Rule
a} :: UpdateRuleMetadata)

-- | The rule description.
updateRuleMetadata_description :: Lens.Lens' UpdateRuleMetadata Prelude.Text
updateRuleMetadata_description :: Lens' UpdateRuleMetadata Text
updateRuleMetadata_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRuleMetadata' {Text
description :: Text
$sel:description:UpdateRuleMetadata' :: UpdateRuleMetadata -> Text
description} -> Text
description) (\s :: UpdateRuleMetadata
s@UpdateRuleMetadata' {} Text
a -> UpdateRuleMetadata
s {$sel:description:UpdateRuleMetadata' :: Text
description = Text
a} :: UpdateRuleMetadata)

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

instance Prelude.NFData UpdateRuleMetadata where
  rnf :: UpdateRuleMetadata -> ()
rnf UpdateRuleMetadata' {Text
Rule
description :: Text
rule :: Rule
$sel:description:UpdateRuleMetadata' :: UpdateRuleMetadata -> Text
$sel:rule:UpdateRuleMetadata' :: UpdateRuleMetadata -> Rule
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Rule
rule
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
description

instance Data.ToHeaders UpdateRuleMetadata where
  toHeaders :: UpdateRuleMetadata -> 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.UpdateRuleMetadata" ::
                          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 UpdateRuleMetadata where
  toJSON :: UpdateRuleMetadata -> Value
toJSON UpdateRuleMetadata' {Text
Rule
description :: Text
rule :: Rule
$sel:description:UpdateRuleMetadata' :: UpdateRuleMetadata -> Text
$sel:rule:UpdateRuleMetadata' :: UpdateRuleMetadata -> 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),
            forall a. a -> Maybe a
Prelude.Just (Key
"description" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
description)
          ]
      )

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

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

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

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

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

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