{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | An object representing the method header to be matched.
--
-- /See:/ 'newGrpcMetadataMatchMethod' smart constructor.
data GrpcMetadataMatchMethod = GrpcMetadataMatchMethod'
  { -- | The exact method header to be matched on.
    GrpcMetadataMatchMethod -> Maybe Text
exact :: 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 regex used to match the method header.
    GrpcMetadataMatchMethod -> Maybe Text
regex :: Prelude.Maybe Prelude.Text,
    -- | The specified ending characters of the method header to match on.
    GrpcMetadataMatchMethod -> Maybe Text
suffix :: Prelude.Maybe Prelude.Text
  }
  deriving (GrpcMetadataMatchMethod -> GrpcMetadataMatchMethod -> Bool
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]
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
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. 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:
--
-- 'exact', 'grpcMetadataMatchMethod_exact' - The exact method header to be matched on.
--
-- 'prefix', 'grpcMetadataMatchMethod_prefix' - The specified beginning characters of the method header to be matched
-- on.
--
-- 'range', 'grpcMetadataMatchMethod_range' - Undocumented member.
--
-- 'regex', 'grpcMetadataMatchMethod_regex' - The regex used to match the method header.
--
-- 'suffix', 'grpcMetadataMatchMethod_suffix' - The specified ending characters of the method header to match on.
newGrpcMetadataMatchMethod ::
  GrpcMetadataMatchMethod
newGrpcMetadataMatchMethod :: GrpcMetadataMatchMethod
newGrpcMetadataMatchMethod =
  GrpcMetadataMatchMethod'
    { $sel:exact:GrpcMetadataMatchMethod' :: Maybe Text
exact = forall a. Maybe a
Prelude.Nothing,
      $sel:prefix:GrpcMetadataMatchMethod' :: Maybe Text
prefix = forall a. Maybe a
Prelude.Nothing,
      $sel:range:GrpcMetadataMatchMethod' :: Maybe MatchRange
range = forall a. Maybe a
Prelude.Nothing,
      $sel:regex:GrpcMetadataMatchMethod' :: Maybe Text
regex = forall a. Maybe a
Prelude.Nothing,
      $sel:suffix:GrpcMetadataMatchMethod' :: Maybe Text
suffix = forall a. Maybe a
Prelude.Nothing
    }

-- | The exact method header to be matched on.
grpcMetadataMatchMethod_exact :: Lens.Lens' GrpcMetadataMatchMethod (Prelude.Maybe Prelude.Text)
grpcMetadataMatchMethod_exact :: Lens' GrpcMetadataMatchMethod (Maybe Text)
grpcMetadataMatchMethod_exact = 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)

-- | The specified beginning characters of the method header to be matched
-- on.
grpcMetadataMatchMethod_prefix :: Lens.Lens' GrpcMetadataMatchMethod (Prelude.Maybe Prelude.Text)
grpcMetadataMatchMethod_prefix :: Lens' GrpcMetadataMatchMethod (Maybe Text)
grpcMetadataMatchMethod_prefix = 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 :: Lens' GrpcMetadataMatchMethod (Maybe MatchRange)
grpcMetadataMatchMethod_range = 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 regex used to match the method header.
grpcMetadataMatchMethod_regex :: Lens.Lens' GrpcMetadataMatchMethod (Prelude.Maybe Prelude.Text)
grpcMetadataMatchMethod_regex :: Lens' GrpcMetadataMatchMethod (Maybe Text)
grpcMetadataMatchMethod_regex = 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 ending characters of the method header to match on.
grpcMetadataMatchMethod_suffix :: Lens.Lens' GrpcMetadataMatchMethod (Prelude.Maybe Prelude.Text)
grpcMetadataMatchMethod_suffix :: Lens' GrpcMetadataMatchMethod (Maybe Text)
grpcMetadataMatchMethod_suffix = 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)

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

instance Prelude.Hashable GrpcMetadataMatchMethod where
  hashWithSalt :: Int -> GrpcMetadataMatchMethod -> Int
hashWithSalt Int
_salt GrpcMetadataMatchMethod' {Maybe Text
Maybe MatchRange
suffix :: Maybe Text
regex :: Maybe Text
range :: Maybe MatchRange
prefix :: Maybe Text
exact :: Maybe Text
$sel:suffix:GrpcMetadataMatchMethod' :: GrpcMetadataMatchMethod -> Maybe Text
$sel:regex:GrpcMetadataMatchMethod' :: GrpcMetadataMatchMethod -> Maybe Text
$sel:range:GrpcMetadataMatchMethod' :: GrpcMetadataMatchMethod -> Maybe MatchRange
$sel:prefix:GrpcMetadataMatchMethod' :: GrpcMetadataMatchMethod -> Maybe Text
$sel:exact:GrpcMetadataMatchMethod' :: GrpcMetadataMatchMethod -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
exact
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
prefix
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe MatchRange
range
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
regex
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
suffix

instance Prelude.NFData GrpcMetadataMatchMethod where
  rnf :: GrpcMetadataMatchMethod -> ()
rnf GrpcMetadataMatchMethod' {Maybe Text
Maybe MatchRange
suffix :: Maybe Text
regex :: Maybe Text
range :: Maybe MatchRange
prefix :: Maybe Text
exact :: Maybe Text
$sel:suffix:GrpcMetadataMatchMethod' :: GrpcMetadataMatchMethod -> Maybe Text
$sel:regex:GrpcMetadataMatchMethod' :: GrpcMetadataMatchMethod -> Maybe Text
$sel:range:GrpcMetadataMatchMethod' :: GrpcMetadataMatchMethod -> Maybe MatchRange
$sel:prefix:GrpcMetadataMatchMethod' :: GrpcMetadataMatchMethod -> Maybe Text
$sel:exact:GrpcMetadataMatchMethod' :: GrpcMetadataMatchMethod -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
exact
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
prefix
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe MatchRange
range
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
regex
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
suffix

instance Data.ToJSON GrpcMetadataMatchMethod where
  toJSON :: GrpcMetadataMatchMethod -> Value
toJSON GrpcMetadataMatchMethod' {Maybe Text
Maybe MatchRange
suffix :: Maybe Text
regex :: Maybe Text
range :: Maybe MatchRange
prefix :: Maybe Text
exact :: Maybe Text
$sel:suffix:GrpcMetadataMatchMethod' :: GrpcMetadataMatchMethod -> Maybe Text
$sel:regex:GrpcMetadataMatchMethod' :: GrpcMetadataMatchMethod -> Maybe Text
$sel:range:GrpcMetadataMatchMethod' :: GrpcMetadataMatchMethod -> Maybe MatchRange
$sel:prefix:GrpcMetadataMatchMethod' :: GrpcMetadataMatchMethod -> Maybe Text
$sel:exact:GrpcMetadataMatchMethod' :: GrpcMetadataMatchMethod -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"exact" 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 Text
exact,
            (Key
"prefix" 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 Text
prefix,
            (Key
"range" 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 MatchRange
range,
            (Key
"regex" 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 Text
regex,
            (Key
"suffix" 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 Text
suffix
          ]
      )