{-# 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.CreateDetectorVersion
-- 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 detector version. The detector version starts in a @DRAFT@
-- status.
module Amazonka.FraudDetector.CreateDetectorVersion
  ( -- * Creating a Request
    CreateDetectorVersion (..),
    newCreateDetectorVersion,

    -- * Request Lenses
    createDetectorVersion_ruleExecutionMode,
    createDetectorVersion_modelVersions,
    createDetectorVersion_externalModelEndpoints,
    createDetectorVersion_description,
    createDetectorVersion_tags,
    createDetectorVersion_detectorId,
    createDetectorVersion_rules,

    -- * Destructuring the Response
    CreateDetectorVersionResponse (..),
    newCreateDetectorVersionResponse,

    -- * Response Lenses
    createDetectorVersionResponse_status,
    createDetectorVersionResponse_detectorVersionId,
    createDetectorVersionResponse_detectorId,
    createDetectorVersionResponse_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:/ 'newCreateDetectorVersion' smart constructor.
data CreateDetectorVersion = CreateDetectorVersion'
  { -- | The rule execution mode for the rules included in the detector version.
    --
    -- You can define and edit the rule mode at the detector version level,
    -- when it is in draft status.
    --
    -- If you specify @FIRST_MATCHED@, Amazon Fraud Detector evaluates rules
    -- sequentially, first to last, stopping at the first matched rule. Amazon
    -- Fraud dectector then provides the outcomes for that single rule.
    --
    -- If you specifiy @ALL_MATCHED@, Amazon Fraud Detector evaluates all rules
    -- and returns the outcomes for all matched rules.
    --
    -- The default behavior is @FIRST_MATCHED@.
    CreateDetectorVersion -> Maybe RuleExecutionMode
ruleExecutionMode :: Prelude.Maybe RuleExecutionMode,
    -- | The model versions to include in the detector version.
    CreateDetectorVersion -> Maybe [ModelVersion]
modelVersions :: Prelude.Maybe [ModelVersion],
    -- | The Amazon Sagemaker model endpoints to include in the detector version.
    CreateDetectorVersion -> Maybe [Text]
externalModelEndpoints :: Prelude.Maybe [Prelude.Text],
    -- | The description of the detector version.
    CreateDetectorVersion -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | A collection of key and value pairs.
    CreateDetectorVersion -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | The ID of the detector under which you want to create a new version.
    CreateDetectorVersion -> Text
detectorId :: Prelude.Text,
    -- | The rules to include in the detector version.
    CreateDetectorVersion -> [Rule]
rules :: [Rule]
  }
  deriving (CreateDetectorVersion -> CreateDetectorVersion -> Bool
(CreateDetectorVersion -> CreateDetectorVersion -> Bool)
-> (CreateDetectorVersion -> CreateDetectorVersion -> Bool)
-> Eq CreateDetectorVersion
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateDetectorVersion -> CreateDetectorVersion -> Bool
$c/= :: CreateDetectorVersion -> CreateDetectorVersion -> Bool
== :: CreateDetectorVersion -> CreateDetectorVersion -> Bool
$c== :: CreateDetectorVersion -> CreateDetectorVersion -> Bool
Prelude.Eq, ReadPrec [CreateDetectorVersion]
ReadPrec CreateDetectorVersion
Int -> ReadS CreateDetectorVersion
ReadS [CreateDetectorVersion]
(Int -> ReadS CreateDetectorVersion)
-> ReadS [CreateDetectorVersion]
-> ReadPrec CreateDetectorVersion
-> ReadPrec [CreateDetectorVersion]
-> Read CreateDetectorVersion
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateDetectorVersion]
$creadListPrec :: ReadPrec [CreateDetectorVersion]
readPrec :: ReadPrec CreateDetectorVersion
$creadPrec :: ReadPrec CreateDetectorVersion
readList :: ReadS [CreateDetectorVersion]
$creadList :: ReadS [CreateDetectorVersion]
readsPrec :: Int -> ReadS CreateDetectorVersion
$creadsPrec :: Int -> ReadS CreateDetectorVersion
Prelude.Read, Int -> CreateDetectorVersion -> ShowS
[CreateDetectorVersion] -> ShowS
CreateDetectorVersion -> String
(Int -> CreateDetectorVersion -> ShowS)
-> (CreateDetectorVersion -> String)
-> ([CreateDetectorVersion] -> ShowS)
-> Show CreateDetectorVersion
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateDetectorVersion] -> ShowS
$cshowList :: [CreateDetectorVersion] -> ShowS
show :: CreateDetectorVersion -> String
$cshow :: CreateDetectorVersion -> String
showsPrec :: Int -> CreateDetectorVersion -> ShowS
$cshowsPrec :: Int -> CreateDetectorVersion -> ShowS
Prelude.Show, (forall x. CreateDetectorVersion -> Rep CreateDetectorVersion x)
-> (forall x. Rep CreateDetectorVersion x -> CreateDetectorVersion)
-> Generic CreateDetectorVersion
forall x. Rep CreateDetectorVersion x -> CreateDetectorVersion
forall x. CreateDetectorVersion -> Rep CreateDetectorVersion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateDetectorVersion x -> CreateDetectorVersion
$cfrom :: forall x. CreateDetectorVersion -> Rep CreateDetectorVersion x
Prelude.Generic)

-- |
-- Create a value of 'CreateDetectorVersion' 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:
--
-- 'ruleExecutionMode', 'createDetectorVersion_ruleExecutionMode' - The rule execution mode for the rules included in the detector version.
--
-- You can define and edit the rule mode at the detector version level,
-- when it is in draft status.
--
-- If you specify @FIRST_MATCHED@, Amazon Fraud Detector evaluates rules
-- sequentially, first to last, stopping at the first matched rule. Amazon
-- Fraud dectector then provides the outcomes for that single rule.
--
-- If you specifiy @ALL_MATCHED@, Amazon Fraud Detector evaluates all rules
-- and returns the outcomes for all matched rules.
--
-- The default behavior is @FIRST_MATCHED@.
--
-- 'modelVersions', 'createDetectorVersion_modelVersions' - The model versions to include in the detector version.
--
-- 'externalModelEndpoints', 'createDetectorVersion_externalModelEndpoints' - The Amazon Sagemaker model endpoints to include in the detector version.
--
-- 'description', 'createDetectorVersion_description' - The description of the detector version.
--
-- 'tags', 'createDetectorVersion_tags' - A collection of key and value pairs.
--
-- 'detectorId', 'createDetectorVersion_detectorId' - The ID of the detector under which you want to create a new version.
--
-- 'rules', 'createDetectorVersion_rules' - The rules to include in the detector version.
newCreateDetectorVersion ::
  -- | 'detectorId'
  Prelude.Text ->
  CreateDetectorVersion
newCreateDetectorVersion :: Text -> CreateDetectorVersion
newCreateDetectorVersion Text
pDetectorId_ =
  CreateDetectorVersion' :: Maybe RuleExecutionMode
-> Maybe [ModelVersion]
-> Maybe [Text]
-> Maybe Text
-> Maybe [Tag]
-> Text
-> [Rule]
-> CreateDetectorVersion
CreateDetectorVersion'
    { $sel:ruleExecutionMode:CreateDetectorVersion' :: Maybe RuleExecutionMode
ruleExecutionMode =
        Maybe RuleExecutionMode
forall a. Maybe a
Prelude.Nothing,
      $sel:modelVersions:CreateDetectorVersion' :: Maybe [ModelVersion]
modelVersions = Maybe [ModelVersion]
forall a. Maybe a
Prelude.Nothing,
      $sel:externalModelEndpoints:CreateDetectorVersion' :: Maybe [Text]
externalModelEndpoints = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:description:CreateDetectorVersion' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:CreateDetectorVersion' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
      $sel:detectorId:CreateDetectorVersion' :: Text
detectorId = Text
pDetectorId_,
      $sel:rules:CreateDetectorVersion' :: [Rule]
rules = [Rule]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The rule execution mode for the rules included in the detector version.
--
-- You can define and edit the rule mode at the detector version level,
-- when it is in draft status.
--
-- If you specify @FIRST_MATCHED@, Amazon Fraud Detector evaluates rules
-- sequentially, first to last, stopping at the first matched rule. Amazon
-- Fraud dectector then provides the outcomes for that single rule.
--
-- If you specifiy @ALL_MATCHED@, Amazon Fraud Detector evaluates all rules
-- and returns the outcomes for all matched rules.
--
-- The default behavior is @FIRST_MATCHED@.
createDetectorVersion_ruleExecutionMode :: Lens.Lens' CreateDetectorVersion (Prelude.Maybe RuleExecutionMode)
createDetectorVersion_ruleExecutionMode :: (Maybe RuleExecutionMode -> f (Maybe RuleExecutionMode))
-> CreateDetectorVersion -> f CreateDetectorVersion
createDetectorVersion_ruleExecutionMode = (CreateDetectorVersion -> Maybe RuleExecutionMode)
-> (CreateDetectorVersion
    -> Maybe RuleExecutionMode -> CreateDetectorVersion)
-> Lens
     CreateDetectorVersion
     CreateDetectorVersion
     (Maybe RuleExecutionMode)
     (Maybe RuleExecutionMode)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDetectorVersion' {Maybe RuleExecutionMode
ruleExecutionMode :: Maybe RuleExecutionMode
$sel:ruleExecutionMode:CreateDetectorVersion' :: CreateDetectorVersion -> Maybe RuleExecutionMode
ruleExecutionMode} -> Maybe RuleExecutionMode
ruleExecutionMode) (\s :: CreateDetectorVersion
s@CreateDetectorVersion' {} Maybe RuleExecutionMode
a -> CreateDetectorVersion
s {$sel:ruleExecutionMode:CreateDetectorVersion' :: Maybe RuleExecutionMode
ruleExecutionMode = Maybe RuleExecutionMode
a} :: CreateDetectorVersion)

