{-# 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.ElastiCache.DescribeSnapshots
-- 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 information about cluster or replication group snapshots. By
-- default, @DescribeSnapshots@ lists all of your snapshots; it can
-- optionally describe a single snapshot, or just the snapshots associated
-- with a particular cache cluster.
--
-- This operation is valid for Redis only.
--
-- This operation returns paginated results.
module Amazonka.ElastiCache.DescribeSnapshots
  ( -- * Creating a Request
    DescribeSnapshots (..),
    newDescribeSnapshots,

    -- * Request Lenses
    describeSnapshots_cacheClusterId,
    describeSnapshots_marker,
    describeSnapshots_maxRecords,
    describeSnapshots_snapshotName,
    describeSnapshots_showNodeGroupConfig,
    describeSnapshots_replicationGroupId,
    describeSnapshots_snapshotSource,

    -- * Destructuring the Response
    DescribeSnapshotsResponse (..),
    newDescribeSnapshotsResponse,

    -- * Response Lenses
    describeSnapshotsResponse_snapshots,
    describeSnapshotsResponse_marker,
    describeSnapshotsResponse_httpStatus,
  )
where

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

-- | Represents the input of a @DescribeSnapshotsMessage@ operation.
--
-- /See:/ 'newDescribeSnapshots' smart constructor.
data DescribeSnapshots = DescribeSnapshots'
  { -- | A user-supplied cluster identifier. If this parameter is specified, only
    -- snapshots associated with that specific cluster are described.
    DescribeSnapshots -> Maybe Text
cacheClusterId :: Prelude.Maybe Prelude.Text,
    -- | An optional marker returned from a prior request. Use this marker for
    -- pagination of results from this operation. If this parameter is
    -- specified, the response includes only records beyond the marker, up to
    -- the value specified by @MaxRecords@.
    DescribeSnapshots -> Maybe Text
marker :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of records to include in the response. If more
    -- records exist than the specified @MaxRecords@ value, a marker is
    -- included in the response so that the remaining results can be retrieved.
    --
    -- Default: 50
    --
    -- Constraints: minimum 20; maximum 50.
    DescribeSnapshots -> Maybe Int
maxRecords :: Prelude.Maybe Prelude.Int,
    -- | A user-supplied name of the snapshot. If this parameter is specified,
    -- only this snapshot are described.
    DescribeSnapshots -> Maybe Text
snapshotName :: Prelude.Maybe Prelude.Text,
    -- | A Boolean value which if true, the node group (shard) configuration is
    -- included in the snapshot description.
    DescribeSnapshots -> Maybe Bool
showNodeGroupConfig :: Prelude.Maybe Prelude.Bool,
    -- | A user-supplied replication group identifier. If this parameter is
    -- specified, only snapshots associated with that specific replication
    -- group are described.
    DescribeSnapshots -> Maybe Text
replicationGroupId :: Prelude.Maybe Prelude.Text,
    -- | If set to @system@, the output shows snapshots that were automatically
    -- created by ElastiCache. If set to @user@ the output shows snapshots that
    -- were manually created. If omitted, the output shows both automatically
    -- and manually created snapshots.
    DescribeSnapshots -> Maybe Text
snapshotSource :: Prelude.Maybe Prelude.Text
  }
  deriving (DescribeSnapshots -> DescribeSnapshots -> Bool
(DescribeSnapshots -> DescribeSnapshots -> Bool)
-> (DescribeSnapshots -> DescribeSnapshots -> Bool)
-> Eq DescribeSnapshots
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeSnapshots -> DescribeSnapshots -> Bool
$c/= :: DescribeSnapshots -> DescribeSnapshots -> Bool
== :: DescribeSnapshots -> DescribeSnapshots -> Bool
$c== :: DescribeSnapshots -> DescribeSnapshots -> Bool
Prelude.Eq, ReadPrec [DescribeSnapshots]
ReadPrec DescribeSnapshots
Int -> ReadS DescribeSnapshots
ReadS [DescribeSnapshots]
(Int -> ReadS DescribeSnapshots)
-> ReadS [DescribeSnapshots]
-> ReadPrec DescribeSnapshots
-> ReadPrec [DescribeSnapshots]
-> Read DescribeSnapshots
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeSnapshots]
$creadListPrec :: ReadPrec [DescribeSnapshots]
readPrec :: ReadPrec DescribeSnapshots
$creadPrec :: ReadPrec DescribeSnapshots
readList :: ReadS [DescribeSnapshots]
$creadList :: ReadS [DescribeSnapshots]
readsPrec :: Int -> ReadS DescribeSnapshots
$creadsPrec :: Int -> ReadS DescribeSnapshots
Prelude.Read, Int -> DescribeSnapshots -> ShowS
[DescribeSnapshots] -> ShowS
DescribeSnapshots -> String
(Int -> DescribeSnapshots -> ShowS)
-> (DescribeSnapshots -> String)
-> ([DescribeSnapshots] -> ShowS)
-> Show DescribeSnapshots
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeSnapshots] -> ShowS
$cshowList :: [DescribeSnapshots] -> ShowS
show :: DescribeSnapshots -> String
$cshow :: DescribeSnapshots -> String
showsPrec :: Int -> DescribeSnapshots -> ShowS
$cshowsPrec :: Int -> DescribeSnapshots -> ShowS
Prelude.Show, (forall x. DescribeSnapshots -> Rep DescribeSnapshots x)
-> (forall x. Rep DescribeSnapshots x -> DescribeSnapshots)
-> Generic DescribeSnapshots
forall x. Rep DescribeSnapshots x -> DescribeSnapshots
forall x. DescribeSnapshots -> Rep DescribeSnapshots x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeSnapshots x -> DescribeSnapshots
$cfrom :: forall x. DescribeSnapshots -> Rep DescribeSnapshots x
Prelude.Generic)

