{-# 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.AppMesh.Types.GrpcRouteMetadataMatchMethod
-- 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.AppMesh.Types.GrpcRouteMetadataMatchMethod where

import Amazonka.AppMesh.Types.MatchRange
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An object that represents the match method. Specify one of the match
-- values.
--
-- /See:/ 'newGrpcRouteMetadataMatchMethod' smart constructor.
data GrpcRouteMetadataMatchMethod = GrpcRouteMetadataMatchMethod'
  { -- | The value sent by the client must end with the specified characters.
    GrpcRouteMetadataMatchMethod -> Maybe Text
suffix :: Prelude.Maybe Prelude.Text,
    -- | The value sent by the client must include the specified characters.
    GrpcRouteMetadataMatchMethod -> Maybe Text
regex :: Prelude.Maybe Prelude.Text,
    -- | The value sent by the client must begin with the specified characters.
    GrpcRouteMetadataMatchMethod -> Maybe Text
prefix :: Prelude.Maybe Prelude.Text,
    -- | An object that represents the range of values to match on.
    GrpcRouteMetadataMatchMethod -> Maybe MatchRange
range :: Prelude.Maybe MatchRange,
    -- | The value sent by the client must match the specified value exactly.
    GrpcRouteMetadataMatchMethod -> Maybe Text
exact :: Prelude.Maybe Prelude.Text
  }
  deriving (GrpcRouteMetadataMatchMethod
-> GrpcRouteMetadataMatchMethod -> Bool
(GrpcRouteMetadataMatchMethod
 -> GrpcRouteMetadataMatchMethod -> Bool)
-> (GrpcRouteMetadataMatchMethod
    -> GrpcRouteMetadataMatchMethod -> Bool)
-> Eq GrpcRouteMetadataMatchMethod
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GrpcRouteMetadataMatchMethod
-> GrpcRouteMetadataMatchMethod -> Bool
$c/= :: GrpcRouteMetadataMatchMethod
-> GrpcRouteMetadataMatchMethod -> Bool
== :: GrpcRouteMetadataMatchMethod
-> GrpcRouteMetadataMatchMethod -> Bool
$c== :: GrpcRouteMetadataMatchMethod
-> GrpcRouteMetadataMatchMethod -> Bool
Prelude.Eq, ReadPrec [GrpcRouteMetadataMatchMethod]
ReadPrec GrpcRouteMetadataMatchMethod
Int -> ReadS GrpcRouteMetadataMatchMethod
ReadS [GrpcRouteMetadataMatchMethod]
(Int -> ReadS GrpcRouteMetadataMatchMethod)
-> ReadS [GrpcRouteMetadataMatchMethod]
-> ReadPrec GrpcRouteMetadataMatchMethod
-> ReadPrec [GrpcRouteMetadataMatchMethod]
-> Read GrpcRouteMetadataMatchMethod
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GrpcRouteMetadataMatchMethod]
$creadListPrec :: ReadPrec [GrpcRouteMetadataMatchMethod]
readPrec :: ReadPrec GrpcRouteMetadataMatchMethod
$creadPrec :: ReadPrec GrpcRouteMetadataMatchMethod
readList :: ReadS [GrpcRouteMetadataMatchMethod]
$creadList :: ReadS [GrpcRouteMetadataMatchMethod]
readsPrec :: Int -> ReadS GrpcRouteMetadataMatchMethod
$creadsPrec :: Int -> ReadS GrpcRouteMetadataMatchMethod
Prelude.Read, Int -> GrpcRouteMetadataMatchMethod -> ShowS
[GrpcRouteMetadataMatchMethod] -> ShowS
GrpcRouteMetadataMatchMethod -> String
(Int -> GrpcRouteMetadataMatchMethod -> ShowS)
-> (GrpcRouteMetadataMatchMethod -> String)
-> ([GrpcRouteMetadataMatchMethod] -> ShowS)
-> Show GrpcRouteMetadataMatchMethod
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GrpcRouteMetadataMatchMethod] -> ShowS
$cshowList :: [GrpcRouteMetadataMatchMethod] -> ShowS
show :: GrpcRouteMetadataMatchMethod -> String
$cshow :: GrpcRouteMetadataMatchMethod -> String
showsPrec :: Int -> GrpcRouteMetadataMatchMethod -> ShowS
$cshowsPrec :: Int -> GrpcRouteMetadataMatchMethod -> ShowS
Prelude.Show, (forall x.
 GrpcRouteMetadataMatchMethod -> Rep GrpcRouteMetadataMatchMethod x)