-- | The model versions to include in the detector version.
createDetectorVersion_modelVersions :: Lens.Lens' CreateDetectorVersion (Prelude.Maybe [ModelVersion])
createDetectorVersion_modelVersions :: (Maybe [ModelVersion] -> f (Maybe [ModelVersion]))
-> CreateDetectorVersion -> f CreateDetectorVersion
createDetectorVersion_modelVersions = (CreateDetectorVersion -> Maybe [ModelVersion])
-> (CreateDetectorVersion
    -> Maybe [ModelVersion] -> CreateDetectorVersion)
-> Lens
     CreateDetectorVersion
     CreateDetectorVersion
     (Maybe [ModelVersion])
     (Maybe [ModelVersion])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDetectorVersion' {Maybe [ModelVersion]
modelVersions :: Maybe [ModelVersion]
$sel:modelVersions:CreateDetectorVersion' :: CreateDetectorVersion -> Maybe [ModelVersion]
modelVersions} -> Maybe [ModelVersion]
modelVersions) (\s :: CreateDetectorVersion
s@CreateDetectorVersion' {} Maybe [ModelVersion]
a -> CreateDetectorVersion
s {$sel:modelVersions:CreateDetectorVersion' :: Maybe [ModelVersion]
modelVersions = Maybe [ModelVersion]
a} :: CreateDetectorVersion) ((Maybe [ModelVersion] -> f (Maybe [ModelVersion]))
 -> CreateDetectorVersion -> f CreateDetectorVersion)
-> ((Maybe [ModelVersion] -> f (Maybe [ModelVersion]))
    -> Maybe [ModelVersion] -> f (Maybe [ModelVersion]))
-> (Maybe [ModelVersion] -> f (Maybe [ModelVersion]))
-> CreateDetectorVersion
-> f CreateDetectorVersion
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [ModelVersion] [ModelVersion] [ModelVersion] [ModelVersion]
-> Iso
     (Maybe [ModelVersion])
     (Maybe [ModelVersion])
     (Maybe [ModelVersion])
     (Maybe [ModelVersion])
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 [ModelVersion] [ModelVersion] [ModelVersion] [ModelVersion]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The Amazon Sagemaker model endpoints to include in the detector version.
createDetectorVersion_externalModelEndpoints :: Lens.Lens' CreateDetectorVersion (Prelude.Maybe [Prelude.Text])
createDetectorVersion_externalModelEndpoints :: (Maybe [Text] -> f (Maybe [Text]))
-> CreateDetectorVersion -> f CreateDetectorVersion
createDetectorVersion_externalModelEndpoints = (CreateDetectorVersion -> Maybe [Text])
-> (CreateDetectorVersion -> Maybe [Text] -> CreateDetectorVersion)
-> Lens
     CreateDetectorVersion
     CreateDetectorVersion
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDetectorVersion' {Maybe [Text]
externalModelEndpoints :: Maybe [Text]
$sel:externalModelEndpoints:CreateDetectorVersion' :: CreateDetectorVersion -> Maybe [Text]
externalModelEndpoints} -> Maybe [Text]
externalModelEndpoints) (\s :: CreateDetectorVersion
s@CreateDetectorVersion' {} Maybe [Text]
a -> CreateDetectorVersion
s {$sel:externalModelEndpoints:CreateDetectorVersion' :: Maybe [Text]
externalModelEndpoints = Maybe [Text]
a} :: CreateDetectorVersion) ((Maybe [Text] -> f (Maybe [Text]))
 -> CreateDetectorVersion -> f CreateDetectorVersion)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> CreateDetectorVersion