-- |
-- Create a value of 'DescribeSnapshots' 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:
--
-- 'cacheClusterId', 'describeSnapshots_cacheClusterId' - A user-supplied cluster identifier. If this parameter is specified, only
-- snapshots associated with that specific cluster are described.
--
-- 'marker', 'describeSnapshots_marker' - An optional marker returned from a prior request. Use this marker for
-- pagination of results from this operation. If this parameter is
-- specified, the response includes only records beyond the marker, up to
-- the value specified by @MaxRecords@.
--
-- 'maxRecords', 'describeSnapshots_maxRecords' - The maximum number of records to include in the response. If more
-- records exist than the specified @MaxRecords@ value, a marker is
-- included in the response so that the remaining results can be retrieved.
--
-- Default: 50
--
-- Constraints: minimum 20; maximum 50.
--
-- 'snapshotName', 'describeSnapshots_snapshotName' - A user-supplied name of the snapshot. If this parameter is specified,
-- only this snapshot are described.
--
-- 'showNodeGroupConfig', 'describeSnapshots_showNodeGroupConfig' - A Boolean value which if true, the node group (shard) configuration is
-- included in the snapshot description.
--
-- 'replicationGroupId', 'describeSnapshots_replicationGroupId' - A user-supplied replication group identifier. If this parameter is
-- specified, only snapshots associated with that specific replication
-- group are described.
--
-- 'snapshotSource', 'describeSnapshots_snapshotSource' - If set to @system@, the output shows snapshots that were automatically
-- created by ElastiCache. If set to @user@ the output shows snapshots that
-- were manually created. If omitted, the output shows both automatically
-- and manually created snapshots.
newDescribeSnapshots ::
  DescribeSnapshots
newDescribeSnapshots :: DescribeSnapshots
newDescribeSnapshots =
  DescribeSnapshots' :: Maybe Text
