{-# 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.ComputeOptimizer.GetEBSVolumeRecommendations
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns Amazon Elastic Block Store (Amazon EBS) volume recommendations.
--
-- Compute Optimizer generates recommendations for Amazon EBS volumes that
-- meet a specific set of requirements. For more information, see the
-- <https://docs.aws.amazon.com/compute-optimizer/latest/ug/requirements.html Supported resources and requirements>
-- in the /Compute Optimizer User Guide/.
module Amazonka.ComputeOptimizer.GetEBSVolumeRecommendations
  ( -- * Creating a Request
    GetEBSVolumeRecommendations (..),
    newGetEBSVolumeRecommendations,

    -- * Request Lenses
    getEBSVolumeRecommendations_accountIds,
    getEBSVolumeRecommendations_filters,
    getEBSVolumeRecommendations_nextToken,
    getEBSVolumeRecommendations_volumeArns,
    getEBSVolumeRecommendations_maxResults,

    -- * Destructuring the Response
    GetEBSVolumeRecommendationsResponse (..),
    newGetEBSVolumeRecommendationsResponse,

    -- * Response Lenses
    getEBSVolumeRecommendationsResponse_nextToken,
    getEBSVolumeRecommendationsResponse_volumeRecommendations,
    getEBSVolumeRecommendationsResponse_errors,
    getEBSVolumeRecommendationsResponse_httpStatus,
  )
where

import Amazonka.ComputeOptimizer.Types
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

-- | /See:/ 'newGetEBSVolumeRecommendations' smart constructor.
data GetEBSVolumeRecommendations = GetEBSVolumeRecommendations'
  { -- | The ID of the Amazon Web Services account for which to return volume
    -- recommendations.
    --
    -- If your account is the management account of an organization, use this
    -- parameter to specify the member account for which you want to return
    -- volume recommendations.
    --
    -- Only one account ID can be specified per request.
    GetEBSVolumeRecommendations -> Maybe [Text]
accountIds :: Prelude.Maybe [Prelude.Text],
    -- | An array of objects to specify a filter that returns a more specific
    -- list of volume recommendations.
    GetEBSVolumeRecommendations -> Maybe [EBSFilter]
filters :: Prelude.Maybe [EBSFilter],
    -- | The token to advance to the next page of volume recommendations.
    GetEBSVolumeRecommendations -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the volumes for which to return
    -- recommendations.
    GetEBSVolumeRecommendations -> Maybe [Text]
volumeArns :: Prelude.Maybe [Prelude.Text],
    -- | The maximum number of volume recommendations to return with a single
    -- request.
    --
    -- To retrieve the remaining results, make another request with the
    -- returned @nextToken@ value.
    GetEBSVolumeRecommendations -> Maybe Int
maxResults :: Prelude.Maybe Prelude.Int
  }
  deriving (GetEBSVolumeRecommendations -> GetEBSVolumeRecommendations -> Bool
(GetEBSVolumeRecommendations
 -> GetEBSVolumeRecommendations -> Bool)
-> (GetEBSVolumeRecommendations
    -> GetEBSVolumeRecommendations -> Bool)
-> Eq GetEBSVolumeRecommendations
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetEBSVolumeRecommendations -> GetEBSVolumeRecommendations -> Bool
$c/= :: GetEBSVolumeRecommendations -> GetEBSVolumeRecommendations -> Bool
== :: GetEBSVolumeRecommendations -> GetEBSVolumeRecommendations -> Bool
$c== :: GetEBSVolumeRecommendations -> GetEBSVolumeRecommendations -> Bool
Prelude.Eq, ReadPrec [GetEBSVolumeRecommendations]
ReadPrec GetEBSVolumeRecommendations
Int -> ReadS GetEBSVolumeRecommendations
ReadS [GetEBSVolumeRecommendations]
(Int -> ReadS GetEBSVolumeRecommendations)
-> ReadS [GetEBSVolumeRecommendations]
-> ReadPrec GetEBSVolumeRecommendations
-> ReadPrec [GetEBSVolumeRecommendations]
-> Read GetEBSVolumeRecommendations
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetEBSVolumeRecommendations]
$creadListPrec :: ReadPrec [GetEBSVolumeRecommendations]
readPrec :: ReadPrec GetEBSVolumeRecommendations
$creadPrec :: ReadPrec GetEBSVolumeRecommendations
readList :: ReadS [GetEBSVolumeRecommendations]
$creadList :: ReadS [GetEBSVolumeRecommendations]
readsPrec :: Int -> ReadS GetEBSVolumeRecommendations
$creadsPrec :: Int -> ReadS GetEBSVolumeRecommendations
Prelude.Read, Int -> GetEBSVolumeRecommendations -> ShowS
[GetEBSVolumeRecommendations] -> ShowS
GetEBSVolumeRecommendations -> String
(Int -> GetEBSVolumeRecommendations -> ShowS)
-> (GetEBSVolumeRecommendations -> String)
-> ([GetEBSVolumeRecommendations] -> ShowS)
-> Show GetEBSVolumeRecommendations
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetEBSVolumeRecommendations] -> ShowS
$cshowList :: [GetEBSVolumeRecommendations] -> ShowS
show :: GetEBSVolumeRecommendations -> String
$cshow :: GetEBSVolumeRecommendations -> String
showsPrec :: Int -> GetEBSVolumeRecommendations -> ShowS
$cshowsPrec :: Int -> GetEBSVolumeRecommendations -> ShowS
Prelude.Show, (forall x.
 GetEBSVolumeRecommendations -> Rep GetEBSVolumeRecommendations x)
