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

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

-- | An optional input parameter for the @ListSignalingChannels@ API. When
-- this parameter is specified while invoking @ListSignalingChannels@, the
-- API returns only the channels that satisfy a condition specified in
-- @ChannelNameCondition@.
--
-- /See:/ 'newChannelNameCondition' smart constructor.
data ChannelNameCondition = ChannelNameCondition'
  { -- | A comparison operator. Currently, you can only specify the @BEGINS_WITH@
    -- operator, which finds signaling channels whose names begin with a given
    -- prefix.
    ChannelNameCondition -> Maybe ComparisonOperator
comparisonOperator :: Prelude.Maybe ComparisonOperator,
    -- | A value to compare.
    ChannelNameCondition -> Maybe Text
comparisonValue :: Prelude.Maybe Prelude.Text
  }
  deriving (ChannelNameCondition -> ChannelNameCondition -> Bool
(ChannelNameCondition -> ChannelNameCondition -> Bool)
-> (ChannelNameCondition -> ChannelNameCondition -> Bool)
-> Eq ChannelNameCondition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ChannelNameCondition -> ChannelNameCondition -> Bool
$c/= :: ChannelNameCondition -> ChannelNameCondition -> Bool
== :: ChannelNameCondition -> ChannelNameCondition -> Bool
$c== :: ChannelNameCondition -> ChannelNameCondition -> Bool
Prelude.Eq, ReadPrec [ChannelNameCondition]
ReadPrec ChannelNameCondition
Int -> ReadS ChannelNameCondition
ReadS [ChannelNameCondition]
(Int -> ReadS ChannelNameCondition)
-> ReadS [ChannelNameCondition]
-> ReadPrec ChannelNameCondition
-> ReadPrec [ChannelNameCondition]
-> Read ChannelNameCondition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ChannelNameCondition]
$creadListPrec :: ReadPrec [ChannelNameCondition]
readPrec :: ReadPrec ChannelNameCondition
$creadPrec :: ReadPrec ChannelNameCondition
readList :: ReadS [ChannelNameCondition]
$creadList :: ReadS [ChannelNameCondition]
readsPrec :: Int -> ReadS ChannelNameCondition
$creadsPrec :: Int -> ReadS ChannelNameCondition
Prelude.Read, Int -> ChannelNameCondition -> ShowS
[ChannelNameCondition] -> ShowS
ChannelNameCondition -> String
(Int -> ChannelNameCondition -> ShowS)
-> (ChannelNameCondition -> String)
-> ([ChannelNameCondition] -> ShowS)
-> Show ChannelNameCondition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ChannelNameCondition] -> ShowS
$cshowList :: [ChannelNameCondition] -> ShowS
show :: ChannelNameCondition -> String
$cshow :: ChannelNameCondition -> String
showsPrec :: Int -> ChannelNameCondition -> ShowS
$cshowsPrec :: Int -> ChannelNameCondition -> ShowS
Prelude.Show, (forall x. ChannelNameCondition -> Rep ChannelNameCondition x)
-> (forall x. Rep ChannelNameCondition x -> ChannelNameCondition)
-> Generic ChannelNameCondition
forall x. Rep ChannelNameCondition x -> ChannelNameCondition
forall x. ChannelNameCondition -> Rep ChannelNameCondition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ChannelNameCondition x -> ChannelNameCondition
$cfrom :: forall x. ChannelNameCondition -> Rep ChannelNameCondition x
Prelude.Generic)

-- |
-- Create a value of 'ChannelNameCondition' 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', 'channelNameCondition_comparisonOperator' - A comparison operator. Currently, you can only specify the @BEGINS_WITH@
-- operator, which finds signaling channels whose names begin with a given
-- prefix.
--
-- 'comparisonValue', 'channelNameCondition_comparisonValue' - A value to compare.
newChannelNameCondition ::
  ChannelNameCondition
newChannelNameCondition :: ChannelNameCondition
newChannelNameCondition =
  ChannelNameCondition' :: Maybe ComparisonOperator -> Maybe Text -> ChannelNameCondition
ChannelNameCondition'
    { $sel:comparisonOperator:ChannelNameCondition' :: Maybe ComparisonOperator
comparisonOperator =
        Maybe ComparisonOperator
forall a. Maybe a
Prelude.Nothing,
      $sel:comparisonValue:ChannelNameCondition' :: Maybe Text
comparisonValue = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

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

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

instance Prelude.Hashable ChannelNameCondition

instance Prelude.NFData ChannelNameCondition

instance Core.ToJSON ChannelNameCondition where
  toJSON :: ChannelNameCondition -> Value
toJSON ChannelNameCondition' {Maybe Text
Maybe ComparisonOperator
comparisonValue :: Maybe Text
comparisonOperator :: Maybe ComparisonOperator
$sel:comparisonValue:ChannelNameCondition' :: ChannelNameCondition -> Maybe Text
$sel:comparisonOperator:ChannelNameCondition' :: ChannelNameCondition -> 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
          ]
      )