{-# 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.Backup.DescribeReportJob
-- 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 details associated with creating a report as specified by
-- its @ReportJobId@.
module Amazonka.Backup.DescribeReportJob
  ( -- * Creating a Request
    DescribeReportJob (..),
    newDescribeReportJob,

    -- * Request Lenses
    describeReportJob_reportJobId,

    -- * Destructuring the Response
    DescribeReportJobResponse (..),
    newDescribeReportJobResponse,

    -- * Response Lenses
    describeReportJobResponse_reportJob,
    describeReportJobResponse_httpStatus,
  )
where

import Amazonka.Backup.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:/ 'newDescribeReportJob' smart constructor.
data DescribeReportJob = DescribeReportJob'
  { -- | The identifier of the report job. A unique, randomly generated, Unicode,
    -- UTF-8 encoded string that is at most 1,024 bytes long. The report job ID
    -- cannot be edited.
    DescribeReportJob -> Text
reportJobId :: Prelude.Text
  }
  deriving (DescribeReportJob -> DescribeReportJob -> Bool
(DescribeReportJob -> DescribeReportJob -> Bool)
-> (DescribeReportJob -> DescribeReportJob -> Bool)
-> Eq DescribeReportJob
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeReportJob -> DescribeReportJob -> Bool
$c/= :: DescribeReportJob -> DescribeReportJob -> Bool
== :: DescribeReportJob -> DescribeReportJob -> Bool
$c== :: DescribeReportJob -> DescribeReportJob -> Bool
Prelude.Eq, ReadPrec [DescribeReportJob]
ReadPrec DescribeReportJob
Int -> ReadS DescribeReportJob
ReadS [DescribeReportJob]
(Int -> ReadS DescribeReportJob)
-> ReadS [DescribeReportJob]
-> ReadPrec DescribeReportJob
-> ReadPrec [DescribeReportJob]
-> Read DescribeReportJob
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeReportJob]
$creadListPrec :: ReadPrec [DescribeReportJob]
readPrec :: ReadPrec DescribeReportJob
$creadPrec :: ReadPrec DescribeReportJob
readList :: ReadS [DescribeReportJob]
$creadList :: ReadS [DescribeReportJob]
readsPrec :: Int -> ReadS DescribeReportJob
$creadsPrec :: Int -> ReadS DescribeReportJob
Prelude.Read, Int -> DescribeReportJob -> ShowS
[DescribeReportJob] -> ShowS
DescribeReportJob -> String
(Int -> DescribeReportJob -> ShowS)
-> (DescribeReportJob -> String)
-> ([DescribeReportJob] -> ShowS)
-> Show DescribeReportJob
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeReportJob] -> ShowS
$cshowList :: [DescribeReportJob] -> ShowS
show :: DescribeReportJob -> String
$cshow :: DescribeReportJob -> String
showsPrec :: Int -> DescribeReportJob -> ShowS
$cshowsPrec :: Int -> DescribeReportJob -> ShowS
Prelude.Show, (forall x. DescribeReportJob -> Rep DescribeReportJob x)
-> (forall x. Rep DescribeReportJob x -> DescribeReportJob)
-> Generic DescribeReportJob
forall x. Rep DescribeReportJob x -> DescribeReportJob
forall x. DescribeReportJob -> Rep DescribeReportJob x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeReportJob x -> DescribeReportJob
$cfrom :: forall x. DescribeReportJob -> Rep DescribeReportJob x
Prelude.Generic)

-- |
-- Create a value of 'DescribeReportJob' 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:
--
-- 'reportJobId', 'describeReportJob_reportJobId' - The identifier of the report job. A unique, randomly generated, Unicode,
-- UTF-8 encoded string that is at most 1,024 bytes long. The report job ID
-- cannot be edited.
newDescribeReportJob ::
  -- | 'reportJobId'
  Prelude.Text ->
  DescribeReportJob
newDescribeReportJob :: Text -> DescribeReportJob
newDescribeReportJob Text
pReportJobId_ =
  DescribeReportJob' :: Text -> DescribeReportJob
DescribeReportJob' {$sel:reportJobId:DescribeReportJob' :: Text
reportJobId = Text
pReportJobId_}

-- | The identifier of the report job. A unique, randomly generated, Unicode,
-- UTF-8 encoded string that is at most 1,024 bytes long. The report job ID
-- cannot be edited.
describeReportJob_reportJobId :: Lens.Lens' DescribeReportJob Prelude.Text
describeReportJob_reportJobId :: (Text -> f Text) -> DescribeReportJob -> f DescribeReportJob
describeReportJob_reportJobId = (DescribeReportJob -> Text)
-> (DescribeReportJob -> Text -> DescribeReportJob)
-> Lens DescribeReportJob DescribeReportJob Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeReportJob' {Text
reportJobId :: Text
$sel:reportJobId:DescribeReportJob' :: DescribeReportJob -> Text
reportJobId} -> Text
reportJobId) (\s :: DescribeReportJob
s@DescribeReportJob' {} Text
a -> DescribeReportJob
s {$sel:reportJobId:DescribeReportJob' :: Text
reportJobId = Text
a} :: DescribeReportJob)

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

instance Prelude.NFData DescribeReportJob

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

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

