{-# 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.Redshift.DescribeClusters
-- 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 properties of provisioned clusters including general cluster
-- properties, cluster database properties, maintenance and backup
-- properties, and security and access properties. This operation supports
-- pagination. For more information about managing clusters, go to
-- <https://docs.aws.amazon.com/redshift/latest/mgmt/working-with-clusters.html Amazon Redshift Clusters>
-- in the /Amazon Redshift Cluster Management Guide/.
--
-- If you specify both tag keys and tag values in the same request, Amazon
-- Redshift returns all clusters that match any combination of the
-- specified keys and values. For example, if you have @owner@ and
-- @environment@ for tag keys, and @admin@ and @test@ for tag values, all
-- clusters that have any combination of those values are returned.
--
-- If both tag keys and values are omitted from the request, clusters are
-- returned regardless of whether they have tag keys or values associated
-- with them.
--
-- This operation returns paginated results.
module Amazonka.Redshift.DescribeClusters
  ( -- * Creating a Request
    DescribeClusters (..),
    newDescribeClusters,

    -- * Request Lenses
    describeClusters_tagValues,
    describeClusters_tagKeys,
    describeClusters_clusterIdentifier,
    describeClusters_marker,
    describeClusters_maxRecords,

    -- * Destructuring the Response
    DescribeClustersResponse (..),
    newDescribeClustersResponse,

    -- * Response Lenses
    describeClustersResponse_marker,
    describeClustersResponse_clusters,
    describeClustersResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Redshift.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- |
--
-- /See:/ 'newDescribeClusters' smart constructor.
data DescribeClusters = DescribeClusters'
  { -- | A tag value or values for which you want to return all matching clusters
    -- that are associated with the specified tag value or values. For example,
    -- suppose that you have clusters that are tagged with values called
    -- @admin@ and @test@. If you specify both of these tag values in the
    -- request, Amazon Redshift returns a response with the clusters that have
    -- either or both of these tag values associated with them.
    DescribeClusters -> Maybe [Text]
tagValues :: Prelude.Maybe [Prelude.Text],
    -- | A tag key or keys for which you want to return all matching clusters
    -- that are associated with the specified key or keys. For example, suppose
    -- that you have clusters that are tagged with keys called @owner@ and
    -- @environment@. If you specify both of these tag keys in the request,
    -- Amazon Redshift returns a response with the clusters that have either or
    -- both of these tag keys associated with them.
    DescribeClusters -> Maybe [Text]
tagKeys :: Prelude.Maybe [Prelude.Text],
    -- | The unique identifier of a cluster whose properties you are requesting.
    -- This parameter is case sensitive.
    --
    -- The default is that all clusters defined for an account are returned.
    DescribeClusters -> Maybe Text
clusterIdentifier :: Prelude.Maybe Prelude.Text,
    -- | An optional parameter that specifies the starting point to return a set
    -- of response records. When the results of a DescribeClusters request
    -- exceed the value specified in @MaxRecords@, Amazon Web Services returns
    -- a value in the @Marker@ field of the response. You can retrieve the next
    -- set of response records by providing the returned marker value in the
    -- @Marker@ parameter and retrying the request.
    --
    -- Constraints: You can specify either the __ClusterIdentifier__ parameter
    -- or the __Marker__ parameter, but not both.
    DescribeClusters -> Maybe Text
marker :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of response records to return in each call. If the
    -- number of remaining response records exceeds the specified @MaxRecords@
    -- value, a value is returned in a @marker@ field of the response. You can
    -- retrieve the next set of records by retrying the command with the
    -- returned marker value.
    --
    -- Default: @100@
    --
    -- Constraints: minimum 20, maximum 100.
    DescribeClusters -> Maybe Int
maxRecords :: Prelude.Maybe Prelude.Int
  }
  deriving (DescribeClusters -> DescribeClusters -> Bool
(DescribeClusters -> DescribeClusters -> Bool)
-> (DescribeClusters -> DescribeClusters -> Bool)
-> Eq DescribeClusters
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeClusters -> DescribeClusters -> Bool
$c/= :: DescribeClusters -> DescribeClusters -> Bool
== :: DescribeClusters -> DescribeClusters -> Bool
$c== :: DescribeClusters -> DescribeClusters -> Bool
Prelude.Eq, ReadPrec [DescribeClusters]
ReadPrec DescribeClusters
Int -> ReadS DescribeClusters
ReadS [DescribeClusters]
(Int -> ReadS DescribeClusters)
-> ReadS [DescribeClusters]
-> ReadPrec DescribeClusters
-> ReadPrec [DescribeClusters]
-> Read DescribeClusters
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeClusters]
$creadListPrec :: ReadPrec [DescribeClusters]
readPrec :: ReadPrec DescribeClusters
$creadPrec :: ReadPrec DescribeClusters
readList :: ReadS [DescribeClusters]
$creadList :: ReadS [DescribeClusters]
readsPrec :: Int -> ReadS DescribeClusters
$creadsPrec :: Int -> ReadS DescribeClusters
Prelude.Read, Int -> DescribeClusters -> ShowS
[DescribeClusters] -> ShowS
DescribeClusters -> String
(Int -> DescribeClusters -> ShowS)
-> (DescribeClusters -> String)
-> ([DescribeClusters] -> ShowS)
-> Show DescribeClusters
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeClusters] -> ShowS
$cshowList :: [DescribeClusters] -> ShowS
show :: DescribeClusters -> String
$cshow :: DescribeClusters -> String
showsPrec :: Int -> DescribeClusters -> ShowS
$cshowsPrec :: Int -> DescribeClusters -> ShowS
Prelude.Show, (forall x. DescribeClusters -> Rep DescribeClusters x)
-> (forall x. Rep DescribeClusters x -> DescribeClusters)
-> Generic DescribeClusters
forall x. Rep DescribeClusters x -> DescribeClusters
forall x. DescribeClusters -> Rep DescribeClusters x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeClusters x -> DescribeClusters
$cfrom :: forall x. DescribeClusters -> Rep DescribeClusters x
Prelude.Generic)

-- |
-- Create a value of 'DescribeClusters' 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:
--
-- 'tagValues', 'describeClusters_tagValues' - A tag value or values for which you want to return all matching clusters
-- that are associated with the specified tag value or values. For example,
-- suppose that you have clusters that are tagged with values called
-- @admin@ and @test@. If you specify both of these tag values in the
-- request, Amazon Redshift returns a response with the clusters that have
-- either or both of these tag values associated with them.
--
-- 'tagKeys', 'describeClusters_tagKeys' - A tag key or keys for which you want to return all matching clusters
-- that are associated with the specified key or keys. For example, suppose
-- that you have clusters that are tagged with keys called @owner@ and
-- @environment@. If you specify both of these tag keys in the request,
-- Amazon Redshift returns a response with the clusters that have either or
-- both of these tag keys associated with them.
--
-- 'clusterIdentifier', 'describeClusters_clusterIdentifier' - The unique identifier of a cluster whose properties you are requesting.
-- This parameter is case sensitive.
--
-- The default is that all clusters defined for an account are returned.
--
-- 'marker', 'describeClusters_marker' - An optional parameter that specifies the starting point to return a set
-- of response records. When the results of a DescribeClusters request
-- exceed the value specified in @MaxRecords@, Amazon Web Services returns
-- a value in the @Marker@ field of the response. You can retrieve the next
-- set of response records by providing the returned marker value in the
-- @Marker@ parameter and retrying the request.
--
-- Constraints: You can specify either the __ClusterIdentifier__ parameter
-- or the __Marker__ parameter, but not both.
--
-- 'maxRecords', 'describeClusters_maxRecords' - The maximum number of response records to return in each call. If the
-- number of remaining response records exceeds the specified @MaxRecords@
-- value, a value is returned in a @marker@ field of the response. You can
-- retrieve the next set of records by retrying the command with the
-- returned marker value.
--
-- Default: @100@
--
-- Constraints: minimum 20, maximum 100.
newDescribeClusters ::
  DescribeClusters
