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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SSM.Types.OpsItemFilterKey
import Amazonka.SSM.Types.OpsItemFilterOperator

-- | Describes an OpsItem filter.
--
-- /See:/ 'newOpsItemFilter' smart constructor.
data OpsItemFilter = OpsItemFilter'
  { -- | The name of the filter.
    OpsItemFilter -> OpsItemFilterKey
key :: OpsItemFilterKey,
    -- | The filter value.
    OpsItemFilter -> [Text]
values :: [Prelude.Text],
    -- | The operator used by the filter call.
    OpsItemFilter -> OpsItemFilterOperator
operator :: OpsItemFilterOperator
  }
  deriving (OpsItemFilter -> OpsItemFilter -> Bool
(OpsItemFilter -> OpsItemFilter -> Bool)
-> (OpsItemFilter -> OpsItemFilter -> Bool) -> Eq OpsItemFilter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OpsItemFilter -> OpsItemFilter -> Bool
$c/= :: OpsItemFilter -> OpsItemFilter -> Bool
== :: OpsItemFilter -> OpsItemFilter -> Bool
$c== :: OpsItemFilter -> OpsItemFilter -> Bool
Prelude.Eq, ReadPrec [OpsItemFilter]
ReadPrec OpsItemFilter
Int -> ReadS OpsItemFilter
ReadS [OpsItemFilter]
(Int -> ReadS OpsItemFilter)
-> ReadS [OpsItemFilter]
-> ReadPrec OpsItemFilter
-> ReadPrec [OpsItemFilter]
-> Read OpsItemFilter
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OpsItemFilter]
$creadListPrec :: ReadPrec [OpsItemFilter]
readPrec :: ReadPrec OpsItemFilter
$creadPrec :: ReadPrec OpsItemFilter
readList :: ReadS [OpsItemFilter]
$creadList :: ReadS [OpsItemFilter]
readsPrec :: Int -> ReadS OpsItemFilter
$creadsPrec :: Int -> ReadS OpsItemFilter
Prelude.Read, Int -> OpsItemFilter -> ShowS
[OpsItemFilter] -> ShowS
OpsItemFilter -> String
(Int -> OpsItemFilter -> ShowS)
-> (OpsItemFilter -> String)
-> ([OpsItemFilter] -> ShowS)
-> Show OpsItemFilter
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OpsItemFilter] -> ShowS
$cshowList :: [OpsItemFilter] -> ShowS
show :: OpsItemFilter -> String
$cshow :: OpsItemFilter -> String
showsPrec :: Int -> OpsItemFilter -> ShowS
$cshowsPrec :: Int -> OpsItemFilter -> ShowS
Prelude.Show, (forall x. OpsItemFilter -> Rep OpsItemFilter x)
-> (forall x. Rep OpsItemFilter x -> OpsItemFilter)
-> Generic OpsItemFilter
forall x. Rep OpsItemFilter x -> OpsItemFilter
forall x. OpsItemFilter -> Rep OpsItemFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OpsItemFilter x -> OpsItemFilter
$cfrom :: forall x. OpsItemFilter -> Rep OpsItemFilter x
Prelude.Generic)

-- |
-- Create a value of 'OpsItemFilter' 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', 'opsItemFilter_key' - The name of the filter.
--
-- 'values', 'opsItemFilter_values' - The filter value.
--
-- 'operator', 'opsItemFilter_operator' - The operator used by the filter call.
newOpsItemFilter ::
  -- | 'key'
  OpsItemFilterKey ->
  -- | 'operator'
  OpsItemFilterOperator ->
  OpsItemFilter
newOpsItemFilter :: OpsItemFilterKey -> OpsItemFilterOperator -> OpsItemFilter
newOpsItemFilter OpsItemFilterKey
pKey_ OpsItemFilterOperator
pOperator_ =
  OpsItemFilter' :: OpsItemFilterKey
-> [Text] -> OpsItemFilterOperator -> OpsItemFilter
OpsItemFilter'
    { $sel:key:OpsItemFilter' :: OpsItemFilterKey
key = OpsItemFilterKey
pKey_,
      $sel:values:OpsItemFilter' :: [Text]
values = [Text]
forall a. Monoid a => a
Prelude.mempty,
      $sel:operator:OpsItemFilter' :: OpsItemFilterOperator
operator = OpsItemFilterOperator
pOperator_
    }

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

-- | The filter value.
opsItemFilter_values :: Lens.Lens' OpsItemFilter [Prelude.Text]
opsItemFilter_values :: ([Text] -> f [Text]) -> OpsItemFilter -> f OpsItemFilter
opsItemFilter_values = (OpsItemFilter -> [Text])
-> (OpsItemFilter -> [Text] -> OpsItemFilter)
-> Lens OpsItemFilter OpsItemFilter [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OpsItemFilter' {[Text]
values :: [Text]
$sel:values:OpsItemFilter' :: OpsItemFilter -> [Text]
values} -> [Text]
values) (\s :: OpsItemFilter
s@OpsItemFilter' {} [Text]
a -> OpsItemFilter
s {$sel:values:OpsItemFilter' :: [Text]
values = [Text]
a} :: OpsItemFilter) (([Text] -> f [Text]) -> OpsItemFilter -> f OpsItemFilter)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> OpsItemFilter
-> f OpsItemFilter
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The operator used by the filter call.
opsItemFilter_operator :: Lens.Lens' OpsItemFilter OpsItemFilterOperator
opsItemFilter_operator :: (OpsItemFilterOperator -> f OpsItemFilterOperator)
-> OpsItemFilter -> f OpsItemFilter
opsItemFilter_operator = (OpsItemFilter -> OpsItemFilterOperator)
-> (OpsItemFilter -> OpsItemFilterOperator -> OpsItemFilter)
-> Lens
     OpsItemFilter
     OpsItemFilter
     OpsItemFilterOperator
     OpsItemFilterOperator
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OpsItemFilter' {OpsItemFilterOperator
operator :: OpsItemFilterOperator
$sel:operator:OpsItemFilter' :: OpsItemFilter -> OpsItemFilterOperator
operator} -> OpsItemFilterOperator
operator) (\s :: OpsItemFilter
s@OpsItemFilter' {} OpsItemFilterOperator
a -> OpsItemFilter
s {$sel:operator:OpsItemFilter' :: OpsItemFilterOperator
operator = OpsItemFilterOperator
a} :: OpsItemFilter)

instance Prelude.Hashable OpsItemFilter

instance Prelude.NFData OpsItemFilter

instance Core.ToJSON OpsItemFilter where
  toJSON :: OpsItemFilter -> Value
toJSON OpsItemFilter' {[Text]
OpsItemFilterKey
OpsItemFilterOperator
operator :: OpsItemFilterOperator
values :: [Text]
key :: OpsItemFilterKey
$sel:operator:OpsItemFilter' :: OpsItemFilter -> OpsItemFilterOperator
$sel:values:OpsItemFilter' :: OpsItemFilter -> [Text]
$sel:key:OpsItemFilter' :: OpsItemFilter -> OpsItemFilterKey
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Key" Text -> OpsItemFilterKey -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= OpsItemFilterKey
key),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Values" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
values),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Operator" Text -> OpsItemFilterOperator -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= OpsItemFilterOperator
operator)
          ]
      )