{-# 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.Route53RecoveryControlConfig.ListControlPanels
-- 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 an array of control panels in an account or in a cluster.
--
-- This operation returns paginated results.
module Amazonka.Route53RecoveryControlConfig.ListControlPanels
  ( -- * Creating a Request
    ListControlPanels (..),
    newListControlPanels,

    -- * Request Lenses
    listControlPanels_clusterArn,
    listControlPanels_maxResults,
    listControlPanels_nextToken,

    -- * Destructuring the Response
    ListControlPanelsResponse (..),
    newListControlPanelsResponse,

    -- * Response Lenses
    listControlPanelsResponse_controlPanels,
    listControlPanelsResponse_nextToken,
    listControlPanelsResponse_httpStatus,
  )
where

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
import Amazonka.Route53RecoveryControlConfig.Types

-- | /See:/ 'newListControlPanels' smart constructor.
data ListControlPanels = ListControlPanels'
  { -- | The Amazon Resource Name (ARN) of a cluster.
    ListControlPanels -> Maybe Text
clusterArn :: Prelude.Maybe Prelude.Text,
    -- | The number of objects that you want to return with this call.
    ListControlPanels -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The token that identifies which batch of results you want to see.
    ListControlPanels -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListControlPanels -> ListControlPanels -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListControlPanels -> ListControlPanels -> Bool
$c/= :: ListControlPanels -> ListControlPanels -> Bool
== :: ListControlPanels -> ListControlPanels -> Bool
$c== :: ListControlPanels -> ListControlPanels -> Bool
Prelude.Eq, ReadPrec [ListControlPanels]
ReadPrec ListControlPanels
Int -> ReadS ListControlPanels
ReadS [ListControlPanels]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListControlPanels]
$creadListPrec :: ReadPrec [ListControlPanels]
readPrec :: ReadPrec ListControlPanels
$creadPrec :: ReadPrec ListControlPanels
readList :: ReadS [ListControlPanels]
$creadList :: ReadS [ListControlPanels]
readsPrec :: Int -> ReadS ListControlPanels
$creadsPrec :: Int -> ReadS ListControlPanels
Prelude.Read, Int -> ListControlPanels -> ShowS
[ListControlPanels] -> ShowS
ListControlPanels -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListControlPanels] -> ShowS
$cshowList :: [ListControlPanels] -> ShowS
show :: ListControlPanels -> String
$cshow :: ListControlPanels -> String
showsPrec :: Int -> ListControlPanels -> ShowS
$cshowsPrec :: Int -> ListControlPanels -> ShowS
Prelude.Show, forall x. Rep ListControlPanels x -> ListControlPanels
forall x. ListControlPanels -> Rep ListControlPanels x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListControlPanels x -> ListControlPanels
$cfrom :: forall x. ListControlPanels -> Rep ListControlPanels x
Prelude.Generic)

-- |
-- Create a value of 'ListControlPanels' 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:
--
-- 'clusterArn', 'listControlPanels_clusterArn' - The Amazon Resource Name (ARN) of a cluster.
--
-- 'maxResults', 'listControlPanels_maxResults' - The number of objects that you want to return with this call.
--
-- 'nextToken', 'listControlPanels_nextToken' - The token that identifies which batch of results you want to see.
newListControlPanels ::
  ListControlPanels
newListControlPanels :: ListControlPanels
newListControlPanels =
  ListControlPanels'
    { $sel:clusterArn:ListControlPanels' :: Maybe Text
clusterArn = forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListControlPanels' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListControlPanels' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) of a cluster.
listControlPanels_clusterArn :: Lens.Lens' ListControlPanels (Prelude.Maybe Prelude.Text)
listControlPanels_clusterArn :: Lens' ListControlPanels (Maybe Text)
listControlPanels_clusterArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListControlPanels' {Maybe Text
clusterArn :: Maybe Text
$sel:clusterArn:ListControlPanels' :: ListControlPanels -> Maybe Text
clusterArn} -> Maybe Text
clusterArn) (\s :: ListControlPanels
s@ListControlPanels' {} Maybe Text
a -> ListControlPanels
s {$sel:clusterArn:ListControlPanels' :: Maybe Text
clusterArn = Maybe Text
a} :: ListControlPanels)