-> (forall x.
    Rep GetEBSVolumeRecommendations x -> GetEBSVolumeRecommendations)
-> Generic GetEBSVolumeRecommendations
forall x.
Rep GetEBSVolumeRecommendations x -> GetEBSVolumeRecommendations
forall x.
GetEBSVolumeRecommendations -> Rep GetEBSVolumeRecommendations x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetEBSVolumeRecommendations x -> GetEBSVolumeRecommendations
$cfrom :: forall x.
GetEBSVolumeRecommendations -> Rep GetEBSVolumeRecommendations x
Prelude.Generic)

-- |
-- Create a value of 'GetEBSVolumeRecommendations' 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:
--
-- 'accountIds', 'getEBSVolumeRecommendations_accountIds' - The ID of the Amazon Web Services account for which to return volume
-- recommendations.
--
-- If your account is the management account of an organization, use this
-- parameter to specify the member account for which you want to return
-- volume recommendations.
--
-- Only one account ID can be specified per request.
--
-- 'filters', 'getEBSVolumeRecommendations_filters' - An array of objects to specify a filter that returns a more specific
-- list of volume recommendations.
--
-- 'nextToken', 'getEBSVolumeRecommendations_nextToken' - The token to advance to the next page of volume recommendations.
--
-- 'volumeArns', 'getEBSVolumeRecommendations_volumeArns' - The Amazon Resource Name (ARN) of the volumes for which to return
-- recommendations.
--
-- 'maxResults', 'getEBSVolumeRecommendations_maxResults' - The maximum number of volume recommendations to return with a single
-- request.
--
-- To retrieve the remaining results, make another request with the
-- returned @nextToken@ value.
newGetEBSVolumeRecommendations ::
  GetEBSVolumeRecommendations
newGetEBSVolumeRecommendations :: GetEBSVolumeRecommendations
newGetEBSVolumeRecommendations =
  GetEBSVolumeRecommendations' :: Maybe [Text]
