{-# 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.JobFilter
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.ComputeOptimizer.Types.JobFilter where

import Amazonka.ComputeOptimizer.Types.JobFilterName
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Describes a filter that returns a more specific list of recommendation
-- export jobs. Use this filter with the DescribeRecommendationExportJobs
-- action.
--
-- You can use @EBSFilter@ with the GetEBSVolumeRecommendations action,
-- @LambdaFunctionRecommendationFilter@ with the
-- GetLambdaFunctionRecommendations action, and @Filter@ with the
-- GetAutoScalingGroupRecommendations and GetEC2InstanceRecommendations
-- actions.
--
-- /See:/ 'newJobFilter' smart constructor.
data JobFilter = JobFilter'
  { -- | The name of the filter.
    --
    -- Specify @ResourceType@ to return export jobs of a specific resource type
    -- (for example, @Ec2Instance@).
    --
    -- Specify @JobStatus@ to return export jobs with a specific status (e.g,
    -- @Complete@).
    JobFilter -> Maybe JobFilterName
name :: Prelude.Maybe JobFilterName,
    -- | The value of the filter.
    --
    -- The valid values for this parameter are as follows, depending on what
    -- you specify for the @name@ parameter:
    --
    -- -   Specify @Ec2Instance@ or @AutoScalingGroup@ if you specify the
    --     @name@ parameter as @ResourceType@. There is no filter for EBS
    --     volumes because volume recommendations cannot be exported at this
    --     time.
    --
    -- -   Specify @Queued@, @InProgress@, @Complete@, or @Failed@ if you
    --     specify the @name@ parameter as @JobStatus@.
    JobFilter -> Maybe [Text]
values :: Prelude.Maybe [Prelude.Text]
  }
  deriving (JobFilter -> JobFilter -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: JobFilter -> JobFilter -> Bool
$c/= :: JobFilter -> JobFilter -> Bool
== :: JobFilter -> JobFilter -> Bool
$c== :: JobFilter -> JobFilter -> Bool
Prelude.Eq, ReadPrec [JobFilter]
ReadPrec JobFilter
Int -> ReadS JobFilter
ReadS [JobFilter]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [JobFilter]
$creadListPrec :: ReadPrec [JobFilter]
readPrec :: ReadPrec JobFilter
$creadPrec :: ReadPrec JobFilter
readList :: ReadS [JobFilter]
$creadList :: ReadS [JobFilter]
readsPrec :: Int -> ReadS JobFilter
$creadsPrec :: Int -> ReadS JobFilter
Prelude.Read, Int -> JobFilter -> ShowS
[JobFilter] -> ShowS
JobFilter -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [JobFilter] -> ShowS
$cshowList :: [JobFilter] -> ShowS
show :: JobFilter -> String
$cshow :: JobFilter -> String
showsPrec :: Int -> JobFilter -> ShowS
$cshowsPrec :: Int -> JobFilter -> ShowS
Prelude.Show, forall x. Rep JobFilter x -> JobFilter
forall x. JobFilter -> Rep JobFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep JobFilter x -> JobFilter
$cfrom :: forall x. JobFilter -> Rep JobFilter x
Prelude.Generic)

-- |
-- Create a value of 'JobFilter' 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:
--
-- 'name', 'jobFilter_name' - The name of the filter.
--
-- Specify @ResourceType@ to return export jobs of a specific resource type
-- (for example, @Ec2Instance@).
--
-- Specify @JobStatus@ to return export jobs with a specific status (e.g,
-- @Complete@).
--
-- 'values', 'jobFilter_values' - The value of the filter.
--
-- The valid values for this parameter are as follows, depending on what
-- you specify for the @name@ parameter:
--
-- -   Specify @Ec2Instance@ or @AutoScalingGroup@ if you specify the
--     @name@ parameter as @ResourceType@. There is no filter for EBS
--     volumes because volume recommendations cannot be exported at this
--     time.
--
-- -   Specify @Queued@, @InProgress@, @Complete@, or @Failed@ if you
--     specify the @name@ parameter as @JobStatus@.
newJobFilter ::
  JobFilter
newJobFilter :: JobFilter
newJobFilter =
  JobFilter'
    { $sel:name:JobFilter' :: Maybe JobFilterName
name = forall a. Maybe a
Prelude.Nothing,
      $sel:values:JobFilter' :: Maybe [Text]
values = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the filter.
--
-- Specify @ResourceType@ to return export jobs of a specific resource type
-- (for example, @Ec2Instance@).
--
-- Specify @JobStatus@ to return export jobs with a specific status (e.g,
-- @Complete@).
jobFilter_name :: Lens.Lens' JobFilter (Prelude.Maybe JobFilterName)
jobFilter_name :: Lens' JobFilter (Maybe JobFilterName)
jobFilter_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobFilter' {Maybe JobFilterName
name :: Maybe JobFilterName
$sel:name:JobFilter' :: JobFilter -> Maybe JobFilterName
name} -> Maybe JobFilterName
name) (\s :: JobFilter
s@JobFilter' {} Maybe JobFilterName
a -> JobFilter
s {$sel:name:JobFilter' :: Maybe JobFilterName
name = Maybe JobFilterName
a} :: JobFilter)

-- | The value of the filter.
--
-- The valid values for this parameter are as follows, depending on what
-- you specify for the @name@ parameter:
--
-- -   Specify @Ec2Instance@ or @AutoScalingGroup@ if you specify the
--     @name@ parameter as @ResourceType@. There is no filter for EBS
--     volumes because volume recommendations cannot be exported at this
--     time.
--
-- -   Specify @Queued@, @InProgress@, @Complete@, or @Failed@ if you
--     specify the @name@ parameter as @JobStatus@.
jobFilter_values :: Lens.Lens' JobFilter (Prelude.Maybe [Prelude.Text])
jobFilter_values :: Lens' JobFilter (Maybe [Text])
jobFilter_values = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobFilter' {Maybe [Text]
values :: Maybe [Text]
$sel:values:JobFilter' :: JobFilter -> Maybe [Text]
values} -> Maybe [Text]
values) (\s :: JobFilter
s@JobFilter' {} Maybe [Text]
a -> JobFilter
s {$sel:values:JobFilter' :: Maybe [Text]
values = Maybe [Text]
a} :: JobFilter) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable JobFilter where
  hashWithSalt :: Int -> JobFilter -> Int
hashWithSalt Int
_salt JobFilter' {Maybe [Text]
Maybe JobFilterName
values :: Maybe [Text]
name :: Maybe JobFilterName
$sel:values:JobFilter' :: JobFilter -> Maybe [Text]
$sel:name:JobFilter' :: JobFilter -> Maybe JobFilterName
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe JobFilterName
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
values

instance Prelude.NFData JobFilter where
  rnf :: JobFilter -> ()
rnf JobFilter' {Maybe [Text]
Maybe JobFilterName
values :: Maybe [Text]
name :: Maybe JobFilterName
$sel:values:JobFilter' :: JobFilter -> Maybe [Text]
$sel:name:JobFilter' :: JobFilter -> Maybe JobFilterName
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe JobFilterName
name seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
values

instance Data.ToJSON JobFilter where
  toJSON :: JobFilter -> Value
toJSON JobFilter' {Maybe [Text]
Maybe JobFilterName
values :: Maybe [Text]
name :: Maybe JobFilterName
$sel:values:JobFilter' :: JobFilter -> Maybe [Text]
$sel:name:JobFilter' :: JobFilter -> Maybe JobFilterName
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe JobFilterName
name,
            (Key
"values" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
values
          ]
      )