{-# 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.PutFeedback
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Add feedback for an anomalous metric.
module Amazonka.LookoutMetrics.PutFeedback
  ( -- * Creating a Request
    PutFeedback (..),
    newPutFeedback,

    -- * Request Lenses
    putFeedback_anomalyDetectorArn,
    putFeedback_anomalyGroupTimeSeriesFeedback,

    -- * Destructuring the Response
    PutFeedbackResponse (..),
    newPutFeedbackResponse,

    -- * Response Lenses
    putFeedbackResponse_httpStatus,
  )
where

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

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

-- |
-- Create a value of 'PutFeedback' 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', 'putFeedback_anomalyDetectorArn' - The Amazon Resource Name (ARN) of the anomaly detector.
--
-- 'anomalyGroupTimeSeriesFeedback', 'putFeedback_anomalyGroupTimeSeriesFeedback' - Feedback for an anomalous metric.
newPutFeedback ::
  -- | 'anomalyDetectorArn'
  Prelude.Text ->
  -- | 'anomalyGroupTimeSeriesFeedback'
  AnomalyGroupTimeSeriesFeedback ->
  PutFeedback
newPutFeedback :: Text -> AnomalyGroupTimeSeriesFeedback -> PutFeedback
newPutFeedback
  Text
pAnomalyDetectorArn_
  AnomalyGroupTimeSeriesFeedback
pAnomalyGroupTimeSeriesFeedback_ =
    PutFeedback'
      { $sel:anomalyDetectorArn:PutFeedback' :: Text
anomalyDetectorArn =
          Text
pAnomalyDetectorArn_,
        $sel:anomalyGroupTimeSeriesFeedback:PutFeedback' :: AnomalyGroupTimeSeriesFeedback
anomalyGroupTimeSeriesFeedback =
          AnomalyGroupTimeSeriesFeedback
pAnomalyGroupTimeSeriesFeedback_
      }

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

-- | Feedback for an anomalous metric.
putFeedback_anomalyGroupTimeSeriesFeedback :: Lens.Lens' PutFeedback AnomalyGroupTimeSeriesFeedback
putFeedback_anomalyGroupTimeSeriesFeedback :: Lens' PutFeedback AnomalyGroupTimeSeriesFeedback
putFeedback_anomalyGroupTimeSeriesFeedback = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutFeedback' {AnomalyGroupTimeSeriesFeedback
anomalyGroupTimeSeriesFeedback :: AnomalyGroupTimeSeriesFeedback
$sel:anomalyGroupTimeSeriesFeedback:PutFeedback' :: PutFeedback -> AnomalyGroupTimeSeriesFeedback
anomalyGroupTimeSeriesFeedback} -> AnomalyGroupTimeSeriesFeedback
anomalyGroupTimeSeriesFeedback) (\s :: PutFeedback
s@PutFeedback' {} AnomalyGroupTimeSeriesFeedback
a -> PutFeedback
s {$sel:anomalyGroupTimeSeriesFeedback:PutFeedback' :: AnomalyGroupTimeSeriesFeedback
anomalyGroupTimeSeriesFeedback = AnomalyGroupTimeSeriesFeedback
a} :: PutFeedback)

instance Core.AWSRequest PutFeedback where
  type AWSResponse PutFeedback = PutFeedbackResponse
  request :: (Service -> Service) -> PutFeedback -> Request PutFeedback
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy PutFeedback
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutFeedback)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> PutFeedbackResponse
PutFeedbackResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable PutFeedback where
  hashWithSalt :: Int -> PutFeedback -> Int
hashWithSalt Int
_salt PutFeedback' {Text
AnomalyGroupTimeSeriesFeedback
anomalyGroupTimeSeriesFeedback :: AnomalyGroupTimeSeriesFeedback
anomalyDetectorArn :: Text
$sel:anomalyGroupTimeSeriesFeedback:PutFeedback' :: PutFeedback -> AnomalyGroupTimeSeriesFeedback
$sel:anomalyDetectorArn:PutFeedback' :: PutFeedback -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
anomalyDetectorArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` AnomalyGroupTimeSeriesFeedback
anomalyGroupTimeSeriesFeedback

instance Prelude.NFData PutFeedback where
  rnf :: PutFeedback -> ()
rnf PutFeedback' {Text
AnomalyGroupTimeSeriesFeedback
anomalyGroupTimeSeriesFeedback :: AnomalyGroupTimeSeriesFeedback
anomalyDetectorArn :: Text
$sel:anomalyGroupTimeSeriesFeedback:PutFeedback' :: PutFeedback -> AnomalyGroupTimeSeriesFeedback
$sel:anomalyDetectorArn:PutFeedback' :: PutFeedback -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
anomalyDetectorArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf AnomalyGroupTimeSeriesFeedback
anomalyGroupTimeSeriesFeedback

instance Data.ToHeaders PutFeedback where
  toHeaders :: PutFeedback -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON PutFeedback where
  toJSON :: PutFeedback -> Value
toJSON PutFeedback' {Text
AnomalyGroupTimeSeriesFeedback
anomalyGroupTimeSeriesFeedback :: AnomalyGroupTimeSeriesFeedback
anomalyDetectorArn :: Text
$sel:anomalyGroupTimeSeriesFeedback:PutFeedback' :: PutFeedback -> AnomalyGroupTimeSeriesFeedback
$sel:anomalyDetectorArn:PutFeedback' :: PutFeedback -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"AnomalyDetectorArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
anomalyDetectorArn),
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"AnomalyGroupTimeSeriesFeedback"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= AnomalyGroupTimeSeriesFeedback
anomalyGroupTimeSeriesFeedback
              )
          ]
      )

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

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

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

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

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

instance Prelude.NFData PutFeedbackResponse where
  rnf :: PutFeedbackResponse -> ()
rnf PutFeedbackResponse' {Int
httpStatus :: Int
$sel:httpStatus:PutFeedbackResponse' :: PutFeedbackResponse -> Int
..} = forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus