{-# 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.KinesisVideo.Types.StreamNameCondition
-- 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.KinesisVideo.Types.StreamNameCondition where

import qualified Amazonka.Core as Core
import Amazonka.KinesisVideo.Types.ComparisonOperator
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Specifies the condition that streams must satisfy to be returned when
-- you list streams (see the @ListStreams@ API). A condition has a
-- comparison operation and a value. Currently, you can specify only the
-- @BEGINS_WITH@ operator, which finds streams whose names start with a
-- given prefix.
--
-- /See:/ 'newStreamNameCondition' smart constructor.
data StreamNameCondition = StreamNameCondition'
  { -- | A comparison operator. Currently, you can specify only the @BEGINS_WITH@
    -- operator, which finds streams whose names start with a given prefix.
    StreamNameCondition -> Maybe ComparisonOperator
comparisonOperator :: Prelude.Maybe ComparisonOperator,
    -- | A value to compare.
    StreamNameCondition -> Maybe Text
comparisonValue :: Prelude.Maybe Prelude.Text
  }
  deriving (StreamNameCondition -> StreamNameCondition -> Bool
(StreamNameCondition -> StreamNameCondition -> Bool)
-> (StreamNameCondition -> StreamNameCondition -> Bool)
-> Eq StreamNameCondition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StreamNameCondition -> StreamNameCondition -> Bool
$c/= :: StreamNameCondition -> StreamNameCondition -> Bool
== :: StreamNameCondition -> StreamNameCondition -> Bool
$c== :: StreamNameCondition -> StreamNameCondition -> Bool
Prelude.Eq, ReadPrec [StreamNameCondition]
ReadPrec StreamNameCondition
Int -> ReadS StreamNameCondition
ReadS [StreamNameCondition]
(Int -> ReadS StreamNameCondition)
-> ReadS [StreamNameCondition]
-> ReadPrec StreamNameCondition
-> ReadPrec [StreamNameCondition]
-> Read StreamNameCondition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StreamNameCondition]
$creadListPrec :: ReadPrec [StreamNameCondition]
readPrec :: ReadPrec StreamNameCondition
$creadPrec :: ReadPrec StreamNameCondition
readList :: ReadS [StreamNameCondition]
$creadList :: ReadS [StreamNameCondition]
readsPrec :: Int -> ReadS StreamNameCondition
$creadsPrec :: Int -> ReadS StreamNameCondition
Prelude.Read, Int -> StreamNameCondition -> ShowS
[StreamNameCondition] -> ShowS
StreamNameCondition -> String
(Int -> StreamNameCondition -> ShowS)
-> (StreamNameCondition -> String)
-> ([StreamNameCondition] -> ShowS)
-> Show StreamNameCondition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StreamNameCondition] -> ShowS
$cshowList :: [StreamNameCondition] -> ShowS
show :: StreamNameCondition -> String
$cshow :: StreamNameCondition -> String
showsPrec :: Int -> StreamNameCondition -> ShowS
$cshowsPrec :: Int -> StreamNameCondition -> ShowS
Prelude.Show, (forall x. StreamNameCondition -> Rep StreamNameCondition x)
-> (forall x. Rep StreamNameCondition x -> StreamNameCondition)
-> Generic StreamNameCondition
forall x. Rep StreamNameCondition x -> StreamNameCondition
forall x. StreamNameCondition -> Rep StreamNameCondition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StreamNameCondition x -> StreamNameCondition
$cfrom :: forall x. StreamNameCondition -> Rep StreamNameCondition x
Prelude.Generic)

-- |
-- Create a value of 'StreamNameCondition' 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:
--
-- 'comparisonOperator', 'streamNameCondition_comparisonOperator' - A comparison operator. Currently, you can specify only the @BEGINS_WITH@
-- operator, which finds streams whose names start with a given prefix.
--
-- 'comparisonValue', 'streamNameCondition_comparisonValue' - A value to compare.
newStreamNameCondition ::
  StreamNameCondition
