{-# 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.LookoutMetrics.BackTestAnomalyDetector
-- 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)
--
-- Runs a backtest for anomaly detection for the specified resource.
module Amazonka.LookoutMetrics.BackTestAnomalyDetector
  ( -- * Creating a Request
    BackTestAnomalyDetector (..),
    newBackTestAnomalyDetector,

    -- * Request Lenses
    backTestAnomalyDetector_anomalyDetectorArn,

    -- * Destructuring the Response
    BackTestAnomalyDetectorResponse (..),
    newBackTestAnomalyDetectorResponse,

    -- * Response Lenses
    backTestAnomalyDetectorResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.LookoutMetrics.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newBackTestAnomalyDetector' smart constructor.
data BackTestAnomalyDetector = BackTestAnomalyDetector'
  { -- | The Amazon Resource Name (ARN) of the anomaly detector.
    BackTestAnomalyDetector -> Text
anomalyDetectorArn :: Prelude.Text
  }
  deriving (BackTestAnomalyDetector -> BackTestAnomalyDetector -> Bool
(BackTestAnomalyDetector -> BackTestAnomalyDetector -> Bool)
-> (BackTestAnomalyDetector -> BackTestAnomalyDetector -> Bool)
-> Eq BackTestAnomalyDetector
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BackTestAnomalyDetector -> BackTestAnomalyDetector -> Bool
$c/= :: BackTestAnomalyDetector -> BackTestAnomalyDetector -> Bool
== :: BackTestAnomalyDetector -> BackTestAnomalyDetector -> Bool
$c== :: BackTestAnomalyDetector -> BackTestAnomalyDetector -> Bool
Prelude.Eq, ReadPrec [BackTestAnomalyDetector]
ReadPrec BackTestAnomalyDetector
Int -> ReadS BackTestAnomalyDetector
ReadS [BackTestAnomalyDetector]
(Int -> ReadS BackTestAnomalyDetector)
-> ReadS [BackTestAnomalyDetector]
-> ReadPrec BackTestAnomalyDetector
-> ReadPrec [BackTestAnomalyDetector]
-> Read BackTestAnomalyDetector
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BackTestAnomalyDetector]
$creadListPrec :: ReadPrec [BackTestAnomalyDetector]
readPrec :: ReadPrec BackTestAnomalyDetector
$creadPrec :: ReadPrec BackTestAnomalyDetector
readList :: ReadS [BackTestAnomalyDetector]
$creadList :: ReadS [BackTestAnomalyDetector]
readsPrec :: Int -> ReadS BackTestAnomalyDetector
$creadsPrec :: Int -> ReadS BackTestAnomalyDetector
Prelude.Read, Int -> BackTestAnomalyDetector -> ShowS
[BackTestAnomalyDetector] -> ShowS
BackTestAnomalyDetector -> String
(Int -> BackTestAnomalyDetector -> ShowS)
-> (BackTestAnomalyDetector -> String)
-> ([BackTestAnomalyDetector] -> ShowS)
-> Show BackTestAnomalyDetector
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BackTestAnomalyDetector] -> ShowS
$cshowList :: [BackTestAnomalyDetector] -> ShowS
show :: BackTestAnomalyDetector -> String
$cshow :: BackTestAnomalyDetector -> String
showsPrec :: Int -> BackTestAnomalyDetector -> ShowS
$cshowsPrec :: Int -> BackTestAnomalyDetector -> ShowS
Prelude.Show, (forall x.
 BackTestAnomalyDetector -> Rep BackTestAnomalyDetector x)
-> (forall x.
    Rep BackTestAnomalyDetector x -> BackTestAnomalyDetector)
-> Generic BackTestAnomalyDetector
forall x. Rep BackTestAnomalyDetector x -> BackTestAnomalyDetector
forall x. BackTestAnomalyDetector -> Rep BackTestAnomalyDetector x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BackTestAnomalyDetector x -> BackTestAnomalyDetector
$cfrom :: forall x. BackTestAnomalyDetector -> Rep BackTestAnomalyDetector x
Prelude.Generic)

-- |
-- Create a value of 'BackTestAnomalyDetector' 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:
--
-- 'anomalyDetectorArn', 'backTestAnomalyDetector_anomalyDetectorArn' - The Amazon Resource Name (ARN) of the anomaly detector.
newBackTestAnomalyDetector ::
  -- | 'anomalyDetectorArn'
  Prelude.Text ->
  BackTestAnomalyDetector
newBackTestAnomalyDetector :: Text -> BackTestAnomalyDetector
newBackTestAnomalyDetector Text
pAnomalyDetectorArn_ =
  BackTestAnomalyDetector' :: Text -> BackTestAnomalyDetector
BackTestAnomalyDetector'
    { $sel:anomalyDetectorArn:BackTestAnomalyDetector' :: Text
anomalyDetectorArn =
        Text
pAnomalyDetectorArn_
    }

-- | The Amazon Resource Name (ARN) of the anomaly detector.
backTestAnomalyDetector_anomalyDetectorArn :: Lens.Lens' BackTestAnomalyDetector Prelude.Text
backTestAnomalyDetector_anomalyDetectorArn :: (Text -> f Text)
-> BackTestAnomalyDetector -> f BackTestAnomalyDetector
backTestAnomalyDetector_anomalyDetectorArn = (BackTestAnomalyDetector -> Text)
-> (BackTestAnomalyDetector -> Text -> BackTestAnomalyDetector)
-> Lens BackTestAnomalyDetector BackTestAnomalyDetector Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackTestAnomalyDetector' {Text
anomalyDetectorArn :: Text
$sel:anomalyDetectorArn:BackTestAnomalyDetector' :: BackTestAnomalyDetector -> Text
anomalyDetectorArn} -> Text
anomalyDetectorArn) (\s :: BackTestAnomalyDetector
s@BackTestAnomalyDetector' {} Text
a -> BackTestAnomalyDetector
s {$sel:anomalyDetectorArn:BackTestAnomalyDetector' :: Text
anomalyDetectorArn = Text
a} :: BackTestAnomalyDetector)

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

instance Prelude.NFData BackTestAnomalyDetector

instance Core.ToHeaders BackTestAnomalyDetector where
  toHeaders :: BackTestAnomalyDetector -> ResponseHeaders
toHeaders =
    ResponseHeaders -> BackTestAnomalyDetector -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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 BackTestAnomalyDetector where
  toJSON :: BackTestAnomalyDetector -> Value
toJSON BackTestAnomalyDetector' {Text
anomalyDetectorArn :: Text
$sel:anomalyDetectorArn:BackTestAnomalyDetector' :: BackTestAnomalyDetector -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"AnomalyDetectorArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
anomalyDetectorArn)
          ]
      )

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

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

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

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

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

instance
  Prelude.NFData
    BackTestAnomalyDetectorResponse