{-# 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.ApiGatewayV2.Types.RouteSettings
-- 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.ApiGatewayV2.Types.RouteSettings where

import Amazonka.ApiGatewayV2.Types.LoggingLevel
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents a collection of route settings.
--
-- /See:/ 'newRouteSettings' smart constructor.
data RouteSettings = RouteSettings'
  { -- | Specifies whether (true) or not (false) data trace logging is enabled
    -- for this route. This property affects the log entries pushed to Amazon
    -- CloudWatch Logs. Supported only for WebSocket APIs.
    RouteSettings -> Maybe Bool
dataTraceEnabled :: Prelude.Maybe Prelude.Bool,
    -- | Specifies the throttling burst limit.
    RouteSettings -> Maybe Int
throttlingBurstLimit :: Prelude.Maybe Prelude.Int,
    -- | Specifies the logging level for this route: INFO, ERROR, or OFF. This
    -- property affects the log entries pushed to Amazon CloudWatch Logs.
    -- Supported only for WebSocket APIs.
    RouteSettings -> Maybe LoggingLevel
loggingLevel :: Prelude.Maybe LoggingLevel,
    -- | Specifies the throttling rate limit.
    RouteSettings -> Maybe Double
throttlingRateLimit :: Prelude.Maybe Prelude.Double,
    -- | Specifies whether detailed metrics are enabled.
    RouteSettings -> Maybe Bool
detailedMetricsEnabled :: Prelude.Maybe Prelude.Bool
  }
  deriving (RouteSettings -> RouteSettings -> Bool
(RouteSettings -> RouteSettings -> Bool)
-> (RouteSettings -> RouteSettings -> Bool) -> Eq RouteSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RouteSettings -> RouteSettings -> Bool
$c/= :: RouteSettings -> RouteSettings -> Bool
== :: RouteSettings -> RouteSettings -> Bool
$c== :: RouteSettings -> RouteSettings -> Bool
Prelude.Eq, ReadPrec [RouteSettings]
ReadPrec RouteSettings
Int -> ReadS RouteSettings
ReadS [RouteSettings]
(Int -> ReadS RouteSettings)
-> ReadS [RouteSettings]
-> ReadPrec RouteSettings
-> ReadPrec [RouteSettings]
-> Read RouteSettings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RouteSettings]
$creadListPrec :: ReadPrec [RouteSettings]
readPrec :: ReadPrec RouteSettings
$creadPrec :: ReadPrec RouteSettings
readList :: ReadS [RouteSettings]
$creadList :: ReadS [RouteSettings]
readsPrec :: Int -> ReadS RouteSettings
$creadsPrec :: Int -> ReadS RouteSettings
Prelude.Read, Int -> RouteSettings -> ShowS
[RouteSettings] -> ShowS
RouteSettings -> String
(Int -> RouteSettings -> ShowS)
-> (RouteSettings -> String)
-> ([RouteSettings] -> ShowS)
-> Show RouteSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RouteSettings] -> ShowS
$cshowList :: [RouteSettings] -> ShowS
show :: RouteSettings -> String
$cshow :: RouteSettings -> String
showsPrec :: Int -> RouteSettings -> ShowS
$cshowsPrec :: Int -> RouteSettings -> ShowS
Prelude.Show, (forall x. RouteSettings -> Rep RouteSettings x)
-> (forall x. Rep RouteSettings x -> RouteSettings)
-> Generic RouteSettings
forall x. Rep RouteSettings x -> RouteSettings
forall x. RouteSettings -> Rep RouteSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RouteSettings x -> RouteSettings
$cfrom :: forall x. RouteSettings -> Rep RouteSettings x
Prelude.Generic)

-- |
-- Create a value of 'RouteSettings' 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:
--
-- 'dataTraceEnabled', 'routeSettings_dataTraceEnabled' - Specifies whether (true) or not (false) data trace logging is enabled
-- for this route. This property affects the log entries pushed to Amazon
-- CloudWatch Logs. Supported only for WebSocket APIs.
--
-- 'throttlingBurstLimit', 'routeSettings_throttlingBurstLimit' - Specifies the throttling burst limit.
--
-- 'loggingLevel', 'routeSettings_loggingLevel' - Specifies the logging level for this route: INFO, ERROR, or OFF. This
-- property affects the log entries pushed to Amazon CloudWatch Logs.
-- Supported only for WebSocket APIs.
--
-- 'throttlingRateLimit', 'routeSettings_throttlingRateLimit' - Specifies the throttling rate limit.
--
-- 'detailedMetricsEnabled', 'routeSettings_detailedMetricsEnabled' - Specifies whether detailed metrics are enabled.
newRouteSettings ::
  RouteSettings
newRouteSettings :: RouteSettings
newRouteSettings =
  RouteSettings' :: Maybe Bool
-> Maybe Int
-> Maybe LoggingLevel
-> Maybe Double
-> Maybe Bool
-> RouteSettings
RouteSettings'
    { $sel:dataTraceEnabled:RouteSettings' :: Maybe Bool
dataTraceEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:throttlingBurstLimit:RouteSettings' :: Maybe Int
throttlingBurstLimit = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:loggingLevel:RouteSettings' :: Maybe LoggingLevel
loggingLevel = Maybe LoggingLevel
forall a. Maybe a
Prelude.Nothing,
      $sel:throttlingRateLimit:RouteSettings' :: Maybe Double
throttlingRateLimit = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:detailedMetricsEnabled:RouteSettings' :: Maybe Bool
detailedMetricsEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies whether (true) or not (false) data trace logging is enabled
-- for this route. This property affects the log entries pushed to Amazon
-- CloudWatch Logs. Supported only for WebSocket APIs.
routeSettings_dataTraceEnabled :: Lens.Lens' RouteSettings (Prelude.Maybe Prelude.Bool)
routeSettings_dataTraceEnabled :: (Maybe Bool -> f (Maybe Bool)) -> RouteSettings -> f RouteSettings
routeSettings_dataTraceEnabled = (RouteSettings -> Maybe Bool)
-> (RouteSettings -> Maybe Bool -> RouteSettings)
-> Lens RouteSettings RouteSettings (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RouteSettings' {Maybe Bool
dataTraceEnabled :: Maybe Bool
$sel:dataTraceEnabled:RouteSettings' :: RouteSettings -> Maybe Bool
dataTraceEnabled} -> Maybe Bool
dataTraceEnabled) (\s :: RouteSettings
s@RouteSettings' {} Maybe Bool
a -> RouteSettings
s {$sel:dataTraceEnabled:RouteSettings' :: Maybe Bool
dataTraceEnabled = Maybe Bool
a} :: RouteSettings)

-- | Specifies the throttling burst limit.
routeSettings_throttlingBurstLimit :: Lens.Lens' RouteSettings (Prelude.Maybe Prelude.Int)
routeSettings_throttlingBurstLimit :: (Maybe Int -> f (Maybe Int)) -> RouteSettings -> f RouteSettings
routeSettings_throttlingBurstLimit = (RouteSettings -> Maybe Int)
-> (RouteSettings -> Maybe Int -> RouteSettings)
-> Lens RouteSettings RouteSettings (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RouteSettings' {Maybe Int
throttlingBurstLimit :: Maybe Int
$sel:throttlingBurstLimit:RouteSettings' :: RouteSettings -> Maybe Int
throttlingBurstLimit} -> Maybe Int
throttlingBurstLimit) (\s :: RouteSettings
s@RouteSettings' {} Maybe Int
a -> RouteSettings
s {$sel:throttlingBurstLimit:RouteSettings' :: Maybe Int
throttlingBurstLimit = Maybe Int
a} :: RouteSettings)

-- | Specifies the logging level for this route: INFO, ERROR, or OFF. This
-- property affects the log entries pushed to Amazon CloudWatch Logs.
-- Supported only for WebSocket APIs.
routeSettings_loggingLevel :: Lens.Lens' RouteSettings (Prelude.Maybe LoggingLevel)
routeSettings_loggingLevel :: (Maybe LoggingLevel -> f (Maybe LoggingLevel))
-> RouteSettings -> f RouteSettings
routeSettings_loggingLevel = (RouteSettings -> Maybe LoggingLevel)
-> (RouteSettings -> Maybe LoggingLevel -> RouteSettings)
-> Lens
     RouteSettings
     RouteSettings
     (Maybe LoggingLevel)
     (Maybe LoggingLevel)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RouteSettings' {Maybe LoggingLevel
loggingLevel :: Maybe LoggingLevel
$sel:loggingLevel:RouteSettings' :: RouteSettings -> Maybe LoggingLevel
loggingLevel} -> Maybe LoggingLevel
loggingLevel) (\s :: RouteSettings
s@RouteSettings' {} Maybe LoggingLevel
a -> RouteSettings
s {$sel:loggingLevel:RouteSettings' :: Maybe LoggingLevel
loggingLevel = Maybe LoggingLevel
a} :: RouteSettings)

-- | Specifies the throttling rate limit.
routeSettings_throttlingRateLimit :: Lens.Lens' RouteSettings (Prelude.Maybe Prelude.Double)
routeSettings_throttlingRateLimit :: (Maybe Double -> f (Maybe Double))
-> RouteSettings -> f RouteSettings
routeSettings_throttlingRateLimit = (RouteSettings -> Maybe Double)
-> (RouteSettings -> Maybe Double -> RouteSettings)
-> Lens RouteSettings RouteSettings (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RouteSettings' {Maybe Double
throttlingRateLimit :: Maybe Double
$sel:throttlingRateLimit:RouteSettings' :: RouteSettings -> Maybe Double
throttlingRateLimit} -> Maybe Double
throttlingRateLimit) (\s :: RouteSettings
s@RouteSettings' {} Maybe Double
a -> RouteSettings
s {$sel:throttlingRateLimit:RouteSettings' :: Maybe Double
throttlingRateLimit = Maybe Double
a} :: RouteSettings)

-- | Specifies whether detailed metrics are enabled.
routeSettings_detailedMetricsEnabled :: Lens.Lens' RouteSettings (Prelude.Maybe Prelude.Bool)
routeSettings_detailedMetricsEnabled :: (Maybe Bool -> f (Maybe Bool)) -> RouteSettings -> f RouteSettings
routeSettings_detailedMetricsEnabled = (RouteSettings -> Maybe Bool)
-> (RouteSettings -> Maybe Bool -> RouteSettings)
-> Lens RouteSettings RouteSettings (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RouteSettings' {Maybe Bool
detailedMetricsEnabled :: Maybe Bool
$sel:detailedMetricsEnabled:RouteSettings' :: RouteSettings -> Maybe Bool
detailedMetricsEnabled} -> Maybe Bool
detailedMetricsEnabled) (\s :: RouteSettings
s@RouteSettings' {} Maybe Bool
a -> RouteSettings
s {$sel:detailedMetricsEnabled:RouteSettings' :: Maybe Bool
detailedMetricsEnabled = Maybe Bool
a} :: RouteSettings)

instance Core.FromJSON RouteSettings where
  parseJSON :: Value -> Parser RouteSettings
parseJSON =
    String
-> (Object -> Parser RouteSettings)
-> Value
-> Parser RouteSettings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RouteSettings"
      ( \Object
x ->
          Maybe Bool
-> Maybe Int
-> Maybe LoggingLevel
-> Maybe Double
-> Maybe Bool
-> RouteSettings
RouteSettings'
            (Maybe Bool
 -> Maybe Int
 -> Maybe LoggingLevel
 -> Maybe Double
 -> Maybe Bool
 -> RouteSettings)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Int
      -> Maybe LoggingLevel
      -> Maybe Double
      -> Maybe Bool
      -> RouteSettings)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"dataTraceEnabled")
            Parser
  (Maybe Int
   -> Maybe LoggingLevel
   -> Maybe Double
   -> Maybe Bool
   -> RouteSettings)
-> Parser (Maybe Int)
-> Parser
     (Maybe LoggingLevel -> Maybe Double -> Maybe Bool -> RouteSettings)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"throttlingBurstLimit")
            Parser
  (Maybe LoggingLevel -> Maybe Double -> Maybe Bool -> RouteSettings)
-> Parser (Maybe LoggingLevel)
-> Parser (Maybe Double -> Maybe Bool -> RouteSettings)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe LoggingLevel)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"loggingLevel")
            Parser (Maybe Double -> Maybe Bool -> RouteSettings)
-> Parser (Maybe Double) -> Parser (Maybe Bool -> RouteSettings)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"throttlingRateLimit")
            Parser (Maybe Bool -> RouteSettings)
-> Parser (Maybe Bool) -> Parser RouteSettings
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"detailedMetricsEnabled")
      )

instance Prelude.Hashable RouteSettings

instance Prelude.NFData RouteSettings

instance Core.ToJSON RouteSettings where
  toJSON :: RouteSettings -> Value
toJSON RouteSettings' {Maybe Bool
Maybe Double
Maybe Int
Maybe LoggingLevel
detailedMetricsEnabled :: Maybe Bool
throttlingRateLimit :: Maybe Double
loggingLevel :: Maybe LoggingLevel
throttlingBurstLimit :: Maybe Int
dataTraceEnabled :: Maybe Bool
$sel:detailedMetricsEnabled:RouteSettings' :: RouteSettings -> Maybe Bool
$sel:throttlingRateLimit:RouteSettings' :: RouteSettings -> Maybe Double
$sel:loggingLevel:RouteSettings' :: RouteSettings -> Maybe LoggingLevel
$sel:throttlingBurstLimit:RouteSettings' :: RouteSettings -> Maybe Int
$sel:dataTraceEnabled:RouteSettings' :: RouteSettings -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"dataTraceEnabled" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
dataTraceEnabled,
            (Text
"throttlingBurstLimit" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
throttlingBurstLimit,
            (Text
"loggingLevel" Text -> LoggingLevel -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (LoggingLevel -> Pair) -> Maybe LoggingLevel -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe LoggingLevel
loggingLevel,
            (Text
"throttlingRateLimit" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Double -> Pair) -> Maybe Double -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Double
throttlingRateLimit,
            (Text
"detailedMetricsEnabled" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
detailedMetricsEnabled
          ]
      )