-> Maybe Text
-> Maybe Int
-> Maybe Text
-> Maybe Bool
-> Maybe Text
-> Maybe Text
-> DescribeSnapshots
DescribeSnapshots'
    { $sel:cacheClusterId:DescribeSnapshots' :: Maybe Text
cacheClusterId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:marker:DescribeSnapshots' :: Maybe Text
marker = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxRecords:DescribeSnapshots' :: Maybe Int
maxRecords = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:snapshotName:DescribeSnapshots' :: Maybe Text
snapshotName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:showNodeGroupConfig:DescribeSnapshots' :: Maybe Bool
showNodeGroupConfig = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:replicationGroupId:DescribeSnapshots' :: Maybe Text
replicationGroupId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:snapshotSource:DescribeSnapshots' :: Maybe Text
snapshotSource = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | A user-supplied cluster identifier. If this parameter is specified, only
-- snapshots associated with that specific cluster are described.
describeSnapshots_cacheClusterId :: Lens.Lens' DescribeSnapshots (Prelude.Maybe Prelude.Text)
describeSnapshots_cacheClusterId :: (Maybe Text -> f (Maybe Text))
-> DescribeSnapshots -> f DescribeSnapshots
describeSnapshots_cacheClusterId = (DescribeSnapshots -> Maybe Text)
-> (DescribeSnapshots -> Maybe Text -> DescribeSnapshots)
-> Lens
     DescribeSnapshots DescribeSnapshots (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSnapshots' {Maybe Text
cacheClusterId :: Maybe Text
$sel:cacheClusterId:DescribeSnapshots' :: DescribeSnapshots -> Maybe Text
cacheClusterId} -> Maybe Text
cacheClusterId) (\s :: DescribeSnapshots
s@DescribeSnapshots' {} Maybe Text
a -> DescribeSnapshots
s {$sel:cacheClusterId:DescribeSnapshots' :: Maybe Text
cacheClusterId = Maybe Text
a} :: DescribeSnapshots)

-- | An optional marker returned from a prior request. Use this marker for
-- pagination of results from this operation. If this parameter is
-- specified, the response includes only records beyond the marker, up to
-- the value specified by @MaxRecords@.
describeSnapshots_marker :: Lens.Lens' DescribeSnapshots (Prelude.Maybe Prelude.Text)
describeSnapshots_marker :: (Maybe Text -> f (Maybe Text))
-> DescribeSnapshots -> f DescribeSnapshots
describeSnapshots_marker = (DescribeSnapshots -> Maybe Text)
-> (DescribeSnapshots -> Maybe Text -> DescribeSnapshots)
-> Lens
     DescribeSnapshots DescribeSnapshots (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSnapshots' {Maybe Text
marker :: Maybe Text
$sel:marker:DescribeSnapshots' :: DescribeSnapshots -> Maybe Text
marker} -> Maybe Text
marker) (\s :: DescribeSnapshots
s@DescribeSnapshots' {} Maybe Text
a -> DescribeSnapshots
s {$sel:marker:DescribeSnapshots' :: Maybe Text
marker = Maybe Text
a} :: DescribeSnapshots)

-- | The maximum number of records to include in the response. If more
-- records exist than the specified @MaxRecords@ value, a marker is
-- included in the response so that the remaining results can be retrieved.
--
-- Default: 50
--
-- Constraints: minimum 20; maximum 50.
describeSnapshots_maxRecords :: Lens.Lens' DescribeSnapshots (Prelude.Maybe Prelude.Int)
describeSnapshots_maxRecords :: (Maybe Int -> f (Maybe Int))
-> DescribeSnapshots -> f DescribeSnapshots
describeSnapshots_maxRecords = (DescribeSnapshots -> Maybe Int)
-> (DescribeSnapshots -> Maybe Int -> DescribeSnapshots)
-> Lens DescribeSnapshots DescribeSnapshots (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSnapshots' {Maybe Int
maxRecords :: Maybe Int
$sel:maxRecords:DescribeSnapshots' :: DescribeSnapshots -> Maybe Int
maxRecords} -> Maybe Int
maxRecords) (\s :: DescribeSnapshots
s@DescribeSnapshots' {} Maybe Int
a -> DescribeSnapshots
s {$sel:maxRecords:DescribeSnapshots' :: Maybe Int
maxRecords = Maybe Int
a} :: DescribeSnapshots)

-- | A user-supplied name of the snapshot. If this parameter is specified,
-- only this snapshot are described.
describeSnapshots_snapshotName :: Lens.Lens' DescribeSnapshots (Prelude.Maybe Prelude.Text)
describeSnapshots_snapshotName :: (Maybe Text -> f (Maybe Text))
-> DescribeSnapshots -> f DescribeSnapshots
describeSnapshots_snapshotName = (DescribeSnapshots -> Maybe Text)
-> (DescribeSnapshots -> Maybe Text -> DescribeSnapshots)
-> Lens
     DescribeSnapshots DescribeSnapshots (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSnapshots' {Maybe Text
snapshotName :: Maybe Text
$sel:snapshotName:DescribeSnapshots' :: DescribeSnapshots -> Maybe Text
snapshotName} -> Maybe Text
snapshotName) (\s :: DescribeSnapshots
s@DescribeSnapshots' {} Maybe Text
a -> DescribeSnapshots
s {$sel:snapshotName:DescribeSnapshots' :: Maybe Text
snapshotName = Maybe Text
a} :: DescribeSnapshots)

-- | A Boolean value which if true, the node group (shard) configuration is
-- included in the snapshot description.
describeSnapshots_showNodeGroupConfig :: Lens.Lens' DescribeSnapshots (Prelude.Maybe Prelude.Bool)
describeSnapshots_showNodeGroupConfig :: (Maybe Bool -> f (Maybe Bool))
-> DescribeSnapshots -> f DescribeSnapshots
describeSnapshots_showNodeGroupConfig = (DescribeSnapshots -> Maybe Bool)
-> (DescribeSnapshots -> Maybe Bool -> DescribeSnapshots)
-> Lens
     DescribeSnapshots DescribeSnapshots (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSnapshots' {Maybe Bool
showNodeGroupConfig :: Maybe Bool
$sel:showNodeGroupConfig:DescribeSnapshots' :: DescribeSnapshots -> Maybe Bool
showNodeGroupConfig} -> Maybe Bool
showNodeGroupConfig) (\s :: DescribeSnapshots
s@DescribeSnapshots' {} Maybe Bool
a -> DescribeSnapshots
s {$sel:showNodeGroupConfig:DescribeSnapshots' :: Maybe Bool
showNodeGroupConfig = Maybe Bool
a} :: DescribeSnapshots)

-- | A user-supplied replication group identifier. If this parameter is
-- specified, only snapshots associated with that specific replication
-- group are described.
describeSnapshots_replicationGroupId :: Lens.Lens' DescribeSnapshots (Prelude.Maybe Prelude.Text)
describeSnapshots_replicationGroupId :: (Maybe Text -> f (Maybe Text))
-> DescribeSnapshots -> f DescribeSnapshots
describeSnapshots_replicationGroupId = (DescribeSnapshots -> Maybe Text)
-> (DescribeSnapshots -> Maybe Text -> DescribeSnapshots)
-> Lens
     DescribeSnapshots DescribeSnapshots (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSnapshots' {Maybe Text
replicationGroupId :: Maybe Text
$sel:replicationGroupId:DescribeSnapshots' :: DescribeSnapshots -> Maybe Text
replicationGroupId} -> Maybe Text
replicationGroupId) (\s :: DescribeSnapshots
s@DescribeSnapshots' {} Maybe Text
a -> DescribeSnapshots
s {$sel:replicationGroupId:DescribeSnapshots' :: Maybe Text
replicationGroupId = Maybe Text
a} :: DescribeSnapshots)

-- | If set to @system@, the output shows snapshots that were automatically
-- created by ElastiCache. If set to @user@ the output shows snapshots that
-- were manually created. If omitted, the output shows both automatically
-- and manually created snapshots.
describeSnapshots_snapshotSource :: Lens.Lens' DescribeSnapshots (Prelude.Maybe Prelude.Text)
describeSnapshots_snapshotSource :: (Maybe Text -> f (Maybe Text))
-> DescribeSnapshots -> f DescribeSnapshots
describeSnapshots_snapshotSource = (DescribeSnapshots -> Maybe Text)
-> (DescribeSnapshots -> Maybe Text -> DescribeSnapshots)
-> Lens
     DescribeSnapshots DescribeSnapshots (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSnapshots' {Maybe Text
snapshotSource :: Maybe Text
$sel:snapshotSource:DescribeSnapshots' :: DescribeSnapshots -> Maybe Text
snapshotSource} -> Maybe Text
snapshotSource) (\s :: DescribeSnapshots
s@DescribeSnapshots' {} Maybe Text
a -> DescribeSnapshots
s {$sel:snapshotSource:DescribeSnapshots' :: Maybe Text
snapshotSource = Maybe Text
a} :: DescribeSnapshots)

instance Core.AWSPager DescribeSnapshots where
  page :: DescribeSnapshots
-> AWSResponse DescribeSnapshots -> Maybe DescribeSnapshots
page DescribeSnapshots
rq AWSResponse DescribeSnapshots
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeSnapshots
DescribeSnapshotsResponse
rs
            DescribeSnapshotsResponse
-> Getting (First Text) DescribeSnapshotsResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeSnapshotsResponse
-> Const (First Text) DescribeSnapshotsResponse
Lens' DescribeSnapshotsResponse (Maybe Text)
describeSnapshotsResponse_marker
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeSnapshotsResponse
 -> Const (First Text) DescribeSnapshotsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeSnapshotsResponse 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 DescribeSnapshots
forall a. Maybe a
Prelude.Nothing
    | Maybe [Snapshot] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeSnapshots
DescribeSnapshotsResponse
rs
            DescribeSnapshotsResponse
-> Getting (First [Snapshot]) DescribeSnapshotsResponse [Snapshot]
-> Maybe [Snapshot]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [Snapshot] -> Const (First [Snapshot]) (Maybe [Snapshot]))
-> DescribeSnapshotsResponse
-> Const (First [Snapshot]) DescribeSnapshotsResponse
Lens' DescribeSnapshotsResponse (Maybe [Snapshot])
describeSnapshotsResponse_snapshots
              ((Maybe [Snapshot] -> Const (First [Snapshot]) (Maybe [Snapshot]))
 -> DescribeSnapshotsResponse
 -> Const (First [Snapshot]) DescribeSnapshotsResponse)
-> (([Snapshot] -> Const (First [Snapshot]) [Snapshot])
    -> Maybe [Snapshot] -> Const (First [Snapshot]) (Maybe [Snapshot]))
-> Getting (First [Snapshot]) DescribeSnapshotsResponse [Snapshot]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Snapshot] -> Const (First [Snapshot]) [Snapshot])
-> Maybe [Snapshot] -> Const (First [Snapshot]) (Maybe [Snapshot])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe DescribeSnapshots
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      DescribeSnapshots -> Maybe DescribeSnapshots
forall a. a -> Maybe a
Prelude.Just (DescribeSnapshots -> Maybe DescribeSnapshots)
-> DescribeSnapshots -> Maybe DescribeSnapshots
forall a b. (a -> b) -> a -> b
Prelude.$
        DescribeSnapshots
rq
          DescribeSnapshots
-> (DescribeSnapshots -> DescribeSnapshots) -> DescribeSnapshots
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> DescribeSnapshots -> Identity DescribeSnapshots
Lens DescribeSnapshots DescribeSnapshots (Maybe Text) (Maybe Text)
describeSnapshots_marker
          ((Maybe Text -> Identity (Maybe Text))
 -> DescribeSnapshots -> Identity DescribeSnapshots)
-> Maybe Text -> DescribeSnapshots -> DescribeSnapshots
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse DescribeSnapshots
DescribeSnapshotsResponse
rs
          DescribeSnapshotsResponse