-> f CreateDetectorVersion
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The description of the detector version.
createDetectorVersion_description :: Lens.Lens' CreateDetectorVersion (Prelude.Maybe Prelude.Text)
createDetectorVersion_description :: (Maybe Text -> f (Maybe Text))
-> CreateDetectorVersion -> f CreateDetectorVersion
createDetectorVersion_description = (CreateDetectorVersion -> Maybe Text)
-> (CreateDetectorVersion -> Maybe Text -> CreateDetectorVersion)
-> Lens
     CreateDetectorVersion
     CreateDetectorVersion
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDetectorVersion' {Maybe Text
description :: Maybe Text
$sel:description:CreateDetectorVersion' :: CreateDetectorVersion -> Maybe Text
description} -> Maybe Text
description) (\s :: CreateDetectorVersion
s@CreateDetectorVersion' {} Maybe Text
a -> CreateDetectorVersion
s {$sel:description:CreateDetectorVersion' :: Maybe Text
description = Maybe Text
a} :: CreateDetectorVersion)

-- | A collection of key and value pairs.
createDetectorVersion_tags :: Lens.Lens' CreateDetectorVersion (Prelude.Maybe [Tag])
createDetectorVersion_tags :: (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateDetectorVersion -> f CreateDetectorVersion
createDetectorVersion_tags = (CreateDetectorVersion -> Maybe [Tag])
-> (CreateDetectorVersion -> Maybe [Tag] -> CreateDetectorVersion)
-> Lens
     CreateDetectorVersion
     CreateDetectorVersion
     (Maybe [Tag])
     (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDetectorVersion' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreateDetectorVersion' :: CreateDetectorVersion -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreateDetectorVersion
s@CreateDetectorVersion' {} Maybe [Tag]
a -> CreateDetectorVersion
s {$sel:tags:CreateDetectorVersion' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreateDetectorVersion) ((Maybe [Tag] -> f (Maybe [Tag]))
 -> CreateDetectorVersion -> f CreateDetectorVersion)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateDetectorVersion
-> f CreateDetectorVersion
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 ID of the detector under which you want to create a new version.
createDetectorVersion_detectorId :: Lens.Lens' CreateDetectorVersion Prelude.Text
createDetectorVersion_detectorId :: (Text -> f Text)
-> CreateDetectorVersion -> f CreateDetectorVersion
createDetectorVersion_detectorId = (CreateDetectorVersion -> Text)
-> (CreateDetectorVersion -> Text -> CreateDetectorVersion)
-> Lens CreateDetectorVersion CreateDetectorVersion Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDetectorVersion' {Text
detectorId :: Text
$sel:detectorId:CreateDetectorVersion' :: CreateDetectorVersion -> Text
detectorId} -> Text
detectorId) (\s :: CreateDetectorVersion
s@CreateDetectorVersion' {} Text
a -> CreateDetectorVersion
s {$sel:detectorId:CreateDetectorVersion' :: Text
detectorId = Text
a} :: CreateDetectorVersion)

-- | The rules to include in the detector version.
createDetectorVersion_rules :: Lens.Lens' CreateDetectorVersion [Rule]
createDetectorVersion_rules :: ([Rule] -> f [Rule])
-> CreateDetectorVersion -> f CreateDetectorVersion
createDetectorVersion_rules = (CreateDetectorVersion -> [Rule])
-> (CreateDetectorVersion -> [Rule] -> CreateDetectorVersion)
-> Lens CreateDetectorVersion CreateDetectorVersion [Rule] [Rule]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDetectorVersion' {[Rule]
rules :: [Rule]
$sel:rules:CreateDetectorVersion' :: CreateDetectorVersion -> [Rule]
rules} -> [Rule]
rules) (\s :: CreateDetectorVersion
s@CreateDetectorVersion' {} [Rule]
a -> CreateDetectorVersion
s {$sel:rules:CreateDetectorVersion' :: [Rule]
rules = [Rule]
a} :: CreateDetectorVersion) (([Rule] -> f [Rule])
 -> CreateDetectorVersion -> f CreateDetectorVersion)
