{-# 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-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)
--
-- 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 Amazonka.FraudDetector.Types
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:/ '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
(UpdateRuleMetadata -> UpdateRuleMetadata -> Bool)
-> (UpdateRuleMetadata -> UpdateRuleMetadata -> Bool)
-> Eq UpdateRuleMetadata
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]
(Int -> ReadS UpdateRuleMetadata)
-> ReadS [UpdateRuleMetadata]
-> ReadPrec UpdateRuleMetadata
-> ReadPrec [UpdateRuleMetadata]
-> Read 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
(Int -> UpdateRuleMetadata -> ShowS)
-> (UpdateRuleMetadata -> String)
-> ([UpdateRuleMetadata] -> ShowS)
-> Show UpdateRuleMetadata
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. UpdateRuleMetadata -> Rep UpdateRuleMetadata x)
-> (forall x. Rep UpdateRuleMetadata x -> UpdateRuleMetadata)
-> Generic UpdateRuleMetadata
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' :: Rule -> Text -> UpdateRuleMetadata
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 :: (Rule -> f Rule) -> UpdateRuleMetadata -> f UpdateRuleMetadata
updateRuleMetadata_rule = (UpdateRuleMetadata -> Rule)
-> (UpdateRuleMetadata -> Rule -> UpdateRuleMetadata)
-> Lens UpdateRuleMetadata UpdateRuleMetadata Rule 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 :: (Text -> f Text) -> UpdateRuleMetadata -> f UpdateRuleMetadata
updateRuleMetadata_description = (UpdateRuleMetadata -> Text)
-> (UpdateRuleMetadata -> Text -> UpdateRuleMetadata)
-> Lens UpdateRuleMetadata UpdateRuleMetadata Text Text
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 :: UpdateRuleMetadata -> Request UpdateRuleMetadata
request = Service -> UpdateRuleMetadata -> Request UpdateRuleMetadata
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateRuleMetadata
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateRuleMetadata)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse UpdateRuleMetadata))
-> Logger
-> Service
-> Proxy UpdateRuleMetadata
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateRuleMetadata)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> UpdateRuleMetadataResponse
UpdateRuleMetadataResponse'
            (Int -> UpdateRuleMetadataResponse)
-> Either String Int -> Either String UpdateRuleMetadataResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable UpdateRuleMetadata

instance Prelude.NFData UpdateRuleMetadata

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

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"rule" Text -> Rule -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Rule
rule),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"description" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
description)
          ]
      )

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

instance Core.ToQuery UpdateRuleMetadata where
  toQuery :: UpdateRuleMetadata -> QueryString
toQuery = QueryString -> UpdateRuleMetadata -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(UpdateRuleMetadataResponse -> UpdateRuleMetadataResponse -> Bool)
-> (UpdateRuleMetadataResponse
    -> UpdateRuleMetadataResponse -> Bool)
-> Eq UpdateRuleMetadataResponse
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]
(Int -> ReadS UpdateRuleMetadataResponse)
-> ReadS [UpdateRuleMetadataResponse]
-> ReadPrec UpdateRuleMetadataResponse
-> ReadPrec [UpdateRuleMetadataResponse]
-> Read 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
(Int -> UpdateRuleMetadataResponse -> ShowS)
-> (UpdateRuleMetadataResponse -> String)
-> ([UpdateRuleMetadataResponse] -> ShowS)
-> Show UpdateRuleMetadataResponse
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.
 UpdateRuleMetadataResponse -> Rep UpdateRuleMetadataResponse x)
-> (forall x.
    Rep UpdateRuleMetadataResponse x -> UpdateRuleMetadataResponse)
-> Generic UpdateRuleMetadataResponse
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' :: Int -> UpdateRuleMetadataResponse
UpdateRuleMetadataResponse'
    { $sel:httpStatus:UpdateRuleMetadataResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
updateRuleMetadataResponse_httpStatus :: Lens.Lens' UpdateRuleMetadataResponse Prelude.Int
updateRuleMetadataResponse_httpStatus :: (Int -> f Int)
-> UpdateRuleMetadataResponse -> f UpdateRuleMetadataResponse
updateRuleMetadataResponse_httpStatus = (UpdateRuleMetadataResponse -> Int)
-> (UpdateRuleMetadataResponse
    -> Int -> UpdateRuleMetadataResponse)
-> Lens
     UpdateRuleMetadataResponse UpdateRuleMetadataResponse Int Int
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