{-# 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.GrpcMetadataMatchMethod
-- 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.GrpcMetadataMatchMethod 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 representing the method header to be matched.
--
-- /See:/ 'newGrpcMetadataMatchMethod' smart constructor.
data GrpcMetadataMatchMethod = GrpcMetadataMatchMethod'
  { -- | The specified ending characters of the method header to match on.
    GrpcMetadataMatchMethod -> Maybe Text
suffix :: Prelude.Maybe Prelude.Text,
    -- | The regex used to match the method header.
    GrpcMetadataMatchMethod -> Maybe Text
regex :: Prelude.Maybe Prelude.Text,
    -- | The specified beginning characters of the method header to be matched
    -- on.
    GrpcMetadataMatchMethod -> Maybe Text
prefix :: Prelude.Maybe Prelude.Text,
    GrpcMetadataMatchMethod -> Maybe MatchRange
range :: Prelude.Maybe MatchRange,
    -- | The exact method header to be matched on.
    GrpcMetadataMatchMethod -> Maybe Text
exact :: Prelude.Maybe Prelude.Text
  }
  deriving (GrpcMetadataMatchMethod -> GrpcMetadataMatchMethod -> Bool
(GrpcMetadataMatchMethod -> GrpcMetadataMatchMethod -> Bool)
-> (GrpcMetadataMatchMethod -> GrpcMetadataMatchMethod -> Bool)
-> Eq GrpcMetadataMatchMethod
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GrpcMetadataMatchMethod -> GrpcMetadataMatchMethod -> Bool
$c/= :: GrpcMetadataMatchMethod -> GrpcMetadataMatchMethod -> Bool
== :: GrpcMetadataMatchMethod -> GrpcMetadataMatchMethod -> Bool
$c== :: GrpcMetadataMatchMethod -> GrpcMetadataMatchMethod -> Bool
Prelude.Eq, ReadPrec [GrpcMetadataMatchMethod]
ReadPrec GrpcMetadataMatchMethod
Int -> ReadS GrpcMetadataMatchMethod
ReadS [GrpcMetadataMatchMethod]
(Int -> ReadS GrpcMetadataMatchMethod)
-> ReadS [GrpcMetadataMatchMethod]
-> ReadPrec GrpcMetadataMatchMethod
-> ReadPrec [GrpcMetadataMatchMethod]
-> Read GrpcMetadataMatchMethod
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GrpcMetadataMatchMethod]
$creadListPrec :: ReadPrec [GrpcMetadataMatchMethod]
readPrec :: ReadPrec GrpcMetadataMatchMethod
$creadPrec :: ReadPrec GrpcMetadataMatchMethod
readList :: ReadS [GrpcMetadataMatchMethod]
$creadList :: ReadS [GrpcMetadataMatchMethod]
readsPrec :: Int -> ReadS GrpcMetadataMatchMethod
$creadsPrec :: Int -> ReadS GrpcMetadataMatchMethod
Prelude.Read, Int -> GrpcMetadataMatchMethod -> ShowS
[GrpcMetadataMatchMethod] -> ShowS
GrpcMetadataMatchMethod -> String
(Int -> GrpcMetadataMatchMethod -> ShowS)
-> (GrpcMetadataMatchMethod -> String)
-> ([GrpcMetadataMatchMethod] -> ShowS)
-> Show GrpcMetadataMatchMethod
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GrpcMetadataMatchMethod] -> ShowS
$cshowList :: [GrpcMetadataMatchMethod] -> ShowS
show :: GrpcMetadataMatchMethod -> String
$cshow :: GrpcMetadataMatchMethod -> String
showsPrec :: Int -> GrpcMetadataMatchMethod -> ShowS
$cshowsPrec :: Int -> GrpcMetadataMatchMethod -> ShowS
Prelude.Show, (forall x.
 GrpcMetadataMatchMethod -> Rep GrpcMetadataMatchMethod x)
-> (forall x.
    Rep GrpcMetadataMatchMethod x -> GrpcMetadataMatchMethod)
-> Generic GrpcMetadataMatchMethod
forall x. Rep GrpcMetadataMatchMethod x -> GrpcMetadataMatchMethod
forall x. GrpcMetadataMatchMethod -> Rep GrpcMetadataMatchMethod x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GrpcMetadataMatchMethod x -> GrpcMetadataMatchMethod
$cfrom :: forall x. GrpcMetadataMatchMethod -> Rep GrpcMetadataMatchMethod x
Prelude.Generic)

-- |
-- Create a value of 'GrpcMetadataMatchMethod' 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', 'grpcMetadataMatchMethod_suffix' - The specified ending characters of the method header to match on.
--
-- 'regex', 'grpcMetadataMatchMethod_regex' - The regex used to match the method header.
--
-- 'prefix', 'grpcMetadataMatchMethod_prefix' - The specified beginning characters of the method header to be matched
-- on.
--
-- 'range', 'grpcMetadataMatchMethod_range' - Undocumented member.
--
-- 'exact', 'grpcMetadataMatchMethod_exact' - The exact method header to be matched on.
newGrpcMetadataMatchMethod ::
  GrpcMetadataMatchMethod
