{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.Filter
-- 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)
module Amazonka.ComputeOptimizer.Types.Filter where

import Amazonka.ComputeOptimizer.Types.FilterName
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes a filter that returns a more specific list of recommendations.
-- Use this filter with the GetAutoScalingGroupRecommendations and
-- GetEC2InstanceRecommendations actions.
--
-- You can use @EBSFilter@ with the GetEBSVolumeRecommendations action,
-- @LambdaFunctionRecommendationFilter@ with the
-- GetLambdaFunctionRecommendations action, and @JobFilter@ with the
-- DescribeRecommendationExportJobs action.
--
-- /See:/ 'newFilter' smart constructor.
data Filter = Filter'
  { -- | The value of the filter.
    --
    -- The valid values for this parameter are as follows, depending on what
    -- you specify for the @name@ parameter and the resource type that you wish
    -- to filter results for:
    --
    -- -   Specify @Optimized@ or @NotOptimized@ if you specify the @name@
    --     parameter as @Finding@ and you want to filter results for Auto
    --     Scaling groups.
    --
    -- -   Specify @Underprovisioned@, @Overprovisioned@, or @Optimized@ if you
    --     specify the @name@ parameter as @Finding@ and you want to filter
    --     results for EC2 instances.
    --
    -- -   Specify @Ec2Instance@ or @AutoScalingGroup@ if you specify the
    --     @name@ parameter as @RecommendationSourceType@.
    --
    -- -   Specify one of the following options if you specify the @name@
    --     parameter as @FindingReasonCodes@:
    --
    --     -   __@CPUOverprovisioned@__ — The instance’s CPU configuration can
    --         be sized down while still meeting the performance requirements
    --         of your workload.
    --
    --     -   __@CPUUnderprovisioned@__ — The instance’s CPU configuration
    --         doesn\'t meet the performance requirements of your workload and
    --         there is an alternative instance type that provides better CPU
    --         performance.
    --
    --     -   __@MemoryOverprovisioned@__ — The instance’s memory
    --         configuration can be sized down while still meeting the
    --         performance requirements of your workload.
    --
    --     -   __@MemoryUnderprovisioned@__ — The instance’s memory
    --         configuration doesn\'t meet the performance requirements of your
    --         workload and there is an alternative instance type that provides
    --         better memory performance.
    --
    --     -   __@EBSThroughputOverprovisioned@__ — The instance’s EBS
    --         throughput configuration can be sized down while still meeting
    --         the performance requirements of your workload.
    --
    --     -   __@EBSThroughputUnderprovisioned@__ — The instance’s EBS
    --         throughput configuration doesn\'t meet the performance
    --         requirements of your workload and there is an alternative
    --         instance type that provides better EBS throughput performance.
    --
    --     -   __@EBSIOPSOverprovisioned@__ — The instance’s EBS IOPS
    --         configuration can be sized down while still meeting the
    --         performance requirements of your workload.
    --
    --     -   __@EBSIOPSUnderprovisioned@__ — The instance’s EBS IOPS
    --         configuration doesn\'t meet the performance requirements of your
    --         workload and there is an alternative instance type that provides
    --         better EBS IOPS performance.
    --
    --     -   __@NetworkBandwidthOverprovisioned@__ — The instance’s network
    --         bandwidth configuration can be sized down while still meeting
    --         the performance requirements of your workload.
    --
    --     -   __@NetworkBandwidthUnderprovisioned@__ — The instance’s network
    --         bandwidth configuration doesn\'t meet the performance
    --         requirements of your workload and there is an alternative
    --         instance type that provides better network bandwidth
    --         performance. This finding reason happens when the @NetworkIn@ or
    --         @NetworkOut@ performance of an instance is impacted.
    --
    --     -   __@NetworkPPSOverprovisioned@__ — The instance’s network PPS
    --         (packets per second) configuration can be sized down while still
    --         meeting the performance requirements of your workload.
    --
    --     -   __@NetworkPPSUnderprovisioned@__ — The instance’s network PPS
    --         (packets per second) configuration doesn\'t meet the performance
    --         requirements of your workload and there is an alternative
    --         instance type that provides better network PPS performance.
    --
    --     -   __@DiskIOPSOverprovisioned@__ — The instance’s disk IOPS
    --         configuration can be sized down while still meeting the
    --         performance requirements of your workload.
    --
    --     -   __@DiskIOPSUnderprovisioned@__ — The instance’s disk IOPS
    --         configuration doesn\'t meet the performance requirements of your
    --         workload and there is an alternative instance type that provides
    --         better disk IOPS performance.
    --
    --     -   __@DiskThroughputOverprovisioned@__ — The instance’s disk
    --         throughput configuration can be sized down while still meeting
    --         the performance requirements of your workload.
    --
    --     -   __@DiskThroughputUnderprovisioned@__ — The instance’s disk
    --         throughput configuration doesn\'t meet the performance
    --         requirements of your workload and there is an alternative
    --         instance type that provides better disk throughput performance.
    Filter -> Maybe [Text]
values :: Prelude.Maybe [Prelude.Text],
    -- | The name of the filter.
    --
    -- Specify @Finding@ to return recommendations with a specific finding
    -- classification (for example, @Underprovisioned@).
    --
    -- Specify @RecommendationSourceType@ to return recommendations of a
    -- specific resource type (for example, @Ec2Instance@).
    --
    -- Specify @FindingReasonCodes@ to return recommendations with a specific
    -- finding reason code (for example, @CPUUnderprovisioned@).
    Filter -> Maybe FilterName
name :: Prelude.Maybe FilterName
  }
  deriving (Filter -> Filter -> Bool
(Filter -> Filter -> Bool)
-> (Filter -> Filter -> Bool) -> Eq Filter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Filter -> Filter -> Bool
$c/= :: Filter -> Filter -> Bool
== :: Filter -> Filter -> Bool
$c== :: Filter -> Filter -> Bool
Prelude.Eq, ReadPrec [Filter]
ReadPrec Filter
Int -> ReadS Filter
ReadS [Filter]
(Int -> ReadS Filter)
-> ReadS [Filter]
-> ReadPrec Filter
-> ReadPrec [Filter]
-> Read Filter
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Filter]
$creadListPrec :: ReadPrec [Filter]
readPrec :: ReadPrec Filter
$creadPrec :: ReadPrec Filter
readList :: ReadS [Filter]
$creadList :: ReadS [Filter]
readsPrec :: Int -> ReadS Filter
$creadsPrec :: Int -> ReadS Filter
Prelude.Read, Int -> Filter -> ShowS
[Filter] -> ShowS
Filter -> String
(Int -> Filter -> ShowS)
-> (Filter -> String) -> ([Filter] -> ShowS) -> Show Filter
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Filter] -> ShowS
$cshowList :: [Filter] -> ShowS
show :: Filter -> String
$cshow :: Filter -> String
showsPrec :: Int -> Filter -> ShowS
$cshowsPrec :: Int -> Filter -> ShowS
Prelude.Show, (forall x. Filter -> Rep Filter x)
-> (forall x. Rep Filter x -> Filter) -> Generic Filter
forall x. Rep Filter x -> Filter
forall x. Filter -> Rep Filter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Filter x -> Filter
$cfrom :: forall x. Filter -> Rep Filter x
Prelude.Generic)

-- |
-- Create a value of 'Filter' 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:
--
-- 'values', 'filter_values' - The value of the filter.
--
-- The valid values for this parameter are as follows, depending on what
-- you specify for the @name@ parameter and the resource type that you wish
-- to filter results for:
--
-- -   Specify @Optimized@ or @NotOptimized@ if you specify the @name@
--     parameter as @Finding@ and you want to filter results for Auto
--     Scaling groups.
--
-- -   Specify @Underprovisioned@, @Overprovisioned@, or @Optimized@ if you
--     specify the @name@ parameter as @Finding@ and you want to filter
--     results for EC2 instances.
--
-- -   Specify @Ec2Instance@ or @AutoScalingGroup@ if you specify the
--     @name@ parameter as @RecommendationSourceType@.
--
-- -   Specify one of the following options if you specify the @name@
--     parameter as @FindingReasonCodes@:
--
--     -   __@CPUOverprovisioned@__ — The instance’s CPU configuration can
--         be sized down while still meeting the performance requirements
--         of your workload.
--
--     -   __@CPUUnderprovisioned@__ — The instance’s CPU configuration
--         doesn\'t meet the performance requirements of your workload and
--         there is an alternative instance type that provides better CPU
--         performance.
--
--     -   __@MemoryOverprovisioned@__ — The instance’s memory
--         configuration can be sized down while still meeting the
--         performance requirements of your workload.
--
--     -   __@MemoryUnderprovisioned@__ — The instance’s memory
--         configuration doesn\'t meet the performance requirements of your
--         workload and there is an alternative instance type that provides
--         better memory performance.
--
--     -   __@EBSThroughputOverprovisioned@__ — The instance’s EBS
--         throughput configuration can be sized down while still meeting
--         the performance requirements of your workload.
--
--     -   __@EBSThroughputUnderprovisioned@__ — The instance’s EBS
--         throughput configuration doesn\'t meet the performance
--         requirements of your workload and there is an alternative
--         instance type that provides better EBS throughput performance.
--
--     -   __@EBSIOPSOverprovisioned@__ — The instance’s EBS IOPS
--         configuration can be sized down while still meeting the
--         performance requirements of your workload.
--
--     -   __@EBSIOPSUnderprovisioned@__ — The instance’s EBS IOPS
--         configuration doesn\'t meet the performance requirements of your
--         workload and there is an alternative instance type that provides
--         better EBS IOPS performance.
--
--     -   __@NetworkBandwidthOverprovisioned@__ — The instance’s network
--         bandwidth configuration can be sized down while still meeting
--         the performance requirements of your workload.
--
--     -   __@NetworkBandwidthUnderprovisioned@__ — The instance’s network
--         bandwidth configuration doesn\'t meet the performance
--         requirements of your workload and there is an alternative
--         instance type that provides better network bandwidth
--         performance. This finding reason happens when the @NetworkIn@ or
--         @NetworkOut@ performance of an instance is impacted.
--
--     -   __@NetworkPPSOverprovisioned@__ — The instance’s network PPS
--         (packets per second) configuration can be sized down while still
--         meeting the performance requirements of your workload.
--
--     -   __@NetworkPPSUnderprovisioned@__ — The instance’s network PPS
--         (packets per second) configuration doesn\'t meet the performance
--         requirements of your workload and there is an alternative
--         instance type that provides better network PPS performance.
--
--     -   __@DiskIOPSOverprovisioned@__ — The instance’s disk IOPS
--         configuration can be sized down while still meeting the
--         performance requirements of your workload.
--
--     -   __@DiskIOPSUnderprovisioned@__ — The instance’s disk IOPS
--         configuration doesn\'t meet the performance requirements of your
--         workload and there is an alternative instance type that provides
--         better disk IOPS performance.
--
--     -   __@DiskThroughputOverprovisioned@__ — The instance’s disk
--         throughput configuration can be sized down while still meeting
--         the performance requirements of your workload.
--
--     -   __@DiskThroughputUnderprovisioned@__ — The instance’s disk
--         throughput configuration doesn\'t meet the performance
--         requirements of your workload and there is an alternative
--         instance type that provides better disk throughput performance.
--
-- 'name', 'filter_name' - The name of the filter.
--
-- Specify @Finding@ to return recommendations with a specific finding
-- classification (for example, @Underprovisioned@).
--
-- Specify @RecommendationSourceType@ to return recommendations of a
-- specific resource type (for example, @Ec2Instance@).
--
-- Specify @FindingReasonCodes@ to return recommendations with a specific
-- finding reason code (for example, @CPUUnderprovisioned@).
newFilter ::
  Filter
