{-# 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.EC2.DescribeSnapshots
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Describes the specified EBS snapshots available to you or all of the EBS
-- snapshots available to you.
--
-- The snapshots available to you include public snapshots, private
-- snapshots that you own, and private snapshots owned by other Amazon Web
-- Services accounts for which you have explicit create volume permissions.
--
-- The create volume permissions fall into the following categories:
--
-- -   /public/: The owner of the snapshot granted create volume
--     permissions for the snapshot to the @all@ group. All Amazon Web
--     Services accounts have create volume permissions for these
--     snapshots.
--
-- -   /explicit/: The owner of the snapshot granted create volume
--     permissions to a specific Amazon Web Services account.
--
-- -   /implicit/: An Amazon Web Services account has implicit create
--     volume permissions for all snapshots it owns.
--
-- The list of snapshots returned can be filtered by specifying snapshot
-- IDs, snapshot owners, or Amazon Web Services accounts with create volume
-- permissions. If no options are specified, Amazon EC2 returns all
-- snapshots for which you have create volume permissions.
--
-- If you specify one or more snapshot IDs, only snapshots that have the
-- specified IDs are returned. If you specify an invalid snapshot ID, an
-- error is returned. If you specify a snapshot ID for which you do not
-- have access, it is not included in the returned results.
--
-- If you specify one or more snapshot owners using the @OwnerIds@ option,
-- only snapshots from the specified owners and for which you have access
-- are returned. The results can include the Amazon Web Services account
-- IDs of the specified owners, @amazon@ for snapshots owned by Amazon, or
-- @self@ for snapshots that you own.
--
-- If you specify a list of restorable users, only snapshots with create
-- snapshot permissions for those users are returned. You can specify
-- Amazon Web Services account IDs (if you own the snapshots), @self@ for
-- snapshots for which you own or have explicit permissions, or @all@ for
-- public snapshots.
--
-- If you are describing a long list of snapshots, we recommend that you
-- paginate the output to make the list more manageable. The @MaxResults@
-- parameter sets the maximum number of results returned in a single page.
-- If the list of results exceeds your @MaxResults@ value, then that number
-- of results is returned along with a @NextToken@ value that can be passed
-- to a subsequent @DescribeSnapshots@ request to retrieve the remaining
-- results.
--
-- To get the state of fast snapshot restores for a snapshot, use
-- DescribeFastSnapshotRestores.
--
-- For more information about EBS snapshots, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSSnapshots.html Amazon EBS snapshots>
-- in the /Amazon Elastic Compute Cloud User Guide/.
--
-- This operation returns paginated results.
module Amazonka.EC2.DescribeSnapshots
  ( -- * Creating a Request
    DescribeSnapshots (..),
    newDescribeSnapshots,

    -- * Request Lenses
    describeSnapshots_dryRun,
    describeSnapshots_filters,
    describeSnapshots_maxResults,
    describeSnapshots_nextToken,
    describeSnapshots_ownerIds,
    describeSnapshots_restorableByUserIds,
    describeSnapshots_snapshotIds,

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

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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EC2.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDescribeSnapshots' smart constructor.
data DescribeSnapshots = DescribeSnapshots'
  { -- | Checks whether you have the required permissions for the action, without
    -- actually making the request, and provides an error response. If you have
    -- the required permissions, the error response is @DryRunOperation@.
    -- Otherwise, it is @UnauthorizedOperation@.
    DescribeSnapshots -> Maybe Bool
dryRun :: Prelude.Maybe Prelude.Bool,
    -- | The filters.
    --
    -- -   @description@ - A description of the snapshot.
    --
    -- -   @encrypted@ - Indicates whether the snapshot is encrypted (@true@ |
    --     @false@)
    --
    -- -   @owner-alias@ - The owner alias, from an Amazon-maintained list
    --     (@amazon@). This is not the user-configured Amazon Web Services
    --     account alias set using the IAM console. We recommend that you use
    --     the related parameter instead of this filter.
    --
    -- -   @owner-id@ - The Amazon Web Services account ID of the owner. We
    --     recommend that you use the related parameter instead of this filter.
    --
    -- -   @progress@ - The progress of the snapshot, as a percentage (for
    --     example, 80%).
    --
    -- -   @snapshot-id@ - The snapshot ID.
    --
    -- -   @start-time@ - The time stamp when the snapshot was initiated.
    --
    -- -   @status@ - The status of the snapshot (@pending@ | @completed@ |
    --     @error@).
    --
    -- -   @storage-tier@ - The storage tier of the snapshot (@archive@ |
    --     @standard@).
    --
    -- -   @tag@:\<key> - The key\/value combination of a tag assigned to the
    --     resource. Use the tag key in the filter name and the tag value as
    --     the filter value. For example, to find all resources that have a tag
    --     with the key @Owner@ and the value @TeamA@, specify @tag:Owner@ for
    --     the filter name and @TeamA@ for the filter value.
    --
    -- -   @tag-key@ - The key of a tag assigned to the resource. Use this
    --     filter to find all resources assigned a tag with a specific key,
    --     regardless of the tag value.
    --
    -- -   @volume-id@ - The ID of the volume the snapshot is for.
    --
    -- -   @volume-size@ - The size of the volume, in GiB.
    DescribeSnapshots -> Maybe [Filter]
filters :: Prelude.Maybe [Filter],
    -- | The maximum number of snapshot results returned by @DescribeSnapshots@
    -- in paginated output. When this parameter is used, @DescribeSnapshots@
    -- only returns @MaxResults@ results in a single page along with a
    -- @NextToken@ response element. The remaining results of the initial
    -- request can be seen by sending another @DescribeSnapshots@ request with
    -- the returned @NextToken@ value. This value can be between 5 and 1,000;
    -- if @MaxResults@ is given a value larger than 1,000, only 1,000 results
    -- are returned. If this parameter is not used, then @DescribeSnapshots@
    -- returns all results. You cannot specify this parameter and the snapshot
    -- IDs parameter in the same request.
    DescribeSnapshots -> Maybe Int
maxResults :: Prelude.Maybe Prelude.Int,
    -- | The @NextToken@ value returned from a previous paginated
    -- @DescribeSnapshots@ request where @MaxResults@ was used and the results
    -- exceeded the value of that parameter. Pagination continues from the end
    -- of the previous results that returned the @NextToken@ value. This value
    -- is @null@ when there are no more results to return.
    DescribeSnapshots -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | Scopes the results to snapshots with the specified owners. You can
    -- specify a combination of Amazon Web Services account IDs, @self@, and
    -- @amazon@.
    DescribeSnapshots -> Maybe [Text]
ownerIds :: Prelude.Maybe [Prelude.Text],
    -- | The IDs of the Amazon Web Services accounts that can create volumes from
    -- the snapshot.
    DescribeSnapshots -> Maybe [Text]
restorableByUserIds :: Prelude.Maybe [Prelude.Text],
    -- | The snapshot IDs.
    --
    -- Default: Describes the snapshots for which you have create volume
    -- permissions.
    DescribeSnapshots -> Maybe [Text]
snapshotIds :: Prelude.Maybe [Prelude.Text]
  }
  deriving (DescribeSnapshots -> DescribeSnapshots -> Bool
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]
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
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. 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:
--
-- 'dryRun', 'describeSnapshots_dryRun' - Checks whether you have the required permissions for the action, without
-- actually making the request, and provides an error response. If you have
-- the required permissions, the error response is @DryRunOperation@.
-- Otherwise, it is @UnauthorizedOperation@.
--
-- 'filters', 'describeSnapshots_filters' - The filters.
--
-- -   @description@ - A description of the snapshot.
--
-- -   @encrypted@ - Indicates whether the snapshot is encrypted (@true@ |
--     @false@)
--
-- -   @owner-alias@ - The owner alias, from an Amazon-maintained list
--     (@amazon@). This is not the user-configured Amazon Web Services
--     account alias set using the IAM console. We recommend that you use
--     the related parameter instead of this filter.
--
-- -   @owner-id@ - The Amazon Web Services account ID of the owner. We
--     recommend that you use the related parameter instead of this filter.
--
-- -   @progress@ - The progress of the snapshot, as a percentage (for
--     example, 80%).
--
-- -   @snapshot-id@ - The snapshot ID.
--
-- -   @start-time@ - The time stamp when the snapshot was initiated.
--
-- -   @status@ - The status of the snapshot (@pending@ | @completed@ |
--     @error@).
--
-- -   @storage-tier@ - The storage tier of the snapshot (@archive@ |
--     @standard@).
--
-- -   @tag@:\<key> - The key\/value combination of a tag assigned to the
--     resource. Use the tag key in the filter name and the tag value as
--     the filter value. For example, to find all resources that have a tag
--     with the key @Owner@ and the value @TeamA@, specify @tag:Owner@ for
--     the filter name and @TeamA@ for the filter value.
--
-- -   @tag-key@ - The key of a tag assigned to the resource. Use this
--     filter to find all resources assigned a tag with a specific key,
--     regardless of the tag value.
--
-- -   @volume-id@ - The ID of the volume the snapshot is for.
--
-- -   @volume-size@ - The size of the volume, in GiB.
--
-- 'maxResults', 'describeSnapshots_maxResults' - The maximum number of snapshot results returned by @DescribeSnapshots@
-- in paginated output. When this parameter is used, @DescribeSnapshots@
-- only returns @MaxResults@ results in a single page along with a
-- @NextToken@ response element. The remaining results of the initial
-- request can be seen by sending another @DescribeSnapshots@ request with
-- the returned @NextToken@ value. This value can be between 5 and 1,000;
-- if @MaxResults@ is given a value larger than 1,000, only 1,000 results
-- are returned. If this parameter is not used, then @DescribeSnapshots@
-- returns all results. You cannot specify this parameter and the snapshot
-- IDs parameter in the same request.
--
-- 'nextToken', 'describeSnapshots_nextToken' - The @NextToken@ value returned from a previous paginated
-- @DescribeSnapshots@ request where @MaxResults@ was used and the results
-- exceeded the value of that parameter. Pagination continues from the end
-- of the previous results that returned the @NextToken@ value. This value
-- is @null@ when there are no more results to return.
--
-- 'ownerIds', 'describeSnapshots_ownerIds' - Scopes the results to snapshots with the specified owners. You can
-- specify a combination of Amazon Web Services account IDs, @self@, and
-- @amazon@.
--
-- 'restorableByUserIds', 'describeSnapshots_restorableByUserIds' - The IDs of the Amazon Web Services accounts that can create volumes from
-- the snapshot.
--
-- 'snapshotIds', 'describeSnapshots_snapshotIds' - The snapshot IDs.
--
-- Default: Describes the snapshots for which you have create volume
-- permissions.
newDescribeSnapshots ::
  DescribeSnapshots
newDescribeSnapshots :: DescribeSnapshots
newDescribeSnapshots =
  DescribeSnapshots'
    { $sel:dryRun:DescribeSnapshots' :: Maybe Bool
dryRun = forall a. Maybe a
Prelude.Nothing,
      $sel:filters:DescribeSnapshots' :: Maybe [Filter]
filters = forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:DescribeSnapshots' :: Maybe Int
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeSnapshots' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:ownerIds:DescribeSnapshots' :: Maybe [Text]
ownerIds = forall a. Maybe a
Prelude.Nothing,
      $sel:restorableByUserIds:DescribeSnapshots' :: Maybe [Text]
restorableByUserIds = forall a. Maybe a
Prelude.Nothing,
      $sel:snapshotIds:DescribeSnapshots' :: Maybe [Text]
snapshotIds = forall a. Maybe a
Prelude.Nothing
    }

-- | Checks whether you have the required permissions for the action, without
-- actually making the request, and provides an error response. If you have
-- the required permissions, the error response is @DryRunOperation@.
-- Otherwise, it is @UnauthorizedOperation@.
describeSnapshots_dryRun :: Lens.Lens' DescribeSnapshots (Prelude.Maybe Prelude.Bool)
describeSnapshots_dryRun :: Lens' DescribeSnapshots (Maybe Bool)
describeSnapshots_dryRun = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSnapshots' {Maybe Bool
dryRun :: Maybe Bool
$sel:dryRun:DescribeSnapshots' :: DescribeSnapshots -> Maybe Bool
dryRun} -> Maybe Bool
dryRun) (\s :: DescribeSnapshots
s@DescribeSnapshots' {} Maybe Bool
a -> DescribeSnapshots
s {$sel:dryRun:DescribeSnapshots' :: Maybe Bool
dryRun = Maybe Bool
a} :: DescribeSnapshots)

-- | The filters.
--
-- -   @description@ - A description of the snapshot.
--
-- -   @encrypted@ - Indicates whether the snapshot is encrypted (@true@ |
--     @false@)
--
-- -   @owner-alias@ - The owner alias, from an Amazon-maintained list
--     (@amazon@). This is not the user-configured Amazon Web Services
--     account alias set using the IAM console. We recommend that you use
--     the related parameter instead of this filter.
--
-- -   @owner-id@ - The Amazon Web Services account ID of the owner. We
--     recommend that you use the related parameter instead of this filter.
--
-- -   @progress@ - The progress of the snapshot, as a percentage (for
--     example, 80%).
--
-- -   @snapshot-id@ - The snapshot ID.
--
-- -   @start-time@ - The time stamp when the snapshot was initiated.
--
-- -   @status@ - The status of the snapshot (@pending@ | @completed@ |
--     @error@).
--
-- -   @storage-tier@ - The storage tier of the snapshot (@archive@ |
--     @standard@).
--
-- -   @tag@:\<key> - The key\/value combination of a tag assigned to the
--     resource. Use the tag key in the filter name and the tag value as
--     the filter value. For example, to find all resources that have a tag
--     with the key @Owner@ and the value @TeamA@, specify @tag:Owner@ for
--     the filter name and @TeamA@ for the filter value.
--
-- -   @tag-key@ - The key of a tag assigned to the resource. Use this
--     filter to find all resources assigned a tag with a specific key,
--     regardless of the tag value.
--
-- -   @volume-id@ - The ID of the volume the snapshot is for.
--
-- -   @volume-size@ - The size of the volume, in GiB.
describeSnapshots_filters :: Lens.Lens' DescribeSnapshots (Prelude.Maybe [Filter])
describeSnapshots_filters :: Lens' DescribeSnapshots (Maybe [Filter])
describeSnapshots_filters = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSnapshots' {Maybe [Filter]
filters :: Maybe [Filter]
$sel:filters:DescribeSnapshots' :: DescribeSnapshots -> Maybe [Filter]
filters} -> Maybe [Filter]
filters) (\s :: DescribeSnapshots
s@DescribeSnapshots' {} Maybe [Filter]
a -> DescribeSnapshots
s {$sel:filters:DescribeSnapshots' :: Maybe [Filter]
filters = Maybe [Filter]
a} :: DescribeSnapshots) 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 maximum number of snapshot results returned by @DescribeSnapshots@
-- in paginated output. When this parameter is used, @DescribeSnapshots@
-- only returns @MaxResults@ results in a single page along with a
-- @NextToken@ response element. The remaining results of the initial
-- request can be seen by sending another @DescribeSnapshots@ request with
-- the returned @NextToken@ value. This value can be between 5 and 1,000;
-- if @MaxResults@ is given a value larger than 1,000, only 1,000 results
-- are returned. If this parameter is not used, then @DescribeSnapshots@
-- returns all results. You cannot specify this parameter and the snapshot
-- IDs parameter in the same request.
describeSnapshots_maxResults :: Lens.Lens' DescribeSnapshots (Prelude.Maybe Prelude.Int)
describeSnapshots_maxResults :: Lens' DescribeSnapshots (Maybe Int)
describeSnapshots_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSnapshots' {Maybe Int
maxResults :: Maybe Int
$sel:maxResults:DescribeSnapshots' :: DescribeSnapshots -> Maybe Int
maxResults} -> Maybe Int
maxResults) (\s :: DescribeSnapshots
s@DescribeSnapshots' {} Maybe Int
a -> DescribeSnapshots
s {$sel:maxResults:DescribeSnapshots' :: Maybe Int
maxResults = Maybe Int
a} :: DescribeSnapshots)

