{-# 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.RouteResponse
-- 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.RouteResponse where

import Amazonka.ApiGatewayV2.Types.ParameterConstraints
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 route response.
--
-- /See:/ 'newRouteResponse' smart constructor.
data RouteResponse = RouteResponse'
  { -- | Represents the model selection expression of a route response. Supported
    -- only for WebSocket APIs.
    RouteResponse -> Maybe Text
modelSelectionExpression :: Prelude.Maybe Prelude.Text,
    -- | Represents the response models of a route response.
    RouteResponse -> Maybe (HashMap Text Text)
responseModels :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | Represents the response parameters of a route response.
    RouteResponse -> Maybe (HashMap Text ParameterConstraints)
responseParameters :: Prelude.Maybe (Prelude.HashMap Prelude.Text ParameterConstraints),
    -- | Represents the identifier of a route response.
    RouteResponse -> Maybe Text
routeResponseId :: Prelude.Maybe Prelude.Text,
    -- | Represents the route response key of a route response.
    RouteResponse -> Text
routeResponseKey :: Prelude.Text
  }
  deriving (RouteResponse -> RouteResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RouteResponse -> RouteResponse -> Bool
$c/= :: RouteResponse -> RouteResponse -> Bool
== :: RouteResponse -> RouteResponse -> Bool
$c== :: RouteResponse -> RouteResponse -> Bool
Prelude.Eq, ReadPrec [RouteResponse]
ReadPrec RouteResponse
Int -> ReadS RouteResponse
ReadS [RouteResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RouteResponse]
$creadListPrec :: ReadPrec [RouteResponse]
readPrec :: ReadPrec RouteResponse
$creadPrec :: ReadPrec RouteResponse
readList :: ReadS [RouteResponse]
$creadList :: ReadS [RouteResponse]
readsPrec :: Int -> ReadS RouteResponse
$creadsPrec :: Int -> ReadS RouteResponse
Prelude.Read, Int -> RouteResponse -> ShowS
[RouteResponse] -> ShowS
RouteResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RouteResponse] -> ShowS
$cshowList :: [RouteResponse] -> ShowS
show :: RouteResponse -> String
$cshow :: RouteResponse -> String
showsPrec :: Int -> RouteResponse -> ShowS
$cshowsPrec :: Int -> RouteResponse -> ShowS
Prelude.Show, forall x. Rep RouteResponse x -> RouteResponse
forall x. RouteResponse -> Rep RouteResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RouteResponse x -> RouteResponse
$cfrom :: forall x. RouteResponse -> Rep RouteResponse x
Prelude.Generic)

-- |
-- Create a value of 'RouteResponse' 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:
--
-- 'modelSelectionExpression', 'routeResponse_modelSelectionExpression' - Represents the model selection expression of a route response. Supported
-- only for WebSocket APIs.
--
-- 'responseModels', 'routeResponse_responseModels' - Represents the response models of a route response.
--
-- 'responseParameters', 'routeResponse_responseParameters' - Represents the response parameters of a route response.
--
-- 'routeResponseId', 'routeResponse_routeResponseId' - Represents the identifier of a route response.
--
-- 'routeResponseKey', 'routeResponse_routeResponseKey' - Represents the route response key of a route response.
newRouteResponse ::
  -- | 'routeResponseKey'
  Prelude.Text ->
  RouteResponse
newRouteResponse :: Text -> RouteResponse
newRouteResponse Text
pRouteResponseKey_ =
  RouteResponse'
    { $sel:modelSelectionExpression:RouteResponse' :: Maybe Text
modelSelectionExpression =
        forall a. Maybe a
Prelude.Nothing,
      $sel:responseModels:RouteResponse' :: Maybe (HashMap Text Text)
responseModels = forall a. Maybe a
Prelude.Nothing,
      $sel:responseParameters:RouteResponse' :: Maybe (HashMap Text ParameterConstraints)
responseParameters = forall a. Maybe a
Prelude.Nothing,
      $sel:routeResponseId:RouteResponse' :: Maybe Text
routeResponseId = forall a. Maybe a
Prelude.Nothing,
      $sel:routeResponseKey:RouteResponse' :: Text
routeResponseKey = Text
pRouteResponseKey_
    }

-- | Represents the model selection expression of a route response. Supported
-- only for WebSocket APIs.
routeResponse_modelSelectionExpression :: Lens.Lens' RouteResponse (Prelude.Maybe Prelude.Text)
routeResponse_modelSelectionExpression :: Lens' RouteResponse (Maybe Text)
routeResponse_modelSelectionExpression = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RouteResponse' {Maybe Text
modelSelectionExpression :: Maybe Text
$sel:modelSelectionExpression:RouteResponse' :: RouteResponse -> Maybe Text
modelSelectionExpression} -> Maybe Text
modelSelectionExpression) (\s :: RouteResponse
s@RouteResponse' {} Maybe Text
a -> RouteResponse
s {$sel:modelSelectionExpression:RouteResponse' :: Maybe Text
modelSelectionExpression = Maybe Text
a} :: RouteResponse)