-> Maybe [EBSFilter]
-> Maybe Text
-> Maybe [Text]
-> Maybe Int
-> GetEBSVolumeRecommendations
GetEBSVolumeRecommendations'
    { $sel:accountIds:GetEBSVolumeRecommendations' :: Maybe [Text]
accountIds =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:filters:GetEBSVolumeRecommendations' :: Maybe [EBSFilter]
filters = Maybe [EBSFilter]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:GetEBSVolumeRecommendations' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:volumeArns:GetEBSVolumeRecommendations' :: Maybe [Text]
volumeArns = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:GetEBSVolumeRecommendations' :: Maybe Int
maxResults = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the Amazon Web Services account for which to return volume
-- recommendations.
--
-- If your account is the management account of an organization, use this
-- parameter to specify the member account for which you want to return
-- volume recommendations.
--
-- Only one account ID can be specified per request.
getEBSVolumeRecommendations_accountIds :: Lens.Lens' GetEBSVolumeRecommendations (Prelude.Maybe [Prelude.Text])
getEBSVolumeRecommendations_accountIds :: (Maybe [Text] -> f (Maybe [Text]))
-> GetEBSVolumeRecommendations -> f GetEBSVolumeRecommendations
getEBSVolumeRecommendations_accountIds = (GetEBSVolumeRecommendations -> Maybe [Text])
-> (GetEBSVolumeRecommendations
    -> Maybe [Text] -> GetEBSVolumeRecommendations)
-> Lens
     GetEBSVolumeRecommendations
     GetEBSVolumeRecommendations
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEBSVolumeRecommendations' {Maybe [Text]
accountIds :: Maybe [Text]
$sel:accountIds:GetEBSVolumeRecommendations' :: GetEBSVolumeRecommendations -> Maybe [Text]
accountIds} -> Maybe [Text]
accountIds) (\s :: GetEBSVolumeRecommendations
s@GetEBSVolumeRecommendations' {} Maybe [Text]
a -> GetEBSVolumeRecommendations
s {$sel:accountIds:GetEBSVolumeRecommendations' :: Maybe [Text]
accountIds = Maybe [Text]
a} :: GetEBSVolumeRecommendations) ((Maybe [Text] -> f (Maybe [Text]))
 -> GetEBSVolumeRecommendations -> f GetEBSVolumeRecommendations)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> GetEBSVolumeRecommendations
-> f GetEBSVolumeRecommendations
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

-- | An array of objects to specify a filter that returns a more specific
-- list of volume recommendations.
getEBSVolumeRecommendations_filters :: Lens.Lens' GetEBSVolumeRecommendations (Prelude.Maybe [EBSFilter])
getEBSVolumeRecommendations_filters :: (Maybe [EBSFilter] -> f (Maybe [EBSFilter]))
-> GetEBSVolumeRecommendations -> f GetEBSVolumeRecommendations
getEBSVolumeRecommendations_filters = (GetEBSVolumeRecommendations -> Maybe [EBSFilter])
-> (GetEBSVolumeRecommendations
    -> Maybe [EBSFilter] -> GetEBSVolumeRecommendations)
-> Lens
     GetEBSVolumeRecommendations
     GetEBSVolumeRecommendations
     (Maybe [EBSFilter])
     (Maybe [EBSFilter])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEBSVolumeRecommendations' {Maybe [EBSFilter]
filters :: Maybe [EBSFilter]
$sel:filters:GetEBSVolumeRecommendations' :: GetEBSVolumeRecommendations -> Maybe [EBSFilter]
filters} -> Maybe [EBSFilter]
filters) (\s :: GetEBSVolumeRecommendations
s@GetEBSVolumeRecommendations' {} Maybe [EBSFilter]
a -> GetEBSVolumeRecommendations
s {$sel:filters:GetEBSVolumeRecommendations' :: Maybe [EBSFilter]
filters = Maybe [EBSFilter]
a} :: GetEBSVolumeRecommendations) ((Maybe [EBSFilter] -> f (Maybe [EBSFilter]))
 -> GetEBSVolumeRecommendations -> f GetEBSVolumeRecommendations)
-> ((Maybe [EBSFilter] -> f (Maybe [EBSFilter]))
    -> Maybe [EBSFilter] -> f (Maybe [EBSFilter]))
-> (Maybe [EBSFilter] -> f (Maybe [EBSFilter]))
-> GetEBSVolumeRecommendations
-> f GetEBSVolumeRecommendations
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [EBSFilter] [EBSFilter] [EBSFilter] [EBSFilter]
-> Iso
     (Maybe [EBSFilter])
     (Maybe [EBSFilter])
     (Maybe [EBSFilter])
     (Maybe [EBSFilter])
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 [EBSFilter] [EBSFilter] [EBSFilter] [EBSFilter]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The token to advance to the next page of volume recommendations.
getEBSVolumeRecommendations_nextToken :: Lens.Lens' GetEBSVolumeRecommendations (Prelude.Maybe Prelude.Text)
getEBSVolumeRecommendations_nextToken :: (Maybe Text -> f (Maybe Text))
-> GetEBSVolumeRecommendations -> f GetEBSVolumeRecommendations
getEBSVolumeRecommendations_nextToken = (GetEBSVolumeRecommendations -> Maybe Text)
-> (GetEBSVolumeRecommendations
    -> Maybe Text -> GetEBSVolumeRecommendations)
-> Lens
     GetEBSVolumeRecommendations
     GetEBSVolumeRecommendations
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEBSVolumeRecommendations' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetEBSVolumeRecommendations' :: GetEBSVolumeRecommendations -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetEBSVolumeRecommendations
s@GetEBSVolumeRecommendations' {} Maybe Text
a -> GetEBSVolumeRecommendations
s {$sel:nextToken:GetEBSVolumeRecommendations' :: Maybe Text
nextToken = Maybe Text
a} :: GetEBSVolumeRecommendations)

-- | The Amazon Resource Name (ARN) of the volumes for which to return
-- recommendations.
getEBSVolumeRecommendations_volumeArns :: Lens.Lens' GetEBSVolumeRecommendations (Prelude.Maybe [Prelude.Text])
getEBSVolumeRecommendations_volumeArns :: (Maybe [Text] -> f (Maybe [Text]))
-> GetEBSVolumeRecommendations -> f GetEBSVolumeRecommendations
getEBSVolumeRecommendations_volumeArns = (GetEBSVolumeRecommendations -> Maybe [Text])
-> (GetEBSVolumeRecommendations
    -> Maybe [Text] -> GetEBSVolumeRecommendations)
-> Lens
     GetEBSVolumeRecommendations
     GetEBSVolumeRecommendations
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEBSVolumeRecommendations' {Maybe [Text]
volumeArns :: Maybe [Text]
$sel:volumeArns:GetEBSVolumeRecommendations' :: GetEBSVolumeRecommendations -> Maybe [Text]
volumeArns} -> Maybe [Text]
volumeArns) (\s :: GetEBSVolumeRecommendations
s@GetEBSVolumeRecommendations' {} Maybe [Text]
a -> GetEBSVolumeRecommendations
s {$sel:volumeArns:GetEBSVolumeRecommendations' :: Maybe [Text]
volumeArns = Maybe [Text]
a} :: GetEBSVolumeRecommendations) ((Maybe [Text] -> f (Maybe [Text]))
 -> GetEBSVolumeRecommendations -> f GetEBSVolumeRecommendations)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> GetEBSVolumeRecommendations
-> f GetEBSVolumeRecommendations
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 volume recommendations to return with a single
-- request.
--
-- To retrieve the remaining results, make another request with the
-- returned @nextToken@ value.
getEBSVolumeRecommendations_maxResults :: Lens.Lens' GetEBSVolumeRecommendations (Prelude.Maybe Prelude.Int)
getEBSVolumeRecommendations_maxResults :: (Maybe Int -> f (Maybe Int))
-> GetEBSVolumeRecommendations -> f GetEBSVolumeRecommendations
getEBSVolumeRecommendations_maxResults = (GetEBSVolumeRecommendations -> Maybe Int)
-> (GetEBSVolumeRecommendations
    -> Maybe Int -> GetEBSVolumeRecommendations)
-> Lens
     GetEBSVolumeRecommendations
     GetEBSVolumeRecommendations
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEBSVolumeRecommendations' {Maybe Int
maxResults :: Maybe Int
$sel:maxResults:GetEBSVolumeRecommendations' :: GetEBSVolumeRecommendations -> Maybe Int
maxResults} -> Maybe Int
maxResults) (\s :: GetEBSVolumeRecommendations
s@GetEBSVolumeRecommendations' {} Maybe Int
a -> GetEBSVolumeRecommendations
s {$sel:maxResults:GetEBSVolumeRecommendations' :: Maybe Int
maxResults = Maybe Int
a} :: GetEBSVolumeRecommendations)

instance Core.AWSRequest GetEBSVolumeRecommendations where
  type
    AWSResponse GetEBSVolumeRecommendations =
      GetEBSVolumeRecommendationsResponse
  request :: GetEBSVolumeRecommendations -> Request GetEBSVolumeRecommendations
request = Service
-> GetEBSVolumeRecommendations
-> Request GetEBSVolumeRecommendations
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetEBSVolumeRecommendations
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetEBSVolumeRecommendations)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetEBSVolumeRecommendations))
-> Logger
-> Service
-> Proxy GetEBSVolumeRecommendations
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetEBSVolumeRecommendations)))
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 Text
-> Maybe [VolumeRecommendation]
-> Maybe [GetRecommendationError]
-> Int
-> GetEBSVolumeRecommendationsResponse
GetEBSVolumeRecommendationsResponse'
            (Maybe Text
 -> Maybe [VolumeRecommendation]
 -> Maybe [GetRecommendationError]
 -> Int
 -> GetEBSVolumeRecommendationsResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe [VolumeRecommendation]
      -> Maybe [GetRecommendationError]
      -> Int
      -> GetEBSVolumeRecommendationsResponse)
forall (f :: * -> *) a b. Functor 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
  (Maybe [VolumeRecommendation]
   -> Maybe [GetRecommendationError]
   -> Int
   -> GetEBSVolumeRecommendationsResponse)
-> Either String (Maybe [VolumeRecommendation])
-> Either
     String
     (Maybe [GetRecommendationError]
      -> Int -> GetEBSVolumeRecommendationsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object
-> Text -> Either String (Maybe (Maybe [VolumeRecommendation]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"volumeRecommendations"
                            Either String (Maybe (Maybe [VolumeRecommendation]))
-> Maybe [VolumeRecommendation]
-> Either String (Maybe [VolumeRecommendation])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [VolumeRecommendation]
forall a. Monoid a => a
Prelude.mempty
                        )
            Either
  String
  (Maybe [GetRecommendationError]
   -> Int -> GetEBSVolumeRecommendationsResponse)
-> Either String (Maybe [GetRecommendationError])
-> Either String (Int -> GetEBSVolumeRecommendationsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object
-> Text -> Either String (Maybe (Maybe [GetRecommendationError]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"errors" Either String (Maybe (Maybe [GetRecommendationError]))
-> Maybe [GetRecommendationError]
-> Either String (Maybe [GetRecommendationError])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [GetRecommendationError]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> GetEBSVolumeRecommendationsResponse)
-> Either String Int
-> Either String GetEBSVolumeRecommendationsResponse
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 GetEBSVolumeRecommendations

instance Prelude.NFData GetEBSVolumeRecommendations

instance Core.ToHeaders GetEBSVolumeRecommendations where
  toHeaders :: GetEBSVolumeRecommendations -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetEBSVolumeRecommendations -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"ComputeOptimizerService.GetEBSVolumeRecommendations" ::
                          Prelude.ByteString
                      ),
            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 GetEBSVolumeRecommendations where
  toJSON :: GetEBSVolumeRecommendations -> Value
toJSON GetEBSVolumeRecommendations' {Maybe Int
Maybe [Text]
Maybe [EBSFilter]
Maybe Text
maxResults :: Maybe Int
volumeArns :: Maybe [Text]
nextToken :: Maybe Text
filters :: Maybe [EBSFilter]
accountIds :: Maybe [Text]
$sel:maxResults:GetEBSVolumeRecommendations' :: GetEBSVolumeRecommendations -> Maybe Int
$sel:volumeArns:GetEBSVolumeRecommendations' :: GetEBSVolumeRecommendations -> Maybe [Text]
$sel:nextToken:GetEBSVolumeRecommendations' :: GetEBSVolumeRecommendations -> Maybe Text
$sel:filters:GetEBSVolumeRecommendations' :: GetEBSVolumeRecommendations -> Maybe [EBSFilter]
$sel:accountIds:GetEBSVolumeRecommendations' :: GetEBSVolumeRecommendations -> Maybe [Text]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"accountIds" 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]
accountIds,
            (Text
"filters" Text -> [EBSFilter] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([EBSFilter] -> Pair) -> Maybe [EBSFilter] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [EBSFilter]
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
"volumeArns" 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]
volumeArns,
            (Text
"maxResults" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
maxResults
          ]
      )

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

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

-- | /See:/ 'newGetEBSVolumeRecommendationsResponse' smart constructor.
data GetEBSVolumeRecommendationsResponse = GetEBSVolumeRecommendationsResponse'
  { -- | The token to use to advance to the next page of volume recommendations.
    --
    -- This value is null when there are no more pages of volume
    -- recommendations to return.
    GetEBSVolumeRecommendationsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | An array of objects that describe volume recommendations.
    GetEBSVolumeRecommendationsResponse -> Maybe [VolumeRecommendation]
volumeRecommendations :: Prelude.Maybe [VolumeRecommendation],
    -- | An array of objects that describe errors of the request.
    --
    -- For example, an error is returned if you request recommendations for an
    -- unsupported volume.
    GetEBSVolumeRecommendationsResponse
-> Maybe [GetRecommendationError]
errors :: Prelude.Maybe [GetRecommendationError],
    -- | The response's http status code.
    GetEBSVolumeRecommendationsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetEBSVolumeRecommendationsResponse
-> GetEBSVolumeRecommendationsResponse -> Bool
(GetEBSVolumeRecommendationsResponse
 -> GetEBSVolumeRecommendationsResponse -> Bool)
-> (GetEBSVolumeRecommendationsResponse
    -> GetEBSVolumeRecommendationsResponse -> Bool)
-> Eq GetEBSVolumeRecommendationsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetEBSVolumeRecommendationsResponse
-> GetEBSVolumeRecommendationsResponse -> Bool
$c/= :: GetEBSVolumeRecommendationsResponse
-> GetEBSVolumeRecommendationsResponse -> Bool
== :: GetEBSVolumeRecommendationsResponse
-> GetEBSVolumeRecommendationsResponse -> Bool
$c== :: GetEBSVolumeRecommendationsResponse
-> GetEBSVolumeRecommendationsResponse -> Bool
Prelude.Eq, ReadPrec [GetEBSVolumeRecommendationsResponse]
ReadPrec GetEBSVolumeRecommendationsResponse
Int -> ReadS GetEBSVolumeRecommendationsResponse
ReadS [GetEBSVolumeRecommendationsResponse]
(Int -> ReadS GetEBSVolumeRecommendationsResponse)
-> ReadS [GetEBSVolumeRecommendationsResponse]
-> ReadPrec GetEBSVolumeRecommendationsResponse
-> ReadPrec [GetEBSVolumeRecommendationsResponse]
-> Read GetEBSVolumeRecommendationsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetEBSVolumeRecommendationsResponse]
$creadListPrec :: ReadPrec [GetEBSVolumeRecommendationsResponse]
readPrec :: ReadPrec GetEBSVolumeRecommendationsResponse
$creadPrec :: ReadPrec GetEBSVolumeRecommendationsResponse
readList :: ReadS [GetEBSVolumeRecommendationsResponse]
$creadList :: ReadS [GetEBSVolumeRecommendationsResponse]
readsPrec :: Int -> ReadS GetEBSVolumeRecommendationsResponse
$creadsPrec :: Int -> ReadS GetEBSVolumeRecommendationsResponse
Prelude.Read, Int -> GetEBSVolumeRecommendationsResponse -> ShowS
[GetEBSVolumeRecommendationsResponse] -> ShowS
GetEBSVolumeRecommendationsResponse -> String
(Int -> GetEBSVolumeRecommendationsResponse -> ShowS)
-> (GetEBSVolumeRecommendationsResponse -> String)
-> ([GetEBSVolumeRecommendationsResponse] -> ShowS)
-> Show GetEBSVolumeRecommendationsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetEBSVolumeRecommendationsResponse] -> ShowS
$cshowList :: [GetEBSVolumeRecommendationsResponse] -> ShowS
show :: GetEBSVolumeRecommendationsResponse -> String
$cshow :: GetEBSVolumeRecommendationsResponse -> String
showsPrec :: Int -> GetEBSVolumeRecommendationsResponse -> ShowS
$cshowsPrec :: Int -> GetEBSVolumeRecommendationsResponse -> ShowS
Prelude.Show, (forall x.
 GetEBSVolumeRecommendationsResponse
 -> Rep GetEBSVolumeRecommendationsResponse x)
-> (forall x.
    Rep GetEBSVolumeRecommendationsResponse x
    -> GetEBSVolumeRecommendationsResponse)
-> Generic GetEBSVolumeRecommendationsResponse
forall x.
Rep GetEBSVolumeRecommendationsResponse x
-> GetEBSVolumeRecommendationsResponse
forall x.
GetEBSVolumeRecommendationsResponse
-> Rep GetEBSVolumeRecommendationsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetEBSVolumeRecommendationsResponse x
-> GetEBSVolumeRecommendationsResponse
$cfrom :: forall x.
GetEBSVolumeRecommendationsResponse
-> Rep GetEBSVolumeRecommendationsResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetEBSVolumeRecommendationsResponse' 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', 'getEBSVolumeRecommendationsResponse_nextToken' - The token to use to advance to the next page of volume recommendations.
--
-- This value is null when there are no more pages of volume
-- recommendations to return.
--
-- 'volumeRecommendations', 'getEBSVolumeRecommendationsResponse_volumeRecommendations' - An array of objects that describe volume recommendations.
--
-- 'errors', 'getEBSVolumeRecommendationsResponse_errors' - An array of objects that describe errors of the request.
--
-- For example, an error is returned if you request recommendations for an
-- unsupported volume.
--
-- 'httpStatus', 'getEBSVolumeRecommendationsResponse_httpStatus' - The response's http status code.
newGetEBSVolumeRecommendationsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetEBSVolumeRecommendationsResponse
newGetEBSVolumeRecommendationsResponse :: Int -> GetEBSVolumeRecommendationsResponse
newGetEBSVolumeRecommendationsResponse Int
pHttpStatus_ =
  GetEBSVolumeRecommendationsResponse' :: Maybe Text
-> Maybe [VolumeRecommendation]
-> Maybe [GetRecommendationError]
-> Int
-> GetEBSVolumeRecommendationsResponse
GetEBSVolumeRecommendationsResponse'
    { $sel:nextToken:GetEBSVolumeRecommendationsResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:volumeRecommendations:GetEBSVolumeRecommendationsResponse' :: Maybe [VolumeRecommendation]
volumeRecommendations =
        Maybe [VolumeRecommendation]
forall a. Maybe a
Prelude.Nothing,
      $sel:errors:GetEBSVolumeRecommendationsResponse' :: Maybe [GetRecommendationError]
errors = Maybe [GetRecommendationError]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetEBSVolumeRecommendationsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

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

-- | An array of objects that describe volume recommendations.
getEBSVolumeRecommendationsResponse_volumeRecommendations :: Lens.Lens' GetEBSVolumeRecommendationsResponse (Prelude.Maybe [VolumeRecommendation])
getEBSVolumeRecommendationsResponse_volumeRecommendations :: (Maybe [VolumeRecommendation] -> f (Maybe [VolumeRecommendation]))
-> GetEBSVolumeRecommendationsResponse
-> f GetEBSVolumeRecommendationsResponse
getEBSVolumeRecommendationsResponse_volumeRecommendations = (GetEBSVolumeRecommendationsResponse
 -> Maybe [VolumeRecommendation])
-> (GetEBSVolumeRecommendationsResponse
    -> Maybe [VolumeRecommendation]
    -> GetEBSVolumeRecommendationsResponse)
-> Lens
     GetEBSVolumeRecommendationsResponse
     GetEBSVolumeRecommendationsResponse
     (Maybe [VolumeRecommendation])
     (Maybe [VolumeRecommendation])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEBSVolumeRecommendationsResponse' {Maybe [VolumeRecommendation]
volumeRecommendations :: Maybe [VolumeRecommendation]
$sel:volumeRecommendations:GetEBSVolumeRecommendationsResponse' :: GetEBSVolumeRecommendationsResponse -> Maybe [VolumeRecommendation]
volumeRecommendations} -> Maybe [VolumeRecommendation]
volumeRecommendations) (\s :: GetEBSVolumeRecommendationsResponse
s@GetEBSVolumeRecommendationsResponse' {} Maybe [VolumeRecommendation]
a -> GetEBSVolumeRecommendationsResponse
s {$sel:volumeRecommendations:GetEBSVolumeRecommendationsResponse' :: Maybe [VolumeRecommendation]
volumeRecommendations = Maybe [VolumeRecommendation]
a} :: GetEBSVolumeRecommendationsResponse) ((Maybe [VolumeRecommendation] -> f (Maybe [VolumeRecommendation]))
 -> GetEBSVolumeRecommendationsResponse
 -> f GetEBSVolumeRecommendationsResponse)
