{-# 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.ListReportPlans
-- 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 your report plans. For detailed information about a
-- single report plan, use @DescribeReportPlan@.
module Amazonka.Backup.ListReportPlans
  ( -- * Creating a Request
    ListReportPlans (..),
    newListReportPlans,

    -- * Request Lenses
    listReportPlans_maxResults,
    listReportPlans_nextToken,

    -- * Destructuring the Response
    ListReportPlansResponse (..),
    newListReportPlansResponse,

    -- * Response Lenses
    listReportPlansResponse_nextToken,
    listReportPlansResponse_reportPlans,
    listReportPlansResponse_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:/ 'newListReportPlans' smart constructor.
data ListReportPlans = ListReportPlans'
  { -- | The number of desired results from 1 to 1000. Optional. If unspecified,
    -- the query will return 1 MB of data.
    ListReportPlans -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | An identifier that was returned from the previous call to this
    -- operation, which can be used to return the next set of items in the
    -- list.
    ListReportPlans -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListReportPlans -> ListReportPlans -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListReportPlans -> ListReportPlans -> Bool
$c/= :: ListReportPlans -> ListReportPlans -> Bool
== :: ListReportPlans -> ListReportPlans -> Bool
$c== :: ListReportPlans -> ListReportPlans -> Bool
Prelude.Eq, ReadPrec [ListReportPlans]
ReadPrec ListReportPlans
Int -> ReadS ListReportPlans
ReadS [ListReportPlans]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListReportPlans]
$creadListPrec :: ReadPrec [ListReportPlans]
readPrec :: ReadPrec ListReportPlans
$creadPrec :: ReadPrec ListReportPlans
readList :: ReadS [ListReportPlans]
$creadList :: ReadS [ListReportPlans]
readsPrec :: Int -> ReadS ListReportPlans
$creadsPrec :: Int -> ReadS ListReportPlans
Prelude.Read, Int -> ListReportPlans -> ShowS
[ListReportPlans] -> ShowS
ListReportPlans -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListReportPlans] -> ShowS
$cshowList :: [ListReportPlans] -> ShowS
show :: ListReportPlans -> String
$cshow :: ListReportPlans -> String
showsPrec :: Int -> ListReportPlans -> ShowS
$cshowsPrec :: Int -> ListReportPlans -> ShowS
Prelude.Show, forall x. Rep ListReportPlans x -> ListReportPlans
forall x. ListReportPlans -> Rep ListReportPlans x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListReportPlans x -> ListReportPlans
$cfrom :: forall x. ListReportPlans -> Rep ListReportPlans x
Prelude.Generic)

-- |
-- Create a value of 'ListReportPlans' 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:
--
-- 'maxResults', 'listReportPlans_maxResults' - The number of desired results from 1 to 1000. Optional. If unspecified,
-- the query will return 1 MB of data.
--
-- 'nextToken', 'listReportPlans_nextToken' - An identifier that was returned from the previous call to this
-- operation, which can be used to return the next set of items in the
-- list.
newListReportPlans ::
  ListReportPlans
newListReportPlans :: ListReportPlans
newListReportPlans =
  ListReportPlans'
    { $sel:maxResults:ListReportPlans' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListReportPlans' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The number of desired results from 1 to 1000. Optional. If unspecified,
-- the query will return 1 MB of data.
listReportPlans_maxResults :: Lens.Lens' ListReportPlans (Prelude.Maybe Prelude.Natural)
listReportPlans_maxResults :: Lens' ListReportPlans (Maybe Natural)
listReportPlans_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListReportPlans' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListReportPlans' :: ListReportPlans -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListReportPlans
s@ListReportPlans' {} Maybe Natural
a -> ListReportPlans
s {$sel:maxResults:ListReportPlans' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListReportPlans)

-- | An identifier that was returned from the previous call to this
-- operation, which can be used to return the next set of items in the
-- list.
listReportPlans_nextToken :: Lens.Lens' ListReportPlans (Prelude.Maybe Prelude.Text)
listReportPlans_nextToken :: Lens' ListReportPlans (Maybe Text)
listReportPlans_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListReportPlans' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListReportPlans' :: ListReportPlans -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListReportPlans
s@ListReportPlans' {} Maybe Text
a -> ListReportPlans
s {$sel:nextToken:ListReportPlans' :: Maybe Text
nextToken = Maybe Text
a} :: ListReportPlans)

instance Core.AWSRequest ListReportPlans where
  type
    AWSResponse ListReportPlans =
      ListReportPlansResponse
  request :: (Service -> Service) -> ListReportPlans -> Request ListReportPlans
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 ListReportPlans
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListReportPlans)))
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 Text -> Maybe [ReportPlan] -> Int -> ListReportPlansResponse
ListReportPlansResponse'
            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
"NextToken")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"ReportPlans" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            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 ListReportPlans where
  hashWithSalt :: Int -> ListReportPlans -> Int
hashWithSalt Int
_salt ListReportPlans' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListReportPlans' :: ListReportPlans -> Maybe Text
$sel:maxResults:ListReportPlans' :: ListReportPlans -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken

instance Prelude.NFData ListReportPlans where
  rnf :: ListReportPlans -> ()
rnf ListReportPlans' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListReportPlans' :: ListReportPlans -> Maybe Text
$sel:maxResults:ListReportPlans' :: ListReportPlans -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxResults
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken

instance Data.ToHeaders ListReportPlans where
  toHeaders :: ListReportPlans -> 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 ListReportPlans where
  toPath :: ListReportPlans -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/audit/report-plans"

instance Data.ToQuery ListReportPlans where
  toQuery :: ListReportPlans -> QueryString
toQuery ListReportPlans' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListReportPlans' :: ListReportPlans -> Maybe Text
$sel:maxResults:ListReportPlans' :: ListReportPlans -> Maybe Natural
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"MaxResults" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Natural
maxResults,
        ByteString
"NextToken" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
nextToken
      ]

-- | /See:/ 'newListReportPlansResponse' smart constructor.
data ListReportPlansResponse = ListReportPlansResponse'
  { -- | An identifier that was returned from the previous call to this
    -- operation, which can be used to return the next set of items in the
    -- list.
    ListReportPlansResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | A list of your report plans with detailed information for each plan.
    -- This information includes the Amazon Resource Name (ARN), report plan
    -- name, description, settings, delivery channel, deployment status,
    -- creation time, and last times the report plan attempted to and
    -- successfully ran.
    ListReportPlansResponse -> Maybe [ReportPlan]
reportPlans :: Prelude.Maybe [ReportPlan],
    -- | The response's http status code.
    ListReportPlansResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListReportPlansResponse -> ListReportPlansResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListReportPlansResponse -> ListReportPlansResponse -> Bool
$c/= :: ListReportPlansResponse -> ListReportPlansResponse -> Bool
== :: ListReportPlansResponse -> ListReportPlansResponse -> Bool
$c== :: ListReportPlansResponse -> ListReportPlansResponse -> Bool
Prelude.Eq, ReadPrec [ListReportPlansResponse]
ReadPrec ListReportPlansResponse
Int -> ReadS ListReportPlansResponse
ReadS [ListReportPlansResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListReportPlansResponse]
$creadListPrec :: ReadPrec [ListReportPlansResponse]
readPrec :: ReadPrec ListReportPlansResponse
$creadPrec :: ReadPrec ListReportPlansResponse
readList :: ReadS [ListReportPlansResponse]
$creadList :: ReadS [ListReportPlansResponse]
readsPrec :: Int -> ReadS ListReportPlansResponse
$creadsPrec :: Int -> ReadS ListReportPlansResponse
Prelude.Read, Int -> ListReportPlansResponse -> ShowS
[ListReportPlansResponse] -> ShowS
ListReportPlansResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListReportPlansResponse] -> ShowS
$cshowList :: [ListReportPlansResponse] -> ShowS
show :: ListReportPlansResponse -> String
$cshow :: ListReportPlansResponse -> String
showsPrec :: Int -> ListReportPlansResponse -> ShowS
$cshowsPrec :: Int -> ListReportPlansResponse -> ShowS
Prelude.Show, forall x. Rep ListReportPlansResponse x -> ListReportPlansResponse
forall x. ListReportPlansResponse -> Rep ListReportPlansResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListReportPlansResponse x -> ListReportPlansResponse
$cfrom :: forall x. ListReportPlansResponse -> Rep ListReportPlansResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListReportPlansResponse' 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:
--
-- 'nextToken', 'listReportPlansResponse_nextToken' - An identifier that was returned from the previous call to this
-- operation, which can be used to return the next set of items in the
-- list.
--
-- 'reportPlans', 'listReportPlansResponse_reportPlans' - A list of your report plans with detailed information for each plan.
-- This information includes the Amazon Resource Name (ARN), report plan
-- name, description, settings, delivery channel, deployment status,
-- creation time, and last times the report plan attempted to and
-- successfully ran.
--
-- 'httpStatus', 'listReportPlansResponse_httpStatus' - The response's http status code.
newListReportPlansResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListReportPlansResponse
newListReportPlansResponse :: Int -> ListReportPlansResponse
newListReportPlansResponse Int
pHttpStatus_ =
  ListReportPlansResponse'
    { $sel:nextToken:ListReportPlansResponse' :: Maybe Text
nextToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:reportPlans:ListReportPlansResponse' :: Maybe [ReportPlan]
reportPlans = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListReportPlansResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An identifier that was returned from the previous call to this
-- operation, which can be used to return the next set of items in the
-- list.
listReportPlansResponse_nextToken :: Lens.Lens' ListReportPlansResponse (Prelude.Maybe Prelude.Text)
listReportPlansResponse_nextToken :: Lens' ListReportPlansResponse (Maybe Text)
listReportPlansResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListReportPlansResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListReportPlansResponse' :: ListReportPlansResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListReportPlansResponse
s@ListReportPlansResponse' {} Maybe Text
a -> ListReportPlansResponse
s {$sel:nextToken:ListReportPlansResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListReportPlansResponse)

-- | A list of your report plans with detailed information for each plan.
-- This information includes the Amazon Resource Name (ARN), report plan
-- name, description, settings, delivery channel, deployment status,
-- creation time, and last times the report plan attempted to and
-- successfully ran.
listReportPlansResponse_reportPlans :: Lens.Lens' ListReportPlansResponse (Prelude.Maybe [ReportPlan])
listReportPlansResponse_reportPlans :: Lens' ListReportPlansResponse (Maybe [ReportPlan])
listReportPlansResponse_reportPlans = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListReportPlansResponse' {Maybe [ReportPlan]
reportPlans :: Maybe [ReportPlan]
$sel:reportPlans:ListReportPlansResponse' :: ListReportPlansResponse -> Maybe [ReportPlan]
reportPlans} -> Maybe [ReportPlan]
reportPlans) (\s :: ListReportPlansResponse
s@ListReportPlansResponse' {} Maybe [ReportPlan]
a -> ListReportPlansResponse
s {$sel:reportPlans:ListReportPlansResponse' :: Maybe [ReportPlan]
reportPlans = Maybe [ReportPlan]
a} :: ListReportPlansResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData ListReportPlansResponse where
  rnf :: ListReportPlansResponse -> ()
rnf ListReportPlansResponse' {Int
Maybe [ReportPlan]
Maybe Text
httpStatus :: Int
reportPlans :: Maybe [ReportPlan]
nextToken :: Maybe Text
$sel:httpStatus:ListReportPlansResponse' :: ListReportPlansResponse -> Int
$sel:reportPlans:ListReportPlansResponse' :: ListReportPlansResponse -> Maybe [ReportPlan]
$sel:nextToken:ListReportPlansResponse' :: ListReportPlansResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [ReportPlan]
reportPlans
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus