{-# 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.DescribeReportPlan
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns a list of all report plans for an Amazon Web Services account
-- and Amazon Web Services Region.
module Amazonka.Backup.DescribeReportPlan
  ( -- * Creating a Request
    DescribeReportPlan (..),
    newDescribeReportPlan,

    -- * Request Lenses
    describeReportPlan_reportPlanName,

    -- * Destructuring the Response
    DescribeReportPlanResponse (..),
    newDescribeReportPlanResponse,

    -- * Response Lenses
    describeReportPlanResponse_reportPlan,
    describeReportPlanResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDescribeReportPlan' smart constructor.
data DescribeReportPlan = DescribeReportPlan'
  { -- | The unique name of a report plan.
    DescribeReportPlan -> Text
reportPlanName :: Prelude.Text
  }
  deriving (DescribeReportPlan -> DescribeReportPlan -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeReportPlan -> DescribeReportPlan -> Bool
$c/= :: DescribeReportPlan -> DescribeReportPlan -> Bool
== :: DescribeReportPlan -> DescribeReportPlan -> Bool
$c== :: DescribeReportPlan -> DescribeReportPlan -> Bool
Prelude.Eq, ReadPrec [DescribeReportPlan]
ReadPrec DescribeReportPlan
Int -> ReadS DescribeReportPlan
ReadS [DescribeReportPlan]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeReportPlan]
$creadListPrec :: ReadPrec [DescribeReportPlan]
readPrec :: ReadPrec DescribeReportPlan
$creadPrec :: ReadPrec DescribeReportPlan
readList :: ReadS [DescribeReportPlan]
$creadList :: ReadS [DescribeReportPlan]
readsPrec :: Int -> ReadS DescribeReportPlan
$creadsPrec :: Int -> ReadS DescribeReportPlan
Prelude.Read, Int -> DescribeReportPlan -> ShowS
[DescribeReportPlan] -> ShowS
DescribeReportPlan -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeReportPlan] -> ShowS
$cshowList :: [DescribeReportPlan] -> ShowS
show :: DescribeReportPlan -> String
$cshow :: DescribeReportPlan -> String
showsPrec :: Int -> DescribeReportPlan -> ShowS
$cshowsPrec :: Int -> DescribeReportPlan -> ShowS
Prelude.Show, forall x. Rep DescribeReportPlan x -> DescribeReportPlan
forall x. DescribeReportPlan -> Rep DescribeReportPlan x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeReportPlan x -> DescribeReportPlan
$cfrom :: forall x. DescribeReportPlan -> Rep DescribeReportPlan x
Prelude.Generic)

-- |
-- Create a value of 'DescribeReportPlan' 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:
--
-- 'reportPlanName', 'describeReportPlan_reportPlanName' - The unique name of a report plan.
newDescribeReportPlan ::
  -- | 'reportPlanName'
  Prelude.Text ->
  DescribeReportPlan
newDescribeReportPlan :: Text -> DescribeReportPlan
newDescribeReportPlan Text
pReportPlanName_ =
  DescribeReportPlan'
    { $sel:reportPlanName:DescribeReportPlan' :: Text
reportPlanName =
        Text
pReportPlanName_
    }

-- | The unique name of a report plan.
describeReportPlan_reportPlanName :: Lens.Lens' DescribeReportPlan Prelude.Text
describeReportPlan_reportPlanName :: Lens' DescribeReportPlan Text
describeReportPlan_reportPlanName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeReportPlan' {Text
reportPlanName :: Text
$sel:reportPlanName:DescribeReportPlan' :: DescribeReportPlan -> Text
reportPlanName} -> Text
reportPlanName) (\s :: DescribeReportPlan
s@DescribeReportPlan' {} Text
a -> DescribeReportPlan
s {$sel:reportPlanName:DescribeReportPlan' :: Text
reportPlanName = Text
a} :: DescribeReportPlan)

instance Core.AWSRequest DescribeReportPlan where
  type
    AWSResponse DescribeReportPlan =
      DescribeReportPlanResponse
  request :: (Service -> Service)
-> DescribeReportPlan -> Request DescribeReportPlan
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DescribeReportPlan
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeReportPlan)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe ReportPlan -> Int -> DescribeReportPlanResponse
DescribeReportPlanResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"ReportPlan")
            forall (f :: * -> *) a b. Applicative f => 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 DescribeReportPlan where
  hashWithSalt :: Int -> DescribeReportPlan -> Int
hashWithSalt Int
_salt DescribeReportPlan' {Text
reportPlanName :: Text
$sel:reportPlanName:DescribeReportPlan' :: DescribeReportPlan -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
reportPlanName

instance Prelude.NFData DescribeReportPlan where
  rnf :: DescribeReportPlan -> ()
rnf DescribeReportPlan' {Text
reportPlanName :: Text
$sel:reportPlanName:DescribeReportPlan' :: DescribeReportPlan -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
reportPlanName

instance Data.ToHeaders DescribeReportPlan where
  toHeaders :: DescribeReportPlan -> 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.ToPath DescribeReportPlan where
  toPath :: DescribeReportPlan -> ByteString
