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

-- | One or more filters. Use a filter to return a more specific list of
-- results.
--
-- /See:/ 'newParameterStringFilter' smart constructor.
data ParameterStringFilter = ParameterStringFilter'
  { -- | 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 value you want to search for.
    ParameterStringFilter -> Maybe (NonEmpty Text)
values :: Prelude.Maybe (Prelude.NonEmpty 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 @DescribeParameters@, 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
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]
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
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. 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:
--
-- '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@.)
--
-- 'values', 'parameterStringFilter_values' - The value you want to search for.
--
-- '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 @DescribeParameters@, 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'
    { $sel:option:ParameterStringFilter' :: Maybe Text
option = forall a. Maybe a
Prelude.Nothing,
      $sel:values:ParameterStringFilter' :: Maybe (NonEmpty Text)
values = forall a. Maybe a
Prelude.Nothing,
      $sel:key:ParameterStringFilter' :: Text
key = Text
pKey_
    }

-- | 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 :: Lens' ParameterStringFilter (Maybe Text)
parameterStringFilter_option = 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 value you want to search for.
parameterStringFilter_values :: Lens.Lens' ParameterStringFilter (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
parameterStringFilter_values :: Lens' ParameterStringFilter (Maybe (NonEmpty Text))
parameterStringFilter_values = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | 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 @DescribeParameters@, 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 :: Lens' ParameterStringFilter Text
parameterStringFilter_key = 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 where
  hashWithSalt :: Int -> ParameterStringFilter -> Int
hashWithSalt Int
_salt ParameterStringFilter' {Maybe (NonEmpty Text)
Maybe Text
Text
key :: Text
values :: Maybe (NonEmpty Text)
option :: Maybe Text
$sel:key:ParameterStringFilter' :: ParameterStringFilter -> Text
$sel:values:ParameterStringFilter' :: ParameterStringFilter -> Maybe (NonEmpty Text)
$sel:option:ParameterStringFilter' :: ParameterStringFilter -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
option
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty Text)
values
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
key

instance Prelude.NFData ParameterStringFilter where
  rnf :: ParameterStringFilter -> ()
rnf ParameterStringFilter' {Maybe (NonEmpty Text)
Maybe Text
Text
key :: Text
values :: Maybe (NonEmpty Text)
option :: Maybe Text
$sel:key:ParameterStringFilter' :: ParameterStringFilter -> Text
$sel:values:ParameterStringFilter' :: ParameterStringFilter -> Maybe (NonEmpty Text)
$sel:option:ParameterStringFilter' :: ParameterStringFilter -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
option
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Text)
values
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
key

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