{-# 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.UpdateModel
-- 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 model description.
module Amazonka.FraudDetector.UpdateModel
  ( -- * Creating a Request
    UpdateModel (..),
    newUpdateModel,

    -- * Request Lenses
    updateModel_description,
    updateModel_modelId,
    updateModel_modelType,

    -- * Destructuring the Response
    UpdateModelResponse (..),
    newUpdateModelResponse,

    -- * Response Lenses
    updateModelResponse_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:/ 'newUpdateModel' smart constructor.
data UpdateModel = UpdateModel'
  { -- | The new model description.
    UpdateModel -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The model ID.
    UpdateModel -> Text
modelId :: Prelude.Text,
    -- | The model type.
    UpdateModel -> ModelTypeEnum
modelType :: ModelTypeEnum
  }
  deriving (UpdateModel -> UpdateModel -> Bool
(UpdateModel -> UpdateModel -> Bool)
-> (UpdateModel -> UpdateModel -> Bool) -> Eq UpdateModel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateModel -> UpdateModel -> Bool
$c/= :: UpdateModel -> UpdateModel -> Bool
== :: UpdateModel -> UpdateModel -> Bool
$c== :: UpdateModel -> UpdateModel -> Bool
Prelude.Eq, ReadPrec [UpdateModel]
ReadPrec UpdateModel
Int -> ReadS UpdateModel
ReadS [UpdateModel]
(Int -> ReadS UpdateModel)
-> ReadS [UpdateModel]
-> ReadPrec UpdateModel
-> ReadPrec [UpdateModel]
-> Read UpdateModel
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateModel]
$creadListPrec :: ReadPrec [UpdateModel]
readPrec :: ReadPrec UpdateModel
$creadPrec :: ReadPrec UpdateModel
readList :: ReadS [UpdateModel]
$creadList :: ReadS [UpdateModel]
readsPrec :: Int -> ReadS UpdateModel
$creadsPrec :: Int -> ReadS UpdateModel
Prelude.Read, Int -> UpdateModel -> ShowS
[UpdateModel] -> ShowS
UpdateModel -> String
(Int -> UpdateModel -> ShowS)
-> (UpdateModel -> String)
-> ([UpdateModel] -> ShowS)
-> Show UpdateModel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateModel] -> ShowS
$cshowList :: [UpdateModel] -> ShowS
show :: UpdateModel -> String
$cshow :: UpdateModel -> String
showsPrec :: Int -> UpdateModel -> ShowS
$cshowsPrec :: Int -> UpdateModel -> ShowS
Prelude.Show, (forall x. UpdateModel -> Rep UpdateModel x)
-> (forall x. Rep UpdateModel x -> UpdateModel)
-> Generic UpdateModel
forall x. Rep UpdateModel x -> UpdateModel
forall x. UpdateModel -> Rep UpdateModel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateModel x -> UpdateModel
$cfrom :: forall x. UpdateModel -> Rep UpdateModel x
Prelude.Generic)

-- |
-- Create a value of 'UpdateModel' 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:
--
-- 'description', 'updateModel_description' - The new model description.
--
-- 'modelId', 'updateModel_modelId' - The model ID.
--
-- 'modelType', 'updateModel_modelType' - The model type.
newUpdateModel ::
  -- | 'modelId'
  Prelude.Text ->
  -- | 'modelType'
  ModelTypeEnum ->
  UpdateModel
newUpdateModel :: Text -> ModelTypeEnum -> UpdateModel
newUpdateModel Text
pModelId_ ModelTypeEnum
pModelType_ =
  UpdateModel' :: Maybe Text -> Text -> ModelTypeEnum -> UpdateModel
UpdateModel'
    { $sel:description:UpdateModel' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:modelId:UpdateModel' :: Text
modelId = Text
pModelId_,
      $sel:modelType:UpdateModel' :: ModelTypeEnum
modelType = ModelTypeEnum
pModelType_
    }

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

-- | The model ID.
updateModel_modelId :: Lens.Lens' UpdateModel Prelude.Text
updateModel_modelId :: (Text -> f Text) -> UpdateModel -> f UpdateModel
updateModel_modelId = (UpdateModel -> Text)
-> (UpdateModel -> Text -> UpdateModel)
-> Lens UpdateModel UpdateModel Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateModel' {Text
modelId :: Text
$sel:modelId:UpdateModel' :: UpdateModel -> Text
modelId} -> Text
modelId) (\s :: UpdateModel
s@UpdateModel' {} Text
a -> UpdateModel
s {$sel:modelId:UpdateModel' :: Text
modelId = Text
a} :: UpdateModel)

-- | The model type.
updateModel_modelType :: Lens.Lens' UpdateModel ModelTypeEnum
updateModel_modelType :: (ModelTypeEnum -> f ModelTypeEnum) -> UpdateModel -> f UpdateModel
updateModel_modelType = (UpdateModel -> ModelTypeEnum)
-> (UpdateModel -> ModelTypeEnum -> UpdateModel)
-> Lens UpdateModel UpdateModel ModelTypeEnum ModelTypeEnum
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateModel' {ModelTypeEnum
modelType :: ModelTypeEnum
$sel:modelType:UpdateModel' :: UpdateModel -> ModelTypeEnum
modelType} -> ModelTypeEnum
modelType) (\s :: UpdateModel
s@UpdateModel' {} ModelTypeEnum
a -> UpdateModel
s {$sel:modelType:UpdateModel' :: ModelTypeEnum
modelType = ModelTypeEnum
a} :: UpdateModel)

instance Core.AWSRequest UpdateModel where
  type AWSResponse UpdateModel = UpdateModelResponse
  request :: UpdateModel -> Request UpdateModel
request = Service -> UpdateModel -> Request UpdateModel
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateModel
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateModel)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse UpdateModel))
-> Logger
-> Service
-> Proxy UpdateModel
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateModel)))
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 -> UpdateModelResponse
UpdateModelResponse'
            (Int -> UpdateModelResponse)
-> Either String Int -> Either String UpdateModelResponse
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 UpdateModel

instance Prelude.NFData UpdateModel

instance Core.ToHeaders UpdateModel where
  toHeaders :: UpdateModel -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateModel -> 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.UpdateModel" ::
                          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 UpdateModel where
  toJSON :: UpdateModel -> Value
toJSON UpdateModel' {Maybe Text
Text
ModelTypeEnum
modelType :: ModelTypeEnum
modelId :: Text
description :: Maybe Text
$sel:modelType:UpdateModel' :: UpdateModel -> ModelTypeEnum
$sel:modelId:UpdateModel' :: UpdateModel -> Text
$sel:description:UpdateModel' :: UpdateModel -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (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
"modelId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
modelId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"modelType" Text -> ModelTypeEnum -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ModelTypeEnum
modelType)
          ]
      )

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

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

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

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

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

instance Prelude.NFData UpdateModelResponse