newDescribeClusters :: DescribeClusters
newDescribeClusters =
  DescribeClusters' :: Maybe [Text]
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe Int
-> DescribeClusters
DescribeClusters'
    { $sel:tagValues:DescribeClusters' :: Maybe [Text]
tagValues = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:tagKeys:DescribeClusters' :: Maybe [Text]
tagKeys = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:clusterIdentifier:DescribeClusters' :: Maybe Text
clusterIdentifier = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:marker:DescribeClusters' :: Maybe Text
marker = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxRecords:DescribeClusters' :: Maybe Int
maxRecords = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | A tag value or values for which you want to return all matching clusters
-- that are associated with the specified tag value or values. For example,
-- suppose that you have clusters that are tagged with values called
-- @admin@ and @test@. If you specify both of these tag values in the
-- request, Amazon Redshift returns a response with the clusters that have
-- either or both of these tag values associated with them.
describeClusters_tagValues :: Lens.Lens' DescribeClusters (Prelude.Maybe [Prelude.Text])
describeClusters_tagValues :: (Maybe [Text] -> f (Maybe [Text]))
-> DescribeClusters -> f DescribeClusters
describeClusters_tagValues = (DescribeClusters -> Maybe [Text])
-> (DescribeClusters -> Maybe [Text] -> DescribeClusters)
-> Lens
     DescribeClusters DescribeClusters (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeClusters' {Maybe [Text]
tagValues :: Maybe [Text]
$sel:tagValues:DescribeClusters' :: DescribeClusters -> Maybe [Text]
tagValues} -> Maybe [Text]
tagValues) (\s :: DescribeClusters
s@DescribeClusters' {} Maybe [Text]
a -> DescribeClusters
s {$sel:tagValues:DescribeClusters' :: Maybe [Text]
tagValues = Maybe [Text]
a} :: DescribeClusters) ((Maybe [Text] -> f (Maybe [Text]))
 -> DescribeClusters -> f DescribeClusters)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> DescribeClusters
-> f DescribeClusters
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A tag key or keys for which you want to return all matching clusters
-- that are associated with the specified key or keys. For example, suppose
-- that you have clusters that are tagged with keys called @owner@ and
-- @environment@. If you specify both of these tag keys in the request,
-- Amazon Redshift returns a response with the clusters that have either or
-- both of these tag keys associated with them.
describeClusters_tagKeys :: Lens.Lens' DescribeClusters (Prelude.Maybe [Prelude.Text])
describeClusters_tagKeys :: (Maybe [Text] -> f (Maybe [Text]))
-> DescribeClusters -> f DescribeClusters
describeClusters_tagKeys = (DescribeClusters -> Maybe [Text])
-> (DescribeClusters -> Maybe [Text] -> DescribeClusters)
-> Lens
     DescribeClusters DescribeClusters (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeClusters' {Maybe [Text]
tagKeys :: Maybe [Text]
$sel:tagKeys:DescribeClusters' :: DescribeClusters -> Maybe [Text]
tagKeys} -> Maybe [Text]
tagKeys) (\s :: DescribeClusters
s@DescribeClusters' {} Maybe [Text]
a -> DescribeClusters
s {$sel:tagKeys:DescribeClusters' :: Maybe [Text]
tagKeys = Maybe [Text]
a} :: DescribeClusters) ((Maybe [Text] -> f (Maybe [Text]))
 -> DescribeClusters -> f DescribeClusters)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> DescribeClusters
-> f DescribeClusters
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The unique identifier of a cluster whose properties you are requesting.
-- This parameter is case sensitive.
--
-- The default is that all clusters defined for an account are returned.
describeClusters_clusterIdentifier :: Lens.Lens' DescribeClusters (Prelude.Maybe Prelude.Text)
describeClusters_clusterIdentifier :: (Maybe Text -> f (Maybe Text))
-> DescribeClusters -> f DescribeClusters
describeClusters_clusterIdentifier = (DescribeClusters -> Maybe Text)
-> (DescribeClusters -> Maybe Text -> DescribeClusters)
-> Lens DescribeClusters DescribeClusters (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeClusters' {Maybe Text
clusterIdentifier :: Maybe Text
$sel:clusterIdentifier:DescribeClusters' :: DescribeClusters -> Maybe Text
clusterIdentifier} -> Maybe Text
clusterIdentifier) (\s :: DescribeClusters
s@DescribeClusters' {} Maybe Text
a -> DescribeClusters
s {$sel:clusterIdentifier:DescribeClusters' :: Maybe Text
clusterIdentifier = Maybe Text
a} :: DescribeClusters)

