{-# 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.CodeGuruProfiler.SubmitFeedback
-- 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)
--
-- Sends feedback to CodeGuru Profiler about whether the anomaly detected
-- by the analysis is useful or not.
module Amazonka.CodeGuruProfiler.SubmitFeedback
  ( -- * Creating a Request
    SubmitFeedback (..),
    newSubmitFeedback,

    -- * Request Lenses
    submitFeedback_comment,
    submitFeedback_anomalyInstanceId,
    submitFeedback_profilingGroupName,
    submitFeedback_type,

    -- * Destructuring the Response
    SubmitFeedbackResponse (..),
    newSubmitFeedbackResponse,

    -- * Response Lenses
    submitFeedbackResponse_httpStatus,
  )
where

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

-- | The structure representing the SubmitFeedbackRequest.
--
-- /See:/ 'newSubmitFeedback' smart constructor.
data SubmitFeedback = SubmitFeedback'
  { -- | Optional feedback about this anomaly.
    SubmitFeedback -> Maybe Text
comment :: Prelude.Maybe Prelude.Text,
    -- | The universally unique identifier (UUID) of the
    -- <https://docs.aws.amazon.com/codeguru/latest/profiler-api/API_AnomalyInstance.html AnomalyInstance>
    -- object that is included in the analysis data.
    SubmitFeedback -> Text
anomalyInstanceId :: Prelude.Text,
    -- | The name of the profiling group that is associated with the analysis
    -- data.
    SubmitFeedback -> Text
profilingGroupName :: Prelude.Text,
    -- | The feedback tpye. Thee are two valid values, @Positive@ and @Negative@.
    SubmitFeedback -> FeedbackType
type' :: FeedbackType
  }
  deriving (SubmitFeedback -> SubmitFeedback -> Bool
(SubmitFeedback -> SubmitFeedback -> Bool)
-> (SubmitFeedback -> SubmitFeedback -> Bool) -> Eq SubmitFeedback
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SubmitFeedback -> SubmitFeedback -> Bool
$c/= :: SubmitFeedback -> SubmitFeedback -> Bool
== :: SubmitFeedback -> SubmitFeedback -> Bool
$c== :: SubmitFeedback -> SubmitFeedback -> Bool
Prelude.Eq, ReadPrec [SubmitFeedback]
ReadPrec SubmitFeedback
Int -> ReadS SubmitFeedback
ReadS [SubmitFeedback]
(Int -> ReadS SubmitFeedback)
-> ReadS [SubmitFeedback]
-> ReadPrec SubmitFeedback
-> ReadPrec [SubmitFeedback]
-> Read SubmitFeedback
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SubmitFeedback]
$creadListPrec :: ReadPrec [SubmitFeedback]
readPrec :: ReadPrec SubmitFeedback
$creadPrec :: ReadPrec SubmitFeedback
readList :: ReadS [SubmitFeedback]
$creadList :: ReadS [SubmitFeedback]
readsPrec :: Int -> ReadS SubmitFeedback
$creadsPrec :: Int -> ReadS SubmitFeedback
Prelude.Read, Int -> SubmitFeedback -> ShowS
[SubmitFeedback] -> ShowS
SubmitFeedback -> String
(Int -> SubmitFeedback -> ShowS)
-> (SubmitFeedback -> String)
-> ([SubmitFeedback] -> ShowS)
-> Show SubmitFeedback
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SubmitFeedback] -> ShowS
$cshowList :: [SubmitFeedback] -> ShowS
show :: SubmitFeedback -> String
$cshow :: SubmitFeedback -> String
showsPrec :: Int -> SubmitFeedback -> ShowS
$cshowsPrec :: Int -> SubmitFeedback -> ShowS
Prelude.Show, (forall x. SubmitFeedback -> Rep SubmitFeedback x)
-> (forall x. Rep SubmitFeedback x -> SubmitFeedback)
-> Generic SubmitFeedback
forall x. Rep SubmitFeedback x -> SubmitFeedback
forall x. SubmitFeedback -> Rep SubmitFeedback x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SubmitFeedback x -> SubmitFeedback
$cfrom :: forall x. SubmitFeedback -> Rep SubmitFeedback x
Prelude.Generic)

-- |
-- Create a value of 'SubmitFeedback' 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:
--
-- 'comment', 'submitFeedback_comment' - Optional feedback about this anomaly.
--
-- 'anomalyInstanceId', 'submitFeedback_anomalyInstanceId' - The universally unique identifier (UUID) of the
-- <https://docs.aws.amazon.com/codeguru/latest/profiler-api/API_AnomalyInstance.html AnomalyInstance>
-- object that is included in the analysis data.
--
-- 'profilingGroupName', 'submitFeedback_profilingGroupName' - The name of the profiling group that is associated with the analysis
-- data.
--
-- 'type'', 'submitFeedback_type' - The feedback tpye. Thee are two valid values, @Positive@ and @Negative@.
newSubmitFeedback ::
  -- | 'anomalyInstanceId'
  Prelude.Text ->
  -- | 'profilingGroupName'
  Prelude.Text ->
  -- | 'type''
  FeedbackType ->
  SubmitFeedback
newSubmitFeedback :: Text -> Text -> FeedbackType -> SubmitFeedback
newSubmitFeedback
  Text
pAnomalyInstanceId_
  Text
pProfilingGroupName_
  FeedbackType
pType_ =
    SubmitFeedback' :: Maybe Text -> Text -> Text -> FeedbackType -> SubmitFeedback
SubmitFeedback'
      { $sel:comment:SubmitFeedback' :: Maybe Text
comment = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:anomalyInstanceId:SubmitFeedback' :: Text
anomalyInstanceId = Text
pAnomalyInstanceId_,
        $sel:profilingGroupName:SubmitFeedback' :: Text
profilingGroupName = Text
pProfilingGroupName_,
        $sel:type':SubmitFeedback' :: FeedbackType
type' = FeedbackType
pType_
      }

-- | Optional feedback about this anomaly.
submitFeedback_comment :: Lens.Lens' SubmitFeedback (Prelude.Maybe Prelude.Text)
submitFeedback_comment :: (Maybe Text -> f (Maybe Text))
-> SubmitFeedback -> f SubmitFeedback
submitFeedback_comment = (SubmitFeedback -> Maybe Text)
-> (SubmitFeedback -> Maybe Text -> SubmitFeedback)
-> Lens SubmitFeedback SubmitFeedback (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SubmitFeedback' {Maybe Text
comment :: Maybe Text
$sel:comment:SubmitFeedback' :: SubmitFeedback -> Maybe Text
comment} -> Maybe Text
comment) (\s :: SubmitFeedback
s@SubmitFeedback' {} Maybe Text
a -> SubmitFeedback
s {$sel:comment:SubmitFeedback' :: Maybe Text
comment = Maybe Text
a} :: SubmitFeedback)

-- | The universally unique identifier (UUID) of the
-- <https://docs.aws.amazon.com/codeguru/latest/profiler-api/API_AnomalyInstance.html AnomalyInstance>
-- object that is included in the analysis data.
submitFeedback_anomalyInstanceId :: Lens.Lens' SubmitFeedback Prelude.Text
submitFeedback_anomalyInstanceId :: (Text -> f Text) -> SubmitFeedback -> f SubmitFeedback
submitFeedback_anomalyInstanceId = (SubmitFeedback -> Text)
-> (SubmitFeedback -> Text -> SubmitFeedback)
-> Lens SubmitFeedback SubmitFeedback Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SubmitFeedback' {Text
anomalyInstanceId :: Text
$sel:anomalyInstanceId:SubmitFeedback' :: SubmitFeedback -> Text
anomalyInstanceId} -> Text
anomalyInstanceId) (\s :: SubmitFeedback
s@SubmitFeedback' {} Text
a -> SubmitFeedback
s {$sel:anomalyInstanceId:SubmitFeedback' :: Text
anomalyInstanceId = Text
a} :: SubmitFeedback)

-- | The name of the profiling group that is associated with the analysis
-- data.
submitFeedback_profilingGroupName :: Lens.Lens' SubmitFeedback Prelude.Text
submitFeedback_profilingGroupName :: (Text -> f Text) -> SubmitFeedback -> f SubmitFeedback
submitFeedback_profilingGroupName = (SubmitFeedback -> Text)
-> (SubmitFeedback -> Text -> SubmitFeedback)
-> Lens SubmitFeedback SubmitFeedback Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SubmitFeedback' {Text
profilingGroupName :: Text
$sel:profilingGroupName:SubmitFeedback' :: SubmitFeedback -> Text
profilingGroupName} -> Text
profilingGroupName) (\s :: SubmitFeedback
s@SubmitFeedback' {} Text
a -> SubmitFeedback
s {$sel:profilingGroupName:SubmitFeedback' :: Text
profilingGroupName = Text
a} :: SubmitFeedback)

-- | The feedback tpye. Thee are two valid values, @Positive@ and @Negative@.
submitFeedback_type :: Lens.Lens' SubmitFeedback FeedbackType
submitFeedback_type :: (FeedbackType -> f FeedbackType)
-> SubmitFeedback -> f SubmitFeedback
submitFeedback_type = (SubmitFeedback -> FeedbackType)
-> (SubmitFeedback -> FeedbackType -> SubmitFeedback)
-> Lens SubmitFeedback SubmitFeedback FeedbackType FeedbackType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SubmitFeedback' {FeedbackType
type' :: FeedbackType
$sel:type':SubmitFeedback' :: SubmitFeedback -> FeedbackType
type'} -> FeedbackType
type') (\s :: SubmitFeedback
s@SubmitFeedback' {} FeedbackType
a -> SubmitFeedback
s {$sel:type':SubmitFeedback' :: FeedbackType
type' = FeedbackType
a} :: SubmitFeedback)

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

instance Prelude.NFData SubmitFeedback

instance Core.ToHeaders SubmitFeedback where
  toHeaders :: SubmitFeedback -> ResponseHeaders
toHeaders =
    ResponseHeaders -> SubmitFeedback -> 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 SubmitFeedback where
  toJSON :: SubmitFeedback -> Value
toJSON SubmitFeedback' {Maybe Text
Text
FeedbackType
type' :: FeedbackType
profilingGroupName :: Text
anomalyInstanceId :: Text
comment :: Maybe Text
$sel:type':SubmitFeedback' :: SubmitFeedback -> FeedbackType
$sel:profilingGroupName:SubmitFeedback' :: SubmitFeedback -> Text
$sel:anomalyInstanceId:SubmitFeedback' :: SubmitFeedback -> Text
$sel:comment:SubmitFeedback' :: SubmitFeedback -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"comment" 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
comment,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"type" Text -> FeedbackType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= FeedbackType
type')
          ]
      )

instance Core.ToPath SubmitFeedback where
  toPath :: SubmitFeedback -> ByteString
toPath SubmitFeedback' {Maybe Text
Text
FeedbackType
type' :: FeedbackType
profilingGroupName :: Text
anomalyInstanceId :: Text
comment :: Maybe Text
$sel:type':SubmitFeedback' :: SubmitFeedback -> FeedbackType
$sel:profilingGroupName:SubmitFeedback' :: SubmitFeedback -> Text
$sel:anomalyInstanceId:SubmitFeedback' :: SubmitFeedback -> Text
$sel:comment:SubmitFeedback' :: SubmitFeedback -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/internal/profilingGroups/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
profilingGroupName,
        ByteString
"/anomalies/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
anomalyInstanceId,
        ByteString
"/feedback"
      ]

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

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

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

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

instance Prelude.NFData SubmitFeedbackResponse