newGrpcMetadataMatchMethod :: GrpcMetadataMatchMethod
newGrpcMetadataMatchMethod =
  GrpcMetadataMatchMethod' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe MatchRange
-> Maybe Text
-> GrpcMetadataMatchMethod
GrpcMetadataMatchMethod'
    { $sel:suffix:GrpcMetadataMatchMethod' :: Maybe Text
suffix = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:regex:GrpcMetadataMatchMethod' :: Maybe Text
regex = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:prefix:GrpcMetadataMatchMethod' :: Maybe Text
prefix = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:range:GrpcMetadataMatchMethod' :: Maybe MatchRange
range = Maybe MatchRange
forall a. Maybe a
Prelude.Nothing,
      $sel:exact:GrpcMetadataMatchMethod' :: Maybe Text
exact = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The specified ending characters of the method header to match on.
grpcMetadataMatchMethod_suffix :: Lens.Lens' GrpcMetadataMatchMethod (Prelude.Maybe Prelude.Text)
grpcMetadataMatchMethod_suffix :: (Maybe Text -> f (Maybe Text))
-> GrpcMetadataMatchMethod -> f GrpcMetadataMatchMethod
grpcMetadataMatchMethod_suffix = (GrpcMetadataMatchMethod -> Maybe Text)
-> (GrpcMetadataMatchMethod
    -> Maybe Text -> GrpcMetadataMatchMethod)
-> Lens
     GrpcMetadataMatchMethod
     GrpcMetadataMatchMethod
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GrpcMetadataMatchMethod' {Maybe Text
suffix :: Maybe Text
$sel:suffix:GrpcMetadataMatchMethod' :: GrpcMetadataMatchMethod -> Maybe Text
suffix} -> Maybe Text
suffix) (\s :: GrpcMetadataMatchMethod
s@GrpcMetadataMatchMethod' {} Maybe Text
a -> GrpcMetadataMatchMethod
s {$sel:suffix:GrpcMetadataMatchMethod' :: Maybe Text
suffix = Maybe Text
a} :: GrpcMetadataMatchMethod)

-- | The regex used to match the method header.
grpcMetadataMatchMethod_regex :: Lens.Lens' GrpcMetadataMatchMethod (Prelude.Maybe Prelude.Text)
grpcMetadataMatchMethod_regex :: (Maybe Text -> f (Maybe Text))
-> GrpcMetadataMatchMethod -> f GrpcMetadataMatchMethod
grpcMetadataMatchMethod_regex = (GrpcMetadataMatchMethod -> Maybe Text)
-> (GrpcMetadataMatchMethod
    -> Maybe Text -> GrpcMetadataMatchMethod)
-> Lens
     GrpcMetadataMatchMethod
     GrpcMetadataMatchMethod
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GrpcMetadataMatchMethod' {Maybe Text
regex :: Maybe Text
$sel:regex:GrpcMetadataMatchMethod' :: GrpcMetadataMatchMethod -> Maybe Text
regex} -> Maybe Text
regex) (\s :: GrpcMetadataMatchMethod
s@GrpcMetadataMatchMethod' {} Maybe Text
a -> GrpcMetadataMatchMethod
s {$sel:regex:GrpcMetadataMatchMethod' :: Maybe Text
regex = Maybe Text
a} :: GrpcMetadataMatchMethod)

-- | The specified beginning characters of the method header to be matched
-- on.
grpcMetadataMatchMethod_prefix :: Lens.Lens' GrpcMetadataMatchMethod (Prelude.Maybe Prelude.Text)
grpcMetadataMatchMethod_prefix :: (Maybe Text -> f (Maybe Text))
-> GrpcMetadataMatchMethod -> f GrpcMetadataMatchMethod
grpcMetadataMatchMethod_prefix = (GrpcMetadataMatchMethod -> Maybe Text)
-> (GrpcMetadataMatchMethod
    -> Maybe Text -> GrpcMetadataMatchMethod)
-> Lens
     GrpcMetadataMatchMethod
     GrpcMetadataMatchMethod
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GrpcMetadataMatchMethod' {Maybe Text
prefix :: Maybe Text
$sel:prefix:GrpcMetadataMatchMethod' :: GrpcMetadataMatchMethod -> Maybe Text
prefix} -> Maybe Text
prefix) (\s :: GrpcMetadataMatchMethod
s@GrpcMetadataMatchMethod' {} Maybe Text
a -> GrpcMetadataMatchMethod
s {$sel:prefix:GrpcMetadataMatchMethod' :: Maybe Text
prefix = Maybe Text
a} :: GrpcMetadataMatchMethod)

-- | Undocumented member.
grpcMetadataMatchMethod_range :: Lens.Lens' GrpcMetadataMatchMethod (Prelude.Maybe MatchRange)
grpcMetadataMatchMethod_range :: (Maybe MatchRange -> f (Maybe MatchRange))
-> GrpcMetadataMatchMethod -> f GrpcMetadataMatchMethod
grpcMetadataMatchMethod_range = (GrpcMetadataMatchMethod -> Maybe MatchRange)
-> (GrpcMetadataMatchMethod
    -> Maybe MatchRange -> GrpcMetadataMatchMethod)
-> Lens
     GrpcMetadataMatchMethod
     GrpcMetadataMatchMethod
     (Maybe MatchRange)
     (Maybe MatchRange)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GrpcMetadataMatchMethod' {Maybe MatchRange
range :: Maybe MatchRange
$sel:range:GrpcMetadataMatchMethod' :: GrpcMetadataMatchMethod -> Maybe MatchRange
range} -> Maybe MatchRange
range) (\s :: GrpcMetadataMatchMethod
s@GrpcMetadataMatchMethod' {} Maybe MatchRange
a -> GrpcMetadataMatchMethod
s {$sel:range:GrpcMetadataMatchMethod' :: Maybe MatchRange
range = Maybe MatchRange
a} :: GrpcMetadataMatchMethod)

-- | The exact method header to be matched on.
grpcMetadataMatchMethod_exact :: Lens.Lens' GrpcMetadataMatchMethod (Prelude.Maybe Prelude.Text)
grpcMetadataMatchMethod_exact :: (Maybe Text -> f (Maybe Text))
-> GrpcMetadataMatchMethod -> f GrpcMetadataMatchMethod
grpcMetadataMatchMethod_exact = (GrpcMetadataMatchMethod -> Maybe Text)
-> (GrpcMetadataMatchMethod
    -> Maybe Text -> GrpcMetadataMatchMethod)
-> Lens
     GrpcMetadataMatchMethod
     GrpcMetadataMatchMethod
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GrpcMetadataMatchMethod' {Maybe Text
exact :: Maybe Text
$sel:exact:GrpcMetadataMatchMethod' :: GrpcMetadataMatchMethod -> Maybe Text
exact} -> Maybe Text
exact) (\s :: GrpcMetadataMatchMethod
s@GrpcMetadataMatchMethod' {} Maybe Text
a -> GrpcMetadataMatchMethod
s {$sel:exact:GrpcMetadataMatchMethod' :: Maybe Text
exact = Maybe Text
a} :: GrpcMetadataMatchMethod)

instance Core.FromJSON GrpcMetadataMatchMethod where
  parseJSON :: Value -> Parser GrpcMetadataMatchMethod
parseJSON =
    String
-> (Object -> Parser GrpcMetadataMatchMethod)
-> Value
-> Parser GrpcMetadataMatchMethod
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"GrpcMetadataMatchMethod"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe MatchRange
-> Maybe Text
-> GrpcMetadataMatchMethod
GrpcMetadataMatchMethod'
            (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe MatchRange
 -> Maybe Text
 -> GrpcMetadataMatchMethod)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe MatchRange
      -> Maybe Text
      -> GrpcMetadataMatchMethod)
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
   -> GrpcMetadataMatchMethod)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe MatchRange -> Maybe Text -> GrpcMetadataMatchMethod)
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 -> GrpcMetadataMatchMethod)
-> Parser (Maybe Text)
-> Parser
     (Maybe MatchRange -> Maybe Text -> GrpcMetadataMatchMethod)
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 -> GrpcMetadataMatchMethod)
-> Parser (Maybe MatchRange)
-> Parser (Maybe Text -> GrpcMetadataMatchMethod)
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 -> GrpcMetadataMatchMethod)
-> Parser (Maybe Text) -> Parser GrpcMetadataMatchMethod
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 GrpcMetadataMatchMethod

instance Prelude.NFData GrpcMetadataMatchMethod

instance Core.ToJSON GrpcMetadataMatchMethod where
  toJSON :: GrpcMetadataMatchMethod -> Value
toJSON GrpcMetadataMatchMethod' {Maybe Text
Maybe MatchRange
exact :: Maybe Text
range :: Maybe MatchRange
prefix :: Maybe Text
regex :: Maybe Text
suffix :: Maybe Text
$sel:exact:GrpcMetadataMatchMethod' :: GrpcMetadataMatchMethod -> Maybe Text
$sel:range:GrpcMetadataMatchMethod' :: GrpcMetadataMatchMethod -> Maybe MatchRange
$sel:prefix:GrpcMetadataMatchMethod' :: GrpcMetadataMatchMethod -> Maybe Text
$sel:regex:GrpcMetadataMatchMethod' :: GrpcMetadataMatchMethod -> Maybe Text
$sel:suffix:GrpcMetadataMatchMethod' :: GrpcMetadataMatchMethod -> 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
          ]
      )