newStreamNameCondition :: StreamNameCondition
newStreamNameCondition =
  StreamNameCondition' :: Maybe ComparisonOperator -> Maybe Text -> StreamNameCondition
StreamNameCondition'
    { $sel:comparisonOperator:StreamNameCondition' :: Maybe ComparisonOperator
comparisonOperator =
        Maybe ComparisonOperator
forall a. Maybe a
Prelude.Nothing,
      $sel:comparisonValue:StreamNameCondition' :: Maybe Text
comparisonValue = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | A comparison operator. Currently, you can specify only the @BEGINS_WITH@
-- operator, which finds streams whose names start with a given prefix.
streamNameCondition_comparisonOperator :: Lens.Lens' StreamNameCondition (Prelude.Maybe ComparisonOperator)
streamNameCondition_comparisonOperator :: (Maybe ComparisonOperator -> f (Maybe ComparisonOperator))
-> StreamNameCondition -> f StreamNameCondition
streamNameCondition_comparisonOperator = (StreamNameCondition -> Maybe ComparisonOperator)
-> (StreamNameCondition
    -> Maybe ComparisonOperator -> StreamNameCondition)
-> Lens
     StreamNameCondition
     StreamNameCondition
     (Maybe ComparisonOperator)
     (Maybe ComparisonOperator)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StreamNameCondition' {Maybe ComparisonOperator
comparisonOperator :: Maybe ComparisonOperator
$sel:comparisonOperator:StreamNameCondition' :: StreamNameCondition -> Maybe ComparisonOperator
comparisonOperator} -> Maybe ComparisonOperator
comparisonOperator) (\s :: StreamNameCondition
s@StreamNameCondition' {} Maybe ComparisonOperator
a -> StreamNameCondition
s {$sel:comparisonOperator:StreamNameCondition' :: Maybe ComparisonOperator
comparisonOperator = Maybe ComparisonOperator
a} :: StreamNameCondition)

-- | A value to compare.
streamNameCondition_comparisonValue :: Lens.Lens' StreamNameCondition (Prelude.Maybe Prelude.Text)
streamNameCondition_comparisonValue :: (Maybe Text -> f (Maybe Text))
-> StreamNameCondition -> f StreamNameCondition
streamNameCondition_comparisonValue = (StreamNameCondition -> Maybe Text)
-> (StreamNameCondition -> Maybe Text -> StreamNameCondition)
-> Lens
     StreamNameCondition StreamNameCondition (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StreamNameCondition' {Maybe Text
comparisonValue :: Maybe Text
$sel:comparisonValue:StreamNameCondition' :: StreamNameCondition -> Maybe Text
comparisonValue} -> Maybe Text
comparisonValue) (\s :: StreamNameCondition
s@StreamNameCondition' {} Maybe Text
a -> StreamNameCondition
s {$sel:comparisonValue:StreamNameCondition' :: Maybe Text
comparisonValue = Maybe Text
a} :: StreamNameCondition)

instance Prelude.Hashable StreamNameCondition

instance Prelude.NFData StreamNameCondition

instance Core.ToJSON StreamNameCondition where
  toJSON :: StreamNameCondition -> Value
toJSON StreamNameCondition' {Maybe Text
Maybe ComparisonOperator
comparisonValue :: Maybe Text
comparisonOperator :: Maybe ComparisonOperator
$sel:comparisonValue:StreamNameCondition' :: StreamNameCondition -> Maybe Text
$sel:comparisonOperator:StreamNameCondition' :: StreamNameCondition -> Maybe ComparisonOperator
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ComparisonOperator" Text -> ComparisonOperator -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ComparisonOperator -> Pair)
-> Maybe ComparisonOperator -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ComparisonOperator
comparisonOperator,
            (Text
"ComparisonValue" 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
comparisonValue
          ]
      )