-> (forall x.
    Rep GrpcRouteMetadataMatchMethod x -> GrpcRouteMetadataMatchMethod)
-> Generic GrpcRouteMetadataMatchMethod
forall x.
Rep GrpcRouteMetadataMatchMethod x -> GrpcRouteMetadataMatchMethod
forall x.
GrpcRouteMetadataMatchMethod -> Rep GrpcRouteMetadataMatchMethod x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GrpcRouteMetadataMatchMethod x -> GrpcRouteMetadataMatchMethod
$cfrom :: forall x.
GrpcRouteMetadataMatchMethod -> Rep GrpcRouteMetadataMatchMethod x
Prelude.Generic)

-- |
-- Create a value of 'GrpcRouteMetadataMatchMethod' 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:
--
-- 'suffix', 'grpcRouteMetadataMatchMethod_suffix' - The value sent by the client must end with the specified characters.
--
-- 'regex', 'grpcRouteMetadataMatchMethod_regex' - The value sent by the client must include the specified characters.
--
-- 'prefix', 'grpcRouteMetadataMatchMethod_prefix' - The value sent by the client must begin with the specified characters.
--
-- 'range', 'grpcRouteMetadataMatchMethod_range' - An object that represents the range of values to match on.
--
-- 'exact', 'grpcRouteMetadataMatchMethod_exact' - The value sent by the client must match the specified value exactly.
newGrpcRouteMetadataMatchMethod ::
  GrpcRouteMetadataMatchMethod
newGrpcRouteMetadataMatchMethod :: GrpcRouteMetadataMatchMethod
newGrpcRouteMetadataMatchMethod =
  GrpcRouteMetadataMatchMethod' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe MatchRange
-> Maybe Text
-> GrpcRouteMetadataMatchMethod
GrpcRouteMetadataMatchMethod'
    { $sel:suffix:GrpcRouteMetadataMatchMethod' :: Maybe Text
suffix =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:regex:GrpcRouteMetadataMatchMethod' :: Maybe Text
regex = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:prefix:GrpcRouteMetadataMatchMethod' :: Maybe Text
prefix = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:range:GrpcRouteMetadataMatchMethod' :: Maybe MatchRange
range = Maybe MatchRange
forall a. Maybe a
Prelude.Nothing,
      $sel:exact:GrpcRouteMetadataMatchMethod' :: Maybe Text
exact = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The value sent by the client must end with the specified characters.
grpcRouteMetadataMatchMethod_suffix :: Lens.Lens' GrpcRouteMetadataMatchMethod (Prelude.Maybe Prelude.Text)
grpcRouteMetadataMatchMethod_suffix :: (Maybe Text -> f (Maybe Text))
-> GrpcRouteMetadataMatchMethod -> f GrpcRouteMetadataMatchMethod
grpcRouteMetadataMatchMethod_suffix = (GrpcRouteMetadataMatchMethod -> Maybe Text)
-> (GrpcRouteMetadataMatchMethod
    -> Maybe Text -> GrpcRouteMetadataMatchMethod)
-> Lens
     GrpcRouteMetadataMatchMethod
     GrpcRouteMetadataMatchMethod
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GrpcRouteMetadataMatchMethod' {Maybe Text
suffix :: Maybe Text
$sel:suffix:GrpcRouteMetadataMatchMethod' :: GrpcRouteMetadataMatchMethod -> Maybe Text
suffix} -> Maybe Text
suffix) (\s :: GrpcRouteMetadataMatchMethod
s@GrpcRouteMetadataMatchMethod' {} Maybe Text
a -> GrpcRouteMetadataMatchMethod
s {$sel:suffix:GrpcRouteMetadataMatchMethod' :: Maybe Text
suffix = Maybe Text
a} :: GrpcRouteMetadataMatchMethod)

