{-# 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.CostExplorer.ProvideAnomalyFeedback
-- 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)
--
-- Modifies the feedback property of a given cost anomaly.
module Amazonka.CostExplorer.ProvideAnomalyFeedback
  ( -- * Creating a Request
    ProvideAnomalyFeedback (..),
    newProvideAnomalyFeedback,

    -- * Request Lenses
    provideAnomalyFeedback_anomalyId,
    provideAnomalyFeedback_feedback,

    -- * Destructuring the Response
    ProvideAnomalyFeedbackResponse (..),
    newProvideAnomalyFeedbackResponse,

    -- * Response Lenses
    provideAnomalyFeedbackResponse_httpStatus,
    provideAnomalyFeedbackResponse_anomalyId,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.CostExplorer.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:/ 'newProvideAnomalyFeedback' smart constructor.
data ProvideAnomalyFeedback = ProvideAnomalyFeedback'
  { -- | A cost anomaly ID.
    ProvideAnomalyFeedback -> Text
anomalyId :: Prelude.Text,
    -- | Describes whether the cost anomaly was a planned activity or you
    -- considered it an anomaly.
    ProvideAnomalyFeedback -> AnomalyFeedbackType
feedback :: AnomalyFeedbackType
  }
  deriving (ProvideAnomalyFeedback -> ProvideAnomalyFeedback -> Bool
(ProvideAnomalyFeedback -> ProvideAnomalyFeedback -> Bool)
-> (ProvideAnomalyFeedback -> ProvideAnomalyFeedback -> Bool)
-> Eq ProvideAnomalyFeedback
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProvideAnomalyFeedback -> ProvideAnomalyFeedback -> Bool
$c/= :: ProvideAnomalyFeedback -> ProvideAnomalyFeedback -> Bool
== :: ProvideAnomalyFeedback -> ProvideAnomalyFeedback -> Bool
$c== :: ProvideAnomalyFeedback -> ProvideAnomalyFeedback -> Bool
Prelude.Eq, ReadPrec [ProvideAnomalyFeedback]
ReadPrec ProvideAnomalyFeedback
Int -> ReadS ProvideAnomalyFeedback
ReadS [ProvideAnomalyFeedback]
(Int -> ReadS ProvideAnomalyFeedback)
-> ReadS [ProvideAnomalyFeedback]
-> ReadPrec ProvideAnomalyFeedback
-> ReadPrec [ProvideAnomalyFeedback]
-> Read ProvideAnomalyFeedback
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ProvideAnomalyFeedback]
$creadListPrec :: ReadPrec [ProvideAnomalyFeedback]
readPrec :: ReadPrec ProvideAnomalyFeedback
$creadPrec :: ReadPrec ProvideAnomalyFeedback
readList :: ReadS [ProvideAnomalyFeedback]
$creadList :: ReadS [ProvideAnomalyFeedback]
readsPrec :: Int -> ReadS ProvideAnomalyFeedback
$creadsPrec :: Int -> ReadS ProvideAnomalyFeedback
Prelude.Read, Int -> ProvideAnomalyFeedback -> ShowS
[ProvideAnomalyFeedback] -> ShowS
ProvideAnomalyFeedback -> String
(Int -> ProvideAnomalyFeedback -> ShowS)
-> (ProvideAnomalyFeedback -> String)
-> ([ProvideAnomalyFeedback] -> ShowS)
-> Show ProvideAnomalyFeedback
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ProvideAnomalyFeedback] -> ShowS
$cshowList :: [ProvideAnomalyFeedback] -> ShowS
show :: ProvideAnomalyFeedback -> String
$cshow :: ProvideAnomalyFeedback -> String
showsPrec :: Int -> ProvideAnomalyFeedback -> ShowS
$cshowsPrec :: Int -> ProvideAnomalyFeedback -> ShowS
Prelude.Show, (forall x. ProvideAnomalyFeedback -> Rep ProvideAnomalyFeedback x)
-> (forall x.
    Rep ProvideAnomalyFeedback x -> ProvideAnomalyFeedback)
-> Generic ProvideAnomalyFeedback
forall x. Rep ProvideAnomalyFeedback x -> ProvideAnomalyFeedback
forall x. ProvideAnomalyFeedback -> Rep ProvideAnomalyFeedback x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ProvideAnomalyFeedback x -> ProvideAnomalyFeedback
$cfrom :: forall x. ProvideAnomalyFeedback -> Rep ProvideAnomalyFeedback x
Prelude.Generic)