-> (([Rule] -> f [Rule]) -> [Rule] -> f [Rule])
-> ([Rule] -> f [Rule])
-> CreateDetectorVersion
-> f CreateDetectorVersion
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Rule] -> f [Rule]) -> [Rule] -> f [Rule]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest CreateDetectorVersion where
  type
    AWSResponse CreateDetectorVersion =
      CreateDetectorVersionResponse
  request :: CreateDetectorVersion -> Request CreateDetectorVersion
request = Service -> CreateDetectorVersion -> Request CreateDetectorVersion
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateDetectorVersion
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateDetectorVersion)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateDetectorVersion))
-> Logger
-> Service
-> Proxy CreateDetectorVersion
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateDetectorVersion)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe DetectorVersionStatus
-> Maybe Text -> Maybe Text -> Int -> CreateDetectorVersionResponse
CreateDetectorVersionResponse'
            (Maybe DetectorVersionStatus
 -> Maybe Text
 -> Maybe Text
 -> Int
 -> CreateDetectorVersionResponse)
-> Either String (Maybe DetectorVersionStatus)
-> Either
     String
     (Maybe Text -> Maybe Text -> Int -> CreateDetectorVersionResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe DetectorVersionStatus)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"status")
            Either
  String
  (Maybe Text -> Maybe Text -> Int -> CreateDetectorVersionResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe Text -> Int -> CreateDetectorVersionResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"detectorVersionId")
            Either String (Maybe Text -> Int -> CreateDetectorVersionResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateDetectorVersionResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"detectorId")
            Either String (Int -> CreateDetectorVersionResponse)
-> Either String Int -> Either String CreateDetectorVersionResponse
forall (f :: * -> *) a b. Applicative f => 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 CreateDetectorVersion

instance Prelude.NFData CreateDetectorVersion

instance Core.ToHeaders CreateDetectorVersion where
  toHeaders :: CreateDetectorVersion -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateDetectorVersion -> 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.CreateDetectorVersion" ::
                          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 CreateDetectorVersion where
  toJSON :: CreateDetectorVersion -> Value
toJSON CreateDetectorVersion' {[Rule]
Maybe [Text]
Maybe [ModelVersion]
Maybe [Tag]
Maybe Text
Maybe RuleExecutionMode
Text
rules :: [Rule]
detectorId :: Text
tags :: Maybe [Tag]
description :: Maybe Text
externalModelEndpoints :: Maybe [Text]
modelVersions :: Maybe [ModelVersion]
ruleExecutionMode :: Maybe RuleExecutionMode
$sel:rules:CreateDetectorVersion' :: CreateDetectorVersion -> [Rule]
$sel:detectorId:CreateDetectorVersion' :: CreateDetectorVersion -> Text
$sel:tags:CreateDetectorVersion' :: CreateDetectorVersion -> Maybe [Tag]
$sel:description:CreateDetectorVersion' :: CreateDetectorVersion -> Maybe Text
$sel:externalModelEndpoints:CreateDetectorVersion' :: CreateDetectorVersion -> Maybe [Text]
$sel:modelVersions:CreateDetectorVersion' :: CreateDetectorVersion -> Maybe [ModelVersion]
$sel:ruleExecutionMode:CreateDetectorVersion' :: CreateDetectorVersion -> Maybe RuleExecutionMode
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ruleExecutionMode" Text -> RuleExecutionMode -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (RuleExecutionMode -> Pair)
-> Maybe RuleExecutionMode -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe RuleExecutionMode
ruleExecutionMode,
            (Text
"modelVersions" Text -> [ModelVersion] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([ModelVersion] -> Pair) -> Maybe [ModelVersion] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [ModelVersion]
modelVersions,
            (Text
"externalModelEndpoints" 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]
externalModelEndpoints,
            (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
"detectorId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
detectorId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"rules" Text -> [Rule] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Rule]
rules)
          ]
      )

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

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