-- | /See:/ 'newDescribeReportJobResponse' smart constructor.
data DescribeReportJobResponse = DescribeReportJobResponse'
  { -- | A list of information about a report job, including its completion and
    -- creation times, report destination, unique report job ID, Amazon
    -- Resource Name (ARN), report template, status, and status message.
    DescribeReportJobResponse -> Maybe ReportJob
reportJob :: Prelude.Maybe ReportJob,
    -- | The response's http status code.
    DescribeReportJobResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeReportJobResponse -> DescribeReportJobResponse -> Bool
(DescribeReportJobResponse -> DescribeReportJobResponse -> Bool)
-> (DescribeReportJobResponse -> DescribeReportJobResponse -> Bool)
-> Eq DescribeReportJobResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeReportJobResponse -> DescribeReportJobResponse -> Bool
$c/= :: DescribeReportJobResponse -> DescribeReportJobResponse -> Bool
== :: DescribeReportJobResponse -> DescribeReportJobResponse -> Bool
$c== :: DescribeReportJobResponse -> DescribeReportJobResponse -> Bool
Prelude.Eq, ReadPrec [DescribeReportJobResponse]
ReadPrec DescribeReportJobResponse
Int -> ReadS DescribeReportJobResponse
ReadS [DescribeReportJobResponse]
(Int -> ReadS DescribeReportJobResponse)
-> ReadS [DescribeReportJobResponse]
-> ReadPrec DescribeReportJobResponse
-> ReadPrec [DescribeReportJobResponse]
-> Read DescribeReportJobResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeReportJobResponse]
$creadListPrec :: ReadPrec [DescribeReportJobResponse]
readPrec :: ReadPrec DescribeReportJobResponse
$creadPrec :: ReadPrec DescribeReportJobResponse
readList :: ReadS [DescribeReportJobResponse]
$creadList :: ReadS [DescribeReportJobResponse]
readsPrec :: Int -> ReadS DescribeReportJobResponse
$creadsPrec :: Int -> ReadS DescribeReportJobResponse
Prelude.Read, Int -> DescribeReportJobResponse -> ShowS
[DescribeReportJobResponse] -> ShowS
DescribeReportJobResponse -> String
(Int -> DescribeReportJobResponse -> ShowS)
-> (DescribeReportJobResponse -> String)
-> ([DescribeReportJobResponse] -> ShowS)
-> Show DescribeReportJobResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeReportJobResponse] -> ShowS
$cshowList :: [DescribeReportJobResponse] -> ShowS
show :: DescribeReportJobResponse -> String
$cshow :: DescribeReportJobResponse -> String
showsPrec :: Int -> DescribeReportJobResponse -> ShowS
$cshowsPrec :: Int -> DescribeReportJobResponse -> ShowS
Prelude.Show, (forall x.
 DescribeReportJobResponse -> Rep DescribeReportJobResponse x)
-> (forall x.
    Rep DescribeReportJobResponse x -> DescribeReportJobResponse)
-> Generic DescribeReportJobResponse
forall x.
Rep DescribeReportJobResponse x -> DescribeReportJobResponse
forall x.
DescribeReportJobResponse -> Rep DescribeReportJobResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeReportJobResponse x -> DescribeReportJobResponse
$cfrom :: forall x.
DescribeReportJobResponse -> Rep DescribeReportJobResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeReportJobResponse' 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:
--
-- 'reportJob', 'describeReportJobResponse_reportJob' - A list of information about a report job, including its completion and
-- creation times, report destination, unique report job ID, Amazon
-- Resource Name (ARN), report template, status, and status message.
--
-- 'httpStatus', 'describeReportJobResponse_httpStatus' - The response's http status code.
newDescribeReportJobResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeReportJobResponse
newDescribeReportJobResponse :: Int -> DescribeReportJobResponse
newDescribeReportJobResponse Int
pHttpStatus_ =
  DescribeReportJobResponse' :: Maybe ReportJob -> Int -> DescribeReportJobResponse
DescribeReportJobResponse'
    { $sel:reportJob:DescribeReportJobResponse' :: Maybe ReportJob
reportJob =
        Maybe ReportJob
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeReportJobResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of information about a report job, including its completion and
-- creation times, report destination, unique report job ID, Amazon
-- Resource Name (ARN), report template, status, and status message.
describeReportJobResponse_reportJob :: Lens.Lens' DescribeReportJobResponse (Prelude.Maybe ReportJob)
describeReportJobResponse_reportJob :: (Maybe ReportJob -> f (Maybe ReportJob))
-> DescribeReportJobResponse -> f DescribeReportJobResponse
describeReportJobResponse_reportJob = (DescribeReportJobResponse -> Maybe ReportJob)
-> (DescribeReportJobResponse
    -> Maybe ReportJob -> DescribeReportJobResponse)
-> Lens
     DescribeReportJobResponse
     DescribeReportJobResponse
     (Maybe ReportJob)
     (Maybe ReportJob)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeReportJobResponse' {Maybe ReportJob
reportJob :: Maybe ReportJob
$sel:reportJob:DescribeReportJobResponse' :: DescribeReportJobResponse -> Maybe ReportJob
reportJob} -> Maybe ReportJob
reportJob) (\s :: DescribeReportJobResponse
s@DescribeReportJobResponse' {} Maybe ReportJob
a -> DescribeReportJobResponse
s {$sel:reportJob:DescribeReportJobResponse' :: Maybe ReportJob
reportJob = Maybe ReportJob
a} :: DescribeReportJobResponse)

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

instance Prelude.NFData DescribeReportJobResponse