-- | The value sent by the client must include the specified characters.
grpcRouteMetadataMatchMethod_regex :: Lens.Lens' GrpcRouteMetadataMatchMethod (Prelude.Maybe Prelude.Text)
grpcRouteMetadataMatchMethod_regex :: (Maybe Text -> f (Maybe Text))
-> GrpcRouteMetadataMatchMethod -> f GrpcRouteMetadataMatchMethod
grpcRouteMetadataMatchMethod_regex = (GrpcRouteMetadataMatchMethod -> Maybe Text)
-> (GrpcRouteMetadataMatchMethod
    -> Maybe Text -> GrpcRouteMetadataMatchMethod)
-> Lens
     GrpcRouteMetadataMatchMethod
     GrpcRouteMetadataMatchMethod
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GrpcRouteMetadataMatchMethod' {Maybe Text
regex :: Maybe Text
$sel:regex:GrpcRouteMetadataMatchMethod' :: GrpcRouteMetadataMatchMethod -> Maybe Text
regex} -> Maybe Text
regex) (\s :: GrpcRouteMetadataMatchMethod
s@GrpcRouteMetadataMatchMethod' {} Maybe Text
a -> GrpcRouteMetadataMatchMethod
s {$sel:regex:GrpcRouteMetadataMatchMethod' :: Maybe Text
regex = Maybe Text
a} :: GrpcRouteMetadataMatchMethod)

-- | The value sent by the client must begin with the specified characters.
grpcRouteMetadataMatchMethod_prefix :: Lens.Lens' GrpcRouteMetadataMatchMethod (Prelude.Maybe Prelude.Text)
grpcRouteMetadataMatchMethod_prefix :: (Maybe Text -> f (Maybe Text))
-> GrpcRouteMetadataMatchMethod -> f GrpcRouteMetadataMatchMethod
grpcRouteMetadataMatchMethod_prefix = (GrpcRouteMetadataMatchMethod -> Maybe Text)
-> (GrpcRouteMetadataMatchMethod
    -> Maybe Text -> GrpcRouteMetadataMatchMethod)
-> Lens
     GrpcRouteMetadataMatchMethod
     GrpcRouteMetadataMatchMethod
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GrpcRouteMetadataMatchMethod' {Maybe Text
prefix :: Maybe Text
$sel:prefix:GrpcRouteMetadataMatchMethod' :: GrpcRouteMetadataMatchMethod -> Maybe Text
prefix} -> Maybe Text
prefix) (\s :: GrpcRouteMetadataMatchMethod
s@GrpcRouteMetadataMatchMethod' {} Maybe Text
a -> GrpcRouteMetadataMatchMethod
s {$sel:prefix:GrpcRouteMetadataMatchMethod' :: Maybe Text
prefix = Maybe Text
a} :: GrpcRouteMetadataMatchMethod)

-- | An object that represents the range of values to match on.
grpcRouteMetadataMatchMethod_range :: Lens.Lens' GrpcRouteMetadataMatchMethod (Prelude.Maybe MatchRange)
grpcRouteMetadataMatchMethod_range :: (Maybe MatchRange -> f (Maybe MatchRange))
-> GrpcRouteMetadataMatchMethod -> f GrpcRouteMetadataMatchMethod
grpcRouteMetadataMatchMethod_range = (GrpcRouteMetadataMatchMethod -> Maybe MatchRange)
-> (GrpcRouteMetadataMatchMethod
    -> Maybe MatchRange -> GrpcRouteMetadataMatchMethod)
-> Lens
     GrpcRouteMetadataMatchMethod
     GrpcRouteMetadataMatchMethod
     (Maybe MatchRange)
     (Maybe MatchRange)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GrpcRouteMetadataMatchMethod' {Maybe MatchRange
range :: Maybe MatchRange
$sel:range:GrpcRouteMetadataMatchMethod' :: GrpcRouteMetadataMatchMethod -> Maybe MatchRange
range} -> Maybe MatchRange
range) (\s :: GrpcRouteMetadataMatchMethod
s@GrpcRouteMetadataMatchMethod' {} Maybe MatchRange
a -> GrpcRouteMetadataMatchMethod
s {$sel:range:GrpcRouteMetadataMatchMethod' :: Maybe MatchRange
range = Maybe MatchRange
a} :: GrpcRouteMetadataMatchMethod)

-- | The value sent by the client must match the specified value exactly.
grpcRouteMetadataMatchMethod_exact :: Lens.Lens' GrpcRouteMetadataMatchMethod (Prelude.Maybe Prelude.Text)
grpcRouteMetadataMatchMethod_exact :: (Maybe Text -> f (Maybe Text))
-> GrpcRouteMetadataMatchMethod -> f GrpcRouteMetadataMatchMethod
grpcRouteMetadataMatchMethod_exact = (GrpcRouteMetadataMatchMethod -> Maybe Text)
-> (GrpcRouteMetadataMatchMethod
    -> Maybe Text -> GrpcRouteMetadataMatchMethod)
-> Lens
     GrpcRouteMetadataMatchMethod
     GrpcRouteMetadataMatchMethod
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GrpcRouteMetadataMatchMethod' {Maybe Text
exact :: Maybe Text
$sel:exact:GrpcRouteMetadataMatchMethod' :: GrpcRouteMetadataMatchMethod -> Maybe Text
exact} -> Maybe Text
exact) (\s :: GrpcRouteMetadataMatchMethod
s@GrpcRouteMetadataMatchMethod' {} Maybe Text
a -> GrpcRouteMetadataMatchMethod
s {$sel:exact:GrpcRouteMetadataMatchMethod' :: Maybe Text
exact = Maybe Text
a} :: GrpcRouteMetadataMatchMethod)

instance Core.FromJSON GrpcRouteMetadataMatchMethod where
  parseJSON :: Value -> Parser GrpcRouteMetadataMatchMethod
parseJSON =
    String
-> (Object -> Parser GrpcRouteMetadataMatchMethod)
-> Value
-> Parser GrpcRouteMetadataMatchMethod
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"GrpcRouteMetadataMatchMethod"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe MatchRange
-> Maybe Text
-> GrpcRouteMetadataMatchMethod
GrpcRouteMetadataMatchMethod'
            (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe MatchRange
 -> Maybe Text
 -> GrpcRouteMetadataMatchMethod)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe MatchRange
      -> Maybe Text
      -> GrpcRouteMetadataMatchMethod)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"suffix")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe MatchRange
   -> Maybe Text
   -> GrpcRouteMetadataMatchMethod)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe MatchRange -> Maybe Text -> GrpcRouteMetadataMatchMethod)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"regex")
            Parser
  (Maybe Text
   -> Maybe MatchRange -> Maybe Text -> GrpcRouteMetadataMatchMethod)
-> Parser (Maybe Text)
-> Parser
     (Maybe MatchRange -> Maybe Text -> GrpcRouteMetadataMatchMethod)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"prefix")
            Parser
  (Maybe MatchRange -> Maybe Text -> GrpcRouteMetadataMatchMethod)
-> Parser (Maybe MatchRange)
-> Parser (Maybe Text -> GrpcRouteMetadataMatchMethod)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe MatchRange)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"range")
            Parser (Maybe Text -> GrpcRouteMetadataMatchMethod)
-> Parser (Maybe Text) -> Parser GrpcRouteMetadataMatchMethod
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"exact")
      )

instance
  Prelude.Hashable
    GrpcRouteMetadataMatchMethod

instance Prelude.NFData GrpcRouteMetadataMatchMethod

instance Core.ToJSON GrpcRouteMetadataMatchMethod where
  toJSON :: GrpcRouteMetadataMatchMethod -> Value
toJSON GrpcRouteMetadataMatchMethod' {Maybe Text
Maybe MatchRange
exact :: Maybe Text
range :: Maybe MatchRange
prefix :: Maybe Text
regex :: Maybe Text
suffix :: Maybe Text
$sel:exact:GrpcRouteMetadataMatchMethod' :: GrpcRouteMetadataMatchMethod -> Maybe Text
$sel:range:GrpcRouteMetadataMatchMethod' :: GrpcRouteMetadataMatchMethod -> Maybe MatchRange
$sel:prefix:GrpcRouteMetadataMatchMethod' :: GrpcRouteMetadataMatchMethod -> Maybe Text
$sel:regex:GrpcRouteMetadataMatchMethod' :: GrpcRouteMetadataMatchMethod -> Maybe Text
$sel:suffix:GrpcRouteMetadataMatchMethod' :: GrpcRouteMetadataMatchMethod -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"suffix" 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
suffix,
            (Text
"regex" 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
regex,
            (Text
"prefix" 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
prefix,
            (Text
"range" Text -> MatchRange -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (MatchRange -> Pair) -> Maybe MatchRange -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe MatchRange
range,
            (Text
"exact" 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
exact
          ]
      )