-- | The @NextToken@ value returned from a previous paginated
-- @DescribeSnapshots@ request where @MaxResults@ was used and the results
-- exceeded the value of that parameter. Pagination continues from the end
-- of the previous results that returned the @NextToken@ value. This value
-- is @null@ when there are no more results to return.
describeSnapshots_nextToken :: Lens.Lens' DescribeSnapshots (Prelude.Maybe Prelude.Text)
describeSnapshots_nextToken :: Lens' DescribeSnapshots (Maybe Text)
describeSnapshots_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSnapshots' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeSnapshots' :: DescribeSnapshots -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeSnapshots
s@DescribeSnapshots' {} Maybe Text
a -> DescribeSnapshots
s {$sel:nextToken:DescribeSnapshots' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeSnapshots)

-- | Scopes the results to snapshots with the specified owners. You can
-- specify a combination of Amazon Web Services account IDs, @self@, and
-- @amazon@.
describeSnapshots_ownerIds :: Lens.Lens' DescribeSnapshots (Prelude.Maybe [Prelude.Text])
describeSnapshots_ownerIds :: Lens' DescribeSnapshots (Maybe [Text])
describeSnapshots_ownerIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSnapshots' {Maybe [Text]
ownerIds :: Maybe [Text]
$sel:ownerIds:DescribeSnapshots' :: DescribeSnapshots -> Maybe [Text]
ownerIds} -> Maybe [Text]
ownerIds) (\s :: DescribeSnapshots
s@DescribeSnapshots' {} Maybe [Text]
a -> DescribeSnapshots
s {$sel:ownerIds:DescribeSnapshots' :: Maybe [Text]
ownerIds = Maybe [Text]
a} :: DescribeSnapshots) 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 IDs of the Amazon Web Services accounts that can create volumes from
-- the snapshot.
describeSnapshots_restorableByUserIds :: Lens.Lens' DescribeSnapshots (Prelude.Maybe [Prelude.Text])
describeSnapshots_restorableByUserIds :: Lens' DescribeSnapshots (Maybe [Text])
describeSnapshots_restorableByUserIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSnapshots' {Maybe [Text]
restorableByUserIds :: Maybe [Text]
$sel:restorableByUserIds:DescribeSnapshots' :: DescribeSnapshots -> Maybe [Text]
restorableByUserIds} -> Maybe [Text]
restorableByUserIds) (\s :: DescribeSnapshots
s@DescribeSnapshots' {} Maybe [Text]
a -> DescribeSnapshots
s {$sel:restorableByUserIds:DescribeSnapshots' :: Maybe [Text]
restorableByUserIds = Maybe [Text]
a} :: DescribeSnapshots) 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 snapshot IDs.
--
-- Default: Describes the snapshots for which you have create volume
-- permissions.
describeSnapshots_snapshotIds :: Lens.Lens' DescribeSnapshots (Prelude.Maybe [Prelude.Text])
describeSnapshots_snapshotIds :: Lens' DescribeSnapshots (Maybe [Text])
describeSnapshots_snapshotIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSnapshots' {Maybe [Text]
snapshotIds :: Maybe [Text]
$sel:snapshotIds:DescribeSnapshots' :: DescribeSnapshots -> Maybe [Text]
snapshotIds} -> Maybe [Text]
snapshotIds) (\s :: DescribeSnapshots
s@DescribeSnapshots' {} Maybe [Text]
a -> DescribeSnapshots
s {$sel:snapshotIds:DescribeSnapshots' :: Maybe [Text]
snapshotIds = Maybe [Text]
a} :: DescribeSnapshots) 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

instance Core.AWSPager DescribeSnapshots where
  page :: DescribeSnapshots
-> AWSResponse DescribeSnapshots -> Maybe DescribeSnapshots
page DescribeSnapshots
rq AWSResponse DescribeSnapshots
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeSnapshots
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' DescribeSnapshotsResponse (Maybe Text)
describeSnapshotsResponse_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 DescribeSnapshots
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' DescribeSnapshotsResponse (Maybe [Snapshot])
describeSnapshotsResponse_snapshots
            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.$ DescribeSnapshots
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' DescribeSnapshots (Maybe Text)
describeSnapshots_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse DescribeSnapshots
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' DescribeSnapshotsResponse (Maybe Text)
describeSnapshotsResponse_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 DescribeSnapshots where
  type
    AWSResponse DescribeSnapshots =
      DescribeSnapshotsResponse
  request :: (Service -> Service)
-> DescribeSnapshots -> Request DescribeSnapshots
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DescribeSnapshots
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeSnapshots)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXML
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe Text -> Maybe [Snapshot] -> Int -> DescribeSnapshotsResponse
DescribeSnapshotsResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"nextToken")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x
                            forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"snapshotSet"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                            forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"item")
                        )
            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 DescribeSnapshots where
  hashWithSalt :: Int -> DescribeSnapshots -> Int
hashWithSalt Int
_salt DescribeSnapshots' {Maybe Bool
Maybe Int
Maybe [Text]
Maybe [Filter]
Maybe Text
snapshotIds :: Maybe [Text]
restorableByUserIds :: Maybe [Text]
ownerIds :: Maybe [Text]
nextToken :: Maybe Text
maxResults :: Maybe Int
filters :: Maybe [Filter]
dryRun :: Maybe Bool
$sel:snapshotIds:DescribeSnapshots' :: DescribeSnapshots -> Maybe [Text]
$sel:restorableByUserIds:DescribeSnapshots' :: DescribeSnapshots -> Maybe [Text]
$sel:ownerIds:DescribeSnapshots' :: DescribeSnapshots -> Maybe [Text]
$sel:nextToken:DescribeSnapshots' :: DescribeSnapshots -> Maybe Text
$sel:maxResults:DescribeSnapshots' :: DescribeSnapshots -> Maybe Int
$sel:filters:DescribeSnapshots' :: DescribeSnapshots -> Maybe [Filter]
$sel:dryRun:DescribeSnapshots' :: DescribeSnapshots -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
dryRun
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Filter]
filters
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
ownerIds
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
restorableByUserIds
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
snapshotIds

instance Prelude.NFData DescribeSnapshots where
  rnf :: DescribeSnapshots -> ()
rnf DescribeSnapshots' {Maybe Bool
Maybe Int
Maybe [Text]
Maybe [Filter]
Maybe Text
snapshotIds :: Maybe [Text]
restorableByUserIds :: Maybe [Text]
ownerIds :: Maybe [Text]
nextToken :: Maybe Text
maxResults :: Maybe Int
filters :: Maybe [Filter]
dryRun :: Maybe Bool
$sel:snapshotIds:DescribeSnapshots' :: DescribeSnapshots -> Maybe [Text]
$sel:restorableByUserIds:DescribeSnapshots' :: DescribeSnapshots -> Maybe [Text]
$sel:ownerIds:DescribeSnapshots' :: DescribeSnapshots -> Maybe [Text]
$sel:nextToken:DescribeSnapshots' :: DescribeSnapshots -> Maybe Text
$sel:maxResults:DescribeSnapshots' :: DescribeSnapshots -> Maybe Int
$sel:filters:DescribeSnapshots' :: DescribeSnapshots -> Maybe [Filter]
$sel:dryRun:DescribeSnapshots' :: DescribeSnapshots -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
dryRun
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Filter]
filters
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
maxResults
      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 Maybe [Text]
ownerIds
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
restorableByUserIds
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
snapshotIds

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

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

instance Data.ToQuery DescribeSnapshots where
  toQuery :: DescribeSnapshots -> QueryString
toQuery DescribeSnapshots' {Maybe Bool
Maybe Int
Maybe [Text]
Maybe [Filter]
Maybe Text
snapshotIds :: Maybe [Text]
restorableByUserIds :: Maybe [Text]
ownerIds :: Maybe [Text]
nextToken :: Maybe Text
maxResults :: Maybe Int
filters :: Maybe [Filter]
dryRun :: Maybe Bool
$sel:snapshotIds:DescribeSnapshots' :: DescribeSnapshots -> Maybe [Text]
$sel:restorableByUserIds:DescribeSnapshots' :: DescribeSnapshots -> Maybe [Text]
$sel:ownerIds:DescribeSnapshots' :: DescribeSnapshots -> Maybe [Text]
$sel:nextToken:DescribeSnapshots' :: DescribeSnapshots -> Maybe Text
$sel:maxResults:DescribeSnapshots' :: DescribeSnapshots -> Maybe Int
$sel:filters:DescribeSnapshots' :: DescribeSnapshots -> Maybe [Filter]
$sel:dryRun:DescribeSnapshots' :: DescribeSnapshots -> Maybe Bool
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"DescribeSnapshots" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2016-11-15" :: Prelude.ByteString),
        ByteString
"DryRun" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Bool
dryRun,
        forall a. ToQuery a => a -> QueryString
Data.toQuery
          (forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"Filter" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Filter]
filters),
        ByteString
"MaxResults" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Int
maxResults,
        ByteString
"NextToken" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
nextToken,
        forall a. ToQuery a => a -> QueryString
Data.toQuery
          (forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"Owner" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
ownerIds),
        forall a. ToQuery a => a -> QueryString
Data.toQuery
          ( forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"RestorableBy"
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
restorableByUserIds
          ),
        forall a. ToQuery a => a -> QueryString
Data.toQuery
          ( forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"SnapshotId"
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
snapshotIds
          )
      ]

-- | /See:/ 'newDescribeSnapshotsResponse' smart constructor.
data DescribeSnapshotsResponse = DescribeSnapshotsResponse'
  { -- | The @NextToken@ value to include in a future @DescribeSnapshots@
    -- request. When the results of a @DescribeSnapshots@ request exceed
    -- @MaxResults@, this value can be used to retrieve the next page of
    -- results. This value is @null@ when there are no more results to return.
    DescribeSnapshotsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | Information about the snapshots.
    DescribeSnapshotsResponse -> Maybe [Snapshot]
snapshots :: Prelude.Maybe [Snapshot],
    -- | The response's http status code.
    DescribeSnapshotsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeSnapshotsResponse -> DescribeSnapshotsResponse -> Bool
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]
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
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.
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:
--
-- 'nextToken', 'describeSnapshotsResponse_nextToken' - The @NextToken@ value to include in a future @DescribeSnapshots@
-- request. When the results of a @DescribeSnapshots@ request exceed
-- @MaxResults@, this value can be used to retrieve the next page of
-- results. This value is @null@ when there are no more results to return.
--
-- 'snapshots', 'describeSnapshotsResponse_snapshots' - Information about the snapshots.
--
-- 'httpStatus', 'describeSnapshotsResponse_httpStatus' - The response's http status code.
newDescribeSnapshotsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeSnapshotsResponse
newDescribeSnapshotsResponse :: Int -> DescribeSnapshotsResponse
newDescribeSnapshotsResponse Int
pHttpStatus_ =
  DescribeSnapshotsResponse'
    { $sel:nextToken:DescribeSnapshotsResponse' :: Maybe Text
nextToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:snapshots:DescribeSnapshotsResponse' :: Maybe [Snapshot]
snapshots = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeSnapshotsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The @NextToken@ value to include in a future @DescribeSnapshots@
-- request. When the results of a @DescribeSnapshots@ request exceed
-- @MaxResults@, this value can be used to retrieve the next page of
-- results. This value is @null@ when there are no more results to return.
describeSnapshotsResponse_nextToken :: Lens.Lens' DescribeSnapshotsResponse (Prelude.Maybe Prelude.Text)
describeSnapshotsResponse_nextToken :: Lens' DescribeSnapshotsResponse (Maybe Text)
describeSnapshotsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSnapshotsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeSnapshotsResponse' :: DescribeSnapshotsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeSnapshotsResponse
s@DescribeSnapshotsResponse' {} Maybe Text
a -> DescribeSnapshotsResponse
s {$sel:nextToken:DescribeSnapshotsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeSnapshotsResponse)

-- | Information about the snapshots.
describeSnapshotsResponse_snapshots :: Lens.Lens' DescribeSnapshotsResponse (Prelude.Maybe [Snapshot])
describeSnapshotsResponse_snapshots :: Lens' DescribeSnapshotsResponse (Maybe [Snapshot])
describeSnapshotsResponse_snapshots = 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) 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 response's http status code.
describeSnapshotsResponse_httpStatus :: Lens.Lens' DescribeSnapshotsResponse Prelude.Int
describeSnapshotsResponse_httpStatus :: Lens' DescribeSnapshotsResponse Int
describeSnapshotsResponse_httpStatus = 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 where
  rnf :: DescribeSnapshotsResponse -> ()
rnf DescribeSnapshotsResponse' {Int
Maybe [Snapshot]
Maybe Text
httpStatus :: Int
snapshots :: Maybe [Snapshot]
nextToken :: Maybe Text
$sel:httpStatus:DescribeSnapshotsResponse' :: DescribeSnapshotsResponse -> Int
$sel:snapshots:DescribeSnapshotsResponse' :: DescribeSnapshotsResponse -> Maybe [Snapshot]
$sel:nextToken:DescribeSnapshotsResponse' :: DescribeSnapshotsResponse -> Maybe Text
..} =
    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 Maybe [Snapshot]
snapshots
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus