{-# 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.UpdateVariable
-- 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 variable.
module Amazonka.FraudDetector.UpdateVariable
  ( -- * Creating a Request
    UpdateVariable (..),
    newUpdateVariable,

    -- * Request Lenses
    updateVariable_defaultValue,
    updateVariable_description,
    updateVariable_variableType,
    updateVariable_name,

    -- * Destructuring the Response
    UpdateVariableResponse (..),
    newUpdateVariableResponse,

    -- * Response Lenses
    updateVariableResponse_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:/ 'newUpdateVariable' smart constructor.
data UpdateVariable = UpdateVariable'
  { -- | The new default value of the variable.
    UpdateVariable -> Maybe Text
defaultValue :: Prelude.Maybe Prelude.Text,
    -- | The new description.
    UpdateVariable -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The variable type. For more information see
    -- <https://docs.aws.amazon.com/frauddetector/latest/ug/create-a-variable.html#variable-types Variable types>.
    UpdateVariable -> Maybe Text
variableType :: Prelude.Maybe Prelude.Text,
    -- | The name of the variable.
    UpdateVariable -> Text
name :: Prelude.Text
  }
  deriving (UpdateVariable -> UpdateVariable -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateVariable -> UpdateVariable -> Bool
$c/= :: UpdateVariable -> UpdateVariable -> Bool
== :: UpdateVariable -> UpdateVariable -> Bool
$c== :: UpdateVariable -> UpdateVariable -> Bool
Prelude.Eq, ReadPrec [UpdateVariable]
ReadPrec UpdateVariable
Int -> ReadS UpdateVariable
ReadS [UpdateVariable]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateVariable]
$creadListPrec :: ReadPrec [UpdateVariable]
readPrec :: ReadPrec UpdateVariable
$creadPrec :: ReadPrec UpdateVariable
readList :: ReadS [UpdateVariable]
$creadList :: ReadS [UpdateVariable]
readsPrec :: Int -> ReadS UpdateVariable
$creadsPrec :: Int -> ReadS UpdateVariable
Prelude.Read, Int -> UpdateVariable -> ShowS
[UpdateVariable] -> ShowS
UpdateVariable -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateVariable] -> ShowS
$cshowList :: [UpdateVariable] -> ShowS
show :: UpdateVariable -> String
$cshow :: UpdateVariable -> String
showsPrec :: Int -> UpdateVariable -> ShowS
$cshowsPrec :: Int -> UpdateVariable -> ShowS
Prelude.Show, forall x. Rep UpdateVariable x -> UpdateVariable
forall x. UpdateVariable -> Rep UpdateVariable x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateVariable x -> UpdateVariable
$cfrom :: forall x. UpdateVariable -> Rep UpdateVariable x
Prelude.Generic)

-- |
-- Create a value of 'UpdateVariable' 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:
--
-- 'defaultValue', 'updateVariable_defaultValue' - The new default value of the variable.
--
-- 'description', 'updateVariable_description' - The new description.
--
-- 'variableType', 'updateVariable_variableType' - The variable type. For more information see
-- <https://docs.aws.amazon.com/frauddetector/latest/ug/create-a-variable.html#variable-types Variable types>.
--
-- 'name', 'updateVariable_name' - The name of the variable.
newUpdateVariable ::
  -- | 'name'
  Prelude.Text ->
  UpdateVariable
newUpdateVariable :: Text -> UpdateVariable
newUpdateVariable Text
pName_ =
  UpdateVariable'
    { $sel:defaultValue:UpdateVariable' :: Maybe Text
defaultValue = forall a. Maybe a
Prelude.Nothing,
      $sel:description:UpdateVariable' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:variableType:UpdateVariable' :: Maybe Text
variableType = forall a. Maybe a
Prelude.Nothing,
      $sel:name:UpdateVariable' :: Text
name = Text
pName_
    }