toPath DescribeReportPlan' {Text
reportPlanName :: Text
$sel:reportPlanName:DescribeReportPlan' :: DescribeReportPlan -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/audit/report-plans/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
reportPlanName]

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

-- | /See:/ 'newDescribeReportPlanResponse' smart constructor.
data DescribeReportPlanResponse = DescribeReportPlanResponse'
  { -- | Returns details about the report plan that is specified by its name.
    -- These details include the report plan\'s Amazon Resource Name (ARN),
    -- description, settings, delivery channel, deployment status, creation
    -- time, and last attempted and successful run times.
    DescribeReportPlanResponse -> Maybe ReportPlan
reportPlan :: Prelude.Maybe ReportPlan,
    -- | The response's http status code.
    DescribeReportPlanResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeReportPlanResponse -> DescribeReportPlanResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeReportPlanResponse -> DescribeReportPlanResponse -> Bool
$c/= :: DescribeReportPlanResponse -> DescribeReportPlanResponse -> Bool
== :: DescribeReportPlanResponse -> DescribeReportPlanResponse -> Bool
$c== :: DescribeReportPlanResponse -> DescribeReportPlanResponse -> Bool
Prelude.Eq, ReadPrec [DescribeReportPlanResponse]
ReadPrec DescribeReportPlanResponse
Int -> ReadS DescribeReportPlanResponse
ReadS [DescribeReportPlanResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeReportPlanResponse]
$creadListPrec :: ReadPrec [DescribeReportPlanResponse]
readPrec :: ReadPrec DescribeReportPlanResponse
$creadPrec :: ReadPrec DescribeReportPlanResponse
readList :: ReadS [DescribeReportPlanResponse]
$creadList :: ReadS [DescribeReportPlanResponse]
readsPrec :: Int -> ReadS DescribeReportPlanResponse
$creadsPrec :: Int -> ReadS DescribeReportPlanResponse
Prelude.Read, Int -> DescribeReportPlanResponse -> ShowS
[DescribeReportPlanResponse] -> ShowS
DescribeReportPlanResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeReportPlanResponse] -> ShowS
$cshowList :: [DescribeReportPlanResponse] -> ShowS
show :: DescribeReportPlanResponse -> String
$cshow :: DescribeReportPlanResponse -> String
showsPrec :: Int -> DescribeReportPlanResponse -> ShowS
$cshowsPrec :: Int -> DescribeReportPlanResponse -> ShowS
Prelude.Show, forall x.
Rep DescribeReportPlanResponse x -> DescribeReportPlanResponse
forall x.
DescribeReportPlanResponse -> Rep DescribeReportPlanResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeReportPlanResponse x -> DescribeReportPlanResponse
$cfrom :: forall x.
DescribeReportPlanResponse -> Rep DescribeReportPlanResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeReportPlanResponse' 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:
--
-- 'reportPlan', 'describeReportPlanResponse_reportPlan' - Returns details about the report plan that is specified by its name.
-- These details include the report plan\'s Amazon Resource Name (ARN),
-- description, settings, delivery channel, deployment status, creation
-- time, and last attempted and successful run times.
--
-- 'httpStatus', 'describeReportPlanResponse_httpStatus' - The response's http status code.
newDescribeReportPlanResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeReportPlanResponse
newDescribeReportPlanResponse :: Int -> DescribeReportPlanResponse
newDescribeReportPlanResponse Int
pHttpStatus_ =
  DescribeReportPlanResponse'
    { $sel:reportPlan:DescribeReportPlanResponse' :: Maybe ReportPlan
reportPlan =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeReportPlanResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Returns details about the report plan that is specified by its name.
-- These details include the report plan\'s Amazon Resource Name (ARN),
-- description, settings, delivery channel, deployment status, creation
-- time, and last attempted and successful run times.
describeReportPlanResponse_reportPlan :: Lens.Lens' DescribeReportPlanResponse (Prelude.Maybe ReportPlan)
describeReportPlanResponse_reportPlan :: Lens' DescribeReportPlanResponse (Maybe ReportPlan)
describeReportPlanResponse_reportPlan = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeReportPlanResponse' {Maybe ReportPlan
reportPlan :: Maybe ReportPlan
$sel:reportPlan:DescribeReportPlanResponse' :: DescribeReportPlanResponse -> Maybe ReportPlan
reportPlan} -> Maybe ReportPlan
reportPlan) (\s :: DescribeReportPlanResponse
s@DescribeReportPlanResponse' {} Maybe ReportPlan
a -> DescribeReportPlanResponse
s {$sel:reportPlan:DescribeReportPlanResponse' :: Maybe ReportPlan
reportPlan = Maybe ReportPlan
a} :: DescribeReportPlanResponse)

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

instance Prelude.NFData DescribeReportPlanResponse where
  rnf :: DescribeReportPlanResponse -> ()
rnf DescribeReportPlanResponse' {Int
Maybe ReportPlan
httpStatus :: Int
reportPlan :: Maybe ReportPlan
$sel:httpStatus:DescribeReportPlanResponse' :: DescribeReportPlanResponse -> Int
$sel:reportPlan:DescribeReportPlanResponse' :: DescribeReportPlanResponse -> Maybe ReportPlan
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ReportPlan
reportPlan
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus