{-# 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.ParameterStringFilter
-- 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.ParameterStringFilter where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | One or more filters. Use a filter to return a more specific list of
-- results.
--
-- /See:/ 'newParameterStringFilter' smart constructor.
data ParameterStringFilter = ParameterStringFilter'
  { -- | The value you want to search for.
    ParameterStringFilter -> Maybe (NonEmpty Text)
values :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | For all filters used with DescribeParameters, valid options include
    -- @Equals@ and @BeginsWith@. The @Name@ filter additionally supports the
    -- @Contains@ option. (Exception: For filters using the key @Path@, valid
    -- options include @Recursive@ and @OneLevel@.)
    --
    -- For filters used with GetParametersByPath, valid options include
    -- @Equals@ and @BeginsWith@. (Exception: For filters using @Label@ as the
    -- Key name, the only valid option is @Equals@.)
    ParameterStringFilter -> Maybe Text
option :: Prelude.Maybe Prelude.Text,
    -- | The name of the filter.
    --
    -- The @ParameterStringFilter@ object is used by the DescribeParameters and
    -- GetParametersByPath API operations. However, not all of the pattern
    -- values listed for @Key@ can be used with both operations.
    --
    -- For @DescribeActions@, all of the listed patterns are valid except
    -- @Label@.
    --
    -- For @GetParametersByPath@, the following patterns listed for @Key@
    -- aren\'t valid: @tag@, @DataType@, @Name@, @Path@, and @Tier@.
    --
    -- For examples of Amazon Web Services CLI commands demonstrating valid
    -- parameter filter constructions, see
    -- <https://docs.aws.amazon.com/systems-manager/latest/userguide/parameter-search.html Searching for Systems Manager parameters>
    -- in the /Amazon Web Services Systems Manager User Guide/.
    ParameterStringFilter -> Text
key :: Prelude.Text
  }
  deriving (ParameterStringFilter -> ParameterStringFilter -> Bool
(ParameterStringFilter -> ParameterStringFilter -> Bool)
-> (ParameterStringFilter -> ParameterStringFilter -> Bool)
-> Eq ParameterStringFilter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ParameterStringFilter -> ParameterStringFilter -> Bool
$c/= :: ParameterStringFilter -> ParameterStringFilter -> Bool
== :: ParameterStringFilter -> ParameterStringFilter -> Bool
$c== :: ParameterStringFilter -> ParameterStringFilter -> Bool
Prelude.Eq, ReadPrec [ParameterStringFilter]
ReadPrec ParameterStringFilter
Int -> ReadS ParameterStringFilter
ReadS [ParameterStringFilter]
(Int -> ReadS ParameterStringFilter)
-> ReadS [ParameterStringFilter]
-> ReadPrec ParameterStringFilter
-> ReadPrec [ParameterStringFilter]
-> Read ParameterStringFilter
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ParameterStringFilter]
$creadListPrec :: ReadPrec [ParameterStringFilter]
readPrec :: ReadPrec ParameterStringFilter
$creadPrec :: ReadPrec ParameterStringFilter
readList :: ReadS [ParameterStringFilter]
$creadList :: ReadS [ParameterStringFilter]
readsPrec :: Int -> ReadS ParameterStringFilter
$creadsPrec :: Int -> ReadS ParameterStringFilter
Prelude.Read, Int -> ParameterStringFilter -> ShowS
[ParameterStringFilter] -> ShowS
ParameterStringFilter -> String
(Int -> ParameterStringFilter -> ShowS)
-> (ParameterStringFilter -> String)
-> ([ParameterStringFilter] -> ShowS)
-> Show ParameterStringFilter
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ParameterStringFilter] -> ShowS
$cshowList :: [ParameterStringFilter] -> ShowS
show :: ParameterStringFilter -> String
$cshow :: ParameterStringFilter -> String
showsPrec :: Int -> ParameterStringFilter -> ShowS
$cshowsPrec :: Int -> ParameterStringFilter -> ShowS
Prelude.Show, (forall x. ParameterStringFilter -> Rep ParameterStringFilter x)
-> (forall x. Rep ParameterStringFilter x -> ParameterStringFilter)
-> Generic ParameterStringFilter
forall x. Rep ParameterStringFilter x -> ParameterStringFilter
forall x. ParameterStringFilter -> Rep ParameterStringFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ParameterStringFilter x -> ParameterStringFilter
$cfrom :: forall x. ParameterStringFilter -> Rep ParameterStringFilter x
Prelude.Generic)

-- |
-- Create a value of 'ParameterStringFilter' 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:
--
-- 'values', 'parameterStringFilter_values' - The value you want to search for.
--
-- 'option', 'parameterStringFilter_option' - For all filters used with DescribeParameters, valid options include
-- @Equals@ and @BeginsWith@. The @Name@ filter additionally supports the
-- @Contains@ option. (Exception: For filters using the key @Path@, valid
-- options include @Recursive@ and @OneLevel@.)
--
-- For filters used with GetParametersByPath, valid options include
-- @Equals@ and @BeginsWith@. (Exception: For filters using @Label@ as the
-- Key name, the only valid option is @Equals@.)
--
-- 'key', 'parameterStringFilter_key' - The name of the filter.
--
-- The @ParameterStringFilter@ object is used by the DescribeParameters and
-- GetParametersByPath API operations. However, not all of the pattern
-- values listed for @Key@ can be used with both operations.
--
-- For @DescribeActions@, all of the listed patterns are valid except
-- @Label@.
--
-- For @GetParametersByPath@, the following patterns listed for @Key@
-- aren\'t valid: @tag@, @DataType@, @Name@, @Path@, and @Tier@.
--
-- For examples of Amazon Web Services CLI commands demonstrating valid
-- parameter filter constructions, see
-- <https://docs.aws.amazon.com/systems-manager/latest/userguide/parameter-search.html Searching for Systems Manager parameters>
-- in the /Amazon Web Services Systems Manager User Guide/.
newParameterStringFilter ::
  -- | 'key'
  Prelude.Text ->
  ParameterStringFilter
newParameterStringFilter :: Text -> ParameterStringFilter
newParameterStringFilter Text
pKey_ =
  ParameterStringFilter' :: Maybe (NonEmpty Text)
-> Maybe Text -> Text -> ParameterStringFilter
ParameterStringFilter'
    { $sel:values:ParameterStringFilter' :: Maybe (NonEmpty Text)
values = Maybe (NonEmpty Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:option:ParameterStringFilter' :: Maybe Text
option = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:key:ParameterStringFilter' :: Text
key = Text
pKey_
    }

-- | The value you want to search for.
parameterStringFilter_values :: Lens.Lens' ParameterStringFilter (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
parameterStringFilter_values :: (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> ParameterStringFilter -> f ParameterStringFilter
parameterStringFilter_values = (ParameterStringFilter -> Maybe (NonEmpty Text))
-> (ParameterStringFilter
    -> Maybe (NonEmpty Text) -> ParameterStringFilter)
-> Lens
     ParameterStringFilter
     ParameterStringFilter
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ParameterStringFilter' {Maybe (NonEmpty Text)
values :: Maybe (NonEmpty Text)
$sel:values:ParameterStringFilter' :: ParameterStringFilter -> Maybe (NonEmpty Text)
values} -> Maybe (NonEmpty Text)
values) (\s :: ParameterStringFilter
s@ParameterStringFilter' {} Maybe (NonEmpty Text)
a -> ParameterStringFilter
s {$sel:values:ParameterStringFilter' :: Maybe (NonEmpty Text)
values = Maybe (NonEmpty Text)
a} :: ParameterStringFilter) ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
 -> ParameterStringFilter -> f ParameterStringFilter)
-> ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
    -> Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> ParameterStringFilter
-> f ParameterStringFilter
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
-> Iso
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
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 AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | For all filters used with DescribeParameters, valid options include
-- @Equals@ and @BeginsWith@. The @Name@ filter additionally supports the
-- @Contains@ option. (Exception: For filters using the key @Path@, valid
-- options include @Recursive@ and @OneLevel@.)
--
-- For filters used with GetParametersByPath, valid options include
-- @Equals@ and @BeginsWith@. (Exception: For filters using @Label@ as the
-- Key name, the only valid option is @Equals@.)
parameterStringFilter_option :: Lens.Lens' ParameterStringFilter (Prelude.Maybe Prelude.Text)
parameterStringFilter_option :: (Maybe Text -> f (Maybe Text))
-> ParameterStringFilter -> f ParameterStringFilter
parameterStringFilter_option = (ParameterStringFilter -> Maybe Text)
-> (ParameterStringFilter -> Maybe Text -> ParameterStringFilter)
-> Lens
     ParameterStringFilter
     ParameterStringFilter
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ParameterStringFilter' {Maybe Text
option :: Maybe Text
$sel:option:ParameterStringFilter' :: ParameterStringFilter -> Maybe Text
option} -> Maybe Text
option) (\s :: ParameterStringFilter
s@ParameterStringFilter' {} Maybe Text
a -> ParameterStringFilter
s {$sel:option:ParameterStringFilter' :: Maybe Text
option = Maybe Text
a} :: ParameterStringFilter)

-- | The name of the filter.
--
-- The @ParameterStringFilter@ object is used by the DescribeParameters and
-- GetParametersByPath API operations. However, not all of the pattern
-- values listed for @Key@ can be used with both operations.
--
-- For @DescribeActions@, all of the listed patterns are valid except
-- @Label@.
--
-- For @GetParametersByPath@, the following patterns listed for @Key@
-- aren\'t valid: @tag@, @DataType@, @Name@, @Path@, and @Tier@.
--
-- For examples of Amazon Web Services CLI commands demonstrating valid
-- parameter filter constructions, see
-- <https://docs.aws.amazon.com/systems-manager/latest/userguide/parameter-search.html Searching for Systems Manager parameters>
-- in the /Amazon Web Services Systems Manager User Guide/.
parameterStringFilter_key :: Lens.Lens' ParameterStringFilter Prelude.Text
parameterStringFilter_key :: (Text -> f Text)
-> ParameterStringFilter -> f ParameterStringFilter
parameterStringFilter_key = (ParameterStringFilter -> Text)
-> (ParameterStringFilter -> Text -> ParameterStringFilter)
-> Lens ParameterStringFilter ParameterStringFilter Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ParameterStringFilter' {Text
key :: Text
$sel:key:ParameterStringFilter' :: ParameterStringFilter -> Text
key} -> Text
key) (\s :: ParameterStringFilter
s@ParameterStringFilter' {} Text
a -> ParameterStringFilter
s {$sel:key:ParameterStringFilter' :: Text
key = Text
a} :: ParameterStringFilter)

instance Prelude.Hashable ParameterStringFilter

instance Prelude.NFData ParameterStringFilter

instance Core.ToJSON ParameterStringFilter where
  toJSON :: ParameterStringFilter -> Value
toJSON ParameterStringFilter' {Maybe (NonEmpty Text)
Maybe Text
Text
key :: Text
option :: Maybe Text
values :: Maybe (NonEmpty Text)
$sel:key:ParameterStringFilter' :: ParameterStringFilter -> Text
$sel:option:ParameterStringFilter' :: ParameterStringFilter -> Maybe Text
$sel:values:ParameterStringFilter' :: ParameterStringFilter -> Maybe (NonEmpty Text)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Values" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty Text -> Pair) -> Maybe (NonEmpty Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Text)
values,
            (Text
"Option" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
option,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Key" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
key)
          ]
      )