{-# 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.CodeGuruReviewer.DescribeCodeReview
-- 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)
--
-- Returns the metadata associated with the code review along with its
-- status.
module Amazonka.CodeGuruReviewer.DescribeCodeReview
  ( -- * Creating a Request
    DescribeCodeReview (..),
    newDescribeCodeReview,

    -- * Request Lenses
    describeCodeReview_codeReviewArn,

    -- * Destructuring the Response
    DescribeCodeReviewResponse (..),
    newDescribeCodeReviewResponse,

    -- * Response Lenses
    describeCodeReviewResponse_codeReview,
    describeCodeReviewResponse_httpStatus,
  )
where

import Amazonka.CodeGuruReviewer.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

-- | /See:/ 'newDescribeCodeReview' smart constructor.
data DescribeCodeReview = DescribeCodeReview'
  { -- | The Amazon Resource Name (ARN) of the
    -- <https://docs.aws.amazon.com/codeguru/latest/reviewer-api/API_CodeReview.html CodeReview>
    -- object.
    DescribeCodeReview -> Text
codeReviewArn :: Prelude.Text
  }
  deriving (DescribeCodeReview -> DescribeCodeReview -> Bool
(DescribeCodeReview -> DescribeCodeReview -> Bool)
-> (DescribeCodeReview -> DescribeCodeReview -> Bool)
-> Eq DescribeCodeReview
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeCodeReview -> DescribeCodeReview -> Bool
$c/= :: DescribeCodeReview -> DescribeCodeReview -> Bool
== :: DescribeCodeReview -> DescribeCodeReview -> Bool
$c== :: DescribeCodeReview -> DescribeCodeReview -> Bool
Prelude.Eq, ReadPrec [DescribeCodeReview]
ReadPrec DescribeCodeReview
Int -> ReadS DescribeCodeReview
ReadS [DescribeCodeReview]
(Int -> ReadS DescribeCodeReview)
-> ReadS [DescribeCodeReview]
-> ReadPrec DescribeCodeReview
-> ReadPrec [DescribeCodeReview]
-> Read DescribeCodeReview
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeCodeReview]
$creadListPrec :: ReadPrec [DescribeCodeReview]
readPrec :: ReadPrec DescribeCodeReview
$creadPrec :: ReadPrec DescribeCodeReview
readList :: ReadS [DescribeCodeReview]
$creadList :: ReadS [DescribeCodeReview]
readsPrec :: Int -> ReadS DescribeCodeReview
$creadsPrec :: Int -> ReadS DescribeCodeReview
Prelude.Read, Int -> DescribeCodeReview -> ShowS
[DescribeCodeReview] -> ShowS
DescribeCodeReview -> String
(Int -> DescribeCodeReview -> ShowS)
-> (DescribeCodeReview -> String)
-> ([DescribeCodeReview] -> ShowS)
-> Show DescribeCodeReview
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeCodeReview] -> ShowS
$cshowList :: [DescribeCodeReview] -> ShowS
show :: DescribeCodeReview -> String
$cshow :: DescribeCodeReview -> String
showsPrec :: Int -> DescribeCodeReview -> ShowS
$cshowsPrec :: Int -> DescribeCodeReview -> ShowS
Prelude.Show, (forall x. DescribeCodeReview -> Rep DescribeCodeReview x)
-> (forall x. Rep DescribeCodeReview x -> DescribeCodeReview)
-> Generic DescribeCodeReview
forall x. Rep DescribeCodeReview x -> DescribeCodeReview
forall x. DescribeCodeReview -> Rep DescribeCodeReview x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeCodeReview x -> DescribeCodeReview
$cfrom :: forall x. DescribeCodeReview -> Rep DescribeCodeReview x
Prelude.Generic)

-- |
-- Create a value of 'DescribeCodeReview' 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:
--
-- 'codeReviewArn', 'describeCodeReview_codeReviewArn' - The Amazon Resource Name (ARN) of the
-- <https://docs.aws.amazon.com/codeguru/latest/reviewer-api/API_CodeReview.html CodeReview>
-- object.
newDescribeCodeReview ::
  -- | 'codeReviewArn'
  Prelude.Text ->
  DescribeCodeReview
newDescribeCodeReview :: Text -> DescribeCodeReview
newDescribeCodeReview Text
pCodeReviewArn_ =
  DescribeCodeReview' :: Text -> DescribeCodeReview
DescribeCodeReview'
    { $sel:codeReviewArn:DescribeCodeReview' :: Text
codeReviewArn =
        Text
pCodeReviewArn_
    }

-- | The Amazon Resource Name (ARN) of the
-- <https://docs.aws.amazon.com/codeguru/latest/reviewer-api/API_CodeReview.html CodeReview>
-- object.
describeCodeReview_codeReviewArn :: Lens.Lens' DescribeCodeReview Prelude.Text
describeCodeReview_codeReviewArn :: (Text -> f Text) -> DescribeCodeReview -> f DescribeCodeReview
describeCodeReview_codeReviewArn = (DescribeCodeReview -> Text)
-> (DescribeCodeReview -> Text -> DescribeCodeReview)
-> Lens DescribeCodeReview DescribeCodeReview Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeCodeReview' {Text
codeReviewArn :: Text
$sel:codeReviewArn:DescribeCodeReview' :: DescribeCodeReview -> Text
codeReviewArn} -> Text
codeReviewArn) (\s :: DescribeCodeReview
s@DescribeCodeReview' {} Text
a -> DescribeCodeReview
s {$sel:codeReviewArn:DescribeCodeReview' :: Text
codeReviewArn = Text
a} :: DescribeCodeReview)

instance Core.AWSRequest DescribeCodeReview where
  type
    AWSResponse DescribeCodeReview =
      DescribeCodeReviewResponse
  request :: DescribeCodeReview -> Request DescribeCodeReview
request = Service -> DescribeCodeReview -> Request DescribeCodeReview
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeCodeReview
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeCodeReview)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeCodeReview))
-> Logger
-> Service
-> Proxy DescribeCodeReview
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeCodeReview)))
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 ->
          Maybe CodeReview -> Int -> DescribeCodeReviewResponse
DescribeCodeReviewResponse'
            (Maybe CodeReview -> Int -> DescribeCodeReviewResponse)
-> Either String (Maybe CodeReview)
-> Either String (Int -> DescribeCodeReviewResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe CodeReview)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"CodeReview")
            Either String (Int -> DescribeCodeReviewResponse)
-> Either String Int -> Either String DescribeCodeReviewResponse
forall (f :: * -> *) a b. Applicative f => 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 DescribeCodeReview

instance Prelude.NFData DescribeCodeReview

instance Core.ToHeaders DescribeCodeReview where
  toHeaders :: DescribeCodeReview -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeCodeReview -> 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.ToPath DescribeCodeReview where
  toPath :: DescribeCodeReview -> ByteString
toPath DescribeCodeReview' {Text
codeReviewArn :: Text
$sel:codeReviewArn:DescribeCodeReview' :: DescribeCodeReview -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/codereviews/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
codeReviewArn]

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

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

-- |
-- Create a value of 'DescribeCodeReviewResponse' 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:
--
-- 'codeReview', 'describeCodeReviewResponse_codeReview' - Information about the code review.
--
-- 'httpStatus', 'describeCodeReviewResponse_httpStatus' - The response's http status code.
newDescribeCodeReviewResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeCodeReviewResponse
newDescribeCodeReviewResponse :: Int -> DescribeCodeReviewResponse
newDescribeCodeReviewResponse Int
pHttpStatus_ =
  DescribeCodeReviewResponse' :: Maybe CodeReview -> Int -> DescribeCodeReviewResponse
DescribeCodeReviewResponse'
    { $sel:codeReview:DescribeCodeReviewResponse' :: Maybe CodeReview
codeReview =
        Maybe CodeReview
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeCodeReviewResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the code review.
describeCodeReviewResponse_codeReview :: Lens.Lens' DescribeCodeReviewResponse (Prelude.Maybe CodeReview)
describeCodeReviewResponse_codeReview :: (Maybe CodeReview -> f (Maybe CodeReview))
-> DescribeCodeReviewResponse -> f DescribeCodeReviewResponse
describeCodeReviewResponse_codeReview = (DescribeCodeReviewResponse -> Maybe CodeReview)
-> (DescribeCodeReviewResponse
    -> Maybe CodeReview -> DescribeCodeReviewResponse)
-> Lens
     DescribeCodeReviewResponse
     DescribeCodeReviewResponse
     (Maybe CodeReview)
     (Maybe CodeReview)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeCodeReviewResponse' {Maybe CodeReview
codeReview :: Maybe CodeReview
$sel:codeReview:DescribeCodeReviewResponse' :: DescribeCodeReviewResponse -> Maybe CodeReview
codeReview} -> Maybe CodeReview
codeReview) (\s :: DescribeCodeReviewResponse
s@DescribeCodeReviewResponse' {} Maybe CodeReview
a -> DescribeCodeReviewResponse
s {$sel:codeReview:DescribeCodeReviewResponse' :: Maybe CodeReview
codeReview = Maybe CodeReview
a} :: DescribeCodeReviewResponse)

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

instance Prelude.NFData DescribeCodeReviewResponse