-- | The number of objects that you want to return with this call.
listControlPanels_maxResults :: Lens.Lens' ListControlPanels (Prelude.Maybe Prelude.Natural)
listControlPanels_maxResults :: Lens' ListControlPanels (Maybe Natural)
listControlPanels_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListControlPanels' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListControlPanels' :: ListControlPanels -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListControlPanels
s@ListControlPanels' {} Maybe Natural
a -> ListControlPanels
s {$sel:maxResults:ListControlPanels' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListControlPanels)

-- | The token that identifies which batch of results you want to see.
listControlPanels_nextToken :: Lens.Lens' ListControlPanels (Prelude.Maybe Prelude.Text)
listControlPanels_nextToken :: Lens' ListControlPanels (Maybe Text)
listControlPanels_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListControlPanels' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListControlPanels' :: ListControlPanels -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListControlPanels
s@ListControlPanels' {} Maybe Text
a -> ListControlPanels
s {$sel:nextToken:ListControlPanels' :: Maybe Text
nextToken = Maybe Text
a} :: ListControlPanels)

instance Core.AWSPager ListControlPanels where
  page :: ListControlPanels
-> AWSResponse ListControlPanels -> Maybe ListControlPanels
page ListControlPanels
rq AWSResponse ListControlPanels
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListControlPanels
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListControlPanelsResponse (Maybe Text)
listControlPanelsResponse_nextToken
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListControlPanels
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListControlPanelsResponse (Maybe [ControlPanel])
listControlPanelsResponse_controlPanels
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
        forall a. a -> Maybe a
Prelude.Just
          forall a b. (a -> b) -> a -> b
Prelude.$ ListControlPanels
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListControlPanels (Maybe Text)
listControlPanels_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListControlPanels
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListControlPanelsResponse (Maybe Text)
listControlPanelsResponse_nextToken
          forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest ListControlPanels where
  type
    AWSResponse ListControlPanels =
      ListControlPanelsResponse
  request :: (Service -> Service)
-> ListControlPanels -> Request ListControlPanels
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 ListControlPanels
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListControlPanels)))
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 [ControlPanel]
-> Maybe Text -> Int -> ListControlPanelsResponse
ListControlPanelsResponse'
            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
"ControlPanels" 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 ListControlPanels where
  hashWithSalt :: Int -> ListControlPanels -> Int
hashWithSalt Int
_salt ListControlPanels' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
clusterArn :: Maybe Text
$sel:nextToken:ListControlPanels' :: ListControlPanels -> Maybe Text
$sel:maxResults:ListControlPanels' :: ListControlPanels -> Maybe Natural
$sel:clusterArn:ListControlPanels' :: ListControlPanels -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
clusterArn
      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 ListControlPanels where
  rnf :: ListControlPanels -> ()
rnf ListControlPanels' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
clusterArn :: Maybe Text
$sel:nextToken:ListControlPanels' :: ListControlPanels -> Maybe Text
$sel:maxResults:ListControlPanels' :: ListControlPanels -> Maybe Natural
$sel:clusterArn:ListControlPanels' :: ListControlPanels -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
clusterArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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 ListControlPanels where
  toHeaders :: ListControlPanels -> 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 ListControlPanels where
  toPath :: ListControlPanels -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/controlpanels"

instance Data.ToQuery ListControlPanels where
  toQuery :: ListControlPanels -> QueryString
toQuery ListControlPanels' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
clusterArn :: Maybe Text
$sel:nextToken:ListControlPanels' :: ListControlPanels -> Maybe Text
$sel:maxResults:ListControlPanels' :: ListControlPanels -> Maybe Natural
$sel:clusterArn:ListControlPanels' :: ListControlPanels -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"ClusterArn" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
clusterArn,
        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:/ 'newListControlPanelsResponse' smart constructor.
