{-# 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.SavingsPlans.DescribeSavingsPlans
-- 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)
--
-- Describes the specified Savings Plans.
module Amazonka.SavingsPlans.DescribeSavingsPlans
  ( -- * Creating a Request
    DescribeSavingsPlans (..),
    newDescribeSavingsPlans,

    -- * Request Lenses
    describeSavingsPlans_states,
    describeSavingsPlans_savingsPlanIds,
    describeSavingsPlans_filters,
    describeSavingsPlans_nextToken,
    describeSavingsPlans_savingsPlanArns,
    describeSavingsPlans_maxResults,

    -- * Destructuring the Response
    DescribeSavingsPlansResponse (..),
    newDescribeSavingsPlansResponse,

    -- * Response Lenses
    describeSavingsPlansResponse_savingsPlans,
    describeSavingsPlansResponse_nextToken,
    describeSavingsPlansResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDescribeSavingsPlans' smart constructor.
data DescribeSavingsPlans = DescribeSavingsPlans'
  { -- | The states.
    DescribeSavingsPlans -> Maybe [SavingsPlanState]
states :: Prelude.Maybe [SavingsPlanState],
    -- | The IDs of the Savings Plans.
    DescribeSavingsPlans -> Maybe [Text]
savingsPlanIds :: Prelude.Maybe [Prelude.Text],
    -- | The filters.
    DescribeSavingsPlans -> Maybe [SavingsPlanFilter]
filters :: Prelude.Maybe [SavingsPlanFilter],
    -- | The token for the next page of results.
    DescribeSavingsPlans -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Names (ARN) of the Savings Plans.
    DescribeSavingsPlans -> Maybe [Text]
savingsPlanArns :: Prelude.Maybe [Prelude.Text],
    -- | The maximum number of results to return with a single call. To retrieve
    -- additional results, make another call with the returned token value.
    DescribeSavingsPlans -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural
  }
  deriving (DescribeSavingsPlans -> DescribeSavingsPlans -> Bool
(DescribeSavingsPlans -> DescribeSavingsPlans -> Bool)
-> (DescribeSavingsPlans -> DescribeSavingsPlans -> Bool)
-> Eq DescribeSavingsPlans
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeSavingsPlans -> DescribeSavingsPlans -> Bool
$c/= :: DescribeSavingsPlans -> DescribeSavingsPlans -> Bool
== :: DescribeSavingsPlans -> DescribeSavingsPlans -> Bool
$c== :: DescribeSavingsPlans -> DescribeSavingsPlans -> Bool
Prelude.Eq, ReadPrec [DescribeSavingsPlans]
ReadPrec DescribeSavingsPlans
Int -> ReadS DescribeSavingsPlans
ReadS [DescribeSavingsPlans]
(Int -> ReadS DescribeSavingsPlans)
-> ReadS [DescribeSavingsPlans]
-> ReadPrec DescribeSavingsPlans
-> ReadPrec [DescribeSavingsPlans]
-> Read DescribeSavingsPlans
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeSavingsPlans]
$creadListPrec :: ReadPrec [DescribeSavingsPlans]
readPrec :: ReadPrec DescribeSavingsPlans
$creadPrec :: ReadPrec DescribeSavingsPlans
readList :: ReadS [DescribeSavingsPlans]
$creadList :: ReadS [DescribeSavingsPlans]
readsPrec :: Int -> ReadS DescribeSavingsPlans
$creadsPrec :: Int -> ReadS DescribeSavingsPlans
Prelude.Read, Int -> DescribeSavingsPlans -> ShowS
[DescribeSavingsPlans] -> ShowS
DescribeSavingsPlans -> String
(Int -> DescribeSavingsPlans -> ShowS)
-> (DescribeSavingsPlans -> String)
-> ([DescribeSavingsPlans] -> ShowS)
-> Show DescribeSavingsPlans
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeSavingsPlans] -> ShowS
$cshowList :: [DescribeSavingsPlans] -> ShowS
show :: DescribeSavingsPlans -> String
$cshow :: DescribeSavingsPlans -> String
showsPrec :: Int -> DescribeSavingsPlans -> ShowS
$cshowsPrec :: Int -> DescribeSavingsPlans -> ShowS
Prelude.Show, (forall x. DescribeSavingsPlans -> Rep DescribeSavingsPlans x)
-> (forall x. Rep DescribeSavingsPlans x -> DescribeSavingsPlans)
-> Generic DescribeSavingsPlans
forall x. Rep DescribeSavingsPlans x -> DescribeSavingsPlans
forall x. DescribeSavingsPlans -> Rep DescribeSavingsPlans x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeSavingsPlans x -> DescribeSavingsPlans
$cfrom :: forall x. DescribeSavingsPlans -> Rep DescribeSavingsPlans x
Prelude.Generic)

-- |
-- Create a value of 'DescribeSavingsPlans' 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:
--
-- 'states', 'describeSavingsPlans_states' - The states.
--
-- 'savingsPlanIds', 'describeSavingsPlans_savingsPlanIds' - The IDs of the Savings Plans.
--
-- 'filters', 'describeSavingsPlans_filters' - The filters.
--
-- 'nextToken', 'describeSavingsPlans_nextToken' - The token for the next page of results.
--
-- 'savingsPlanArns', 'describeSavingsPlans_savingsPlanArns' - The Amazon Resource Names (ARN) of the Savings Plans.
--
-- 'maxResults', 'describeSavingsPlans_maxResults' - The maximum number of results to return with a single call. To retrieve
-- additional results, make another call with the returned token value.
newDescribeSavingsPlans ::
  DescribeSavingsPlans
newDescribeSavingsPlans :: DescribeSavingsPlans
newDescribeSavingsPlans =
  DescribeSavingsPlans' :: Maybe [SavingsPlanState]
-> Maybe [Text]
-> Maybe [SavingsPlanFilter]
-> Maybe Text
-> Maybe [Text]
-> Maybe Natural
-> DescribeSavingsPlans
DescribeSavingsPlans'
    { $sel:states:DescribeSavingsPlans' :: Maybe [SavingsPlanState]
states = Maybe [SavingsPlanState]
forall a. Maybe a
Prelude.Nothing,
      $sel:savingsPlanIds:DescribeSavingsPlans' :: Maybe [Text]
savingsPlanIds = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:filters:DescribeSavingsPlans' :: Maybe [SavingsPlanFilter]
filters = Maybe [SavingsPlanFilter]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeSavingsPlans' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:savingsPlanArns:DescribeSavingsPlans' :: Maybe [Text]
savingsPlanArns = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:DescribeSavingsPlans' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The states.
describeSavingsPlans_states :: Lens.Lens' DescribeSavingsPlans (Prelude.Maybe [SavingsPlanState])
describeSavingsPlans_states :: (Maybe [SavingsPlanState] -> f (Maybe [SavingsPlanState]))
-> DescribeSavingsPlans -> f DescribeSavingsPlans
describeSavingsPlans_states = (DescribeSavingsPlans -> Maybe [SavingsPlanState])
-> (DescribeSavingsPlans
    -> Maybe [SavingsPlanState] -> DescribeSavingsPlans)
-> Lens
     DescribeSavingsPlans
     DescribeSavingsPlans
     (Maybe [SavingsPlanState])
     (Maybe [SavingsPlanState])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSavingsPlans' {Maybe [SavingsPlanState]
states :: Maybe [SavingsPlanState]
$sel:states:DescribeSavingsPlans' :: DescribeSavingsPlans -> Maybe [SavingsPlanState]
states} -> Maybe [SavingsPlanState]
states) (\s :: DescribeSavingsPlans
s@DescribeSavingsPlans' {} Maybe [SavingsPlanState]
a -> DescribeSavingsPlans
s {$sel:states:DescribeSavingsPlans' :: Maybe [SavingsPlanState]
states = Maybe [SavingsPlanState]
a} :: DescribeSavingsPlans) ((Maybe [SavingsPlanState] -> f (Maybe [SavingsPlanState]))
 -> DescribeSavingsPlans -> f DescribeSavingsPlans)
