{-# 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.ListFrameworks
-- 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 frameworks for an Amazon Web Services account and
-- Amazon Web Services Region.
module Amazonka.Backup.ListFrameworks
  ( -- * Creating a Request
    ListFrameworks (..),
    newListFrameworks,

    -- * Request Lenses
    listFrameworks_maxResults,
    listFrameworks_nextToken,

    -- * Destructuring the Response
    ListFrameworksResponse (..),
    newListFrameworksResponse,

    -- * Response Lenses
    listFrameworksResponse_frameworks,
    listFrameworksResponse_nextToken,
    listFrameworksResponse_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:/ 'newListFrameworks' smart constructor.
data ListFrameworks = ListFrameworks'
  { -- | The number of desired results from 1 to 1000. Optional. If unspecified,
    -- the query will return 1 MB of data.
    ListFrameworks -> 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.
    ListFrameworks -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListFrameworks -> ListFrameworks -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListFrameworks -> ListFrameworks -> Bool
$c/= :: ListFrameworks -> ListFrameworks -> Bool
== :: ListFrameworks -> ListFrameworks -> Bool
$c== :: ListFrameworks -> ListFrameworks -> Bool
Prelude.Eq, ReadPrec [ListFrameworks]
ReadPrec ListFrameworks
Int -> ReadS ListFrameworks
ReadS [ListFrameworks]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListFrameworks]
$creadListPrec :: ReadPrec [ListFrameworks]
readPrec :: ReadPrec ListFrameworks
$creadPrec :: ReadPrec ListFrameworks
readList :: ReadS [ListFrameworks]
$creadList :: ReadS [ListFrameworks]
readsPrec :: Int -> ReadS ListFrameworks
$creadsPrec :: Int -> ReadS ListFrameworks
Prelude.Read, Int -> ListFrameworks -> ShowS
[ListFrameworks] -> ShowS
ListFrameworks -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListFrameworks] -> ShowS
$cshowList :: [ListFrameworks] -> ShowS
show :: ListFrameworks -> String
$cshow :: ListFrameworks -> String
showsPrec :: Int -> ListFrameworks -> ShowS
$cshowsPrec :: Int -> ListFrameworks -> ShowS
Prelude.Show, forall x. Rep ListFrameworks x -> ListFrameworks
forall x. ListFrameworks -> Rep ListFrameworks x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListFrameworks x -> ListFrameworks
$cfrom :: forall x. ListFrameworks -> Rep ListFrameworks x
Prelude.Generic)

-- |
-- Create a value of 'ListFrameworks' 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', 'listFrameworks_maxResults' - The number of desired results from 1 to 1000. Optional. If unspecified,
-- the query will return 1 MB of data.
--
-- 'nextToken', 'listFrameworks_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.
newListFrameworks ::
  ListFrameworks
newListFrameworks :: ListFrameworks
newListFrameworks =
  ListFrameworks'
    { $sel:maxResults:ListFrameworks' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListFrameworks' :: 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.
listFrameworks_maxResults :: Lens.Lens' ListFrameworks (Prelude.Maybe Prelude.Natural)
listFrameworks_maxResults :: Lens' ListFrameworks (Maybe Natural)
listFrameworks_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListFrameworks' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListFrameworks' :: ListFrameworks -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListFrameworks
s@ListFrameworks' {} Maybe Natural
a -> ListFrameworks
s {$sel:maxResults:ListFrameworks' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListFrameworks)

-- | 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.
listFrameworks_nextToken :: Lens.Lens' ListFrameworks (Prelude.Maybe Prelude.Text)
listFrameworks_nextToken :: Lens' ListFrameworks (Maybe Text)
listFrameworks_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListFrameworks' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListFrameworks' :: ListFrameworks -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListFrameworks
s@ListFrameworks' {} Maybe Text
a -> ListFrameworks
s {$sel:nextToken:ListFrameworks' :: Maybe Text
nextToken = Maybe Text
a} :: ListFrameworks)

instance Core.AWSRequest ListFrameworks where
  type
    AWSResponse ListFrameworks =
      ListFrameworksResponse
  request :: (Service -> Service) -> ListFrameworks -> Request ListFrameworks
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 ListFrameworks
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListFrameworks)))
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 [Framework] -> Maybe Text -> Int -> ListFrameworksResponse
ListFrameworksResponse'
            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
"Frameworks" 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.<*> (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.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ListFrameworks where
  hashWithSalt :: Int -> ListFrameworks -> Int
hashWithSalt Int
_salt ListFrameworks' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListFrameworks' :: ListFrameworks -> Maybe Text
$sel:maxResults:ListFrameworks' :: ListFrameworks -> 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 ListFrameworks where
  rnf :: ListFrameworks -> ()
rnf ListFrameworks' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListFrameworks' :: ListFrameworks -> Maybe Text
$sel:maxResults:ListFrameworks' :: ListFrameworks -> 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 ListFrameworks where
  toHeaders :: ListFrameworks -> 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 ListFrameworks where
  toPath :: ListFrameworks -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/audit/frameworks"

instance Data.ToQuery ListFrameworks where
  toQuery :: ListFrameworks -> QueryString
toQuery ListFrameworks' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListFrameworks' :: ListFrameworks -> Maybe Text
$sel:maxResults:ListFrameworks' :: ListFrameworks -> 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:/ 'newListFrameworksResponse' smart constructor.
data ListFrameworksResponse = ListFrameworksResponse'
  { -- | A list of frameworks with details for each framework, including the
    -- framework name, Amazon Resource Name (ARN), description, number of
    -- controls, creation time, and deployment status.
    ListFrameworksResponse -> Maybe [Framework]
frameworks :: Prelude.Maybe [Framework],
    -- | 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.
    ListFrameworksResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListFrameworksResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListFrameworksResponse -> ListFrameworksResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListFrameworksResponse -> ListFrameworksResponse -> Bool
$c/= :: ListFrameworksResponse -> ListFrameworksResponse -> Bool
== :: ListFrameworksResponse -> ListFrameworksResponse -> Bool
$c== :: ListFrameworksResponse -> ListFrameworksResponse -> Bool
Prelude.Eq, ReadPrec [ListFrameworksResponse]
ReadPrec ListFrameworksResponse
Int -> ReadS ListFrameworksResponse
ReadS [ListFrameworksResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListFrameworksResponse]
$creadListPrec :: ReadPrec [ListFrameworksResponse]
readPrec :: ReadPrec ListFrameworksResponse
$creadPrec :: ReadPrec ListFrameworksResponse
readList :: ReadS [ListFrameworksResponse]
$creadList :: ReadS [ListFrameworksResponse]
readsPrec :: Int -> ReadS ListFrameworksResponse
$creadsPrec :: Int -> ReadS ListFrameworksResponse
Prelude.Read, Int -> ListFrameworksResponse -> ShowS
[ListFrameworksResponse] -> ShowS
ListFrameworksResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListFrameworksResponse] -> ShowS
$cshowList :: [ListFrameworksResponse] -> ShowS
show :: ListFrameworksResponse -> String
$cshow :: ListFrameworksResponse -> String
showsPrec :: Int -> ListFrameworksResponse -> ShowS
$cshowsPrec :: Int -> ListFrameworksResponse -> ShowS
Prelude.Show, forall x. Rep ListFrameworksResponse x -> ListFrameworksResponse
forall x. ListFrameworksResponse -> Rep ListFrameworksResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListFrameworksResponse x -> ListFrameworksResponse
$cfrom :: forall x. ListFrameworksResponse -> Rep ListFrameworksResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListFrameworksResponse' 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:
--
-- 'frameworks', 'listFrameworksResponse_frameworks' - A list of frameworks with details for each framework, including the
-- framework name, Amazon Resource Name (ARN), description, number of
-- controls, creation time, and deployment status.
--
-- 'nextToken', 'listFrameworksResponse_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.
--
-- 'httpStatus', 'listFrameworksResponse_httpStatus' - The response's http status code.
newListFrameworksResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListFrameworksResponse
newListFrameworksResponse :: Int -> ListFrameworksResponse
newListFrameworksResponse Int
pHttpStatus_ =
  ListFrameworksResponse'
    { $sel:frameworks:ListFrameworksResponse' :: Maybe [Framework]
frameworks =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListFrameworksResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListFrameworksResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of frameworks with details for each framework, including the
-- framework name, Amazon Resource Name (ARN), description, number of
-- controls, creation time, and deployment status.
listFrameworksResponse_frameworks :: Lens.Lens' ListFrameworksResponse (Prelude.Maybe [Framework])
listFrameworksResponse_frameworks :: Lens' ListFrameworksResponse (Maybe [Framework])
listFrameworksResponse_frameworks = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListFrameworksResponse' {Maybe [Framework]
frameworks :: Maybe [Framework]
$sel:frameworks:ListFrameworksResponse' :: ListFrameworksResponse -> Maybe [Framework]
frameworks} -> Maybe [Framework]
frameworks) (\s :: ListFrameworksResponse
s@ListFrameworksResponse' {} Maybe [Framework]
a -> ListFrameworksResponse
s {$sel:frameworks:ListFrameworksResponse' :: Maybe [Framework]
frameworks = Maybe [Framework]
a} :: ListFrameworksResponse) 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

-- | 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.
listFrameworksResponse_nextToken :: Lens.Lens' ListFrameworksResponse (Prelude.Maybe Prelude.Text)
listFrameworksResponse_nextToken :: Lens' ListFrameworksResponse (Maybe Text)
listFrameworksResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListFrameworksResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListFrameworksResponse' :: ListFrameworksResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListFrameworksResponse
s@ListFrameworksResponse' {} Maybe Text
a -> ListFrameworksResponse
s {$sel:nextToken:ListFrameworksResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListFrameworksResponse)

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

instance Prelude.NFData ListFrameworksResponse where
  rnf :: ListFrameworksResponse -> ()
rnf ListFrameworksResponse' {Int
Maybe [Framework]
Maybe Text
httpStatus :: Int
nextToken :: Maybe Text
frameworks :: Maybe [Framework]
$sel:httpStatus:ListFrameworksResponse' :: ListFrameworksResponse -> Int
$sel:nextToken:ListFrameworksResponse' :: ListFrameworksResponse -> Maybe Text
$sel:frameworks:ListFrameworksResponse' :: ListFrameworksResponse -> Maybe [Framework]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Framework]
frameworks
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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 Int
httpStatus