data ListControlPanelsResponse = ListControlPanelsResponse'
  { -- | The result of a successful ListControlPanel request.
    ListControlPanelsResponse -> Maybe [ControlPanel]
controlPanels :: Prelude.Maybe [ControlPanel],
    -- | The token that identifies which batch of results you want to see.
    ListControlPanelsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListControlPanelsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListControlPanelsResponse -> ListControlPanelsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListControlPanelsResponse -> ListControlPanelsResponse -> Bool
$c/= :: ListControlPanelsResponse -> ListControlPanelsResponse -> Bool
== :: ListControlPanelsResponse -> ListControlPanelsResponse -> Bool
$c== :: ListControlPanelsResponse -> ListControlPanelsResponse -> Bool
Prelude.Eq, ReadPrec [ListControlPanelsResponse]
ReadPrec ListControlPanelsResponse
Int -> ReadS ListControlPanelsResponse
ReadS [ListControlPanelsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListControlPanelsResponse]
$creadListPrec :: ReadPrec [ListControlPanelsResponse]
readPrec :: ReadPrec ListControlPanelsResponse
$creadPrec :: ReadPrec ListControlPanelsResponse
readList :: ReadS [ListControlPanelsResponse]
$creadList :: ReadS [ListControlPanelsResponse]
readsPrec :: Int -> ReadS ListControlPanelsResponse
$creadsPrec :: Int -> ReadS ListControlPanelsResponse
Prelude.Read, Int -> ListControlPanelsResponse -> ShowS
[ListControlPanelsResponse] -> ShowS
ListControlPanelsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListControlPanelsResponse] -> ShowS
$cshowList :: [ListControlPanelsResponse] -> ShowS
show :: ListControlPanelsResponse -> String
$cshow :: ListControlPanelsResponse -> String
showsPrec :: Int -> ListControlPanelsResponse -> ShowS
$cshowsPrec :: Int -> ListControlPanelsResponse -> ShowS
Prelude.Show, forall x.
Rep ListControlPanelsResponse x -> ListControlPanelsResponse
forall x.
ListControlPanelsResponse -> Rep ListControlPanelsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListControlPanelsResponse x -> ListControlPanelsResponse
$cfrom :: forall x.
ListControlPanelsResponse -> Rep ListControlPanelsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListControlPanelsResponse' 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:
--
-- 'controlPanels', 'listControlPanelsResponse_controlPanels' - The result of a successful ListControlPanel request.
--
-- 'nextToken', 'listControlPanelsResponse_nextToken' - The token that identifies which batch of results you want to see.
--
-- 'httpStatus', 'listControlPanelsResponse_httpStatus' - The response's http status code.
newListControlPanelsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListControlPanelsResponse
newListControlPanelsResponse :: Int -> ListControlPanelsResponse
newListControlPanelsResponse Int
pHttpStatus_ =
  ListControlPanelsResponse'
    { $sel:controlPanels:ListControlPanelsResponse' :: Maybe [ControlPanel]
controlPanels =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListControlPanelsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListControlPanelsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The result of a successful ListControlPanel request.
listControlPanelsResponse_controlPanels :: Lens.Lens' ListControlPanelsResponse (Prelude.Maybe [ControlPanel])
listControlPanelsResponse_controlPanels :: Lens' ListControlPanelsResponse (Maybe [ControlPanel])
listControlPanelsResponse_controlPanels = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListControlPanelsResponse' {Maybe [ControlPanel]
controlPanels :: Maybe [ControlPanel]
$sel:controlPanels:ListControlPanelsResponse' :: ListControlPanelsResponse -> Maybe [ControlPanel]
controlPanels} -> Maybe [ControlPanel]
controlPanels) (\s :: ListControlPanelsResponse
s@ListControlPanelsResponse' {} Maybe [ControlPanel]
a -> ListControlPanelsResponse
s {$sel:controlPanels:ListControlPanelsResponse' :: Maybe [ControlPanel]
controlPanels = Maybe [ControlPanel]
a} :: ListControlPanelsResponse) 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 token that identifies which batch of results you want to see.
listControlPanelsResponse_nextToken :: Lens.Lens' ListControlPanelsResponse (Prelude.Maybe Prelude.Text)
listControlPanelsResponse_nextToken :: Lens' ListControlPanelsResponse (Maybe Text)
listControlPanelsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListControlPanelsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListControlPanelsResponse' :: ListControlPanelsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListControlPanelsResponse
s@ListControlPanelsResponse' {} Maybe Text
a -> ListControlPanelsResponse
s {$sel:nextToken:ListControlPanelsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListControlPanelsResponse)

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

instance Prelude.NFData ListControlPanelsResponse where
  rnf :: ListControlPanelsResponse -> ()
rnf ListControlPanelsResponse' {Int
Maybe [ControlPanel]
Maybe Text
httpStatus :: Int
nextToken :: Maybe Text
controlPanels :: Maybe [ControlPanel]
$sel:httpStatus:ListControlPanelsResponse' :: ListControlPanelsResponse -> Int
$sel:nextToken:ListControlPanelsResponse' :: ListControlPanelsResponse -> Maybe Text
$sel:controlPanels:ListControlPanelsResponse' :: ListControlPanelsResponse -> Maybe [ControlPanel]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [ControlPanel]
controlPanels
      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