-- | An optional parameter that specifies the starting point to return a set
-- of response records. When the results of a DescribeClusters request
-- exceed the value specified in @MaxRecords@, Amazon Web Services returns
-- a value in the @Marker@ field of the response. You can retrieve the next
-- set of response records by providing the returned marker value in the
-- @Marker@ parameter and retrying the request.
--
-- Constraints: You can specify either the __ClusterIdentifier__ parameter
-- or the __Marker__ parameter, but not both.
describeClusters_marker :: Lens.Lens' DescribeClusters (Prelude.Maybe Prelude.Text)
describeClusters_marker :: (Maybe Text -> f (Maybe Text))
-> DescribeClusters -> f DescribeClusters
describeClusters_marker = (DescribeClusters -> Maybe Text)
-> (DescribeClusters -> Maybe Text -> DescribeClusters)
-> Lens DescribeClusters DescribeClusters (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeClusters' {Maybe Text
marker :: Maybe Text
$sel:marker:DescribeClusters' :: DescribeClusters -> Maybe Text
marker} -> Maybe Text
marker) (\s :: DescribeClusters
s@DescribeClusters' {} Maybe Text
a -> DescribeClusters
s {$sel:marker:DescribeClusters' :: Maybe Text
marker = Maybe Text
a} :: DescribeClusters)

-- | The maximum number of response records to return in each call. If the
-- number of remaining response records exceeds the specified @MaxRecords@
-- value, a value is returned in a @marker@ field of the response. You can
-- retrieve the next set of records by retrying the command with the
-- returned marker value.
--
-- Default: @100@
--
-- Constraints: minimum 20, maximum 100.
describeClusters_maxRecords :: Lens.Lens' DescribeClusters (Prelude.Maybe Prelude.Int)
describeClusters_maxRecords :: (Maybe Int -> f (Maybe Int))
-> DescribeClusters -> f DescribeClusters
describeClusters_maxRecords = (DescribeClusters -> Maybe Int)
-> (DescribeClusters -> Maybe Int -> DescribeClusters)
-> Lens DescribeClusters DescribeClusters (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeClusters' {Maybe Int
maxRecords :: Maybe Int
$sel:maxRecords:DescribeClusters' :: DescribeClusters -> Maybe Int
maxRecords} -> Maybe Int
maxRecords) (\s :: DescribeClusters
s@DescribeClusters' {} Maybe Int
a -> DescribeClusters
s {$sel:maxRecords:DescribeClusters' :: Maybe Int
maxRecords = Maybe Int
a} :: DescribeClusters)

instance Core.AWSPager DescribeClusters where
  page :: DescribeClusters
-> AWSResponse DescribeClusters -> Maybe DescribeClusters
page DescribeClusters
rq AWSResponse DescribeClusters
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeClusters
DescribeClustersResponse
rs
            DescribeClustersResponse
-> Getting (First Text) DescribeClustersResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeClustersResponse
-> Const (First Text) DescribeClustersResponse
Lens' DescribeClustersResponse (Maybe Text)
describeClustersResponse_marker ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeClustersResponse
 -> Const (First Text) DescribeClustersResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeClustersResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe DescribeClusters
forall a. Maybe a
Prelude.Nothing
    | Maybe [Cluster] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeClusters
DescribeClustersResponse
rs
            DescribeClustersResponse
-> Getting (First [Cluster]) DescribeClustersResponse [Cluster]
-> Maybe [Cluster]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [Cluster] -> Const (First [Cluster]) (Maybe [Cluster]))
-> DescribeClustersResponse
-> Const (First [Cluster]) DescribeClustersResponse
Lens' DescribeClustersResponse (Maybe [Cluster])
describeClustersResponse_clusters
              ((Maybe [Cluster] -> Const (First [Cluster]) (Maybe [Cluster]))
 -> DescribeClustersResponse
 -> Const (First [Cluster]) DescribeClustersResponse)
-> (([Cluster] -> Const (First [Cluster]) [Cluster])
    -> Maybe [Cluster] -> Const (First [Cluster]) (Maybe [Cluster]))
-> Getting (First [Cluster]) DescribeClustersResponse [Cluster]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Cluster] -> Const (First [Cluster]) [Cluster])
-> Maybe [Cluster] -> Const (First [Cluster]) (Maybe [Cluster])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe DescribeClusters
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      DescribeClusters -> Maybe DescribeClusters
forall a. a -> Maybe a
Prelude.Just (DescribeClusters -> Maybe DescribeClusters)
-> DescribeClusters -> Maybe DescribeClusters
forall a b. (a -> b) -> a -> b
Prelude.$
        DescribeClusters
rq
          DescribeClusters
-> (DescribeClusters -> DescribeClusters) -> DescribeClusters
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> DescribeClusters -> Identity DescribeClusters
Lens DescribeClusters DescribeClusters (Maybe Text) (Maybe Text)
describeClusters_marker
          ((Maybe Text -> Identity (Maybe Text))
 -> DescribeClusters -> Identity DescribeClusters)
-> Maybe Text -> DescribeClusters -> DescribeClusters
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse DescribeClusters
DescribeClustersResponse
rs
          DescribeClustersResponse
-> Getting (First Text) DescribeClustersResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeClustersResponse
-> Const (First Text) DescribeClustersResponse
Lens' DescribeClustersResponse (Maybe Text)
describeClustersResponse_marker ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeClustersResponse
 -> Const (First Text) DescribeClustersResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeClustersResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest DescribeClusters where
  type
    AWSResponse DescribeClusters =
      DescribeClustersResponse
  request :: DescribeClusters -> Request DescribeClusters
request = Service -> DescribeClusters -> Request DescribeClusters
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeClusters
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeClusters)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse DescribeClusters))
-> Logger
-> Service
-> Proxy DescribeClusters
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeClusters)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"DescribeClustersResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe Text -> Maybe [Cluster] -> Int -> DescribeClustersResponse
DescribeClustersResponse'
            (Maybe Text -> Maybe [Cluster] -> Int -> DescribeClustersResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe [Cluster] -> Int -> DescribeClustersResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Marker")
            Either String (Maybe [Cluster] -> Int -> DescribeClustersResponse)
-> Either String (Maybe [Cluster])
-> Either String (Int -> DescribeClustersResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Clusters" Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                            Either String [Node]
-> ([Node] -> Either String (Maybe [Cluster]))
-> Either String (Maybe [Cluster])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [Cluster])
-> [Node] -> Either String (Maybe [Cluster])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [Cluster]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"Cluster")
                        )
            Either String (Int -> DescribeClustersResponse)
-> Either String Int -> Either String DescribeClustersResponse
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 DescribeClusters

instance Prelude.NFData DescribeClusters

instance Core.ToHeaders DescribeClusters where
  toHeaders :: DescribeClusters -> ResponseHeaders
toHeaders = ResponseHeaders -> DescribeClusters -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToPath DescribeClusters where
  toPath :: DescribeClusters -> ByteString
toPath = ByteString -> DescribeClusters -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery DescribeClusters where
  toQuery :: DescribeClusters -> QueryString
toQuery DescribeClusters' {Maybe Int
Maybe [Text]
Maybe Text
maxRecords :: Maybe Int
marker :: Maybe Text
clusterIdentifier :: Maybe Text
tagKeys :: Maybe [Text]
tagValues :: Maybe [Text]
$sel:maxRecords:DescribeClusters' :: DescribeClusters -> Maybe Int
$sel:marker:DescribeClusters' :: DescribeClusters -> Maybe Text
$sel:clusterIdentifier:DescribeClusters' :: DescribeClusters -> Maybe Text
$sel:tagKeys:DescribeClusters' :: DescribeClusters -> Maybe [Text]
$sel:tagValues:DescribeClusters' :: DescribeClusters -> Maybe [Text]
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"DescribeClusters" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2012-12-01" :: Prelude.ByteString),
        ByteString
"TagValues"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            (ByteString -> [Text] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"TagValue" ([Text] -> QueryString) -> Maybe [Text] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
tagValues),
        ByteString
"TagKeys"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            (ByteString -> [Text] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"TagKey" ([Text] -> QueryString) -> Maybe [Text] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
tagKeys),
        ByteString
"ClusterIdentifier" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
clusterIdentifier,
        ByteString
"Marker" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
marker,
        ByteString
"MaxRecords" ByteString -> Maybe Int -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Int
maxRecords
      ]

