{-# 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.Backup.Types.Conditions
-- 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.Backup.Types.Conditions where

import Amazonka.Backup.Types.ConditionParameter
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

-- | Contains information about which resources to include or exclude from a
-- backup plan using their tags. Conditions are case sensitive.
--
-- /See:/ 'newConditions' smart constructor.
data Conditions = Conditions'
  { -- | Filters the values of your tagged resources for only those resources
    -- that you tagged with the same value. Also called \"exact matching.\"
    Conditions -> Maybe [ConditionParameter]
stringEquals :: Prelude.Maybe [ConditionParameter],
    -- | Filters the values of your tagged resources for matching tag values with
    -- the use of a wildcard character (*) anywhere in the string. For example,
    -- \"prod*\" or \"*rod*\" matches the tag value \"production\".
    Conditions -> Maybe [ConditionParameter]
stringLike :: Prelude.Maybe [ConditionParameter],
    -- | Filters the values of your tagged resources for only those resources
    -- that you tagged that do not have the same value. Also called \"negated
    -- matching.\"
    Conditions -> Maybe [ConditionParameter]
stringNotEquals :: Prelude.Maybe [ConditionParameter],
    -- | Filters the values of your tagged resources for non-matching tag values
    -- with the use of a wildcard character (*) anywhere in the string.
    Conditions -> Maybe [ConditionParameter]
stringNotLike :: Prelude.Maybe [ConditionParameter]
  }
  deriving (Conditions -> Conditions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Conditions -> Conditions -> Bool
$c/= :: Conditions -> Conditions -> Bool
== :: Conditions -> Conditions -> Bool
$c== :: Conditions -> Conditions -> Bool
Prelude.Eq, ReadPrec [Conditions]
ReadPrec Conditions
Int -> ReadS Conditions
ReadS [Conditions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Conditions]
$creadListPrec :: ReadPrec [Conditions]
readPrec :: ReadPrec Conditions
$creadPrec :: ReadPrec Conditions
readList :: ReadS [Conditions]
$creadList :: ReadS [Conditions]
readsPrec :: Int -> ReadS Conditions
$creadsPrec :: Int -> ReadS Conditions
Prelude.Read, Int -> Conditions -> ShowS
[Conditions] -> ShowS
Conditions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Conditions] -> ShowS
$cshowList :: [Conditions] -> ShowS
show :: Conditions -> String
$cshow :: Conditions -> String
showsPrec :: Int -> Conditions -> ShowS
$cshowsPrec :: Int -> Conditions -> ShowS
Prelude.Show, forall x. Rep Conditions x -> Conditions
forall x. Conditions -> Rep Conditions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Conditions x -> Conditions
$cfrom :: forall x. Conditions -> Rep Conditions x
Prelude.Generic)

-- |
-- Create a value of 'Conditions' 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:
--
-- 'stringEquals', 'conditions_stringEquals' - Filters the values of your tagged resources for only those resources
-- that you tagged with the same value. Also called \"exact matching.\"
--
-- 'stringLike', 'conditions_stringLike' - Filters the values of your tagged resources for matching tag values with
-- the use of a wildcard character (*) anywhere in the string. For example,
-- \"prod*\" or \"*rod*\" matches the tag value \"production\".
--
-- 'stringNotEquals', 'conditions_stringNotEquals' - Filters the values of your tagged resources for only those resources
-- that you tagged that do not have the same value. Also called \"negated
-- matching.\"
--
-- 'stringNotLike', 'conditions_stringNotLike' - Filters the values of your tagged resources for non-matching tag values
-- with the use of a wildcard character (*) anywhere in the string.
newConditions ::
  Conditions
newConditions :: Conditions
newConditions =
  Conditions'
    { $sel:stringEquals:Conditions' :: Maybe [ConditionParameter]
stringEquals = forall a. Maybe a
Prelude.Nothing,
      $sel:stringLike:Conditions' :: Maybe [ConditionParameter]
stringLike = forall a. Maybe a
Prelude.Nothing,
      $sel:stringNotEquals:Conditions' :: Maybe [ConditionParameter]
stringNotEquals = forall a. Maybe a
Prelude.Nothing,
      $sel:stringNotLike:Conditions' :: Maybe [ConditionParameter]
stringNotLike = forall a. Maybe a
Prelude.Nothing
    }

-- | Filters the values of your tagged resources for only those resources
-- that you tagged with the same value. Also called \"exact matching.\"
conditions_stringEquals :: Lens.Lens' Conditions (Prelude.Maybe [ConditionParameter])
conditions_stringEquals :: Lens' Conditions (Maybe [ConditionParameter])
conditions_stringEquals = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Conditions' {Maybe [ConditionParameter]
stringEquals :: Maybe [ConditionParameter]
$sel:stringEquals:Conditions' :: Conditions -> Maybe [ConditionParameter]
stringEquals} -> Maybe [ConditionParameter]
stringEquals) (\s :: Conditions
s@Conditions' {} Maybe [ConditionParameter]
a -> Conditions
s {$sel:stringEquals:Conditions' :: Maybe [ConditionParameter]
stringEquals = Maybe [ConditionParameter]
a} :: Conditions) 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

-- | Filters the values of your tagged resources for matching tag values with
-- the use of a wildcard character (*) anywhere in the string. For example,
-- \"prod*\" or \"*rod*\" matches the tag value \"production\".
conditions_stringLike :: Lens.Lens' Conditions (Prelude.Maybe [ConditionParameter])
conditions_stringLike :: Lens' Conditions (Maybe [ConditionParameter])
conditions_stringLike = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Conditions' {Maybe [ConditionParameter]
stringLike :: Maybe [ConditionParameter]
$sel:stringLike:Conditions' :: Conditions -> Maybe [ConditionParameter]
stringLike} -> Maybe [ConditionParameter]
stringLike) (\s :: Conditions
s@Conditions' {} Maybe [ConditionParameter]
a -> Conditions
s {$sel:stringLike:Conditions' :: Maybe [ConditionParameter]
stringLike = Maybe [ConditionParameter]
a} :: Conditions) 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

-- | Filters the values of your tagged resources for only those resources
-- that you tagged that do not have the same value. Also called \"negated
-- matching.\"
conditions_stringNotEquals :: Lens.Lens' Conditions (Prelude.Maybe [ConditionParameter])
conditions_stringNotEquals :: Lens' Conditions (Maybe [ConditionParameter])
conditions_stringNotEquals = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Conditions' {Maybe [ConditionParameter]
stringNotEquals :: Maybe [ConditionParameter]
$sel:stringNotEquals:Conditions' :: Conditions -> Maybe [ConditionParameter]
stringNotEquals} -> Maybe [ConditionParameter]
stringNotEquals) (\s :: Conditions
s@Conditions' {} Maybe [ConditionParameter]
a -> Conditions
s {$sel:stringNotEquals:Conditions' :: Maybe [ConditionParameter]
stringNotEquals = Maybe [ConditionParameter]
a} :: Conditions) 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

-- | Filters the values of your tagged resources for non-matching tag values
-- with the use of a wildcard character (*) anywhere in the string.
conditions_stringNotLike :: Lens.Lens' Conditions (Prelude.Maybe [ConditionParameter])
conditions_stringNotLike :: Lens' Conditions (Maybe [ConditionParameter])
conditions_stringNotLike = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Conditions' {Maybe [ConditionParameter]
stringNotLike :: Maybe [ConditionParameter]
$sel:stringNotLike:Conditions' :: Conditions -> Maybe [ConditionParameter]
stringNotLike} -> Maybe [ConditionParameter]
stringNotLike) (\s :: Conditions
s@Conditions' {} Maybe [ConditionParameter]
a -> Conditions
s {$sel:stringNotLike:Conditions' :: Maybe [ConditionParameter]
stringNotLike = Maybe [ConditionParameter]
a} :: Conditions) 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

instance Data.FromJSON Conditions where
  parseJSON :: Value -> Parser Conditions
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Conditions"
      ( \Object
x ->
          Maybe [ConditionParameter]
-> Maybe [ConditionParameter]
-> Maybe [ConditionParameter]
-> Maybe [ConditionParameter]
-> Conditions
Conditions'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"StringEquals" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"StringLike" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"StringNotEquals"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"StringNotLike" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable Conditions where
  hashWithSalt :: Int -> Conditions -> Int
hashWithSalt Int
_salt Conditions' {Maybe [ConditionParameter]
stringNotLike :: Maybe [ConditionParameter]
stringNotEquals :: Maybe [ConditionParameter]
stringLike :: Maybe [ConditionParameter]
stringEquals :: Maybe [ConditionParameter]
$sel:stringNotLike:Conditions' :: Conditions -> Maybe [ConditionParameter]
$sel:stringNotEquals:Conditions' :: Conditions -> Maybe [ConditionParameter]
$sel:stringLike:Conditions' :: Conditions -> Maybe [ConditionParameter]
$sel:stringEquals:Conditions' :: Conditions -> Maybe [ConditionParameter]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [ConditionParameter]
stringEquals
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [ConditionParameter]
stringLike
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [ConditionParameter]
stringNotEquals
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [ConditionParameter]
stringNotLike

instance Prelude.NFData Conditions where
  rnf :: Conditions -> ()
rnf Conditions' {Maybe [ConditionParameter]
stringNotLike :: Maybe [ConditionParameter]
stringNotEquals :: Maybe [ConditionParameter]
stringLike :: Maybe [ConditionParameter]
stringEquals :: Maybe [ConditionParameter]
$sel:stringNotLike:Conditions' :: Conditions -> Maybe [ConditionParameter]
$sel:stringNotEquals:Conditions' :: Conditions -> Maybe [ConditionParameter]
$sel:stringLike:Conditions' :: Conditions -> Maybe [ConditionParameter]
$sel:stringEquals:Conditions' :: Conditions -> Maybe [ConditionParameter]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [ConditionParameter]
stringEquals
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [ConditionParameter]
stringLike
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [ConditionParameter]
stringNotEquals
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [ConditionParameter]
stringNotLike

instance Data.ToJSON Conditions where
  toJSON :: Conditions -> Value
toJSON Conditions' {Maybe [ConditionParameter]
stringNotLike :: Maybe [ConditionParameter]
stringNotEquals :: Maybe [ConditionParameter]
stringLike :: Maybe [ConditionParameter]
stringEquals :: Maybe [ConditionParameter]
$sel:stringNotLike:Conditions' :: Conditions -> Maybe [ConditionParameter]
$sel:stringNotEquals:Conditions' :: Conditions -> Maybe [ConditionParameter]
$sel:stringLike:Conditions' :: Conditions -> Maybe [ConditionParameter]
$sel:stringEquals:Conditions' :: Conditions -> Maybe [ConditionParameter]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"StringEquals" 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 [ConditionParameter]
stringEquals,
            (Key
"StringLike" 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 [ConditionParameter]
stringLike,
            (Key
"StringNotEquals" 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 [ConditionParameter]
stringNotEquals,
            (Key
"StringNotLike" 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 [ConditionParameter]
stringNotLike
          ]
      )