{-# 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.ListClusters
-- 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 an array of all the clusters in an account.
module Amazonka.Route53RecoveryControlConfig.ListClusters
  ( -- * Creating a Request
    ListClusters (..),
    newListClusters,

    -- * Request Lenses
    listClusters_nextToken,
    listClusters_maxResults,

    -- * Destructuring the Response
    ListClustersResponse (..),
    newListClustersResponse,

    -- * Response Lenses
    listClustersResponse_nextToken,
    listClustersResponse_clusters,
    listClustersResponse_httpStatus,
  )
where

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

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

-- |
-- Create a value of 'ListClusters' 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', 'listClusters_nextToken' - The token that identifies which batch of results you want to see.
--
-- 'maxResults', 'listClusters_maxResults' - The number of objects that you want to return with this call.
newListClusters ::
  ListClusters
newListClusters :: ListClusters
newListClusters =
  ListClusters' :: Maybe Text -> Maybe Natural -> ListClusters
ListClusters'
    { $sel:nextToken:ListClusters' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListClusters' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

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

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

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

instance Prelude.NFData ListClusters

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

instance Core.ToQuery ListClusters where
  toQuery :: ListClusters -> QueryString
toQuery ListClusters' {Maybe Natural
Maybe Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
$sel:maxResults:ListClusters' :: ListClusters -> Maybe Natural
$sel:nextToken:ListClusters' :: ListClusters -> 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:/ 'newListClustersResponse' smart constructor.
data ListClustersResponse = ListClustersResponse'
  { -- | The token that identifies which batch of results you want to see.
    ListClustersResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | An array of the clusters in an account.
    ListClustersResponse -> Maybe [Cluster]
clusters :: Prelude.Maybe [Cluster],
    -- | The response's http status code.
    ListClustersResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListClustersResponse -> ListClustersResponse -> Bool
(ListClustersResponse -> ListClustersResponse -> Bool)
-> (ListClustersResponse -> ListClustersResponse -> Bool)
-> Eq ListClustersResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListClustersResponse -> ListClustersResponse -> Bool
$c/= :: ListClustersResponse -> ListClustersResponse -> Bool
== :: ListClustersResponse -> ListClustersResponse -> Bool
$c== :: ListClustersResponse -> ListClustersResponse -> Bool
Prelude.Eq, ReadPrec [ListClustersResponse]
ReadPrec ListClustersResponse
Int -> ReadS ListClustersResponse
ReadS [ListClustersResponse]
(Int -> ReadS ListClustersResponse)
-> ReadS [ListClustersResponse]
-> ReadPrec ListClustersResponse
-> ReadPrec [ListClustersResponse]
-> Read ListClustersResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListClustersResponse]
$creadListPrec :: ReadPrec [ListClustersResponse]
readPrec :: ReadPrec ListClustersResponse
$creadPrec :: ReadPrec ListClustersResponse
readList :: ReadS [ListClustersResponse]
$creadList :: ReadS [ListClustersResponse]
readsPrec :: Int -> ReadS ListClustersResponse
$creadsPrec :: Int -> ReadS ListClustersResponse
Prelude.Read, Int -> ListClustersResponse -> ShowS
[ListClustersResponse] -> ShowS
ListClustersResponse -> String
(Int -> ListClustersResponse -> ShowS)
-> (ListClustersResponse -> String)
-> ([ListClustersResponse] -> ShowS)
-> Show ListClustersResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListClustersResponse] -> ShowS
$cshowList :: [ListClustersResponse] -> ShowS
show :: ListClustersResponse -> String
$cshow :: ListClustersResponse -> String
showsPrec :: Int -> ListClustersResponse -> ShowS
$cshowsPrec :: Int -> ListClustersResponse -> ShowS
Prelude.Show, (forall x. ListClustersResponse -> Rep ListClustersResponse x)
-> (forall x. Rep ListClustersResponse x -> ListClustersResponse)
-> Generic ListClustersResponse
forall x. Rep ListClustersResponse x -> ListClustersResponse
forall x. ListClustersResponse -> Rep ListClustersResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListClustersResponse x -> ListClustersResponse
$cfrom :: forall x. ListClustersResponse -> Rep ListClustersResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListClustersResponse' 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', 'listClustersResponse_nextToken' - The token that identifies which batch of results you want to see.
--
-- 'clusters', 'listClustersResponse_clusters' - An array of the clusters in an account.
--
-- 'httpStatus', 'listClustersResponse_httpStatus' - The response's http status code.
newListClustersResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListClustersResponse
newListClustersResponse :: Int -> ListClustersResponse
newListClustersResponse Int
pHttpStatus_ =
  ListClustersResponse' :: Maybe Text -> Maybe [Cluster] -> Int -> ListClustersResponse
ListClustersResponse'
    { $sel:nextToken:ListClustersResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:clusters:ListClustersResponse' :: Maybe [Cluster]
clusters = Maybe [Cluster]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListClustersResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

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

-- | An array of the clusters in an account.
listClustersResponse_clusters :: Lens.Lens' ListClustersResponse (Prelude.Maybe [Cluster])
listClustersResponse_clusters :: (Maybe [Cluster] -> f (Maybe [Cluster]))
-> ListClustersResponse -> f ListClustersResponse
listClustersResponse_clusters = (ListClustersResponse -> Maybe [Cluster])
-> (ListClustersResponse
    -> Maybe [Cluster] -> ListClustersResponse)
-> Lens
     ListClustersResponse
     ListClustersResponse
     (Maybe [Cluster])
     (Maybe [Cluster])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListClustersResponse' {Maybe [Cluster]
clusters :: Maybe [Cluster]
$sel:clusters:ListClustersResponse' :: ListClustersResponse -> Maybe [Cluster]
clusters} -> Maybe [Cluster]
clusters) (\s :: ListClustersResponse
s@ListClustersResponse' {} Maybe [Cluster]
a -> ListClustersResponse
s {$sel:clusters:ListClustersResponse' :: Maybe [Cluster]
clusters = Maybe [Cluster]
a} :: ListClustersResponse) ((Maybe [Cluster] -> f (Maybe [Cluster]))
 -> ListClustersResponse -> f ListClustersResponse)
-> ((Maybe [Cluster] -> f (Maybe [Cluster]))
    -> Maybe [Cluster] -> f (Maybe [Cluster]))
-> (Maybe [Cluster] -> f (Maybe [Cluster]))
-> ListClustersResponse
-> f ListClustersResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Cluster] [Cluster] [Cluster] [Cluster]
-> Iso
     (Maybe [Cluster])
     (Maybe [Cluster])
     (Maybe [Cluster])
     (Maybe [Cluster])
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 [Cluster] [Cluster] [Cluster] [Cluster]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData ListClustersResponse