{-# 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.Inspector.Types.AgentFilter
-- 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.Inspector.Types.AgentFilter where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Inspector.Types.AgentHealth
import Amazonka.Inspector.Types.AgentHealthCode
import qualified Amazonka.Prelude as Prelude

-- | Contains information about an Amazon Inspector agent. This data type is
-- used as a request parameter in the ListAssessmentRunAgents action.
--
-- /See:/ 'newAgentFilter' smart constructor.
data AgentFilter = AgentFilter'
  { -- | The current health state of the agent. Values can be set to __HEALTHY__
    -- or __UNHEALTHY__.
    AgentFilter -> [AgentHealth]
agentHealths :: [AgentHealth],
    -- | The detailed health state of the agent. Values can be set to __IDLE__,
    -- __RUNNING__, __SHUTDOWN__, __UNHEALTHY__, __THROTTLED__, and
    -- __UNKNOWN__.
    AgentFilter -> [AgentHealthCode]
agentHealthCodes :: [AgentHealthCode]
  }
  deriving (AgentFilter -> AgentFilter -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AgentFilter -> AgentFilter -> Bool
$c/= :: AgentFilter -> AgentFilter -> Bool
== :: AgentFilter -> AgentFilter -> Bool
$c== :: AgentFilter -> AgentFilter -> Bool
Prelude.Eq, ReadPrec [AgentFilter]
ReadPrec AgentFilter
Int -> ReadS AgentFilter
ReadS [AgentFilter]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AgentFilter]
$creadListPrec :: ReadPrec [AgentFilter]
readPrec :: ReadPrec AgentFilter
$creadPrec :: ReadPrec AgentFilter
readList :: ReadS [AgentFilter]
$creadList :: ReadS [AgentFilter]
readsPrec :: Int -> ReadS AgentFilter
$creadsPrec :: Int -> ReadS AgentFilter
Prelude.Read, Int -> AgentFilter -> ShowS
[AgentFilter] -> ShowS
AgentFilter -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AgentFilter] -> ShowS
$cshowList :: [AgentFilter] -> ShowS
show :: AgentFilter -> String
$cshow :: AgentFilter -> String
showsPrec :: Int -> AgentFilter -> ShowS
$cshowsPrec :: Int -> AgentFilter -> ShowS
Prelude.Show, forall x. Rep AgentFilter x -> AgentFilter
forall x. AgentFilter -> Rep AgentFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AgentFilter x -> AgentFilter
$cfrom :: forall x. AgentFilter -> Rep AgentFilter x
Prelude.Generic)

-- |
-- Create a value of 'AgentFilter' 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:
--
-- 'agentHealths', 'agentFilter_agentHealths' - The current health state of the agent. Values can be set to __HEALTHY__
-- or __UNHEALTHY__.
--
-- 'agentHealthCodes', 'agentFilter_agentHealthCodes' - The detailed health state of the agent. Values can be set to __IDLE__,
-- __RUNNING__, __SHUTDOWN__, __UNHEALTHY__, __THROTTLED__, and
-- __UNKNOWN__.
newAgentFilter ::
  AgentFilter
newAgentFilter :: AgentFilter
newAgentFilter =
  AgentFilter'
    { $sel:agentHealths:AgentFilter' :: [AgentHealth]
agentHealths = forall a. Monoid a => a
Prelude.mempty,
      $sel:agentHealthCodes:AgentFilter' :: [AgentHealthCode]
agentHealthCodes = forall a. Monoid a => a
Prelude.mempty
    }

-- | The current health state of the agent. Values can be set to __HEALTHY__
-- or __UNHEALTHY__.
agentFilter_agentHealths :: Lens.Lens' AgentFilter [AgentHealth]
agentFilter_agentHealths :: Lens' AgentFilter [AgentHealth]
agentFilter_agentHealths = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AgentFilter' {[AgentHealth]
agentHealths :: [AgentHealth]
$sel:agentHealths:AgentFilter' :: AgentFilter -> [AgentHealth]
agentHealths} -> [AgentHealth]
agentHealths) (\s :: AgentFilter
s@AgentFilter' {} [AgentHealth]
a -> AgentFilter
s {$sel:agentHealths:AgentFilter' :: [AgentHealth]
agentHealths = [AgentHealth]
a} :: AgentFilter) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The detailed health state of the agent. Values can be set to __IDLE__,
-- __RUNNING__, __SHUTDOWN__, __UNHEALTHY__, __THROTTLED__, and
-- __UNKNOWN__.
agentFilter_agentHealthCodes :: Lens.Lens' AgentFilter [AgentHealthCode]
agentFilter_agentHealthCodes :: Lens' AgentFilter [AgentHealthCode]
agentFilter_agentHealthCodes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AgentFilter' {[AgentHealthCode]
agentHealthCodes :: [AgentHealthCode]
$sel:agentHealthCodes:AgentFilter' :: AgentFilter -> [AgentHealthCode]
agentHealthCodes} -> [AgentHealthCode]
agentHealthCodes) (\s :: AgentFilter
s@AgentFilter' {} [AgentHealthCode]
a -> AgentFilter
s {$sel:agentHealthCodes:AgentFilter' :: [AgentHealthCode]
agentHealthCodes = [AgentHealthCode]
a} :: AgentFilter) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable AgentFilter where
  hashWithSalt :: Int -> AgentFilter -> Int
hashWithSalt Int
_salt AgentFilter' {[AgentHealth]
[AgentHealthCode]
agentHealthCodes :: [AgentHealthCode]
agentHealths :: [AgentHealth]
$sel:agentHealthCodes:AgentFilter' :: AgentFilter -> [AgentHealthCode]
$sel:agentHealths:AgentFilter' :: AgentFilter -> [AgentHealth]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [AgentHealth]
agentHealths
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [AgentHealthCode]
agentHealthCodes

instance Prelude.NFData AgentFilter where
  rnf :: AgentFilter -> ()
rnf AgentFilter' {[AgentHealth]
[AgentHealthCode]
agentHealthCodes :: [AgentHealthCode]
agentHealths :: [AgentHealth]
$sel:agentHealthCodes:AgentFilter' :: AgentFilter -> [AgentHealthCode]
$sel:agentHealths:AgentFilter' :: AgentFilter -> [AgentHealth]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf [AgentHealth]
agentHealths
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [AgentHealthCode]
agentHealthCodes

instance Data.ToJSON AgentFilter where
  toJSON :: AgentFilter -> Value
toJSON AgentFilter' {[AgentHealth]
[AgentHealthCode]
agentHealthCodes :: [AgentHealthCode]
agentHealths :: [AgentHealth]
$sel:agentHealthCodes:AgentFilter' :: AgentFilter -> [AgentHealthCode]
$sel:agentHealths:AgentFilter' :: AgentFilter -> [AgentHealth]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"agentHealths" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [AgentHealth]
agentHealths),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"agentHealthCodes" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [AgentHealthCode]
agentHealthCodes)
          ]
      )