newFilter :: Filter
newFilter =
  Filter' :: Maybe [Text] -> Maybe FilterName -> Filter
Filter'
    { $sel:values:Filter' :: Maybe [Text]
values = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:name:Filter' :: Maybe FilterName
name = Maybe FilterName
forall a. Maybe a
Prelude.Nothing
    }

-- | The value of the filter.
--
-- The valid values for this parameter are as follows, depending on what
-- you specify for the @name@ parameter and the resource type that you wish
-- to filter results for:
--
-- -   Specify @Optimized@ or @NotOptimized@ if you specify the @name@
--     parameter as @Finding@ and you want to filter results for Auto
--     Scaling groups.
--
-- -   Specify @Underprovisioned@, @Overprovisioned@, or @Optimized@ if you
--     specify the @name@ parameter as @Finding@ and you want to filter
--     results for EC2 instances.
--
-- -   Specify @Ec2Instance@ or @AutoScalingGroup@ if you specify the
--     @name@ parameter as @RecommendationSourceType@.
--
-- -   Specify one of the following options if you specify the @name@
--     parameter as @FindingReasonCodes@:
--
--     -   __@CPUOverprovisioned@__ — The instance’s CPU configuration can
--         be sized down while still meeting the performance requirements
--         of your workload.
--
--     -   __@CPUUnderprovisioned@__ — The instance’s CPU configuration
--         doesn\'t meet the performance requirements of your workload and
--         there is an alternative instance type that provides better CPU
--         performance.
--
--     -   __@MemoryOverprovisioned@__ — The instance’s memory
--         configuration can be sized down while still meeting the
--         performance requirements of your workload.
--
--     -   __@MemoryUnderprovisioned@__ — The instance’s memory
--         configuration doesn\'t meet the performance requirements of your
--         workload and there is an alternative instance type that provides
--         better memory performance.
--
--     -   __@EBSThroughputOverprovisioned@__ — The instance’s EBS
--         throughput configuration can be sized down while still meeting
--         the performance requirements of your workload.
--
--     -   __@EBSThroughputUnderprovisioned@__ — The instance’s EBS
--         throughput configuration doesn\'t meet the performance
--         requirements of your workload and there is an alternative
--         instance type that provides better EBS throughput performance.
--
--     -   __@EBSIOPSOverprovisioned@__ — The instance’s EBS IOPS
--         configuration can be sized down while still meeting the
--         performance requirements of your workload.
--
--     -   __@EBSIOPSUnderprovisioned@__ — The instance’s EBS IOPS
--         configuration doesn\'t meet the performance requirements of your
--         workload and there is an alternative instance type that provides
--         better EBS IOPS performance.
--
--     -   __@NetworkBandwidthOverprovisioned@__ — The instance’s network
--         bandwidth configuration can be sized down while still meeting
--         the performance requirements of your workload.
--
--     -   __@NetworkBandwidthUnderprovisioned@__ — The instance’s network
--         bandwidth configuration doesn\'t meet the performance
--         requirements of your workload and there is an alternative
--         instance type that provides better network bandwidth
--         performance. This finding reason happens when the @NetworkIn@ or
--         @NetworkOut@ performance of an instance is impacted.
--
--     -   __@NetworkPPSOverprovisioned@__ — The instance’s network PPS
--         (packets per second) configuration can be sized down while still
--         meeting the performance requirements of your workload.
--
--     -   __@NetworkPPSUnderprovisioned@__ — The instance’s network PPS
--         (packets per second) configuration doesn\'t meet the performance
--         requirements of your workload and there is an alternative
--         instance type that provides better network PPS performance.
--
--     -   __@DiskIOPSOverprovisioned@__ — The instance’s disk IOPS
--         configuration can be sized down while still meeting the
--         performance requirements of your workload.
--
--     -   __@DiskIOPSUnderprovisioned@__ — The instance’s disk IOPS
--         configuration doesn\'t meet the performance requirements of your
--         workload and there is an alternative instance type that provides
--         better disk IOPS performance.
--
--     -   __@DiskThroughputOverprovisioned@__ — The instance’s disk
--         throughput configuration can be sized down while still meeting
--         the performance requirements of your workload.
--
--     -   __@DiskThroughputUnderprovisioned@__ — The instance’s disk
--         throughput configuration doesn\'t meet the performance
--         requirements of your workload and there is an alternative
--         instance type that provides better disk throughput performance.
filter_values :: Lens.Lens' Filter (Prelude.Maybe [Prelude.Text])
filter_values :: (Maybe [Text] -> f (Maybe [Text])) -> Filter -> f Filter
filter_values = (Filter -> Maybe [Text])
-> (Filter -> Maybe [Text] -> Filter)
-> Lens Filter Filter (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Filter' {Maybe [Text]
values :: Maybe [Text]
$sel:values:Filter' :: Filter -> Maybe [Text]
values} -> Maybe [Text]
values) (\s :: Filter
s@Filter' {} Maybe [Text]
a -> Filter
s {$sel:values:Filter' :: Maybe [Text]
values = Maybe [Text]
a} :: Filter) ((Maybe [Text] -> f (Maybe [Text])) -> Filter -> f Filter)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> Filter
-> f Filter
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 name of the filter.
--
-- Specify @Finding@ to return recommendations with a specific finding
-- classification (for example, @Underprovisioned@).
--
-- Specify @RecommendationSourceType@ to return recommendations of a
-- specific resource type (for example, @Ec2Instance@).
--
-- Specify @FindingReasonCodes@ to return recommendations with a specific
-- finding reason code (for example, @CPUUnderprovisioned@).
filter_name :: Lens.Lens' Filter (Prelude.Maybe FilterName)
filter_name :: (Maybe FilterName -> f (Maybe FilterName)) -> Filter -> f Filter
filter_name = (Filter -> Maybe FilterName)
-> (Filter -> Maybe FilterName -> Filter)
-> Lens Filter Filter (Maybe FilterName) (Maybe FilterName)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Filter' {Maybe FilterName
name :: Maybe FilterName
$sel:name:Filter' :: Filter -> Maybe FilterName
name} -> Maybe FilterName
name) (\s :: Filter
s@Filter' {} Maybe FilterName
a -> Filter
s {$sel:name:Filter' :: Maybe FilterName
name = Maybe FilterName
a} :: Filter)

instance Prelude.Hashable Filter

instance Prelude.NFData Filter

instance Core.ToJSON Filter where
  toJSON :: Filter -> Value
toJSON Filter' {Maybe [Text]
Maybe FilterName
name :: Maybe FilterName
values :: Maybe [Text]
$sel:name:Filter' :: Filter -> Maybe FilterName
$sel:values:Filter' :: Filter -> Maybe [Text]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"values" 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]
values,
            (Text
"name" Text -> FilterName -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (FilterName -> Pair) -> Maybe FilterName -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe FilterName
name
          ]
      )