-- | Represents the response models of a route response.
routeResponse_responseModels :: Lens.Lens' RouteResponse (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
routeResponse_responseModels :: Lens' RouteResponse (Maybe (HashMap Text Text))
routeResponse_responseModels = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RouteResponse' {Maybe (HashMap Text Text)
responseModels :: Maybe (HashMap Text Text)
$sel:responseModels:RouteResponse' :: RouteResponse -> Maybe (HashMap Text Text)
responseModels} -> Maybe (HashMap Text Text)
responseModels) (\s :: RouteResponse
s@RouteResponse' {} Maybe (HashMap Text Text)
a -> RouteResponse
s {$sel:responseModels:RouteResponse' :: Maybe (HashMap Text Text)
responseModels = Maybe (HashMap Text Text)
a} :: RouteResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Represents the response parameters of a route response.
routeResponse_responseParameters :: Lens.Lens' RouteResponse (Prelude.Maybe (Prelude.HashMap Prelude.Text ParameterConstraints))
routeResponse_responseParameters :: Lens' RouteResponse (Maybe (HashMap Text ParameterConstraints))
routeResponse_responseParameters = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RouteResponse' {Maybe (HashMap Text ParameterConstraints)
responseParameters :: Maybe (HashMap Text ParameterConstraints)
$sel:responseParameters:RouteResponse' :: RouteResponse -> Maybe (HashMap Text ParameterConstraints)
responseParameters} -> Maybe (HashMap Text ParameterConstraints)
responseParameters) (\s :: RouteResponse
s@RouteResponse' {} Maybe (HashMap Text ParameterConstraints)
a -> RouteResponse
s {$sel:responseParameters:RouteResponse' :: Maybe (HashMap Text ParameterConstraints)
responseParameters = Maybe (HashMap Text ParameterConstraints)
a} :: RouteResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Represents the identifier of a route response.
routeResponse_routeResponseId :: Lens.Lens' RouteResponse (Prelude.Maybe Prelude.Text)
routeResponse_routeResponseId :: Lens' RouteResponse (Maybe Text)
routeResponse_routeResponseId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RouteResponse' {Maybe Text
routeResponseId :: Maybe Text
$sel:routeResponseId:RouteResponse' :: RouteResponse -> Maybe Text
routeResponseId} -> Maybe Text
routeResponseId) (\s :: RouteResponse
s@RouteResponse' {} Maybe Text
a -> RouteResponse
s {$sel:routeResponseId:RouteResponse' :: Maybe Text
routeResponseId = Maybe Text
a} :: RouteResponse)

-- | Represents the route response key of a route response.
routeResponse_routeResponseKey :: Lens.Lens' RouteResponse Prelude.Text
routeResponse_routeResponseKey :: Lens' RouteResponse Text
routeResponse_routeResponseKey = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RouteResponse' {Text
routeResponseKey :: Text
$sel:routeResponseKey:RouteResponse' :: RouteResponse -> Text
routeResponseKey} -> Text
routeResponseKey) (\s :: RouteResponse
s@RouteResponse' {} Text
a -> RouteResponse
s {$sel:routeResponseKey:RouteResponse' :: Text
routeResponseKey = Text
a} :: RouteResponse)

instance Data.FromJSON RouteResponse where
  parseJSON :: Value -> Parser RouteResponse
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RouteResponse"
      ( \Object
x ->
          Maybe Text
-> Maybe (HashMap Text Text)
-> Maybe (HashMap Text ParameterConstraints)
-> Maybe Text
-> Text
-> RouteResponse
RouteResponse'
            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
"modelSelectionExpression")
            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
"responseModels" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"responseParameters"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            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
"routeResponseId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"routeResponseKey")
      )

instance Prelude.Hashable RouteResponse where
  hashWithSalt :: Int -> RouteResponse -> Int
hashWithSalt Int
_salt RouteResponse' {Maybe Text
Maybe (HashMap Text Text)
Maybe (HashMap Text ParameterConstraints)
Text
routeResponseKey :: Text
routeResponseId :: Maybe Text
responseParameters :: Maybe (HashMap Text ParameterConstraints)
responseModels :: Maybe (HashMap Text Text)
modelSelectionExpression :: Maybe Text
$sel:routeResponseKey:RouteResponse' :: RouteResponse -> Text
$sel:routeResponseId:RouteResponse' :: RouteResponse -> Maybe Text
$sel:responseParameters:RouteResponse' :: RouteResponse -> Maybe (HashMap Text ParameterConstraints)
$sel:responseModels:RouteResponse' :: RouteResponse -> Maybe (HashMap Text Text)
$sel:modelSelectionExpression:RouteResponse' :: RouteResponse -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
modelSelectionExpression
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
responseModels
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text ParameterConstraints)
responseParameters
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
routeResponseId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
routeResponseKey

instance Prelude.NFData RouteResponse where
  rnf :: RouteResponse -> ()
rnf RouteResponse' {Maybe Text
Maybe (HashMap Text Text)
Maybe (HashMap Text ParameterConstraints)
Text
routeResponseKey :: Text
routeResponseId :: Maybe Text
responseParameters :: Maybe (HashMap Text ParameterConstraints)
responseModels :: Maybe (HashMap Text Text)
modelSelectionExpression :: Maybe Text
$sel:routeResponseKey:RouteResponse' :: RouteResponse -> Text
$sel:routeResponseId:RouteResponse' :: RouteResponse -> Maybe Text
$sel:responseParameters:RouteResponse' :: RouteResponse -> Maybe (HashMap Text ParameterConstraints)
$sel:responseModels:RouteResponse' :: RouteResponse -> Maybe (HashMap Text Text)
$sel:modelSelectionExpression:RouteResponse' :: RouteResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
modelSelectionExpression
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
responseModels
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text ParameterConstraints)
responseParameters
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
routeResponseId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
routeResponseKey