-> ((Maybe [SavingsPlanState] -> f (Maybe [SavingsPlanState]))
    -> Maybe [SavingsPlanState] -> f (Maybe [SavingsPlanState]))
-> (Maybe [SavingsPlanState] -> f (Maybe [SavingsPlanState]))
-> DescribeSavingsPlans
-> f DescribeSavingsPlans
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [SavingsPlanState]
  [SavingsPlanState]
  [SavingsPlanState]
  [SavingsPlanState]
-> Iso
     (Maybe [SavingsPlanState])
     (Maybe [SavingsPlanState])
     (Maybe [SavingsPlanState])
     (Maybe [SavingsPlanState])
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
  [SavingsPlanState]
  [SavingsPlanState]
  [SavingsPlanState]
  [SavingsPlanState]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The IDs of the Savings Plans.
describeSavingsPlans_savingsPlanIds :: Lens.Lens' DescribeSavingsPlans (Prelude.Maybe [Prelude.Text])
describeSavingsPlans_savingsPlanIds :: (Maybe [Text] -> f (Maybe [Text]))
-> DescribeSavingsPlans -> f DescribeSavingsPlans
describeSavingsPlans_savingsPlanIds = (DescribeSavingsPlans -> Maybe [Text])
-> (DescribeSavingsPlans -> Maybe [Text] -> DescribeSavingsPlans)
-> Lens
     DescribeSavingsPlans
     DescribeSavingsPlans
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSavingsPlans' {Maybe [Text]
savingsPlanIds :: Maybe [Text]
$sel:savingsPlanIds:DescribeSavingsPlans' :: DescribeSavingsPlans -> Maybe [Text]
savingsPlanIds} -> Maybe [Text]
savingsPlanIds) (\s :: DescribeSavingsPlans
s@DescribeSavingsPlans' {} Maybe [Text]
a -> DescribeSavingsPlans
s {$sel:savingsPlanIds:DescribeSavingsPlans' :: Maybe [Text]
savingsPlanIds = Maybe [Text]
a} :: DescribeSavingsPlans) ((Maybe [Text] -> f (Maybe [Text]))
 -> DescribeSavingsPlans -> f DescribeSavingsPlans)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> DescribeSavingsPlans
-> f DescribeSavingsPlans
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The filters.
describeSavingsPlans_filters :: Lens.Lens' DescribeSavingsPlans (Prelude.Maybe [SavingsPlanFilter])
describeSavingsPlans_filters :: (Maybe [SavingsPlanFilter] -> f (Maybe [SavingsPlanFilter]))
-> DescribeSavingsPlans -> f DescribeSavingsPlans
describeSavingsPlans_filters = (DescribeSavingsPlans -> Maybe [SavingsPlanFilter])
-> (DescribeSavingsPlans
    -> Maybe [SavingsPlanFilter] -> DescribeSavingsPlans)
-> Lens
     DescribeSavingsPlans
     DescribeSavingsPlans
     (Maybe [SavingsPlanFilter])
     (Maybe [SavingsPlanFilter])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSavingsPlans' {Maybe [SavingsPlanFilter]
filters :: Maybe [SavingsPlanFilter]
$sel:filters:DescribeSavingsPlans' :: DescribeSavingsPlans -> Maybe [SavingsPlanFilter]
filters} -> Maybe [SavingsPlanFilter]
filters) (\s :: DescribeSavingsPlans
s@DescribeSavingsPlans' {} Maybe [SavingsPlanFilter]
a -> DescribeSavingsPlans
s {$sel:filters:DescribeSavingsPlans' :: Maybe [SavingsPlanFilter]
filters = Maybe [SavingsPlanFilter]
a} :: DescribeSavingsPlans) ((Maybe [SavingsPlanFilter] -> f (Maybe [SavingsPlanFilter]))
 -> DescribeSavingsPlans -> f DescribeSavingsPlans)
-> ((Maybe [SavingsPlanFilter] -> f (Maybe [SavingsPlanFilter]))
    -> Maybe [SavingsPlanFilter] -> f (Maybe [SavingsPlanFilter]))
-> (Maybe [SavingsPlanFilter] -> f (Maybe [SavingsPlanFilter]))
-> DescribeSavingsPlans
-> f DescribeSavingsPlans
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [SavingsPlanFilter]
  [SavingsPlanFilter]
  [SavingsPlanFilter]
  [SavingsPlanFilter]
-> Iso
     (Maybe [SavingsPlanFilter])
     (Maybe [SavingsPlanFilter])
     (Maybe [SavingsPlanFilter])
     (Maybe [SavingsPlanFilter])
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
  [SavingsPlanFilter]
  [SavingsPlanFilter]
  [SavingsPlanFilter]
  [SavingsPlanFilter]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The token for the next page of results.
describeSavingsPlans_nextToken :: Lens.Lens' DescribeSavingsPlans (Prelude.Maybe Prelude.Text)
describeSavingsPlans_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeSavingsPlans -> f DescribeSavingsPlans
describeSavingsPlans_nextToken = (DescribeSavingsPlans -> Maybe Text)
-> (DescribeSavingsPlans -> Maybe Text -> DescribeSavingsPlans)
-> Lens
     DescribeSavingsPlans DescribeSavingsPlans (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSavingsPlans' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeSavingsPlans' :: DescribeSavingsPlans -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeSavingsPlans
s@DescribeSavingsPlans' {} Maybe Text
a -> DescribeSavingsPlans
s {$sel:nextToken:DescribeSavingsPlans' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeSavingsPlans)

-- | The Amazon Resource Names (ARN) of the Savings Plans.
describeSavingsPlans_savingsPlanArns :: Lens.Lens' DescribeSavingsPlans (Prelude.Maybe [Prelude.Text])
describeSavingsPlans_savingsPlanArns :: (Maybe [Text] -> f (Maybe [Text]))
-> DescribeSavingsPlans -> f DescribeSavingsPlans
describeSavingsPlans_savingsPlanArns = (DescribeSavingsPlans -> Maybe [Text])
-> (DescribeSavingsPlans -> Maybe [Text] -> DescribeSavingsPlans)
-> Lens
     DescribeSavingsPlans
     DescribeSavingsPlans
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSavingsPlans' {Maybe [Text]
savingsPlanArns :: Maybe [Text]
$sel:savingsPlanArns:DescribeSavingsPlans' :: DescribeSavingsPlans -> Maybe [Text]
savingsPlanArns} -> Maybe [Text]
savingsPlanArns) (\s :: DescribeSavingsPlans
s@DescribeSavingsPlans' {} Maybe [Text]
a -> DescribeSavingsPlans
s {$sel:savingsPlanArns:DescribeSavingsPlans' :: Maybe [Text]
savingsPlanArns = Maybe [Text]
a} :: DescribeSavingsPlans) ((Maybe [Text] -> f (Maybe [Text]))
 -> DescribeSavingsPlans -> f DescribeSavingsPlans)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> DescribeSavingsPlans
-> f DescribeSavingsPlans
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The maximum number of results to return with a single call. To retrieve
-- additional results, make another call with the returned token value.
describeSavingsPlans_maxResults :: Lens.Lens' DescribeSavingsPlans (Prelude.Maybe Prelude.Natural)
describeSavingsPlans_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> DescribeSavingsPlans -> f DescribeSavingsPlans
describeSavingsPlans_maxResults = (DescribeSavingsPlans -> Maybe Natural)
-> (DescribeSavingsPlans -> Maybe Natural -> DescribeSavingsPlans)
-> Lens
     DescribeSavingsPlans
     DescribeSavingsPlans
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSavingsPlans' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:DescribeSavingsPlans' :: DescribeSavingsPlans -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: DescribeSavingsPlans
s@DescribeSavingsPlans' {} Maybe Natural
a -> DescribeSavingsPlans
s {$sel:maxResults:DescribeSavingsPlans' :: Maybe Natural
maxResults = Maybe Natural
a} :: DescribeSavingsPlans)

