{-# 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.DescribeCapacityReservations
-- 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 one or more of your Capacity Reservations. The results
-- describe only the Capacity Reservations in the Amazon Web Services
-- Region that you\'re currently using.
--
-- This operation returns paginated results.
module Amazonka.EC2.DescribeCapacityReservations
  ( -- * Creating a Request
    DescribeCapacityReservations (..),
    newDescribeCapacityReservations,

    -- * Request Lenses
    describeCapacityReservations_capacityReservationIds,
    describeCapacityReservations_dryRun,
    describeCapacityReservations_filters,
    describeCapacityReservations_maxResults,
    describeCapacityReservations_nextToken,

    -- * Destructuring the Response
    DescribeCapacityReservationsResponse (..),
    newDescribeCapacityReservationsResponse,

    -- * Response Lenses
    describeCapacityReservationsResponse_capacityReservations,
    describeCapacityReservationsResponse_nextToken,
    describeCapacityReservationsResponse_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:/ 'newDescribeCapacityReservations' smart constructor.
data DescribeCapacityReservations = DescribeCapacityReservations'
  { -- | The ID of the Capacity Reservation.
    DescribeCapacityReservations -> Maybe [Text]
capacityReservationIds :: Prelude.Maybe [Prelude.Text],
    -- | 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@.
    DescribeCapacityReservations -> Maybe Bool
dryRun :: Prelude.Maybe Prelude.Bool,
    -- | One or more filters.
    --
    -- -   @instance-type@ - The type of instance for which the Capacity
    --     Reservation reserves capacity.
    --
    -- -   @owner-id@ - The ID of the Amazon Web Services account that owns the
    --     Capacity Reservation.
    --
    -- -   @instance-platform@ - The type of operating system for which the
    --     Capacity Reservation reserves capacity.
    --
    -- -   @availability-zone@ - The Availability Zone of the Capacity
    --     Reservation.
    --
    -- -   @tenancy@ - Indicates the tenancy of the Capacity Reservation. A
    --     Capacity Reservation can have one of the following tenancy settings:
    --
    --     -   @default@ - The Capacity Reservation is created on hardware that
    --         is shared with other Amazon Web Services accounts.
    --
    --     -   @dedicated@ - The Capacity Reservation is created on
    --         single-tenant hardware that is dedicated to a single Amazon Web
    --         Services account.
    --
    -- -   @outpost-arn@ - The Amazon Resource Name (ARN) of the Outpost on
    --     which the Capacity Reservation was created.
    --
    -- -   @state@ - The current state of the Capacity Reservation. A Capacity
    --     Reservation can be in one of the following states:
    --
    --     -   @active@- The Capacity Reservation is active and the capacity is
    --         available for your use.
    --
    --     -   @expired@ - The Capacity Reservation expired automatically at
    --         the date and time specified in your request. The reserved
    --         capacity is no longer available for your use.
    --
    --     -   @cancelled@ - The Capacity Reservation was cancelled. The
    --         reserved capacity is no longer available for your use.
    --
    --     -   @pending@ - The Capacity Reservation request was successful but
    --         the capacity provisioning is still pending.
    --
    --     -   @failed@ - The Capacity Reservation request has failed. A
    --         request might fail due to invalid request parameters, capacity
    --         constraints, or instance limit constraints. Failed requests are
    --         retained for 60 minutes.
    --
    -- -   @start-date@ - The date and time at which the Capacity Reservation
    --     was started.
    --
    -- -   @end-date@ - The date and time at which the Capacity Reservation
    --     expires. When a Capacity Reservation expires, the reserved capacity
    --     is released and you can no longer launch instances into it. The
    --     Capacity Reservation\'s state changes to expired when it reaches its
    --     end date and time.
    --
    -- -   @end-date-type@ - Indicates the way in which the Capacity
    --     Reservation ends. A Capacity Reservation can have one of the
    --     following end types:
    --
    --     -   @unlimited@ - The Capacity Reservation remains active until you
    --         explicitly cancel it.
    --
    --     -   @limited@ - The Capacity Reservation expires automatically at a
    --         specified date and time.
    --
    -- -   @instance-match-criteria@ - Indicates the type of instance launches
    --     that the Capacity Reservation accepts. The options include:
    --
    --     -   @open@ - The Capacity Reservation accepts all instances that
    --         have matching attributes (instance type, platform, and
    --         Availability Zone). Instances that have matching attributes
    --         launch into the Capacity Reservation automatically without
    --         specifying any additional parameters.
    --
    --     -   @targeted@ - The Capacity Reservation only accepts instances
    --         that have matching attributes (instance type, platform, and
    --         Availability Zone), and explicitly target the Capacity
    --         Reservation. This ensures that only permitted instances can use
    --         the reserved capacity.
    --
    -- -   @placement-group-arn@ - The ARN of the cluster placement group in
    --     which the Capacity Reservation was created.
    DescribeCapacityReservations -> Maybe [Filter]
filters :: Prelude.Maybe [Filter],
    -- | The maximum number of results to return for the request in a single
    -- page. The remaining results can be seen by sending another request with
    -- the returned @nextToken@ value. This value can be between 5 and 500. If
    -- @maxResults@ is given a larger value than 500, you receive an error.
    DescribeCapacityReservations -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The token to use to retrieve the next page of results.
    DescribeCapacityReservations -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (DescribeCapacityReservations
-> DescribeCapacityReservations -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeCapacityReservations
-> DescribeCapacityReservations -> Bool
$c/= :: DescribeCapacityReservations
-> DescribeCapacityReservations -> Bool
== :: DescribeCapacityReservations
-> DescribeCapacityReservations -> Bool
$c== :: DescribeCapacityReservations
-> DescribeCapacityReservations -> Bool
Prelude.Eq, ReadPrec [DescribeCapacityReservations]
ReadPrec DescribeCapacityReservations
Int -> ReadS DescribeCapacityReservations
ReadS [DescribeCapacityReservations]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeCapacityReservations]
$creadListPrec :: ReadPrec [DescribeCapacityReservations]
readPrec :: ReadPrec DescribeCapacityReservations
$creadPrec :: ReadPrec DescribeCapacityReservations
readList :: ReadS [DescribeCapacityReservations]
$creadList :: ReadS [DescribeCapacityReservations]
readsPrec :: Int -> ReadS DescribeCapacityReservations
$creadsPrec :: Int -> ReadS DescribeCapacityReservations
Prelude.Read, Int -> DescribeCapacityReservations -> ShowS
[DescribeCapacityReservations] -> ShowS
DescribeCapacityReservations -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeCapacityReservations] -> ShowS
$cshowList :: [DescribeCapacityReservations] -> ShowS
show :: DescribeCapacityReservations -> String
$cshow :: DescribeCapacityReservations -> String
showsPrec :: Int -> DescribeCapacityReservations -> ShowS
$cshowsPrec :: Int -> DescribeCapacityReservations -> ShowS
Prelude.Show, forall x.
Rep DescribeCapacityReservations x -> DescribeCapacityReservations
forall x.
DescribeCapacityReservations -> Rep DescribeCapacityReservations x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeCapacityReservations x -> DescribeCapacityReservations
$cfrom :: forall x.
DescribeCapacityReservations -> Rep DescribeCapacityReservations x
Prelude.Generic)

-- |
-- Create a value of 'DescribeCapacityReservations' 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:
--
-- 'capacityReservationIds', 'describeCapacityReservations_capacityReservationIds' - The ID of the Capacity Reservation.
--
-- 'dryRun', 'describeCapacityReservations_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', 'describeCapacityReservations_filters' - One or more filters.
--
-- -   @instance-type@ - The type of instance for which the Capacity
--     Reservation reserves capacity.
--
-- -   @owner-id@ - The ID of the Amazon Web Services account that owns the
--     Capacity Reservation.
--
-- -   @instance-platform@ - The type of operating system for which the
--     Capacity Reservation reserves capacity.
--
-- -   @availability-zone@ - The Availability Zone of the Capacity
--     Reservation.
--
-- -   @tenancy@ - Indicates the tenancy of the Capacity Reservation. A
--     Capacity Reservation can have one of the following tenancy settings:
--
--     -   @default@ - The Capacity Reservation is created on hardware that
--         is shared with other Amazon Web Services accounts.
--
--     -   @dedicated@ - The Capacity Reservation is created on
--         single-tenant hardware that is dedicated to a single Amazon Web
--         Services account.
--
-- -   @outpost-arn@ - The Amazon Resource Name (ARN) of the Outpost on
--     which the Capacity Reservation was created.
--
-- -   @state@ - The current state of the Capacity Reservation. A Capacity
--     Reservation can be in one of the following states:
--
--     -   @active@- The Capacity Reservation is active and the capacity is
--         available for your use.
--
--     -   @expired@ - The Capacity Reservation expired automatically at
--         the date and time specified in your request. The reserved
--         capacity is no longer available for your use.
--
--     -   @cancelled@ - The Capacity Reservation was cancelled. The
--         reserved capacity is no longer available for your use.
--
--     -   @pending@ - The Capacity Reservation request was successful but
--         the capacity provisioning is still pending.
--
--     -   @failed@ - The Capacity Reservation request has failed. A
--         request might fail due to invalid request parameters, capacity
--         constraints, or instance limit constraints. Failed requests are
--         retained for 60 minutes.
--
-- -   @start-date@ - The date and time at which the Capacity Reservation
--     was started.
--
-- -   @end-date@ - The date and time at which the Capacity Reservation
--     expires. When a Capacity Reservation expires, the reserved capacity
--     is released and you can no longer launch instances into it. The
--     Capacity Reservation\'s state changes to expired when it reaches its
--     end date and time.
--
-- -   @end-date-type@ - Indicates the way in which the Capacity
--     Reservation ends. A Capacity Reservation can have one of the
--     following end types:
--
--     -   @unlimited@ - The Capacity Reservation remains active until you
--         explicitly cancel it.
--
--     -   @limited@ - The Capacity Reservation expires automatically at a
--         specified date and time.
--
-- -   @instance-match-criteria@ - Indicates the type of instance launches
--     that the Capacity Reservation accepts. The options include:
--
--     -   @open@ - The Capacity Reservation accepts all instances that
--         have matching attributes (instance type, platform, and
--         Availability Zone). Instances that have matching attributes
--         launch into the Capacity Reservation automatically without
--         specifying any additional parameters.
--
--     -   @targeted@ - The Capacity Reservation only accepts instances
--         that have matching attributes (instance type, platform, and
--         Availability Zone), and explicitly target the Capacity
--         Reservation. This ensures that only permitted instances can use
--         the reserved capacity.
--
-- -   @placement-group-arn@ - The ARN of the cluster placement group in
--     which the Capacity Reservation was created.
--
-- 'maxResults', 'describeCapacityReservations_maxResults' - The maximum number of results to return for the request in a single
-- page. The remaining results can be seen by sending another request with
-- the returned @nextToken@ value. This value can be between 5 and 500. If
-- @maxResults@ is given a larger value than 500, you receive an error.
--
-- 'nextToken', 'describeCapacityReservations_nextToken' - The token to use to retrieve the next page of results.
newDescribeCapacityReservations ::
  DescribeCapacityReservations
newDescribeCapacityReservations :: DescribeCapacityReservations
newDescribeCapacityReservations =
  DescribeCapacityReservations'
    { $sel:capacityReservationIds:DescribeCapacityReservations' :: Maybe [Text]
capacityReservationIds =
        forall a. Maybe a
Prelude.Nothing,
      $sel:dryRun:DescribeCapacityReservations' :: Maybe Bool
dryRun = forall a. Maybe a
Prelude.Nothing,
      $sel:filters:DescribeCapacityReservations' :: Maybe [Filter]
filters = forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:DescribeCapacityReservations' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeCapacityReservations' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the Capacity Reservation.
describeCapacityReservations_capacityReservationIds :: Lens.Lens' DescribeCapacityReservations (Prelude.Maybe [Prelude.Text])
describeCapacityReservations_capacityReservationIds :: Lens' DescribeCapacityReservations (Maybe [Text])
describeCapacityReservations_capacityReservationIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeCapacityReservations' {Maybe [Text]
capacityReservationIds :: Maybe [Text]
$sel:capacityReservationIds:DescribeCapacityReservations' :: DescribeCapacityReservations -> Maybe [Text]
capacityReservationIds} -> Maybe [Text]
capacityReservationIds) (\s :: DescribeCapacityReservations
s@DescribeCapacityReservations' {} Maybe [Text]
a -> DescribeCapacityReservations
s {$sel:capacityReservationIds:DescribeCapacityReservations' :: Maybe [Text]
capacityReservationIds = Maybe [Text]
a} :: DescribeCapacityReservations) 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