-- | Contains the output from the DescribeClusters action.
--
-- /See:/ 'newDescribeClustersResponse' smart constructor.
data DescribeClustersResponse = DescribeClustersResponse'
  { -- | A value that indicates the starting point for the next set of response
    -- records in a subsequent request. If a value is returned in a response,
    -- you can retrieve the next set of records by providing this returned
    -- marker value in the @Marker@ parameter and retrying the command. If the
    -- @Marker@ field is empty, all response records have been retrieved for
    -- the request.
    DescribeClustersResponse -> Maybe Text
marker :: Prelude.Maybe Prelude.Text,
    -- | A list of @Cluster@ objects, where each object describes one cluster.
    DescribeClustersResponse -> Maybe [Cluster]
clusters :: Prelude.Maybe [Cluster],
    -- | The response's http status code.
    DescribeClustersResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeClustersResponse -> DescribeClustersResponse -> Bool
(DescribeClustersResponse -> DescribeClustersResponse -> Bool)
-> (DescribeClustersResponse -> DescribeClustersResponse -> Bool)
-> Eq DescribeClustersResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeClustersResponse -> DescribeClustersResponse -> Bool
$c/= :: DescribeClustersResponse -> DescribeClustersResponse -> Bool
== :: DescribeClustersResponse -> DescribeClustersResponse -> Bool
$c== :: DescribeClustersResponse -> DescribeClustersResponse -> Bool
Prelude.Eq, ReadPrec [DescribeClustersResponse]
ReadPrec DescribeClustersResponse
Int -> ReadS DescribeClustersResponse
ReadS [DescribeClustersResponse]
(Int -> ReadS DescribeClustersResponse)
-> ReadS [DescribeClustersResponse]
-> ReadPrec DescribeClustersResponse
-> ReadPrec [DescribeClustersResponse]
-> Read DescribeClustersResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeClustersResponse]
$creadListPrec :: ReadPrec [DescribeClustersResponse]
readPrec :: ReadPrec DescribeClustersResponse
$creadPrec :: ReadPrec DescribeClustersResponse
readList :: ReadS [DescribeClustersResponse]
$creadList :: ReadS [DescribeClustersResponse]
readsPrec :: Int -> ReadS DescribeClustersResponse
$creadsPrec :: Int -> ReadS DescribeClustersResponse
Prelude.Read, Int -> DescribeClustersResponse -> ShowS
[DescribeClustersResponse] -> ShowS
DescribeClustersResponse -> String
(Int -> DescribeClustersResponse -> ShowS)
-> (DescribeClustersResponse -> String)
-> ([DescribeClustersResponse] -> ShowS)
-> Show DescribeClustersResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeClustersResponse] -> ShowS
$cshowList :: [DescribeClustersResponse] -> ShowS
show :: DescribeClustersResponse -> String
$cshow :: DescribeClustersResponse -> String
showsPrec :: Int -> DescribeClustersResponse -> ShowS
$cshowsPrec :: Int -> DescribeClustersResponse -> ShowS
Prelude.Show, (forall x.
 DescribeClustersResponse -> Rep DescribeClustersResponse x)
-> (forall x.
    Rep DescribeClustersResponse x -> DescribeClustersResponse)
-> Generic DescribeClustersResponse
forall x.
Rep DescribeClustersResponse x -> DescribeClustersResponse
forall x.
DescribeClustersResponse -> Rep DescribeClustersResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeClustersResponse x -> DescribeClustersResponse
$cfrom :: forall x.
DescribeClustersResponse -> Rep DescribeClustersResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeClustersResponse' 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:
--
-- 'marker', 'describeClustersResponse_marker' - A value that indicates the starting point for the next set of response
-- records in a subsequent request. If a value is returned in a response,
-- you can retrieve the next set of records by providing this returned
-- marker value in the @Marker@ parameter and retrying the command. If the
-- @Marker@ field is empty, all response records have been retrieved for
-- the request.
--
-- 'clusters', 'describeClustersResponse_clusters' - A list of @Cluster@ objects, where each object describes one cluster.
--
-- 'httpStatus', 'describeClustersResponse_httpStatus' - The response's http status code.
newDescribeClustersResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeClustersResponse
newDescribeClustersResponse :: Int -> DescribeClustersResponse
newDescribeClustersResponse Int
pHttpStatus_ =
  DescribeClustersResponse' :: Maybe Text -> Maybe [Cluster] -> Int -> DescribeClustersResponse
