{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
      { $sel:comment:SubmitFeedback' :: Maybe Text
comment = 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 :: Lens' SubmitFeedback (Maybe Text)
submitFeedback_comment = 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 :: Lens' SubmitFeedback Text
submitFeedback_anomalyInstanceId = 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 :: Lens' SubmitFeedback Text
submitFeedback_profilingGroupName = 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 :: Lens' SubmitFeedback FeedbackType
submitFeedback_type = 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 :: (Service -> Service) -> SubmitFeedback -> Request SubmitFeedback
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 SubmitFeedback
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse SubmitFeedback)))
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 -> SubmitFeedbackResponse
SubmitFeedbackResponse'
            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 SubmitFeedback where
  hashWithSalt :: Int -> SubmitFeedback -> Int
hashWithSalt Int
_salt 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
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
comment
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
anomalyInstanceId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
profilingGroupName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` FeedbackType
type'

instance Prelude.NFData SubmitFeedback where
  rnf :: SubmitFeedback -> ()
rnf 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
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
comment
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
anomalyInstanceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
profilingGroupName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf FeedbackType
type'

instance Data.ToHeaders SubmitFeedback where
  toHeaders :: SubmitFeedback -> 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 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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"comment" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
comment,
            forall a. a -> Maybe a
Prelude.Just (Key
"type" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= FeedbackType
type')
          ]
      )

instance Data.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
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/internal/profilingGroups/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
profilingGroupName,
        ByteString
"/anomalies/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
anomalyInstanceId,
        ByteString
"/feedback"
      ]

instance Data.ToQuery SubmitFeedback where
  toQuery :: SubmitFeedback -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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. 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' {$sel:httpStatus:SubmitFeedbackResponse' :: Int
httpStatus = Int
pHttpStatus_}

-- | The response's http status code.
submitFeedbackResponse_httpStatus :: Lens.Lens' SubmitFeedbackResponse Prelude.Int
submitFeedbackResponse_httpStatus :: Lens' SubmitFeedbackResponse Int
submitFeedbackResponse_httpStatus = 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 where
  rnf :: SubmitFeedbackResponse -> ()
rnf SubmitFeedbackResponse' {Int
httpStatus :: Int
$sel:httpStatus:SubmitFeedbackResponse' :: SubmitFeedbackResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus