{-# 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-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 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_nextToken,
    listFrameworks_maxResults,

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

    -- * Response Lenses
    listFrameworksResponse_nextToken,
    listFrameworksResponse_frameworks,
    listFrameworksResponse_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:/ 'newListFrameworks' smart constructor.
data ListFrameworks = 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 -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | 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
  }
  deriving (ListFrameworks -> ListFrameworks -> Bool
(ListFrameworks -> ListFrameworks -> Bool)
-> (ListFrameworks -> ListFrameworks -> Bool) -> Eq ListFrameworks
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]
(Int -> ReadS ListFrameworks)
-> ReadS [ListFrameworks]
-> ReadPrec ListFrameworks
-> ReadPrec [ListFrameworks]
-> Read 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
(Int -> ListFrameworks -> ShowS)
-> (ListFrameworks -> String)
-> ([ListFrameworks] -> ShowS)
-> Show ListFrameworks
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. ListFrameworks -> Rep ListFrameworks x)
-> (forall x. Rep ListFrameworks x -> ListFrameworks)
-> Generic ListFrameworks
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:
--
-- '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.
--
-- 'maxResults', 'listFrameworks_maxResults' - The number of desired results from 1 to 1000. Optional. If unspecified,
-- the query will return 1 MB of data.
newListFrameworks ::
  ListFrameworks
newListFrameworks :: ListFrameworks
newListFrameworks =
  ListFrameworks' :: Maybe Text -> Maybe Natural -> ListFrameworks
ListFrameworks'
    { $sel:nextToken:ListFrameworks' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListFrameworks' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> ListFrameworks -> f ListFrameworks
listFrameworks_nextToken = (ListFrameworks -> Maybe Text)
-> (ListFrameworks -> Maybe Text -> ListFrameworks)
-> Lens ListFrameworks ListFrameworks (Maybe Text) (Maybe Text)
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)

-- | 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 :: (Maybe Natural -> f (Maybe Natural))
-> ListFrameworks -> f ListFrameworks
listFrameworks_maxResults = (ListFrameworks -> Maybe Natural)
-> (ListFrameworks -> Maybe Natural -> ListFrameworks)
-> Lens
     ListFrameworks ListFrameworks (Maybe Natural) (Maybe Natural)
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)

instance Core.AWSRequest ListFrameworks where
  type
    AWSResponse ListFrameworks =
      ListFrameworksResponse
  request :: ListFrameworks -> Request ListFrameworks
request = Service -> ListFrameworks -> Request ListFrameworks
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy ListFrameworks
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListFrameworks)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListFrameworks))
-> Logger
-> Service
-> Proxy ListFrameworks
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListFrameworks)))
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 Text -> Maybe [Framework] -> Int -> ListFrameworksResponse
ListFrameworksResponse'
            (Maybe Text -> Maybe [Framework] -> Int -> ListFrameworksResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe [Framework] -> Int -> ListFrameworksResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"NextToken")
            Either String (Maybe [Framework] -> Int -> ListFrameworksResponse)
-> Either String (Maybe [Framework])
-> Either String (Int -> ListFrameworksResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe (Maybe [Framework]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Frameworks" Either String (Maybe (Maybe [Framework]))
-> Maybe [Framework] -> Either String (Maybe [Framework])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Framework]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> ListFrameworksResponse)
-> Either String Int -> Either String ListFrameworksResponse
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 ListFrameworks

instance Prelude.NFData ListFrameworks

instance Core.ToHeaders ListFrameworks where
  toHeaders :: ListFrameworks -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListFrameworks -> 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 ListFrameworks where
  toPath :: ListFrameworks -> ByteString
toPath = ByteString -> ListFrameworks -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/audit/frameworks"

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

-- | /See:/ 'newListFrameworksResponse' smart constructor.
data ListFrameworksResponse = ListFrameworksResponse'
  { -- | 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,
    -- | 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],
    -- | The response's http status code.
    ListFrameworksResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListFrameworksResponse -> ListFrameworksResponse -> Bool
(ListFrameworksResponse -> ListFrameworksResponse -> Bool)
-> (ListFrameworksResponse -> ListFrameworksResponse -> Bool)
-> Eq ListFrameworksResponse
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]
(Int -> ReadS ListFrameworksResponse)
-> ReadS [ListFrameworksResponse]
-> ReadPrec ListFrameworksResponse
-> ReadPrec [ListFrameworksResponse]
-> Read 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
(Int -> ListFrameworksResponse -> ShowS)
-> (ListFrameworksResponse -> String)
-> ([ListFrameworksResponse] -> ShowS)
-> Show ListFrameworksResponse
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. ListFrameworksResponse -> Rep ListFrameworksResponse x)
-> (forall x.
    Rep ListFrameworksResponse x -> ListFrameworksResponse)
-> Generic ListFrameworksResponse
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:
--
-- '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.
--
-- '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.
--
-- 'httpStatus', 'listFrameworksResponse_httpStatus' - The response's http status code.
newListFrameworksResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListFrameworksResponse
newListFrameworksResponse :: Int -> ListFrameworksResponse
newListFrameworksResponse Int
pHttpStatus_ =
  ListFrameworksResponse' :: Maybe Text -> Maybe [Framework] -> Int -> ListFrameworksResponse
ListFrameworksResponse'
    { $sel:nextToken:ListFrameworksResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:frameworks:ListFrameworksResponse' :: Maybe [Framework]
frameworks = Maybe [Framework]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListFrameworksResponse' :: 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.
listFrameworksResponse_nextToken :: Lens.Lens' ListFrameworksResponse (Prelude.Maybe Prelude.Text)
listFrameworksResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListFrameworksResponse -> f ListFrameworksResponse
listFrameworksResponse_nextToken = (ListFrameworksResponse -> Maybe Text)
-> (ListFrameworksResponse -> Maybe Text -> ListFrameworksResponse)
-> Lens
     ListFrameworksResponse
     ListFrameworksResponse
     (Maybe Text)
     (Maybe Text)
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)

-- | 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 :: (Maybe [Framework] -> f (Maybe [Framework]))
-> ListFrameworksResponse -> f ListFrameworksResponse
listFrameworksResponse_frameworks = (ListFrameworksResponse -> Maybe [Framework])
-> (ListFrameworksResponse
    -> Maybe [Framework] -> ListFrameworksResponse)
-> Lens
     ListFrameworksResponse
     ListFrameworksResponse
     (Maybe [Framework])
     (Maybe [Framework])
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) ((Maybe [Framework] -> f (Maybe [Framework]))
 -> ListFrameworksResponse -> f ListFrameworksResponse)
-> ((Maybe [Framework] -> f (Maybe [Framework]))
    -> Maybe [Framework] -> f (Maybe [Framework]))
-> (Maybe [Framework] -> f (Maybe [Framework]))
-> ListFrameworksResponse
-> f ListFrameworksResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Framework] [Framework] [Framework] [Framework]
-> Iso
     (Maybe [Framework])
     (Maybe [Framework])
     (Maybe [Framework])
     (Maybe [Framework])
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 AnIso [Framework] [Framework] [Framework] [Framework]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The response's http status code.
listFrameworksResponse_httpStatus :: Lens.Lens' ListFrameworksResponse Prelude.Int
listFrameworksResponse_httpStatus :: (Int -> f Int)
-> ListFrameworksResponse -> f ListFrameworksResponse
listFrameworksResponse_httpStatus = (ListFrameworksResponse -> Int)
-> (ListFrameworksResponse -> Int -> ListFrameworksResponse)
-> Lens ListFrameworksResponse ListFrameworksResponse Int Int
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