DescribeClustersResponse'
    { $sel:marker:DescribeClustersResponse' :: Maybe Text
marker = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:clusters:DescribeClustersResponse' :: Maybe [Cluster]
clusters = Maybe [Cluster]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeClustersResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A value that indicates the starting point for the next set of response
-- records in a subsequent request. If a value is returned in a response,
-- you can retrieve the next set of records by providing this returned
-- marker value in the @Marker@ parameter and retrying the command. If the
-- @Marker@ field is empty, all response records have been retrieved for
-- the request.
describeClustersResponse_marker :: Lens.Lens' DescribeClustersResponse (Prelude.Maybe Prelude.Text)
describeClustersResponse_marker :: (Maybe Text -> f (Maybe Text))
-> DescribeClustersResponse -> f DescribeClustersResponse
describeClustersResponse_marker = (DescribeClustersResponse -> Maybe Text)
-> (DescribeClustersResponse
    -> Maybe Text -> DescribeClustersResponse)
-> Lens' DescribeClustersResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeClustersResponse' {Maybe Text
marker :: Maybe Text
$sel:marker:DescribeClustersResponse' :: DescribeClustersResponse -> Maybe Text
marker} -> Maybe Text
marker) (\s :: DescribeClustersResponse
s@DescribeClustersResponse' {} Maybe Text
a -> DescribeClustersResponse
s {$sel:marker:DescribeClustersResponse' :: Maybe Text
marker = Maybe Text
a} :: DescribeClustersResponse)

-- | A list of @Cluster@ objects, where each object describes one cluster.
describeClustersResponse_clusters :: Lens.Lens' DescribeClustersResponse (Prelude.Maybe [Cluster])
describeClustersResponse_clusters :: (Maybe [Cluster] -> f (Maybe [Cluster]))
-> DescribeClustersResponse -> f DescribeClustersResponse
describeClustersResponse_clusters = (DescribeClustersResponse -> Maybe [Cluster])
-> (DescribeClustersResponse
    -> Maybe [Cluster] -> DescribeClustersResponse)
-> Lens' DescribeClustersResponse (Maybe [Cluster])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeClustersResponse' {Maybe [Cluster]
clusters :: Maybe [Cluster]
$sel:clusters:DescribeClustersResponse' :: DescribeClustersResponse -> Maybe [Cluster]
clusters} -> Maybe [Cluster]
clusters) (\s :: DescribeClustersResponse
s@DescribeClustersResponse' {} Maybe [Cluster]
a -> DescribeClustersResponse
s {$sel:clusters:DescribeClustersResponse' :: Maybe [Cluster]
clusters = Maybe [Cluster]
a} :: DescribeClustersResponse) ((Maybe [Cluster] -> f (Maybe [Cluster]))
 -> DescribeClustersResponse -> f DescribeClustersResponse)
-> ((Maybe [Cluster] -> f (Maybe [Cluster]))
    -> Maybe [Cluster] -> f (Maybe [Cluster]))
-> (Maybe [Cluster] -> f (Maybe [Cluster]))
-> DescribeClustersResponse
-> f DescribeClustersResponse
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.
describeClustersResponse_httpStatus :: Lens.Lens' DescribeClustersResponse Prelude.Int
describeClustersResponse_httpStatus :: (Int -> f Int)
-> DescribeClustersResponse -> f DescribeClustersResponse
describeClustersResponse_httpStatus = (DescribeClustersResponse -> Int)
-> (DescribeClustersResponse -> Int -> DescribeClustersResponse)
-> Lens DescribeClustersResponse DescribeClustersResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeClustersResponse' {Int
httpStatus :: Int
$sel:httpStatus:DescribeClustersResponse' :: DescribeClustersResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DescribeClustersResponse
s@DescribeClustersResponse' {} Int
a -> DescribeClustersResponse
s {$sel:httpStatus:DescribeClustersResponse' :: Int
httpStatus = Int
a} :: DescribeClustersResponse)

instance Prelude.NFData DescribeClustersResponse