{-# 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.CreateModel
-- 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)
--
-- Creates a model using the specified model type.
module Amazonka.FraudDetector.CreateModel
  ( -- * Creating a Request
    CreateModel (..),
    newCreateModel,

    -- * Request Lenses
    createModel_description,
    createModel_tags,
    createModel_modelId,
    createModel_modelType,
    createModel_eventTypeName,

    -- * Destructuring the Response
    CreateModelResponse (..),
    newCreateModelResponse,

    -- * Response Lenses
    createModelResponse_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:/ 'newCreateModel' smart constructor.
data CreateModel = CreateModel'
  { -- | The model description.
    CreateModel -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | A collection of key and value pairs.
    CreateModel -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | The model ID.
    CreateModel -> Text
modelId :: Prelude.Text,
    -- | The model type.
    CreateModel -> ModelTypeEnum
modelType :: ModelTypeEnum,
    -- | The name of the event type.
    CreateModel -> Text
eventTypeName :: Prelude.Text
  }
  deriving (CreateModel -> CreateModel -> Bool
(CreateModel -> CreateModel -> Bool)
-> (CreateModel -> CreateModel -> Bool) -> Eq CreateModel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateModel -> CreateModel -> Bool
$c/= :: CreateModel -> CreateModel -> Bool
== :: CreateModel -> CreateModel -> Bool
$c== :: CreateModel -> CreateModel -> Bool
Prelude.Eq, ReadPrec [CreateModel]
ReadPrec CreateModel
Int -> ReadS CreateModel
ReadS [CreateModel]
(Int -> ReadS CreateModel)
-> ReadS [CreateModel]
-> ReadPrec CreateModel
-> ReadPrec [CreateModel]
-> Read CreateModel
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateModel]
$creadListPrec :: ReadPrec [CreateModel]
readPrec :: ReadPrec CreateModel
$creadPrec :: ReadPrec CreateModel
readList :: ReadS [CreateModel]
$creadList :: ReadS [CreateModel]
readsPrec :: Int -> ReadS CreateModel
$creadsPrec :: Int -> ReadS CreateModel
Prelude.Read, Int -> CreateModel -> ShowS
[CreateModel] -> ShowS
CreateModel -> String
(Int -> CreateModel -> ShowS)
-> (CreateModel -> String)
-> ([CreateModel] -> ShowS)
-> Show CreateModel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateModel] -> ShowS
$cshowList :: [CreateModel] -> ShowS
show :: CreateModel -> String
$cshow :: CreateModel -> String
showsPrec :: Int -> CreateModel -> ShowS
$cshowsPrec :: Int -> CreateModel -> ShowS
Prelude.Show, (forall x. CreateModel -> Rep CreateModel x)
-> (forall x. Rep CreateModel x -> CreateModel)
-> Generic CreateModel
forall x. Rep CreateModel x -> CreateModel
forall x. CreateModel -> Rep CreateModel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateModel x -> CreateModel
$cfrom :: forall x. CreateModel -> Rep CreateModel x
Prelude.Generic)

-- |
-- Create a value of 'CreateModel' 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', 'createModel_description' - The model description.
--
-- 'tags', 'createModel_tags' - A collection of key and value pairs.
--
-- 'modelId', 'createModel_modelId' - The model ID.
--
-- 'modelType', 'createModel_modelType' - The model type.
--
-- 'eventTypeName', 'createModel_eventTypeName' - The name of the event type.
newCreateModel ::
  -- | 'modelId'
  Prelude.Text ->
  -- | 'modelType'
  ModelTypeEnum ->
  -- | 'eventTypeName'
  Prelude.Text ->
  CreateModel
newCreateModel :: Text -> ModelTypeEnum -> Text -> CreateModel
newCreateModel Text
pModelId_ ModelTypeEnum
pModelType_ Text
pEventTypeName_ =
  CreateModel' :: Maybe Text
-> Maybe [Tag] -> Text -> ModelTypeEnum -> Text -> CreateModel
CreateModel'
    { $sel:description:CreateModel' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:CreateModel' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
      $sel:modelId:CreateModel' :: Text
modelId = Text
pModelId_,
      $sel:modelType:CreateModel' :: ModelTypeEnum
modelType = ModelTypeEnum
pModelType_,
      $sel:eventTypeName:CreateModel' :: Text
eventTypeName = Text
pEventTypeName_
    }

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

-- | A collection of key and value pairs.
createModel_tags :: Lens.Lens' CreateModel (Prelude.Maybe [Tag])
createModel_tags :: (Maybe [Tag] -> f (Maybe [Tag])) -> CreateModel -> f CreateModel
createModel_tags = (CreateModel -> Maybe [Tag])
-> (CreateModel -> Maybe [Tag] -> CreateModel)
-> Lens CreateModel CreateModel (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateModel' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreateModel' :: CreateModel -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreateModel
s@CreateModel' {} Maybe [Tag]
a -> CreateModel
s {$sel:tags:CreateModel' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreateModel) ((Maybe [Tag] -> f (Maybe [Tag])) -> CreateModel -> f CreateModel)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateModel
-> f CreateModel
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

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

-- | The name of the event type.
createModel_eventTypeName :: Lens.Lens' CreateModel Prelude.Text
createModel_eventTypeName :: (Text -> f Text) -> CreateModel -> f CreateModel
createModel_eventTypeName = (CreateModel -> Text)
-> (CreateModel -> Text -> CreateModel)
-> Lens CreateModel CreateModel Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateModel' {Text
eventTypeName :: Text
$sel:eventTypeName:CreateModel' :: CreateModel -> Text
eventTypeName} -> Text
eventTypeName) (\s :: CreateModel
s@CreateModel' {} Text
a -> CreateModel
s {$sel:eventTypeName:CreateModel' :: Text
eventTypeName = Text
a} :: CreateModel)

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

instance Prelude.NFData CreateModel

instance Core.ToHeaders CreateModel where
  toHeaders :: CreateModel -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateModel -> 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.CreateModel" ::
                          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 CreateModel where
  toJSON :: CreateModel -> Value
toJSON CreateModel' {Maybe [Tag]
Maybe Text
Text
ModelTypeEnum
eventTypeName :: Text
modelType :: ModelTypeEnum
modelId :: Text
tags :: Maybe [Tag]
description :: Maybe Text
$sel:eventTypeName:CreateModel' :: CreateModel -> Text
$sel:modelType:CreateModel' :: CreateModel -> ModelTypeEnum
$sel:modelId:CreateModel' :: CreateModel -> Text
$sel:tags:CreateModel' :: CreateModel -> Maybe [Tag]
$sel:description:CreateModel' :: CreateModel -> 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,
            (Text
"tags" Text -> [Tag] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Tag] -> Pair) -> Maybe [Tag] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags,
            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),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"eventTypeName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
eventTypeName)
          ]
      )

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

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

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

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

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

instance Prelude.NFData CreateModelResponse