-- | The new default value of the variable.
updateVariable_defaultValue :: Lens.Lens' UpdateVariable (Prelude.Maybe Prelude.Text)
updateVariable_defaultValue :: Lens' UpdateVariable (Maybe Text)
updateVariable_defaultValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateVariable' {Maybe Text
defaultValue :: Maybe Text
$sel:defaultValue:UpdateVariable' :: UpdateVariable -> Maybe Text
defaultValue} -> Maybe Text
defaultValue) (\s :: UpdateVariable
s@UpdateVariable' {} Maybe Text
a -> UpdateVariable
s {$sel:defaultValue:UpdateVariable' :: Maybe Text
defaultValue = Maybe Text
a} :: UpdateVariable)

-- | The new description.
updateVariable_description :: Lens.Lens' UpdateVariable (Prelude.Maybe Prelude.Text)
updateVariable_description :: Lens' UpdateVariable (Maybe Text)
updateVariable_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateVariable' {Maybe Text
description :: Maybe Text
$sel:description:UpdateVariable' :: UpdateVariable -> Maybe Text
description} -> Maybe Text
description) (\s :: UpdateVariable
s@UpdateVariable' {} Maybe Text
a -> UpdateVariable
s {$sel:description:UpdateVariable' :: Maybe Text
description = Maybe Text
a} :: UpdateVariable)

-- | The variable type. For more information see
-- <https://docs.aws.amazon.com/frauddetector/latest/ug/create-a-variable.html#variable-types Variable types>.
updateVariable_variableType :: Lens.Lens' UpdateVariable (Prelude.Maybe Prelude.Text)
updateVariable_variableType :: Lens' UpdateVariable (Maybe Text)
updateVariable_variableType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateVariable' {Maybe Text
variableType :: Maybe Text
$sel:variableType:UpdateVariable' :: UpdateVariable -> Maybe Text
variableType} -> Maybe Text
variableType) (\s :: UpdateVariable
s@UpdateVariable' {} Maybe Text
a -> UpdateVariable
s {$sel:variableType:UpdateVariable' :: Maybe Text
variableType = Maybe Text
a} :: UpdateVariable)

-- | The name of the variable.
updateVariable_name :: Lens.Lens' UpdateVariable Prelude.Text
updateVariable_name :: Lens' UpdateVariable Text
updateVariable_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateVariable' {Text
name :: Text
$sel:name:UpdateVariable' :: UpdateVariable -> Text
name} -> Text
name) (\s :: UpdateVariable
s@UpdateVariable' {} Text
a -> UpdateVariable
s {$sel:name:UpdateVariable' :: Text
name = Text
a} :: UpdateVariable)

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

instance Prelude.NFData UpdateVariable where
  rnf :: UpdateVariable -> ()
rnf UpdateVariable' {Maybe Text
Text
name :: Text
variableType :: Maybe Text
description :: Maybe Text
defaultValue :: Maybe Text
$sel:name:UpdateVariable' :: UpdateVariable -> Text
$sel:variableType:UpdateVariable' :: UpdateVariable -> Maybe Text
$sel:description:UpdateVariable' :: UpdateVariable -> Maybe Text
$sel:defaultValue:UpdateVariable' :: UpdateVariable -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
defaultValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
variableType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name

instance Data.ToHeaders UpdateVariable where
  toHeaders :: UpdateVariable -> 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.UpdateVariable" ::
                          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 UpdateVariable where
  toJSON :: UpdateVariable -> Value
toJSON UpdateVariable' {Maybe Text
Text
name :: Text
variableType :: Maybe Text
description :: Maybe Text
defaultValue :: Maybe Text
$sel:name:UpdateVariable' :: UpdateVariable -> Text
$sel:variableType:UpdateVariable' :: UpdateVariable -> Maybe Text
$sel:description:UpdateVariable' :: UpdateVariable -> Maybe Text
$sel:defaultValue:UpdateVariable' :: UpdateVariable -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"defaultValue" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
defaultValue,
            (Key
"description" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
description,
            (Key
"variableType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
variableType,
            forall a. a -> Maybe a
Prelude.Just (Key
"name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name)
          ]
      )

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

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

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

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

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

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