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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents an API mapping.
--
-- /See:/ 'newApiMapping' smart constructor.
data ApiMapping = ApiMapping'
  { -- | The API mapping key.
    ApiMapping -> Maybe Text
apiMappingKey :: Prelude.Maybe Prelude.Text,
    -- | The API mapping identifier.
    ApiMapping -> Maybe Text
apiMappingId :: Prelude.Maybe Prelude.Text,
    -- | The API stage.
    ApiMapping -> Text
stage :: Prelude.Text,
    -- | The API identifier.
    ApiMapping -> Text
apiId :: Prelude.Text
  }
  deriving (ApiMapping -> ApiMapping -> Bool
(ApiMapping -> ApiMapping -> Bool)
-> (ApiMapping -> ApiMapping -> Bool) -> Eq ApiMapping
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ApiMapping -> ApiMapping -> Bool
$c/= :: ApiMapping -> ApiMapping -> Bool
== :: ApiMapping -> ApiMapping -> Bool
$c== :: ApiMapping -> ApiMapping -> Bool
Prelude.Eq, ReadPrec [ApiMapping]
ReadPrec ApiMapping
Int -> ReadS ApiMapping
ReadS [ApiMapping]
(Int -> ReadS ApiMapping)
-> ReadS [ApiMapping]
-> ReadPrec ApiMapping
-> ReadPrec [ApiMapping]
-> Read ApiMapping
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ApiMapping]
$creadListPrec :: ReadPrec [ApiMapping]
readPrec :: ReadPrec ApiMapping
$creadPrec :: ReadPrec ApiMapping
readList :: ReadS [ApiMapping]
$creadList :: ReadS [ApiMapping]
readsPrec :: Int -> ReadS ApiMapping
$creadsPrec :: Int -> ReadS ApiMapping
Prelude.Read, Int -> ApiMapping -> ShowS
[ApiMapping] -> ShowS
ApiMapping -> String
(Int -> ApiMapping -> ShowS)
-> (ApiMapping -> String)
-> ([ApiMapping] -> ShowS)
-> Show ApiMapping
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ApiMapping] -> ShowS
$cshowList :: [ApiMapping] -> ShowS
show :: ApiMapping -> String
$cshow :: ApiMapping -> String
showsPrec :: Int -> ApiMapping -> ShowS
$cshowsPrec :: Int -> ApiMapping -> ShowS
Prelude.Show, (forall x. ApiMapping -> Rep ApiMapping x)
-> (forall x. Rep ApiMapping x -> ApiMapping) -> Generic ApiMapping
forall x. Rep ApiMapping x -> ApiMapping
forall x. ApiMapping -> Rep ApiMapping x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ApiMapping x -> ApiMapping
$cfrom :: forall x. ApiMapping -> Rep ApiMapping x
Prelude.Generic)

-- |
-- Create a value of 'ApiMapping' 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:
--
-- 'apiMappingKey', 'apiMapping_apiMappingKey' - The API mapping key.
--
-- 'apiMappingId', 'apiMapping_apiMappingId' - The API mapping identifier.
--
-- 'stage', 'apiMapping_stage' - The API stage.
--
-- 'apiId', 'apiMapping_apiId' - The API identifier.
newApiMapping ::
  -- | 'stage'
  Prelude.Text ->
  -- | 'apiId'
  Prelude.Text ->
  ApiMapping
newApiMapping :: Text -> Text -> ApiMapping
newApiMapping Text
pStage_ Text
pApiId_ =
  ApiMapping' :: Maybe Text -> Maybe Text -> Text -> Text -> ApiMapping
ApiMapping'
    { $sel:apiMappingKey:ApiMapping' :: Maybe Text
apiMappingKey = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:apiMappingId:ApiMapping' :: Maybe Text
apiMappingId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:stage:ApiMapping' :: Text
stage = Text
pStage_,
      $sel:apiId:ApiMapping' :: Text
apiId = Text
pApiId_
    }

-- | The API mapping key.
apiMapping_apiMappingKey :: Lens.Lens' ApiMapping (Prelude.Maybe Prelude.Text)
apiMapping_apiMappingKey :: (Maybe Text -> f (Maybe Text)) -> ApiMapping -> f ApiMapping
apiMapping_apiMappingKey = (ApiMapping -> Maybe Text)
-> (ApiMapping -> Maybe Text -> ApiMapping)
-> Lens ApiMapping ApiMapping (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApiMapping' {Maybe Text
apiMappingKey :: Maybe Text
$sel:apiMappingKey:ApiMapping' :: ApiMapping -> Maybe Text
apiMappingKey} -> Maybe Text
apiMappingKey) (\s :: ApiMapping
s@ApiMapping' {} Maybe Text
a -> ApiMapping
s {$sel:apiMappingKey:ApiMapping' :: Maybe Text
apiMappingKey = Maybe Text
a} :: ApiMapping)

-- | The API mapping identifier.
apiMapping_apiMappingId :: Lens.Lens' ApiMapping (Prelude.Maybe Prelude.Text)
apiMapping_apiMappingId :: (Maybe Text -> f (Maybe Text)) -> ApiMapping -> f ApiMapping
apiMapping_apiMappingId = (ApiMapping -> Maybe Text)
-> (ApiMapping -> Maybe Text -> ApiMapping)
-> Lens ApiMapping ApiMapping (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApiMapping' {Maybe Text
apiMappingId :: Maybe Text
$sel:apiMappingId:ApiMapping' :: ApiMapping -> Maybe Text
apiMappingId} -> Maybe Text
apiMappingId) (\s :: ApiMapping
s@ApiMapping' {} Maybe Text
a -> ApiMapping
s {$sel:apiMappingId:ApiMapping' :: Maybe Text
apiMappingId = Maybe Text
a} :: ApiMapping)

-- | The API stage.
apiMapping_stage :: Lens.Lens' ApiMapping Prelude.Text
apiMapping_stage :: (Text -> f Text) -> ApiMapping -> f ApiMapping
apiMapping_stage = (ApiMapping -> Text)
-> (ApiMapping -> Text -> ApiMapping)
-> Lens ApiMapping ApiMapping Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApiMapping' {Text
stage :: Text
$sel:stage:ApiMapping' :: ApiMapping -> Text
stage} -> Text
stage) (\s :: ApiMapping
s@ApiMapping' {} Text
a -> ApiMapping
s {$sel:stage:ApiMapping' :: Text
stage = Text
a} :: ApiMapping)

-- | The API identifier.
apiMapping_apiId :: Lens.Lens' ApiMapping Prelude.Text
apiMapping_apiId :: (Text -> f Text) -> ApiMapping -> f ApiMapping
apiMapping_apiId = (ApiMapping -> Text)
-> (ApiMapping -> Text -> ApiMapping)
-> Lens ApiMapping ApiMapping Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApiMapping' {Text
apiId :: Text
$sel:apiId:ApiMapping' :: ApiMapping -> Text
apiId} -> Text
apiId) (\s :: ApiMapping
s@ApiMapping' {} Text
a -> ApiMapping
s {$sel:apiId:ApiMapping' :: Text
apiId = Text
a} :: ApiMapping)

instance Core.FromJSON ApiMapping where
  parseJSON :: Value -> Parser ApiMapping
parseJSON =
    String
-> (Object -> Parser ApiMapping) -> Value -> Parser ApiMapping
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ApiMapping"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Text -> Text -> ApiMapping
ApiMapping'
            (Maybe Text -> Maybe Text -> Text -> Text -> ApiMapping)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Text -> Text -> ApiMapping)
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
"apiMappingKey")
            Parser (Maybe Text -> Text -> Text -> ApiMapping)
-> Parser (Maybe Text) -> Parser (Text -> Text -> ApiMapping)
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
"apiMappingId")
            Parser (Text -> Text -> ApiMapping)
-> Parser Text -> Parser (Text -> ApiMapping)
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
"stage")
            Parser (Text -> ApiMapping) -> Parser Text -> Parser ApiMapping
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
"apiId")
      )

instance Prelude.Hashable ApiMapping

instance Prelude.NFData ApiMapping