{-# 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.DocumentFilter
-- 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.DocumentFilter 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.DocumentFilterKey

-- | This data type is deprecated. Instead, use DocumentKeyValuesFilter.
--
-- /See:/ 'newDocumentFilter' smart constructor.
data DocumentFilter = DocumentFilter'
  { -- | The name of the filter.
    DocumentFilter -> DocumentFilterKey
key :: DocumentFilterKey,
    -- | The value of the filter.
    DocumentFilter -> Text
value :: Prelude.Text
  }
  deriving (DocumentFilter -> DocumentFilter -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DocumentFilter -> DocumentFilter -> Bool
$c/= :: DocumentFilter -> DocumentFilter -> Bool
== :: DocumentFilter -> DocumentFilter -> Bool
$c== :: DocumentFilter -> DocumentFilter -> Bool
Prelude.Eq, ReadPrec [DocumentFilter]
ReadPrec DocumentFilter
Int -> ReadS DocumentFilter
ReadS [DocumentFilter]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DocumentFilter]
$creadListPrec :: ReadPrec [DocumentFilter]
readPrec :: ReadPrec DocumentFilter
$creadPrec :: ReadPrec DocumentFilter
readList :: ReadS [DocumentFilter]
$creadList :: ReadS [DocumentFilter]
readsPrec :: Int -> ReadS DocumentFilter
$creadsPrec :: Int -> ReadS DocumentFilter
Prelude.Read, Int -> DocumentFilter -> ShowS
[DocumentFilter] -> ShowS
DocumentFilter -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DocumentFilter] -> ShowS
$cshowList :: [DocumentFilter] -> ShowS
show :: DocumentFilter -> String
$cshow :: DocumentFilter -> String
showsPrec :: Int -> DocumentFilter -> ShowS
$cshowsPrec :: Int -> DocumentFilter -> ShowS
Prelude.Show, forall x. Rep DocumentFilter x -> DocumentFilter
forall x. DocumentFilter -> Rep DocumentFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DocumentFilter x -> DocumentFilter
$cfrom :: forall x. DocumentFilter -> Rep DocumentFilter x
Prelude.Generic)

-- |
-- Create a value of 'DocumentFilter' 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', 'documentFilter_key' - The name of the filter.
--
-- 'value', 'documentFilter_value' - The value of the filter.
newDocumentFilter ::
  -- | 'key'
  DocumentFilterKey ->
  -- | 'value'
  Prelude.Text ->
  DocumentFilter
newDocumentFilter :: DocumentFilterKey -> Text -> DocumentFilter
newDocumentFilter DocumentFilterKey
pKey_ Text
pValue_ =
  DocumentFilter' {$sel:key:DocumentFilter' :: DocumentFilterKey
key = DocumentFilterKey
pKey_, $sel:value:DocumentFilter' :: Text
value = Text
pValue_}

-- | The name of the filter.
documentFilter_key :: Lens.Lens' DocumentFilter DocumentFilterKey
documentFilter_key :: Lens' DocumentFilter DocumentFilterKey
documentFilter_key = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DocumentFilter' {DocumentFilterKey
key :: DocumentFilterKey
$sel:key:DocumentFilter' :: DocumentFilter -> DocumentFilterKey
key} -> DocumentFilterKey
key) (\s :: DocumentFilter
s@DocumentFilter' {} DocumentFilterKey
a -> DocumentFilter
s {$sel:key:DocumentFilter' :: DocumentFilterKey
key = DocumentFilterKey
a} :: DocumentFilter)

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

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

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

instance Data.ToJSON DocumentFilter where
  toJSON :: DocumentFilter -> Value
toJSON DocumentFilter' {Text
DocumentFilterKey
value :: Text
key :: DocumentFilterKey
$sel:value:DocumentFilter' :: DocumentFilter -> Text
$sel:key:DocumentFilter' :: DocumentFilter -> DocumentFilterKey
..} =
    [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..= DocumentFilterKey
key),
            forall a. a -> Maybe a
Prelude.Just (Key
"value" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
value)
          ]
      )