-> ((Maybe [VolumeRecommendation]
     -> f (Maybe [VolumeRecommendation]))
    -> Maybe [VolumeRecommendation]
    -> f (Maybe [VolumeRecommendation]))
-> (Maybe [VolumeRecommendation]
    -> f (Maybe [VolumeRecommendation]))
-> GetEBSVolumeRecommendationsResponse
-> f GetEBSVolumeRecommendationsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [VolumeRecommendation]
  [VolumeRecommendation]
  [VolumeRecommendation]
  [VolumeRecommendation]
-> Iso
     (Maybe [VolumeRecommendation])
     (Maybe [VolumeRecommendation])
     (Maybe [VolumeRecommendation])
     (Maybe [VolumeRecommendation])
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
  [VolumeRecommendation]
  [VolumeRecommendation]
  [VolumeRecommendation]
  [VolumeRecommendation]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | An array of objects that describe errors of the request.
--
-- For example, an error is returned if you request recommendations for an
-- unsupported volume.
getEBSVolumeRecommendationsResponse_errors :: Lens.Lens' GetEBSVolumeRecommendationsResponse (Prelude.Maybe [GetRecommendationError])
getEBSVolumeRecommendationsResponse_errors :: (Maybe [GetRecommendationError]
 -> f (Maybe [GetRecommendationError]))