-- | 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@.
describeCapacityReservations_dryRun :: Lens.Lens' DescribeCapacityReservations (Prelude.Maybe Prelude.Bool)
describeCapacityReservations_dryRun :: Lens' DescribeCapacityReservations (Maybe Bool)
describeCapacityReservations_dryRun = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeCapacityReservations' {Maybe Bool
dryRun :: Maybe Bool
$sel:dryRun:DescribeCapacityReservations' :: DescribeCapacityReservations -> Maybe Bool
dryRun} -> Maybe Bool
dryRun) (\s :: DescribeCapacityReservations
s@DescribeCapacityReservations' {} Maybe Bool
a -> DescribeCapacityReservations
s {$sel:dryRun:DescribeCapacityReservations' :: Maybe Bool
dryRun = Maybe Bool
a} :: DescribeCapacityReservations)

-- | One or more filters.
--
-- -   @instance-type@ - The type of instance for which the Capacity
--     Reservation reserves capacity.
--
-- -   @owner-id@ - The ID of the Amazon Web Services account that owns the
--     Capacity Reservation.
--
-- -   @instance-platform@ - The type of operating system for which the
--     Capacity Reservation reserves capacity.
--
-- -   @availability-zone@ - The Availability Zone of the Capacity
--     Reservation.
--
-- -   @tenancy@ - Indicates the tenancy of the Capacity Reservation. A
--     Capacity Reservation can have one of the following tenancy settings:
--
--     -   @default@ - The Capacity Reservation is created on hardware that
--         is shared with other Amazon Web Services accounts.
--
--     -   @dedicated@ - The Capacity Reservation is created on
--         single-tenant hardware that is dedicated to a single Amazon Web
--         Services account.
--
-- -   @outpost-arn@ - The Amazon Resource Name (ARN) of the Outpost on
--     which the Capacity Reservation was created.
--
-- -   @state@ - The current state of the Capacity Reservation. A Capacity
--     Reservation can be in one of the following states:
--
--     -   @active@- The Capacity Reservation is active and the capacity is
--         available for your use.
--
--     -   @expired@ - The Capacity Reservation expired automatically at
--         the date and time specified in your request. The reserved
--         capacity is no longer available for your use.
--
--     -   @cancelled@ - The Capacity Reservation was cancelled. The
--         reserved capacity is no longer available for your use.
--
--     -   @pending@ - The Capacity Reservation request was successful but
--         the capacity provisioning is still pending.
--
--     -   @failed@ - The Capacity Reservation request has failed. A
--         request might fail due to invalid request parameters, capacity
--         constraints, or instance limit constraints. Failed requests are
--         retained for 60 minutes.
--
-- -   @start-date@ - The date and time at which the Capacity Reservation
--     was started.
--
-- -   @end-date@ - The date and time at which the Capacity Reservation
--     expires. When a Capacity Reservation expires, the reserved capacity
--     is released and you can no longer launch instances into it. The
--     Capacity Reservation\'s state changes to expired when it reaches its
--     end date and time.
--
-- -   @end-date-type@ - Indicates the way in which the Capacity
--     Reservation ends. A Capacity Reservation can have one of the
--     following end types:
--
--     -   @unlimited@ - The Capacity Reservation remains active until you
--         explicitly cancel it.
--
--     -   @limited@ - The Capacity Reservation expires automatically at a
--         specified date and time.
--
-- -   @instance-match-criteria@ - Indicates the type of instance launches
--     that the Capacity Reservation accepts. The options include:
--
--     -   @open@ - The Capacity Reservation accepts all instances that
--         have matching attributes (instance type, platform, and
--         Availability Zone). Instances that have matching attributes
--         launch into the Capacity Reservation automatically without
--         specifying any additional parameters.
--
--     -   @targeted@ - The Capacity Reservation only accepts instances
--         that have matching attributes (instance type, platform, and
--         Availability Zone), and explicitly target the Capacity
--         Reservation. This ensures that only permitted instances can use
--         the reserved capacity.
--
-- -   @placement-group-arn@ - The ARN of the cluster placement group in
--     which the Capacity Reservation was created.
describeCapacityReservations_filters :: Lens.Lens' DescribeCapacityReservations (Prelude.Maybe [Filter])
describeCapacityReservations_filters :: Lens' DescribeCapacityReservations (Maybe [Filter])
describeCapacityReservations_filters = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeCapacityReservations' {Maybe [Filter]
filters :: Maybe [Filter]
$sel:filters:DescribeCapacityReservations' :: DescribeCapacityReservations -> Maybe [Filter]
filters} -> Maybe [Filter]
filters) (\s :: DescribeCapacityReservations
s@DescribeCapacityReservations' {} Maybe [Filter]
a -> DescribeCapacityReservations
s {$sel:filters:DescribeCapacityReservations' :: Maybe [Filter]
filters = Maybe [Filter]
a} :: DescribeCapacityReservations) 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 results to return for the request in a single
-- page. The remaining results can be seen by sending another request with
-- the returned @nextToken@ value. This value can be between 5 and 500. If
-- @maxResults@ is given a larger value than 500, you receive an error.
describeCapacityReservations_maxResults :: Lens.Lens' DescribeCapacityReservations (Prelude.Maybe Prelude.Natural)
describeCapacityReservations_maxResults :: Lens' DescribeCapacityReservations (Maybe Natural)
describeCapacityReservations_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeCapacityReservations' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:DescribeCapacityReservations' :: DescribeCapacityReservations -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: DescribeCapacityReservations
s@DescribeCapacityReservations' {} Maybe Natural
a -> DescribeCapacityReservations
s {$sel:maxResults:DescribeCapacityReservations' :: Maybe Natural
maxResults = Maybe Natural
a} :: DescribeCapacityReservations)

-- | The token to use to retrieve the next page of results.
describeCapacityReservations_nextToken :: Lens.Lens' DescribeCapacityReservations (Prelude.Maybe Prelude.Text)
describeCapacityReservations_nextToken :: Lens' DescribeCapacityReservations (Maybe Text)
describeCapacityReservations_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeCapacityReservations' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeCapacityReservations' :: DescribeCapacityReservations -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeCapacityReservations
s@DescribeCapacityReservations' {} Maybe Text
a -> DescribeCapacityReservations
s {$sel:nextToken:DescribeCapacityReservations' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeCapacityReservations)

instance Core.AWSPager DescribeCapacityReservations where
  page :: DescribeCapacityReservations
-> AWSResponse DescribeCapacityReservations
-> Maybe DescribeCapacityReservations
page DescribeCapacityReservations
rq AWSResponse DescribeCapacityReservations
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeCapacityReservations
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' DescribeCapacityReservationsResponse (Maybe Text)
describeCapacityReservationsResponse_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 DescribeCapacityReservations
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens'
  DescribeCapacityReservationsResponse (Maybe [CapacityReservation])
describeCapacityReservationsResponse_capacityReservations
            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.$ DescribeCapacityReservations
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' DescribeCapacityReservations (Maybe Text)
describeCapacityReservations_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse DescribeCapacityReservations
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' DescribeCapacityReservationsResponse (Maybe Text)
describeCapacityReservationsResponse_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 DescribeCapacityReservations where
  type
    AWSResponse DescribeCapacityReservations =
      DescribeCapacityReservationsResponse
  request :: (Service -> Service)
-> DescribeCapacityReservations
-> Request DescribeCapacityReservations
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 DescribeCapacityReservations
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeCapacityReservations)))
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 [CapacityReservation]
-> Maybe Text -> Int -> DescribeCapacityReservationsResponse
DescribeCapacityReservationsResponse'
            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
"capacityReservationSet"
                            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.<*> ([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.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance
  Prelude.Hashable
    DescribeCapacityReservations
  where
  hashWithSalt :: Int -> DescribeCapacityReservations -> Int
hashWithSalt Int
_salt DescribeCapacityReservations' {Maybe Bool
Maybe Natural
Maybe [Text]
Maybe [Filter]
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
filters :: Maybe [Filter]
dryRun :: Maybe Bool
capacityReservationIds :: Maybe [Text]
$sel:nextToken:DescribeCapacityReservations' :: DescribeCapacityReservations -> Maybe Text
$sel:maxResults:DescribeCapacityReservations' :: DescribeCapacityReservations -> Maybe Natural
$sel:filters:DescribeCapacityReservations' :: DescribeCapacityReservations -> Maybe [Filter]
$sel:dryRun:DescribeCapacityReservations' :: DescribeCapacityReservations -> Maybe Bool
$sel:capacityReservationIds:DescribeCapacityReservations' :: DescribeCapacityReservations -> Maybe [Text]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
capacityReservationIds
      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 Natural
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken

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

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

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

instance Data.ToQuery DescribeCapacityReservations where
  toQuery :: DescribeCapacityReservations -> QueryString
toQuery DescribeCapacityReservations' {Maybe Bool
Maybe Natural
Maybe [Text]
Maybe [Filter]
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
filters :: Maybe [Filter]
dryRun :: Maybe Bool
capacityReservationIds :: Maybe [Text]
$sel:nextToken:DescribeCapacityReservations' :: DescribeCapacityReservations -> Maybe Text
$sel:maxResults:DescribeCapacityReservations' :: DescribeCapacityReservations -> Maybe Natural
$sel:filters:DescribeCapacityReservations' :: DescribeCapacityReservations -> Maybe [Filter]
$sel:dryRun:DescribeCapacityReservations' :: DescribeCapacityReservations -> Maybe Bool
$sel:capacityReservationIds:DescribeCapacityReservations' :: DescribeCapacityReservations -> Maybe [Text]
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: ( ByteString
"DescribeCapacityReservations" ::
                      Prelude.ByteString
                  ),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2016-11-15" :: Prelude.ByteString),
        forall a. ToQuery a => a -> QueryString
Data.toQuery
          ( forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"CapacityReservationId"
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
capacityReservationIds
          ),
        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 Natural
maxResults,
        ByteString
"NextToken" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
nextToken
      ]

-- | /See:/ 'newDescribeCapacityReservationsResponse' smart constructor.
data DescribeCapacityReservationsResponse = DescribeCapacityReservationsResponse'
  { -- | Information about the Capacity Reservations.
    DescribeCapacityReservationsResponse -> Maybe [CapacityReservation]
capacityReservations :: Prelude.Maybe [CapacityReservation],
    -- | The token to use to retrieve the next page of results. This value is
    -- @null@ when there are no more results to return.
    DescribeCapacityReservationsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DescribeCapacityReservationsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeCapacityReservationsResponse
-> DescribeCapacityReservationsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeCapacityReservationsResponse
-> DescribeCapacityReservationsResponse -> Bool
$c/= :: DescribeCapacityReservationsResponse
-> DescribeCapacityReservationsResponse -> Bool
== :: DescribeCapacityReservationsResponse
-> DescribeCapacityReservationsResponse -> Bool
$c== :: DescribeCapacityReservationsResponse
-> DescribeCapacityReservationsResponse -> Bool
Prelude.Eq, ReadPrec [DescribeCapacityReservationsResponse]
ReadPrec DescribeCapacityReservationsResponse
Int -> ReadS DescribeCapacityReservationsResponse
ReadS [DescribeCapacityReservationsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeCapacityReservationsResponse]
$creadListPrec :: ReadPrec [DescribeCapacityReservationsResponse]
readPrec :: ReadPrec DescribeCapacityReservationsResponse
$creadPrec :: ReadPrec DescribeCapacityReservationsResponse
readList :: ReadS [DescribeCapacityReservationsResponse]
$creadList :: ReadS [DescribeCapacityReservationsResponse]
readsPrec :: Int -> ReadS DescribeCapacityReservationsResponse
$creadsPrec :: Int -> ReadS DescribeCapacityReservationsResponse
Prelude.Read, Int -> DescribeCapacityReservationsResponse -> ShowS
[DescribeCapacityReservationsResponse] -> ShowS
DescribeCapacityReservationsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeCapacityReservationsResponse] -> ShowS
$cshowList :: [DescribeCapacityReservationsResponse] -> ShowS
show :: DescribeCapacityReservationsResponse -> String
$cshow :: DescribeCapacityReservationsResponse -> String
showsPrec :: Int -> DescribeCapacityReservationsResponse -> ShowS
$cshowsPrec :: Int -> DescribeCapacityReservationsResponse -> ShowS
Prelude.Show, forall x.
Rep DescribeCapacityReservationsResponse x
-> DescribeCapacityReservationsResponse
forall x.
DescribeCapacityReservationsResponse
-> Rep DescribeCapacityReservationsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeCapacityReservationsResponse x
-> DescribeCapacityReservationsResponse
$cfrom :: forall x.
DescribeCapacityReservationsResponse
-> Rep DescribeCapacityReservationsResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeCapacityReservationsResponse' 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:
--
-- 'capacityReservations', 'describeCapacityReservationsResponse_capacityReservations' - Information about the Capacity Reservations.
--
-- 'nextToken', 'describeCapacityReservationsResponse_nextToken' - The token to use to retrieve the next page of results. This value is
-- @null@ when there are no more results to return.
--
-- 'httpStatus', 'describeCapacityReservationsResponse_httpStatus' - The response's http status code.
newDescribeCapacityReservationsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeCapacityReservationsResponse
newDescribeCapacityReservationsResponse :: Int -> DescribeCapacityReservationsResponse
newDescribeCapacityReservationsResponse Int
pHttpStatus_ =
  DescribeCapacityReservationsResponse'
    { $sel:capacityReservations:DescribeCapacityReservationsResponse' :: Maybe [CapacityReservation]
capacityReservations =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeCapacityReservationsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeCapacityReservationsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the Capacity Reservations.
describeCapacityReservationsResponse_capacityReservations :: Lens.Lens' DescribeCapacityReservationsResponse (Prelude.Maybe [CapacityReservation])
describeCapacityReservationsResponse_capacityReservations :: Lens'
  DescribeCapacityReservationsResponse (Maybe [CapacityReservation])
describeCapacityReservationsResponse_capacityReservations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeCapacityReservationsResponse' {Maybe [CapacityReservation]
capacityReservations :: Maybe [CapacityReservation]
$sel:capacityReservations:DescribeCapacityReservationsResponse' :: DescribeCapacityReservationsResponse -> Maybe [CapacityReservation]
capacityReservations} -> Maybe [CapacityReservation]
capacityReservations) (\s :: DescribeCapacityReservationsResponse
s@DescribeCapacityReservationsResponse' {} Maybe [CapacityReservation]
a -> DescribeCapacityReservationsResponse
s {$sel:capacityReservations:DescribeCapacityReservationsResponse' :: Maybe [CapacityReservation]
capacityReservations = Maybe [CapacityReservation]
a} :: DescribeCapacityReservationsResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The token to use to retrieve the next page of results. This value is
-- @null@ when there are no more results to return.
describeCapacityReservationsResponse_nextToken :: Lens.Lens' DescribeCapacityReservationsResponse (Prelude.Maybe Prelude.Text)
describeCapacityReservationsResponse_nextToken :: Lens' DescribeCapacityReservationsResponse (Maybe Text)
describeCapacityReservationsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeCapacityReservationsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeCapacityReservationsResponse' :: DescribeCapacityReservationsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeCapacityReservationsResponse
s@DescribeCapacityReservationsResponse' {} Maybe Text
a -> DescribeCapacityReservationsResponse
s {$sel:nextToken:DescribeCapacityReservationsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeCapacityReservationsResponse)

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

instance
  Prelude.NFData
    DescribeCapacityReservationsResponse
  where
  rnf :: DescribeCapacityReservationsResponse -> ()
rnf DescribeCapacityReservationsResponse' {Int
Maybe [CapacityReservation]
Maybe Text
httpStatus :: Int
nextToken :: Maybe Text
capacityReservations :: Maybe [CapacityReservation]
$sel:httpStatus:DescribeCapacityReservationsResponse' :: DescribeCapacityReservationsResponse -> Int
$sel:nextToken:DescribeCapacityReservationsResponse' :: DescribeCapacityReservationsResponse -> Maybe Text
$sel:capacityReservations:DescribeCapacityReservationsResponse' :: DescribeCapacityReservationsResponse -> Maybe [CapacityReservation]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [CapacityReservation]
capacityReservations
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus