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

import Amazonka.ApiGatewayV2.Types.ParameterConstraints
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 identifier of a route response.
    RouteResponse -> Maybe Text
routeResponseId :: Prelude.Maybe 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 route response key of a route response.
    RouteResponse -> Text
routeResponseKey :: Prelude.Text
  }
  deriving (RouteResponse -> RouteResponse -> Bool
(RouteResponse -> RouteResponse -> Bool)
-> (RouteResponse -> RouteResponse -> Bool) -> Eq RouteResponse
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]
(Int -> ReadS RouteResponse)
-> ReadS [RouteResponse]
-> ReadPrec RouteResponse
-> ReadPrec [RouteResponse]
-> Read 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
(Int -> RouteResponse -> ShowS)
-> (RouteResponse -> String)
-> ([RouteResponse] -> ShowS)
-> Show RouteResponse
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. RouteResponse -> Rep RouteResponse x)
-> (forall x. Rep RouteResponse x -> RouteResponse)
-> Generic RouteResponse
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.
--
-- 'routeResponseId', 'routeResponse_routeResponseId' - Represents the identifier of a route response.
--
-- 'responseParameters', 'routeResponse_responseParameters' - Represents the response parameters 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' :: Maybe Text
-> Maybe (HashMap Text Text)
-> Maybe Text
-> Maybe (HashMap Text ParameterConstraints)
-> Text
-> RouteResponse
RouteResponse'
    { $sel:modelSelectionExpression:RouteResponse' :: Maybe Text
modelSelectionExpression =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:responseModels:RouteResponse' :: Maybe (HashMap Text Text)
responseModels = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:routeResponseId:RouteResponse' :: Maybe Text
routeResponseId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:responseParameters:RouteResponse' :: Maybe (HashMap Text ParameterConstraints)
responseParameters = Maybe (HashMap Text ParameterConstraints)
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 :: (Maybe Text -> f (Maybe Text)) -> RouteResponse -> f RouteResponse
routeResponse_modelSelectionExpression = (RouteResponse -> Maybe Text)
-> (RouteResponse -> Maybe Text -> RouteResponse)
-> Lens RouteResponse RouteResponse (Maybe Text) (Maybe Text)
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 :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> RouteResponse -> f RouteResponse
routeResponse_responseModels = (RouteResponse -> Maybe (HashMap Text Text))
-> (RouteResponse -> Maybe (HashMap Text Text) -> RouteResponse)
-> Lens
     RouteResponse
     RouteResponse
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> RouteResponse -> f RouteResponse)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> RouteResponse
-> f RouteResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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 AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
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 :: (Maybe Text -> f (Maybe Text)) -> RouteResponse -> f RouteResponse
routeResponse_routeResponseId = (RouteResponse -> Maybe Text)
-> (RouteResponse -> Maybe Text -> RouteResponse)
-> Lens RouteResponse RouteResponse (Maybe Text) (Maybe Text)
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 response parameters of a route response.
routeResponse_responseParameters :: Lens.Lens' RouteResponse (Prelude.Maybe (Prelude.HashMap Prelude.Text ParameterConstraints))
routeResponse_responseParameters :: (Maybe (HashMap Text ParameterConstraints)
 -> f (Maybe (HashMap Text ParameterConstraints)))
-> RouteResponse -> f RouteResponse
routeResponse_responseParameters = (RouteResponse -> Maybe (HashMap Text ParameterConstraints))
-> (RouteResponse
    -> Maybe (HashMap Text ParameterConstraints) -> RouteResponse)
-> Lens
     RouteResponse
     RouteResponse
     (Maybe (HashMap Text ParameterConstraints))
     (Maybe (HashMap Text ParameterConstraints))
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) ((Maybe (HashMap Text ParameterConstraints)
  -> f (Maybe (HashMap Text ParameterConstraints)))
 -> RouteResponse -> f RouteResponse)
-> ((Maybe (HashMap Text ParameterConstraints)
     -> f (Maybe (HashMap Text ParameterConstraints)))
    -> Maybe (HashMap Text ParameterConstraints)
    -> f (Maybe (HashMap Text ParameterConstraints)))
-> (Maybe (HashMap Text ParameterConstraints)
    -> f (Maybe (HashMap Text ParameterConstraints)))
-> RouteResponse
-> f RouteResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text ParameterConstraints)
  (HashMap Text ParameterConstraints)
  (HashMap Text ParameterConstraints)
  (HashMap Text ParameterConstraints)
-> Iso
     (Maybe (HashMap Text ParameterConstraints))
     (Maybe (HashMap Text ParameterConstraints))
     (Maybe (HashMap Text ParameterConstraints))
     (Maybe (HashMap Text ParameterConstraints))
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 AnIso
  (HashMap Text ParameterConstraints)
  (HashMap Text ParameterConstraints)
  (HashMap Text ParameterConstraints)
  (HashMap Text ParameterConstraints)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Represents the route response key of a route response.
routeResponse_routeResponseKey :: Lens.Lens' RouteResponse Prelude.Text
routeResponse_routeResponseKey :: (Text -> f Text) -> RouteResponse -> f RouteResponse
routeResponse_routeResponseKey = (RouteResponse -> Text)
-> (RouteResponse -> Text -> RouteResponse)
-> Lens RouteResponse RouteResponse Text Text
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 Core.FromJSON RouteResponse where
  parseJSON :: Value -> Parser RouteResponse
parseJSON =
    String
-> (Object -> Parser RouteResponse)
-> Value
-> Parser RouteResponse
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RouteResponse"
      ( \Object
x ->
          Maybe Text
-> Maybe (HashMap Text Text)
-> Maybe Text
-> Maybe (HashMap Text ParameterConstraints)
-> Text
-> RouteResponse
RouteResponse'
            (Maybe Text
 -> Maybe (HashMap Text Text)
 -> Maybe Text
 -> Maybe (HashMap Text ParameterConstraints)
 -> Text
 -> RouteResponse)
-> Parser (Maybe Text)
-> Parser
     (Maybe (HashMap Text Text)
      -> Maybe Text
      -> Maybe (HashMap Text ParameterConstraints)
      -> Text
      -> RouteResponse)
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
"modelSelectionExpression")
            Parser
  (Maybe (HashMap Text Text)
   -> Maybe Text
   -> Maybe (HashMap Text ParameterConstraints)
   -> Text
   -> RouteResponse)
-> Parser (Maybe (HashMap Text Text))
-> Parser
     (Maybe Text
      -> Maybe (HashMap Text ParameterConstraints)
      -> Text
      -> RouteResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text Text)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"responseModels" Parser (Maybe (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> Parser (Maybe (HashMap Text Text))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text Text)
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe Text
   -> Maybe (HashMap Text ParameterConstraints)
   -> Text
   -> RouteResponse)
-> Parser (Maybe Text)
-> Parser
     (Maybe (HashMap Text ParameterConstraints)
      -> Text -> RouteResponse)
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
"routeResponseId")
            Parser
  (Maybe (HashMap Text ParameterConstraints)
   -> Text -> RouteResponse)
-> Parser (Maybe (HashMap Text ParameterConstraints))
-> Parser (Text -> RouteResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object
-> Text
-> Parser (Maybe (Maybe (HashMap Text ParameterConstraints)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"responseParameters"
                            Parser (Maybe (Maybe (HashMap Text ParameterConstraints)))
-> Maybe (HashMap Text ParameterConstraints)
-> Parser (Maybe (HashMap Text ParameterConstraints))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text ParameterConstraints)
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Text -> RouteResponse)
-> Parser Text -> Parser RouteResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"routeResponseKey")
      )

instance Prelude.Hashable RouteResponse

instance Prelude.NFData RouteResponse