-- | /See:/ 'newCreateDetectorVersionResponse' smart constructor.
data CreateDetectorVersionResponse = CreateDetectorVersionResponse'
  { -- | The status of the detector version.
    CreateDetectorVersionResponse -> Maybe DetectorVersionStatus
status :: Prelude.Maybe DetectorVersionStatus,
    -- | The ID for the created detector.
    CreateDetectorVersionResponse -> Maybe Text
detectorVersionId :: Prelude.Maybe Prelude.Text,
    -- | The ID for the created version\'s parent detector.
    CreateDetectorVersionResponse -> Maybe Text
detectorId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    CreateDetectorVersionResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateDetectorVersionResponse
-> CreateDetectorVersionResponse -> Bool
(CreateDetectorVersionResponse
 -> CreateDetectorVersionResponse -> Bool)
-> (CreateDetectorVersionResponse
    -> CreateDetectorVersionResponse -> Bool)
-> Eq CreateDetectorVersionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateDetectorVersionResponse
-> CreateDetectorVersionResponse -> Bool
$c/= :: CreateDetectorVersionResponse
-> CreateDetectorVersionResponse -> Bool
== :: CreateDetectorVersionResponse
-> CreateDetectorVersionResponse -> Bool
$c== :: CreateDetectorVersionResponse
-> CreateDetectorVersionResponse -> Bool
Prelude.Eq, ReadPrec [CreateDetectorVersionResponse]
ReadPrec CreateDetectorVersionResponse
Int -> ReadS CreateDetectorVersionResponse
ReadS [CreateDetectorVersionResponse]
(Int -> ReadS CreateDetectorVersionResponse)
-> ReadS [CreateDetectorVersionResponse]
-> ReadPrec CreateDetectorVersionResponse
-> ReadPrec [CreateDetectorVersionResponse]
-> Read CreateDetectorVersionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateDetectorVersionResponse]
$creadListPrec :: ReadPrec [CreateDetectorVersionResponse]
readPrec :: ReadPrec CreateDetectorVersionResponse
$creadPrec :: ReadPrec CreateDetectorVersionResponse
readList :: ReadS [CreateDetectorVersionResponse]
$creadList :: ReadS [CreateDetectorVersionResponse]
readsPrec :: Int -> ReadS CreateDetectorVersionResponse
$creadsPrec :: Int -> ReadS CreateDetectorVersionResponse
Prelude.Read, Int -> CreateDetectorVersionResponse -> ShowS
[CreateDetectorVersionResponse] -> ShowS
CreateDetectorVersionResponse -> String
(Int -> CreateDetectorVersionResponse -> ShowS)
-> (CreateDetectorVersionResponse -> String)
-> ([CreateDetectorVersionResponse] -> ShowS)
-> Show CreateDetectorVersionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateDetectorVersionResponse] -> ShowS
$cshowList :: [CreateDetectorVersionResponse] -> ShowS
show :: CreateDetectorVersionResponse -> String
$cshow :: CreateDetectorVersionResponse -> String
showsPrec :: Int -> CreateDetectorVersionResponse -> ShowS
$cshowsPrec :: Int -> CreateDetectorVersionResponse -> ShowS
Prelude.Show, (forall x.
 CreateDetectorVersionResponse
 -> Rep CreateDetectorVersionResponse x)
-> (forall x.
    Rep CreateDetectorVersionResponse x
    -> CreateDetectorVersionResponse)
-> Generic CreateDetectorVersionResponse
forall x.
Rep CreateDetectorVersionResponse x
-> CreateDetectorVersionResponse
forall x.
CreateDetectorVersionResponse
-> Rep CreateDetectorVersionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateDetectorVersionResponse x
-> CreateDetectorVersionResponse
$cfrom :: forall x.
CreateDetectorVersionResponse
-> Rep CreateDetectorVersionResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateDetectorVersionResponse' 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:
--
-- 'status', 'createDetectorVersionResponse_status' - The status of the detector version.
--
-- 'detectorVersionId', 'createDetectorVersionResponse_detectorVersionId' - The ID for the created detector.
--
-- 'detectorId', 'createDetectorVersionResponse_detectorId' - The ID for the created version\'s parent detector.
--
-- 'httpStatus', 'createDetectorVersionResponse_httpStatus' - The response's http status code.
newCreateDetectorVersionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateDetectorVersionResponse
newCreateDetectorVersionResponse :: Int -> CreateDetectorVersionResponse
newCreateDetectorVersionResponse Int
pHttpStatus_ =
  CreateDetectorVersionResponse' :: Maybe DetectorVersionStatus