-- |
-- Create a value of 'ProvideAnomalyFeedback' 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:
--
-- 'anomalyId', 'provideAnomalyFeedback_anomalyId' - A cost anomaly ID.
--
-- 'feedback', 'provideAnomalyFeedback_feedback' - Describes whether the cost anomaly was a planned activity or you
-- considered it an anomaly.
newProvideAnomalyFeedback ::
  -- | 'anomalyId'
  Prelude.Text ->
  -- | 'feedback'
  AnomalyFeedbackType ->
  ProvideAnomalyFeedback
newProvideAnomalyFeedback :: Text -> AnomalyFeedbackType -> ProvideAnomalyFeedback
newProvideAnomalyFeedback Text
pAnomalyId_ AnomalyFeedbackType
pFeedback_ =
  ProvideAnomalyFeedback' :: Text -> AnomalyFeedbackType -> ProvideAnomalyFeedback
ProvideAnomalyFeedback'
    { $sel:anomalyId:ProvideAnomalyFeedback' :: Text
anomalyId = Text
pAnomalyId_,
      $sel:feedback:ProvideAnomalyFeedback' :: AnomalyFeedbackType
feedback = AnomalyFeedbackType
pFeedback_
    }

-- | A cost anomaly ID.
provideAnomalyFeedback_anomalyId :: Lens.Lens' ProvideAnomalyFeedback Prelude.Text
provideAnomalyFeedback_anomalyId :: (Text -> f Text)
-> ProvideAnomalyFeedback -> f ProvideAnomalyFeedback
provideAnomalyFeedback_anomalyId = (ProvideAnomalyFeedback -> Text)
-> (ProvideAnomalyFeedback -> Text -> ProvideAnomalyFeedback)
-> Lens ProvideAnomalyFeedback ProvideAnomalyFeedback Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProvideAnomalyFeedback' {Text
anomalyId :: Text
$sel:anomalyId:ProvideAnomalyFeedback' :: ProvideAnomalyFeedback -> Text
anomalyId} -> Text
anomalyId) (\s :: ProvideAnomalyFeedback
s@ProvideAnomalyFeedback' {} Text
a -> ProvideAnomalyFeedback
s {$sel:anomalyId:ProvideAnomalyFeedback' :: Text
anomalyId = Text
a} :: ProvideAnomalyFeedback)

-- | Describes whether the cost anomaly was a planned activity or you
-- considered it an anomaly.
provideAnomalyFeedback_feedback :: Lens.Lens' ProvideAnomalyFeedback AnomalyFeedbackType
provideAnomalyFeedback_feedback :: (AnomalyFeedbackType -> f AnomalyFeedbackType)
-> ProvideAnomalyFeedback -> f ProvideAnomalyFeedback
provideAnomalyFeedback_feedback = (ProvideAnomalyFeedback -> AnomalyFeedbackType)
-> (ProvideAnomalyFeedback
    -> AnomalyFeedbackType -> ProvideAnomalyFeedback)
-> Lens
     ProvideAnomalyFeedback
     ProvideAnomalyFeedback
     AnomalyFeedbackType
     AnomalyFeedbackType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProvideAnomalyFeedback' {AnomalyFeedbackType
feedback :: AnomalyFeedbackType
$sel:feedback:ProvideAnomalyFeedback' :: ProvideAnomalyFeedback -> AnomalyFeedbackType
feedback} -> AnomalyFeedbackType
feedback) (\s :: ProvideAnomalyFeedback
s@ProvideAnomalyFeedback' {} AnomalyFeedbackType
a -> ProvideAnomalyFeedback
s {$sel:feedback:ProvideAnomalyFeedback' :: AnomalyFeedbackType
feedback = AnomalyFeedbackType
a} :: ProvideAnomalyFeedback)

instance Core.AWSRequest ProvideAnomalyFeedback where
  type
    AWSResponse ProvideAnomalyFeedback =
      ProvideAnomalyFeedbackResponse
  request :: ProvideAnomalyFeedback -> Request ProvideAnomalyFeedback