-> Getting (First Text) DescribeSnapshotsResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeSnapshotsResponse
-> Const (First Text) DescribeSnapshotsResponse
Lens' DescribeSnapshotsResponse (Maybe Text)
describeSnapshotsResponse_marker ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeSnapshotsResponse
 -> Const (First Text) DescribeSnapshotsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeSnapshotsResponse 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 DescribeSnapshots where
  type
    AWSResponse DescribeSnapshots =
      DescribeSnapshotsResponse
  request :: DescribeSnapshots -> Request DescribeSnapshots
request = Service -> DescribeSnapshots -> Request DescribeSnapshots
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeSnapshots
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeSnapshots)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse DescribeSnapshots))
-> Logger
-> Service
-> Proxy DescribeSnapshots
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeSnapshots)))
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
"DescribeSnapshotsResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe [Snapshot] -> Maybe Text -> Int -> DescribeSnapshotsResponse
DescribeSnapshotsResponse'
            (Maybe [Snapshot]
 -> Maybe Text -> Int -> DescribeSnapshotsResponse)
-> Either String (Maybe [Snapshot])
-> Either String (Maybe Text -> Int -> DescribeSnapshotsResponse)
forall (f :: * -> *) a b. Functor 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
"Snapshots" 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 [Snapshot]))
-> Either String (Maybe [Snapshot])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [Snapshot])
-> [Node] -> Either String (Maybe [Snapshot])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [Snapshot]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"Snapshot")
                        )
            Either String (Maybe Text -> Int -> DescribeSnapshotsResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DescribeSnapshotsResponse)
forall (f :: * -> *) a b. Applicative f => 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 (Int -> DescribeSnapshotsResponse)
-> Either String Int -> Either String DescribeSnapshotsResponse
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 DescribeSnapshots

instance Prelude.NFData DescribeSnapshots

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

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

instance Core.ToQuery DescribeSnapshots where
  toQuery :: DescribeSnapshots -> QueryString
toQuery DescribeSnapshots' {Maybe Bool
Maybe Int
Maybe Text
snapshotSource :: Maybe Text
replicationGroupId :: Maybe Text
showNodeGroupConfig :: Maybe Bool
snapshotName :: Maybe Text
maxRecords :: Maybe Int
marker :: Maybe Text
cacheClusterId :: Maybe Text
$sel:snapshotSource:DescribeSnapshots' :: DescribeSnapshots -> Maybe Text
$sel:replicationGroupId:DescribeSnapshots' :: DescribeSnapshots -> Maybe Text
$sel:showNodeGroupConfig:DescribeSnapshots' :: DescribeSnapshots -> Maybe Bool
$sel:snapshotName:DescribeSnapshots' :: DescribeSnapshots -> Maybe Text
$sel:maxRecords:DescribeSnapshots' :: DescribeSnapshots -> Maybe Int
$sel:marker:DescribeSnapshots' :: DescribeSnapshots -> Maybe Text
$sel:cacheClusterId:DescribeSnapshots' :: DescribeSnapshots -> 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
"DescribeSnapshots" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2015-02-02" :: Prelude.ByteString),
        ByteString
"CacheClusterId" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
cacheClusterId,
        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,
        ByteString
"SnapshotName" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
snapshotName,
        ByteString
"ShowNodeGroupConfig" ByteString -> Maybe Bool -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Bool
showNodeGroupConfig,
        ByteString
"ReplicationGroupId" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
replicationGroupId,
        ByteString
"SnapshotSource" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
snapshotSource
      ]

-- | Represents the output of a @DescribeSnapshots@ operation.
--
-- /See:/ 'newDescribeSnapshotsResponse' smart constructor.
data DescribeSnapshotsResponse = DescribeSnapshotsResponse'
  { -- | A list of snapshots. Each item in the list contains detailed information
    -- about one snapshot.
    DescribeSnapshotsResponse -> Maybe [Snapshot]
snapshots :: Prelude.Maybe [Snapshot],
    -- | An optional marker returned from a prior request. Use this marker for
    -- pagination of results from this operation. If this parameter is
    -- specified, the response includes only records beyond the marker, up to
    -- the value specified by @MaxRecords@.
    DescribeSnapshotsResponse -> Maybe Text
marker :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DescribeSnapshotsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeSnapshotsResponse -> DescribeSnapshotsResponse -> Bool
(DescribeSnapshotsResponse -> DescribeSnapshotsResponse -> Bool)
-> (DescribeSnapshotsResponse -> DescribeSnapshotsResponse -> Bool)
-> Eq DescribeSnapshotsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeSnapshotsResponse -> DescribeSnapshotsResponse -> Bool
$c/= :: DescribeSnapshotsResponse -> DescribeSnapshotsResponse -> Bool
== :: DescribeSnapshotsResponse -> DescribeSnapshotsResponse -> Bool
$c== :: DescribeSnapshotsResponse -> DescribeSnapshotsResponse -> Bool
Prelude.Eq, ReadPrec [DescribeSnapshotsResponse]
ReadPrec DescribeSnapshotsResponse
Int -> ReadS DescribeSnapshotsResponse
ReadS [DescribeSnapshotsResponse]
(Int -> ReadS DescribeSnapshotsResponse)
-> ReadS [DescribeSnapshotsResponse]
-> ReadPrec DescribeSnapshotsResponse
-> ReadPrec [DescribeSnapshotsResponse]
-> Read DescribeSnapshotsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeSnapshotsResponse]
$creadListPrec :: ReadPrec [DescribeSnapshotsResponse]
readPrec :: ReadPrec DescribeSnapshotsResponse
$creadPrec :: ReadPrec DescribeSnapshotsResponse
readList :: ReadS [DescribeSnapshotsResponse]
$creadList :: ReadS [DescribeSnapshotsResponse]
readsPrec :: Int -> ReadS DescribeSnapshotsResponse
$creadsPrec :: Int -> ReadS DescribeSnapshotsResponse
Prelude.Read, Int -> DescribeSnapshotsResponse -> ShowS
[DescribeSnapshotsResponse] -> ShowS
DescribeSnapshotsResponse -> String
(Int -> DescribeSnapshotsResponse -> ShowS)
-> (DescribeSnapshotsResponse -> String)
-> ([DescribeSnapshotsResponse] -> ShowS)
-> Show DescribeSnapshotsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeSnapshotsResponse] -> ShowS
$cshowList :: [DescribeSnapshotsResponse] -> ShowS
show :: DescribeSnapshotsResponse -> String
$cshow :: DescribeSnapshotsResponse -> String
showsPrec :: Int -> DescribeSnapshotsResponse -> ShowS
$cshowsPrec :: Int -> DescribeSnapshotsResponse -> ShowS
Prelude.Show, (forall x.
 DescribeSnapshotsResponse -> Rep DescribeSnapshotsResponse x)
-> (forall x.
    Rep DescribeSnapshotsResponse x -> DescribeSnapshotsResponse)
-> Generic DescribeSnapshotsResponse
forall x.
Rep DescribeSnapshotsResponse x -> DescribeSnapshotsResponse
forall x.
DescribeSnapshotsResponse -> Rep DescribeSnapshotsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeSnapshotsResponse x -> DescribeSnapshotsResponse
$cfrom :: forall x.
DescribeSnapshotsResponse -> Rep DescribeSnapshotsResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeSnapshotsResponse' 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:
--
-- 'snapshots', 'describeSnapshotsResponse_snapshots' - A list of snapshots. Each item in the list contains detailed information
-- about one snapshot.
--
-- 'marker', 'describeSnapshotsResponse_marker' - An optional marker returned from a prior request. Use this marker for
-- pagination of results from this operation. If this parameter is
-- specified, the response includes only records beyond the marker, up to
-- the value specified by @MaxRecords@.
--
-- 'httpStatus', 'describeSnapshotsResponse_httpStatus' - The response's http status code.
newDescribeSnapshotsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeSnapshotsResponse
newDescribeSnapshotsResponse :: Int -> DescribeSnapshotsResponse
newDescribeSnapshotsResponse Int
pHttpStatus_ =
  DescribeSnapshotsResponse' :: Maybe [Snapshot] -> Maybe Text -> Int -> DescribeSnapshotsResponse
DescribeSnapshotsResponse'
    { $sel:snapshots:DescribeSnapshotsResponse' :: Maybe [Snapshot]
snapshots =
        Maybe [Snapshot]
forall a. Maybe a
Prelude.Nothing,
      $sel:marker:DescribeSnapshotsResponse' :: Maybe Text
marker = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeSnapshotsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of snapshots. Each item in the list contains detailed information
-- about one snapshot.
describeSnapshotsResponse_snapshots :: Lens.Lens' DescribeSnapshotsResponse (Prelude.Maybe [Snapshot])
describeSnapshotsResponse_snapshots :: (Maybe [Snapshot] -> f (Maybe [Snapshot]))
-> DescribeSnapshotsResponse -> f DescribeSnapshotsResponse
describeSnapshotsResponse_snapshots = (DescribeSnapshotsResponse -> Maybe [Snapshot])
-> (DescribeSnapshotsResponse
    -> Maybe [Snapshot] -> DescribeSnapshotsResponse)
-> Lens' DescribeSnapshotsResponse (Maybe [Snapshot])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSnapshotsResponse' {Maybe [Snapshot]
snapshots :: Maybe [Snapshot]
$sel:snapshots:DescribeSnapshotsResponse' :: DescribeSnapshotsResponse -> Maybe [Snapshot]
snapshots} -> Maybe [Snapshot]
snapshots) (\s :: DescribeSnapshotsResponse
s@DescribeSnapshotsResponse' {} Maybe [Snapshot]
a -> DescribeSnapshotsResponse
s {$sel:snapshots:DescribeSnapshotsResponse' :: Maybe [Snapshot]
snapshots = Maybe [Snapshot]
a} :: DescribeSnapshotsResponse) ((Maybe [Snapshot] -> f (Maybe [Snapshot]))
 -> DescribeSnapshotsResponse -> f DescribeSnapshotsResponse)
-> ((Maybe [Snapshot] -> f (Maybe [Snapshot]))
    -> Maybe [Snapshot] -> f (Maybe [Snapshot]))
-> (Maybe [Snapshot] -> f (Maybe [Snapshot]))
-> DescribeSnapshotsResponse
-> f DescribeSnapshotsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Snapshot] [Snapshot] [Snapshot] [Snapshot]
-> Iso
     (Maybe [Snapshot])
     (Maybe [Snapshot])
     (Maybe [Snapshot])
     (Maybe [Snapshot])
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 [Snapshot] [Snapshot] [Snapshot] [Snapshot]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | An optional marker returned from a prior request. Use this marker for
-- pagination of results from this operation. If this parameter is
-- specified, the response includes only records beyond the marker, up to
-- the value specified by @MaxRecords@.
describeSnapshotsResponse_marker :: Lens.Lens' DescribeSnapshotsResponse (Prelude.Maybe Prelude.Text)
describeSnapshotsResponse_marker :: (Maybe Text -> f (Maybe Text))
-> DescribeSnapshotsResponse -> f DescribeSnapshotsResponse
describeSnapshotsResponse_marker = (DescribeSnapshotsResponse -> Maybe Text)
-> (DescribeSnapshotsResponse
    -> Maybe Text -> DescribeSnapshotsResponse)
-> Lens' DescribeSnapshotsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSnapshotsResponse' {Maybe Text
marker :: Maybe Text
$sel:marker:DescribeSnapshotsResponse' :: DescribeSnapshotsResponse -> Maybe Text
marker} -> Maybe Text
marker) (\s :: DescribeSnapshotsResponse
s@DescribeSnapshotsResponse' {} Maybe Text
a -> DescribeSnapshotsResponse
s {$sel:marker:DescribeSnapshotsResponse' :: Maybe Text
marker = Maybe Text
a} :: DescribeSnapshotsResponse)

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

instance Prelude.NFData DescribeSnapshotsResponse