-> Maybe Text -> Maybe Text -> Int -> CreateDetectorVersionResponse
CreateDetectorVersionResponse'
    { $sel:status:CreateDetectorVersionResponse' :: Maybe DetectorVersionStatus
status =
        Maybe DetectorVersionStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:detectorVersionId:CreateDetectorVersionResponse' :: Maybe Text
detectorVersionId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:detectorId:CreateDetectorVersionResponse' :: Maybe Text
detectorId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateDetectorVersionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The status of the detector version.
createDetectorVersionResponse_status :: Lens.Lens' CreateDetectorVersionResponse (Prelude.Maybe DetectorVersionStatus)
createDetectorVersionResponse_status :: (Maybe DetectorVersionStatus -> f (Maybe DetectorVersionStatus))
-> CreateDetectorVersionResponse -> f CreateDetectorVersionResponse
createDetectorVersionResponse_status = (CreateDetectorVersionResponse -> Maybe DetectorVersionStatus)
-> (CreateDetectorVersionResponse
    -> Maybe DetectorVersionStatus -> CreateDetectorVersionResponse)
-> Lens
     CreateDetectorVersionResponse
     CreateDetectorVersionResponse
     (Maybe DetectorVersionStatus)
     (Maybe DetectorVersionStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDetectorVersionResponse' {Maybe DetectorVersionStatus
status :: Maybe DetectorVersionStatus
$sel:status:CreateDetectorVersionResponse' :: CreateDetectorVersionResponse -> Maybe DetectorVersionStatus
status} -> Maybe DetectorVersionStatus
status) (\s :: CreateDetectorVersionResponse
s@CreateDetectorVersionResponse' {} Maybe DetectorVersionStatus
a -> CreateDetectorVersionResponse
s {$sel:status:CreateDetectorVersionResponse' :: Maybe DetectorVersionStatus
status = Maybe DetectorVersionStatus
a} :: CreateDetectorVersionResponse)

-- | The ID for the created detector.
createDetectorVersionResponse_detectorVersionId :: Lens.Lens' CreateDetectorVersionResponse (Prelude.Maybe Prelude.Text)
createDetectorVersionResponse_detectorVersionId :: (Maybe Text -> f (Maybe Text))
-> CreateDetectorVersionResponse -> f CreateDetectorVersionResponse
createDetectorVersionResponse_detectorVersionId = (CreateDetectorVersionResponse -> Maybe Text)
-> (CreateDetectorVersionResponse
    -> Maybe Text -> CreateDetectorVersionResponse)
-> Lens
     CreateDetectorVersionResponse
     CreateDetectorVersionResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDetectorVersionResponse' {Maybe Text
detectorVersionId :: Maybe Text
$sel:detectorVersionId:CreateDetectorVersionResponse' :: CreateDetectorVersionResponse -> Maybe Text
detectorVersionId} -> Maybe Text
detectorVersionId) (\s :: CreateDetectorVersionResponse
s@CreateDetectorVersionResponse' {} Maybe Text
a -> CreateDetectorVersionResponse
s {$sel:detectorVersionId:CreateDetectorVersionResponse' :: Maybe Text
detectorVersionId = Maybe Text
a} :: CreateDetectorVersionResponse)

-- | The ID for the created version\'s parent detector.
createDetectorVersionResponse_detectorId :: Lens.Lens' CreateDetectorVersionResponse (Prelude.Maybe Prelude.Text)
createDetectorVersionResponse_detectorId :: (Maybe Text -> f (Maybe Text))
-> CreateDetectorVersionResponse -> f CreateDetectorVersionResponse
createDetectorVersionResponse_detectorId = (CreateDetectorVersionResponse -> Maybe Text)
-> (CreateDetectorVersionResponse
    -> Maybe Text -> CreateDetectorVersionResponse)
-> Lens
     CreateDetectorVersionResponse
     CreateDetectorVersionResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDetectorVersionResponse' {Maybe Text
detectorId :: Maybe Text
$sel:detectorId:CreateDetectorVersionResponse' :: CreateDetectorVersionResponse -> Maybe Text
detectorId} -> Maybe Text
detectorId) (\s :: CreateDetectorVersionResponse
s@CreateDetectorVersionResponse' {} Maybe Text
a -> CreateDetectorVersionResponse
s {$sel:detectorId:CreateDetectorVersionResponse' :: Maybe Text
detectorId = Maybe Text
a} :: CreateDetectorVersionResponse)

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

instance Prelude.NFData CreateDetectorVersionResponse