{-# 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.SSM.Types.AssociationFilter
-- 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.SSM.Types.AssociationFilter where

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

-- | Describes a filter.
--
-- /See:/ 'newAssociationFilter' smart constructor.
data AssociationFilter = AssociationFilter'
  { -- | The name of the filter.
    --
    -- @InstanceId@ has been deprecated.
    AssociationFilter -> AssociationFilterKey
key :: AssociationFilterKey,
    -- | The filter value.
    AssociationFilter -> Text
value :: Prelude.Text
  }
  deriving (AssociationFilter -> AssociationFilter -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociationFilter -> AssociationFilter -> Bool
$c/= :: AssociationFilter -> AssociationFilter -> Bool
== :: AssociationFilter -> AssociationFilter -> Bool
$c== :: AssociationFilter -> AssociationFilter -> Bool
Prelude.Eq, ReadPrec [AssociationFilter]
ReadPrec AssociationFilter
Int -> ReadS AssociationFilter
ReadS [AssociationFilter]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociationFilter]
$creadListPrec :: ReadPrec [AssociationFilter]
readPrec :: ReadPrec AssociationFilter
$creadPrec :: ReadPrec AssociationFilter
readList :: ReadS [AssociationFilter]
$creadList :: ReadS [AssociationFilter]
readsPrec :: Int -> ReadS AssociationFilter
$creadsPrec :: Int -> ReadS AssociationFilter
Prelude.Read, Int -> AssociationFilter -> ShowS
[AssociationFilter] -> ShowS
AssociationFilter -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociationFilter] -> ShowS
$cshowList :: [AssociationFilter] -> ShowS
show :: AssociationFilter -> String
$cshow :: AssociationFilter -> String
showsPrec :: Int -> AssociationFilter -> ShowS
$cshowsPrec :: Int -> AssociationFilter -> ShowS
Prelude.Show, forall x. Rep AssociationFilter x -> AssociationFilter
forall x. AssociationFilter -> Rep AssociationFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AssociationFilter x -> AssociationFilter
$cfrom :: forall x. AssociationFilter -> Rep AssociationFilter x
Prelude.Generic)

-- |
-- Create a value of 'AssociationFilter' 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:
--
-- 'key', 'associationFilter_key' - The name of the filter.
--
-- @InstanceId@ has been deprecated.
--
-- 'value', 'associationFilter_value' - The filter value.
newAssociationFilter ::
  -- | 'key'
  AssociationFilterKey ->
  -- | 'value'
  Prelude.Text ->
  AssociationFilter
newAssociationFilter :: AssociationFilterKey -> Text -> AssociationFilter
newAssociationFilter AssociationFilterKey
pKey_ Text
pValue_ =
  AssociationFilter' {$sel:key:AssociationFilter' :: AssociationFilterKey
key = AssociationFilterKey
pKey_, $sel:value:AssociationFilter' :: Text
value = Text
pValue_}

-- | The name of the filter.
--
-- @InstanceId@ has been deprecated.
associationFilter_key :: Lens.Lens' AssociationFilter AssociationFilterKey
associationFilter_key :: Lens' AssociationFilter AssociationFilterKey
associationFilter_key = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociationFilter' {AssociationFilterKey
key :: AssociationFilterKey
$sel:key:AssociationFilter' :: AssociationFilter -> AssociationFilterKey
key} -> AssociationFilterKey
key) (\s :: AssociationFilter
s@AssociationFilter' {} AssociationFilterKey
a -> AssociationFilter
s {$sel:key:AssociationFilter' :: AssociationFilterKey
key = AssociationFilterKey
a} :: AssociationFilter)

-- | The filter value.
associationFilter_value :: Lens.Lens' AssociationFilter Prelude.Text
associationFilter_value :: Lens' AssociationFilter Text
associationFilter_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociationFilter' {Text
value :: Text
$sel:value:AssociationFilter' :: AssociationFilter -> Text
value} -> Text
value) (\s :: AssociationFilter
s@AssociationFilter' {} Text
a -> AssociationFilter
s {$sel:value:AssociationFilter' :: Text
value = Text
a} :: AssociationFilter)

instance Prelude.Hashable AssociationFilter where
  hashWithSalt :: Int -> AssociationFilter -> Int
hashWithSalt Int
_salt AssociationFilter' {Text
AssociationFilterKey
value :: Text
key :: AssociationFilterKey
$sel:value:AssociationFilter' :: AssociationFilter -> Text
$sel:key:AssociationFilter' :: AssociationFilter -> AssociationFilterKey
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` AssociationFilterKey
key
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
value

instance Prelude.NFData AssociationFilter where
  rnf :: AssociationFilter -> ()
rnf AssociationFilter' {Text
AssociationFilterKey
value :: Text
key :: AssociationFilterKey
$sel:value:AssociationFilter' :: AssociationFilter -> Text
$sel:key:AssociationFilter' :: AssociationFilter -> AssociationFilterKey
..} =
    forall a. NFData a => a -> ()
Prelude.rnf AssociationFilterKey
key seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
value

instance Data.ToJSON AssociationFilter where
  toJSON :: AssociationFilter -> Value
toJSON AssociationFilter' {Text
AssociationFilterKey
value :: Text
key :: AssociationFilterKey
$sel:value:AssociationFilter' :: AssociationFilter -> Text
$sel:key:AssociationFilter' :: AssociationFilter -> AssociationFilterKey
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"key" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= AssociationFilterKey
key),
            forall a. a -> Maybe a
Prelude.Just (Key
"value" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
value)
          ]
      )