{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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 whether detailed metrics are enabled.
    RouteSettings -> Maybe Bool
detailedMetricsEnabled :: Prelude.Maybe Prelude.Bool,
    -- | 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 burst limit.
    RouteSettings -> Maybe Int
throttlingBurstLimit :: Prelude.Maybe Prelude.Int,
    -- | Specifies the throttling rate limit.
    RouteSettings -> Maybe Double
throttlingRateLimit :: Prelude.Maybe Prelude.Double
  }
  deriving (RouteSettings -> RouteSettings -> Bool
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]
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
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. 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.
--
-- 'detailedMetricsEnabled', 'routeSettings_detailedMetricsEnabled' - Specifies whether detailed metrics are enabled.
--
-- '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.
--
-- 'throttlingBurstLimit', 'routeSettings_throttlingBurstLimit' - Specifies the throttling burst limit.
--
-- 'throttlingRateLimit', 'routeSettings_throttlingRateLimit' - Specifies the throttling rate limit.
newRouteSettings ::
  RouteSettings
newRouteSettings :: RouteSettings
newRouteSettings =
  RouteSettings'
    { $sel:dataTraceEnabled:RouteSettings' :: Maybe Bool
dataTraceEnabled = forall a. Maybe a
Prelude.Nothing,
      $sel:detailedMetricsEnabled:RouteSettings' :: Maybe Bool
detailedMetricsEnabled = forall a. Maybe a
Prelude.Nothing,
      $sel:loggingLevel:RouteSettings' :: Maybe LoggingLevel
loggingLevel = forall a. Maybe a
Prelude.Nothing,
      $sel:throttlingBurstLimit:RouteSettings' :: Maybe Int
throttlingBurstLimit = forall a. Maybe a
Prelude.Nothing,
      $sel:throttlingRateLimit:RouteSettings' :: Maybe Double
throttlingRateLimit = 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 :: Lens' RouteSettings (Maybe Bool)
routeSettings_dataTraceEnabled = 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 whether detailed metrics are enabled.
routeSettings_detailedMetricsEnabled :: Lens.Lens' RouteSettings (Prelude.Maybe Prelude.Bool)
routeSettings_detailedMetricsEnabled :: Lens' RouteSettings (Maybe Bool)
routeSettings_detailedMetricsEnabled = 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)

-- | 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 :: Lens' RouteSettings (Maybe LoggingLevel)
routeSettings_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 burst limit.
routeSettings_throttlingBurstLimit :: Lens.Lens' RouteSettings (Prelude.Maybe Prelude.Int)
routeSettings_throttlingBurstLimit :: Lens' RouteSettings (Maybe Int)
routeSettings_throttlingBurstLimit = 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 throttling rate limit.
routeSettings_throttlingRateLimit :: Lens.Lens' RouteSettings (Prelude.Maybe Prelude.Double)
routeSettings_throttlingRateLimit :: Lens' RouteSettings (Maybe Double)
routeSettings_throttlingRateLimit = 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)

instance Data.FromJSON RouteSettings where
  parseJSON :: Value -> Parser RouteSettings
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RouteSettings"
      ( \Object
x ->
          Maybe Bool
-> Maybe Bool
-> Maybe LoggingLevel
-> Maybe Int
-> Maybe Double
-> RouteSettings
RouteSettings'
            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
"dataTraceEnabled")
            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
"detailedMetricsEnabled")
            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
"loggingLevel")
            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
"throttlingBurstLimit")
            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
"throttlingRateLimit")
      )

instance Prelude.Hashable RouteSettings where
  hashWithSalt :: Int -> RouteSettings -> Int
hashWithSalt Int
_salt RouteSettings' {Maybe Bool
Maybe Double
Maybe Int
Maybe LoggingLevel
throttlingRateLimit :: Maybe Double
throttlingBurstLimit :: Maybe Int
loggingLevel :: Maybe LoggingLevel
detailedMetricsEnabled :: Maybe Bool
dataTraceEnabled :: Maybe Bool
$sel:throttlingRateLimit:RouteSettings' :: RouteSettings -> Maybe Double
$sel:throttlingBurstLimit:RouteSettings' :: RouteSettings -> Maybe Int
$sel:loggingLevel:RouteSettings' :: RouteSettings -> Maybe LoggingLevel
$sel:detailedMetricsEnabled:RouteSettings' :: RouteSettings -> Maybe Bool
$sel:dataTraceEnabled:RouteSettings' :: RouteSettings -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
dataTraceEnabled
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
detailedMetricsEnabled
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe LoggingLevel
loggingLevel
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
throttlingBurstLimit
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
throttlingRateLimit

instance Prelude.NFData RouteSettings where
  rnf :: RouteSettings -> ()
rnf RouteSettings' {Maybe Bool
Maybe Double
Maybe Int
Maybe LoggingLevel
throttlingRateLimit :: Maybe Double
throttlingBurstLimit :: Maybe Int
loggingLevel :: Maybe LoggingLevel
detailedMetricsEnabled :: Maybe Bool
dataTraceEnabled :: Maybe Bool
$sel:throttlingRateLimit:RouteSettings' :: RouteSettings -> Maybe Double
$sel:throttlingBurstLimit:RouteSettings' :: RouteSettings -> Maybe Int
$sel:loggingLevel:RouteSettings' :: RouteSettings -> Maybe LoggingLevel
$sel:detailedMetricsEnabled:RouteSettings' :: RouteSettings -> Maybe Bool
$sel:dataTraceEnabled:RouteSettings' :: RouteSettings -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
dataTraceEnabled
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
detailedMetricsEnabled
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe LoggingLevel
loggingLevel
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
throttlingBurstLimit
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
throttlingRateLimit

instance Data.ToJSON RouteSettings where
  toJSON :: RouteSettings -> Value
toJSON RouteSettings' {Maybe Bool
Maybe Double
Maybe Int
Maybe LoggingLevel
throttlingRateLimit :: Maybe Double
throttlingBurstLimit :: Maybe Int
loggingLevel :: Maybe LoggingLevel
detailedMetricsEnabled :: Maybe Bool
dataTraceEnabled :: Maybe Bool
$sel:throttlingRateLimit:RouteSettings' :: RouteSettings -> Maybe Double
$sel:throttlingBurstLimit:RouteSettings' :: RouteSettings -> Maybe Int
$sel:loggingLevel:RouteSettings' :: RouteSettings -> Maybe LoggingLevel
$sel:detailedMetricsEnabled:RouteSettings' :: RouteSettings -> Maybe Bool
$sel:dataTraceEnabled:RouteSettings' :: RouteSettings -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"dataTraceEnabled" 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 Bool
dataTraceEnabled,
            (Key
"detailedMetricsEnabled" 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 Bool
detailedMetricsEnabled,
            (Key
"loggingLevel" 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 LoggingLevel
loggingLevel,
            (Key
"throttlingBurstLimit" 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 Int
throttlingBurstLimit,
            (Key
"throttlingRateLimit" 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 Double
throttlingRateLimit
          ]
      )