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

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

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

    -- * Response Lenses
    updateVariableResponse_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:/ 'newUpdateVariable' smart constructor.
data UpdateVariable = UpdateVariable'
  { -- | The new default value of the variable.
    UpdateVariable -> Maybe Text
defaultValue :: 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 new description.
    UpdateVariable -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The name of the variable.
    UpdateVariable -> Text
name :: Prelude.Text
  }
  deriving (UpdateVariable -> UpdateVariable -> Bool
(UpdateVariable -> UpdateVariable -> Bool)
-> (UpdateVariable -> UpdateVariable -> Bool) -> Eq UpdateVariable
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]
(Int -> ReadS UpdateVariable)
-> ReadS [UpdateVariable]
-> ReadPrec UpdateVariable
-> ReadPrec [UpdateVariable]
-> Read 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
(Int -> UpdateVariable -> ShowS)
-> (UpdateVariable -> String)
-> ([UpdateVariable] -> ShowS)
-> Show UpdateVariable
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. UpdateVariable -> Rep UpdateVariable x)
-> (forall x. Rep UpdateVariable x -> UpdateVariable)
-> Generic UpdateVariable
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.
--
-- '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>.
--
-- 'description', 'updateVariable_description' - The new description.
--
-- 'name', 'updateVariable_name' - The name of the variable.
newUpdateVariable ::
  -- | 'name'
  Prelude.Text ->
  UpdateVariable
newUpdateVariable :: Text -> UpdateVariable
newUpdateVariable Text
pName_ =
  UpdateVariable' :: Maybe Text -> Maybe Text -> Maybe Text -> Text -> UpdateVariable
UpdateVariable'
    { $sel:defaultValue:UpdateVariable' :: Maybe Text
defaultValue = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:variableType:UpdateVariable' :: Maybe Text
variableType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:description:UpdateVariable' :: Maybe Text
description = Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> UpdateVariable -> f UpdateVariable
updateVariable_defaultValue = (UpdateVariable -> Maybe Text)
-> (UpdateVariable -> Maybe Text -> UpdateVariable)
-> Lens UpdateVariable UpdateVariable (Maybe Text) (Maybe Text)
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 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 :: (Maybe Text -> f (Maybe Text))
-> UpdateVariable -> f UpdateVariable
updateVariable_variableType = (UpdateVariable -> Maybe Text)
-> (UpdateVariable -> Maybe Text -> UpdateVariable)
-> Lens UpdateVariable UpdateVariable (Maybe Text) (Maybe Text)
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 new description.
updateVariable_description :: Lens.Lens' UpdateVariable (Prelude.Maybe Prelude.Text)
updateVariable_description :: (Maybe Text -> f (Maybe Text))
-> UpdateVariable -> f UpdateVariable
updateVariable_description = (UpdateVariable -> Maybe Text)
-> (UpdateVariable -> Maybe Text -> UpdateVariable)
-> Lens UpdateVariable UpdateVariable (Maybe Text) (Maybe Text)
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 name of the variable.
updateVariable_name :: Lens.Lens' UpdateVariable Prelude.Text
updateVariable_name :: (Text -> f Text) -> UpdateVariable -> f UpdateVariable
updateVariable_name = (UpdateVariable -> Text)
-> (UpdateVariable -> Text -> UpdateVariable)
-> Lens UpdateVariable UpdateVariable Text Text
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 :: UpdateVariable -> Request UpdateVariable
request = Service -> UpdateVariable -> Request UpdateVariable
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateVariable
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateVariable)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse UpdateVariable))
-> Logger
-> Service
-> Proxy UpdateVariable
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateVariable)))
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 -> UpdateVariableResponse
UpdateVariableResponse'
            (Int -> UpdateVariableResponse)
-> Either String Int -> Either String UpdateVariableResponse
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 UpdateVariable

instance Prelude.NFData UpdateVariable

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

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

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

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