{-# 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-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)
--
-- 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.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:/ '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
(PutFeedback -> PutFeedback -> Bool)
-> (PutFeedback -> PutFeedback -> Bool) -> Eq PutFeedback
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]
(Int -> ReadS PutFeedback)
-> ReadS [PutFeedback]
-> ReadPrec PutFeedback
-> ReadPrec [PutFeedback]
-> Read 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
(Int -> PutFeedback -> ShowS)
-> (PutFeedback -> String)
-> ([PutFeedback] -> ShowS)
-> Show PutFeedback
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. PutFeedback -> Rep PutFeedback x)
-> (forall x. Rep PutFeedback x -> PutFeedback)
-> Generic PutFeedback
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' :: Text -> AnomalyGroupTimeSeriesFeedback -> PutFeedback
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 :: (Text -> f Text) -> PutFeedback -> f PutFeedback
putFeedback_anomalyDetectorArn = (PutFeedback -> Text)
-> (PutFeedback -> Text -> PutFeedback)
-> Lens PutFeedback PutFeedback Text Text
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 :: (AnomalyGroupTimeSeriesFeedback
 -> f AnomalyGroupTimeSeriesFeedback)
-> PutFeedback -> f PutFeedback
putFeedback_anomalyGroupTimeSeriesFeedback = (PutFeedback -> AnomalyGroupTimeSeriesFeedback)
-> (PutFeedback -> AnomalyGroupTimeSeriesFeedback -> PutFeedback)
-> Lens
     PutFeedback
     PutFeedback
     AnomalyGroupTimeSeriesFeedback
     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 :: PutFeedback -> Request PutFeedback
request = Service -> PutFeedback -> Request PutFeedback
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy PutFeedback
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutFeedback)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse PutFeedback))
-> Logger
-> Service
-> Proxy PutFeedback
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutFeedback)))
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 -> PutFeedbackResponse
PutFeedbackResponse'
            (Int -> PutFeedbackResponse)
-> Either String Int -> Either String PutFeedbackResponse
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 PutFeedback

instance Prelude.NFData PutFeedback

instance Core.ToHeaders PutFeedback where
  toHeaders :: PutFeedback -> ResponseHeaders
toHeaders =
    ResponseHeaders -> PutFeedback -> 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 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
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),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"AnomalyGroupTimeSeriesFeedback"
                  Text -> AnomalyGroupTimeSeriesFeedback -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= AnomalyGroupTimeSeriesFeedback
anomalyGroupTimeSeriesFeedback
              )
          ]
      )

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

instance Core.ToQuery PutFeedback where
  toQuery :: PutFeedback -> QueryString
toQuery = QueryString -> PutFeedback -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(PutFeedbackResponse -> PutFeedbackResponse -> Bool)
-> (PutFeedbackResponse -> PutFeedbackResponse -> Bool)
-> Eq PutFeedbackResponse
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]
(Int -> ReadS PutFeedbackResponse)
-> ReadS [PutFeedbackResponse]
-> ReadPrec PutFeedbackResponse
-> ReadPrec [PutFeedbackResponse]
-> Read 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
(Int -> PutFeedbackResponse -> ShowS)
-> (PutFeedbackResponse -> String)
-> ([PutFeedbackResponse] -> ShowS)
-> Show PutFeedbackResponse
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. PutFeedbackResponse -> Rep PutFeedbackResponse x)
-> (forall x. Rep PutFeedbackResponse x -> PutFeedbackResponse)
-> Generic PutFeedbackResponse
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' :: Int -> PutFeedbackResponse
PutFeedbackResponse' {$sel:httpStatus:PutFeedbackResponse' :: Int
httpStatus = Int
pHttpStatus_}

-- | The response's http status code.
putFeedbackResponse_httpStatus :: Lens.Lens' PutFeedbackResponse Prelude.Int
putFeedbackResponse_httpStatus :: (Int -> f Int) -> PutFeedbackResponse -> f PutFeedbackResponse
putFeedbackResponse_httpStatus = (PutFeedbackResponse -> Int)
-> (PutFeedbackResponse -> Int -> PutFeedbackResponse)
-> Lens PutFeedbackResponse PutFeedbackResponse Int Int
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