{-# 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.DevOpsGuru.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)
--
-- Collects customer feedback about the specified insight.
module Amazonka.DevOpsGuru.PutFeedback
  ( -- * Creating a Request
    PutFeedback (..),
    newPutFeedback,

    -- * Request Lenses
    putFeedback_insightFeedback,

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

    -- * Response Lenses
    putFeedbackResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.DevOpsGuru.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:/ 'newPutFeedback' smart constructor.
data PutFeedback = PutFeedback'
  { -- | The feedback from customers is about the recommendations in this
    -- insight.
    PutFeedback -> Maybe InsightFeedback
insightFeedback :: Prelude.Maybe InsightFeedback
  }
  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:
--
-- 'insightFeedback', 'putFeedback_insightFeedback' - The feedback from customers is about the recommendations in this
-- insight.
newPutFeedback ::
  PutFeedback
newPutFeedback :: PutFeedback
newPutFeedback =
  PutFeedback' :: Maybe InsightFeedback -> PutFeedback
PutFeedback' {$sel:insightFeedback:PutFeedback' :: Maybe InsightFeedback
insightFeedback = Maybe InsightFeedback
forall a. Maybe a
Prelude.Nothing}

-- | The feedback from customers is about the recommendations in this
-- insight.
putFeedback_insightFeedback :: Lens.Lens' PutFeedback (Prelude.Maybe InsightFeedback)
putFeedback_insightFeedback :: (Maybe InsightFeedback -> f (Maybe InsightFeedback))
-> PutFeedback -> f PutFeedback
putFeedback_insightFeedback = (PutFeedback -> Maybe InsightFeedback)
-> (PutFeedback -> Maybe InsightFeedback -> PutFeedback)
-> Lens
     PutFeedback
     PutFeedback
     (Maybe InsightFeedback)
     (Maybe InsightFeedback)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutFeedback' {Maybe InsightFeedback
insightFeedback :: Maybe InsightFeedback
$sel:insightFeedback:PutFeedback' :: PutFeedback -> Maybe InsightFeedback
insightFeedback} -> Maybe InsightFeedback
insightFeedback) (\s :: PutFeedback
s@PutFeedback' {} Maybe InsightFeedback
a -> PutFeedback
s {$sel:insightFeedback:PutFeedback' :: Maybe InsightFeedback
insightFeedback = Maybe InsightFeedback
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.putJSON 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' {Maybe InsightFeedback
insightFeedback :: Maybe InsightFeedback
$sel:insightFeedback:PutFeedback' :: PutFeedback -> Maybe InsightFeedback
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"InsightFeedback" Text -> InsightFeedback -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (InsightFeedback -> Pair) -> Maybe InsightFeedback -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe InsightFeedback
insightFeedback
          ]
      )

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

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