-> GetEBSVolumeRecommendationsResponse
-> f GetEBSVolumeRecommendationsResponse
getEBSVolumeRecommendationsResponse_errors = (GetEBSVolumeRecommendationsResponse
 -> Maybe [GetRecommendationError])
-> (GetEBSVolumeRecommendationsResponse
    -> Maybe [GetRecommendationError]
    -> GetEBSVolumeRecommendationsResponse)
-> Lens
     GetEBSVolumeRecommendationsResponse
     GetEBSVolumeRecommendationsResponse
     (Maybe [GetRecommendationError])
     (Maybe [GetRecommendationError])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEBSVolumeRecommendationsResponse' {Maybe [GetRecommendationError]
errors :: Maybe [GetRecommendationError]
$sel:errors:GetEBSVolumeRecommendationsResponse' :: GetEBSVolumeRecommendationsResponse
-> Maybe [GetRecommendationError]
errors} -> Maybe [GetRecommendationError]
errors) (\s :: GetEBSVolumeRecommendationsResponse
s@GetEBSVolumeRecommendationsResponse' {} Maybe [GetRecommendationError]
a -> GetEBSVolumeRecommendationsResponse
s {$sel:errors:GetEBSVolumeRecommendationsResponse' :: Maybe [GetRecommendationError]
errors = Maybe [GetRecommendationError]
a} :: GetEBSVolumeRecommendationsResponse) ((Maybe [GetRecommendationError]
  -> f (Maybe [GetRecommendationError]))
 -> GetEBSVolumeRecommendationsResponse
 -> f GetEBSVolumeRecommendationsResponse)
-> ((Maybe [GetRecommendationError]
     -> f (Maybe [GetRecommendationError]))
    -> Maybe [GetRecommendationError]
    -> f (Maybe [GetRecommendationError]))
-> (Maybe [GetRecommendationError]
    -> f (Maybe [GetRecommendationError]))
-> GetEBSVolumeRecommendationsResponse
-> f GetEBSVolumeRecommendationsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [GetRecommendationError]
  [GetRecommendationError]
  [GetRecommendationError]
  [GetRecommendationError]
-> Iso
     (Maybe [GetRecommendationError])
     (Maybe [GetRecommendationError])
     (Maybe [GetRecommendationError])
     (Maybe [GetRecommendationError])
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
  [GetRecommendationError]
  [GetRecommendationError]
  [GetRecommendationError]
  [GetRecommendationError]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance
  Prelude.NFData
    GetEBSVolumeRecommendationsResponse