instance Core.AWSRequest DescribeSavingsPlans where
  type
    AWSResponse DescribeSavingsPlans =
      DescribeSavingsPlansResponse
  request :: DescribeSavingsPlans -> Request DescribeSavingsPlans
request = Service -> DescribeSavingsPlans -> Request DescribeSavingsPlans
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeSavingsPlans
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeSavingsPlans)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeSavingsPlans))
-> Logger
-> Service
-> Proxy DescribeSavingsPlans
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeSavingsPlans)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [SavingsPlan]
-> Maybe Text -> Int -> DescribeSavingsPlansResponse
DescribeSavingsPlansResponse'
            (Maybe [SavingsPlan]
 -> Maybe Text -> Int -> DescribeSavingsPlansResponse)
-> Either String (Maybe [SavingsPlan])
-> Either
     String (Maybe Text -> Int -> DescribeSavingsPlansResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [SavingsPlan]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"savingsPlans" Either String (Maybe (Maybe [SavingsPlan]))
-> Maybe [SavingsPlan] -> Either String (Maybe [SavingsPlan])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [SavingsPlan]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Maybe Text -> Int -> DescribeSavingsPlansResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DescribeSavingsPlansResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"nextToken")
            Either String (Int -> DescribeSavingsPlansResponse)
-> Either String Int -> Either String DescribeSavingsPlansResponse
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 DescribeSavingsPlans

instance Prelude.NFData DescribeSavingsPlans

instance Core.ToHeaders DescribeSavingsPlans where
  toHeaders :: DescribeSavingsPlans -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeSavingsPlans -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON DescribeSavingsPlans where
  toJSON :: DescribeSavingsPlans -> Value
toJSON DescribeSavingsPlans' {Maybe Natural
Maybe [Text]
Maybe [SavingsPlanState]
Maybe [SavingsPlanFilter]
Maybe Text
maxResults :: Maybe Natural
savingsPlanArns :: Maybe [Text]
nextToken :: Maybe Text
filters :: Maybe [SavingsPlanFilter]
savingsPlanIds :: Maybe [Text]
states :: Maybe [SavingsPlanState]
$sel:maxResults:DescribeSavingsPlans' :: DescribeSavingsPlans -> Maybe Natural
$sel:savingsPlanArns:DescribeSavingsPlans' :: DescribeSavingsPlans -> Maybe [Text]
$sel:nextToken:DescribeSavingsPlans' :: DescribeSavingsPlans -> Maybe Text
$sel:filters:DescribeSavingsPlans' :: DescribeSavingsPlans -> Maybe [SavingsPlanFilter]
$sel:savingsPlanIds:DescribeSavingsPlans' :: DescribeSavingsPlans -> Maybe [Text]
$sel:states:DescribeSavingsPlans' :: DescribeSavingsPlans -> Maybe [SavingsPlanState]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"states" Text -> [SavingsPlanState] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([SavingsPlanState] -> Pair)
-> Maybe [SavingsPlanState] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [SavingsPlanState]
states,
            (Text
"savingsPlanIds" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
savingsPlanIds,
            (Text
"filters" Text -> [SavingsPlanFilter] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([SavingsPlanFilter] -> Pair)
-> Maybe [SavingsPlanFilter] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [SavingsPlanFilter]
filters,
            (Text
"nextToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken,
            (Text
"savingsPlanArns" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
savingsPlanArns,
            (Text
"maxResults" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults
          ]
      )

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

instance Core.ToQuery DescribeSavingsPlans where
  toQuery :: DescribeSavingsPlans -> QueryString
toQuery = QueryString -> DescribeSavingsPlans -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

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

-- |
-- Create a value of 'DescribeSavingsPlansResponse' 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:
--
-- 'savingsPlans', 'describeSavingsPlansResponse_savingsPlans' - Information about the Savings Plans.
--
-- 'nextToken', 'describeSavingsPlansResponse_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', 'describeSavingsPlansResponse_httpStatus' - The response's http status code.
newDescribeSavingsPlansResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeSavingsPlansResponse
newDescribeSavingsPlansResponse :: Int -> DescribeSavingsPlansResponse
newDescribeSavingsPlansResponse Int
pHttpStatus_ =
  DescribeSavingsPlansResponse' :: Maybe [SavingsPlan]
-> Maybe Text -> Int -> DescribeSavingsPlansResponse
DescribeSavingsPlansResponse'
    { $sel:savingsPlans:DescribeSavingsPlansResponse' :: Maybe [SavingsPlan]
savingsPlans =
        Maybe [SavingsPlan]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeSavingsPlansResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeSavingsPlansResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the Savings Plans.
describeSavingsPlansResponse_savingsPlans :: Lens.Lens' DescribeSavingsPlansResponse (Prelude.Maybe [SavingsPlan])
describeSavingsPlansResponse_savingsPlans :: (Maybe [SavingsPlan] -> f (Maybe [SavingsPlan]))
-> DescribeSavingsPlansResponse -> f DescribeSavingsPlansResponse
describeSavingsPlansResponse_savingsPlans = (DescribeSavingsPlansResponse -> Maybe [SavingsPlan])
-> (DescribeSavingsPlansResponse
    -> Maybe [SavingsPlan] -> DescribeSavingsPlansResponse)
-> Lens
     DescribeSavingsPlansResponse
     DescribeSavingsPlansResponse
     (Maybe [SavingsPlan])
     (Maybe [SavingsPlan])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSavingsPlansResponse' {Maybe [SavingsPlan]
savingsPlans :: Maybe [SavingsPlan]
$sel:savingsPlans:DescribeSavingsPlansResponse' :: DescribeSavingsPlansResponse -> Maybe [SavingsPlan]
savingsPlans} -> Maybe [SavingsPlan]
savingsPlans) (\s :: DescribeSavingsPlansResponse
s@DescribeSavingsPlansResponse' {} Maybe [SavingsPlan]
a -> DescribeSavingsPlansResponse
s {$sel:savingsPlans:DescribeSavingsPlansResponse' :: Maybe [SavingsPlan]
savingsPlans = Maybe [SavingsPlan]
a} :: DescribeSavingsPlansResponse) ((Maybe [SavingsPlan] -> f (Maybe [SavingsPlan]))
 -> DescribeSavingsPlansResponse -> f DescribeSavingsPlansResponse)
-> ((Maybe [SavingsPlan] -> f (Maybe [SavingsPlan]))
    -> Maybe [SavingsPlan] -> f (Maybe [SavingsPlan]))
-> (Maybe [SavingsPlan] -> f (Maybe [SavingsPlan]))
-> DescribeSavingsPlansResponse
-> f DescribeSavingsPlansResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [SavingsPlan] [SavingsPlan] [SavingsPlan] [SavingsPlan]
-> Iso
     (Maybe [SavingsPlan])
     (Maybe [SavingsPlan])
     (Maybe [SavingsPlan])
     (Maybe [SavingsPlan])
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 [SavingsPlan] [SavingsPlan] [SavingsPlan] [SavingsPlan]
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.
describeSavingsPlansResponse_nextToken :: Lens.Lens' DescribeSavingsPlansResponse (Prelude.Maybe Prelude.Text)
describeSavingsPlansResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeSavingsPlansResponse -> f DescribeSavingsPlansResponse
describeSavingsPlansResponse_nextToken = (DescribeSavingsPlansResponse -> Maybe Text)
-> (DescribeSavingsPlansResponse
    -> Maybe Text -> DescribeSavingsPlansResponse)
-> Lens
     DescribeSavingsPlansResponse
     DescribeSavingsPlansResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSavingsPlansResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeSavingsPlansResponse' :: DescribeSavingsPlansResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeSavingsPlansResponse
s@DescribeSavingsPlansResponse' {} Maybe Text
a -> DescribeSavingsPlansResponse
s {$sel:nextToken:DescribeSavingsPlansResponse' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeSavingsPlansResponse)

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

instance Prelude.NFData DescribeSavingsPlansResponse