request = Service -> ProvideAnomalyFeedback -> Request ProvideAnomalyFeedback
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ProvideAnomalyFeedback
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ProvideAnomalyFeedback)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ProvideAnomalyFeedback))
-> Logger
-> Service
-> Proxy ProvideAnomalyFeedback
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ProvideAnomalyFeedback)))
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 ->
          Int -> Text -> ProvideAnomalyFeedbackResponse
ProvideAnomalyFeedbackResponse'
            (Int -> Text -> ProvideAnomalyFeedbackResponse)
-> Either String Int
-> Either String (Text -> ProvideAnomalyFeedbackResponse)
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))
            Either String (Text -> ProvideAnomalyFeedbackResponse)
-> Either String Text
-> Either String ProvideAnomalyFeedbackResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Text
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"AnomalyId")
      )

instance Prelude.Hashable ProvideAnomalyFeedback

instance Prelude.NFData ProvideAnomalyFeedback

instance Core.ToHeaders ProvideAnomalyFeedback where
  toHeaders :: ProvideAnomalyFeedback -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ProvideAnomalyFeedback -> 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
"AWSInsightsIndexService.ProvideAnomalyFeedback" ::
                          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 ProvideAnomalyFeedback where
  toJSON :: ProvideAnomalyFeedback -> Value
toJSON ProvideAnomalyFeedback' {Text
AnomalyFeedbackType
feedback :: AnomalyFeedbackType
anomalyId :: Text
$sel:feedback:ProvideAnomalyFeedback' :: ProvideAnomalyFeedback -> AnomalyFeedbackType
$sel:anomalyId:ProvideAnomalyFeedback' :: ProvideAnomalyFeedback -> 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
"AnomalyId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
anomalyId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Feedback" Text -> AnomalyFeedbackType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= AnomalyFeedbackType
feedback)
          ]
      )

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

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

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

-- |
-- Create a value of 'ProvideAnomalyFeedbackResponse' 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', 'provideAnomalyFeedbackResponse_httpStatus' - The response's http status code.
--
-- 'anomalyId', 'provideAnomalyFeedbackResponse_anomalyId' - The ID of the modified cost anomaly.
newProvideAnomalyFeedbackResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'anomalyId'
  Prelude.Text ->
  ProvideAnomalyFeedbackResponse
newProvideAnomalyFeedbackResponse :: Int -> Text -> ProvideAnomalyFeedbackResponse
newProvideAnomalyFeedbackResponse
  Int
pHttpStatus_
  Text
pAnomalyId_ =
    ProvideAnomalyFeedbackResponse' :: Int -> Text -> ProvideAnomalyFeedbackResponse
ProvideAnomalyFeedbackResponse'
      { $sel:httpStatus:ProvideAnomalyFeedbackResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:anomalyId:ProvideAnomalyFeedbackResponse' :: Text
anomalyId = Text
pAnomalyId_
      }

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

-- | The ID of the modified cost anomaly.
provideAnomalyFeedbackResponse_anomalyId :: Lens.Lens' ProvideAnomalyFeedbackResponse Prelude.Text
provideAnomalyFeedbackResponse_anomalyId :: (Text -> f Text)
-> ProvideAnomalyFeedbackResponse
-> f ProvideAnomalyFeedbackResponse
provideAnomalyFeedbackResponse_anomalyId = (ProvideAnomalyFeedbackResponse -> Text)
-> (ProvideAnomalyFeedbackResponse
    -> Text -> ProvideAnomalyFeedbackResponse)
-> Lens
     ProvideAnomalyFeedbackResponse
     ProvideAnomalyFeedbackResponse
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProvideAnomalyFeedbackResponse' {Text
anomalyId :: Text
$sel:anomalyId:ProvideAnomalyFeedbackResponse' :: ProvideAnomalyFeedbackResponse -> Text
anomalyId} -> Text
anomalyId) (\s :: ProvideAnomalyFeedbackResponse
s@ProvideAnomalyFeedbackResponse' {} Text
a -> ProvideAnomalyFeedbackResponse
s {$sel:anomalyId:ProvideAnomalyFeedbackResponse' :: Text
anomalyId = Text
a} :: ProvideAnomalyFeedbackResponse)

instance
  Prelude.NFData
    ProvideAnomalyFeedbackResponse