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

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 an API mapping.
--
-- /See:/ 'newApiMapping' smart constructor.
data ApiMapping = ApiMapping'
  { -- | The API mapping identifier.
    ApiMapping -> Maybe Text
apiMappingId :: Prelude.Maybe Prelude.Text,
    -- | The API mapping key.
    ApiMapping -> Maybe Text
apiMappingKey :: Prelude.Maybe Prelude.Text,
    -- | The API stage.
    ApiMapping -> Text
stage :: Prelude.Text,
    -- | The API identifier.
    ApiMapping -> Text
apiId :: Prelude.Text
  }
  deriving (ApiMapping -> ApiMapping -> Bool
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]
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
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. 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:
--
-- 'apiMappingId', 'apiMapping_apiMappingId' - The API mapping identifier.
--
-- 'apiMappingKey', 'apiMapping_apiMappingKey' - The API mapping key.
--
-- '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'
    { $sel:apiMappingId:ApiMapping' :: Maybe Text
apiMappingId = forall a. Maybe a
Prelude.Nothing,
      $sel:apiMappingKey:ApiMapping' :: Maybe Text
apiMappingKey = forall a. Maybe a
Prelude.Nothing,
      $sel:stage:ApiMapping' :: Text
stage = Text
pStage_,
      $sel:apiId:ApiMapping' :: Text
apiId = Text
pApiId_
    }

-- | The API mapping identifier.
apiMapping_apiMappingId :: Lens.Lens' ApiMapping (Prelude.Maybe Prelude.Text)
apiMapping_apiMappingId :: Lens' ApiMapping (Maybe Text)
apiMapping_apiMappingId = 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 mapping key.
apiMapping_apiMappingKey :: Lens.Lens' ApiMapping (Prelude.Maybe Prelude.Text)
apiMapping_apiMappingKey :: Lens' ApiMapping (Maybe Text)
apiMapping_apiMappingKey = 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 stage.
apiMapping_stage :: Lens.Lens' ApiMapping Prelude.Text
apiMapping_stage :: Lens' ApiMapping Text
apiMapping_stage = 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 :: Lens' ApiMapping Text
apiMapping_apiId = 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 Data.FromJSON ApiMapping where
  parseJSON :: Value -> Parser ApiMapping
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ApiMapping"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Text -> Text -> ApiMapping
ApiMapping'
            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
"apiMappingId")
            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
"apiMappingKey")
            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
"stage")
            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
"apiId")
      )

instance Prelude.Hashable ApiMapping where
  hashWithSalt :: Int -> ApiMapping -> Int
hashWithSalt Int
_salt ApiMapping' {Maybe Text
Text
apiId :: Text
stage :: Text
apiMappingKey :: Maybe Text
apiMappingId :: Maybe Text
$sel:apiId:ApiMapping' :: ApiMapping -> Text
$sel:stage:ApiMapping' :: ApiMapping -> Text
$sel:apiMappingKey:ApiMapping' :: ApiMapping -> Maybe Text
$sel:apiMappingId:ApiMapping' :: ApiMapping -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
apiMappingId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
apiMappingKey
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
stage
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
apiId

instance Prelude.NFData ApiMapping where
  rnf :: ApiMapping -> ()
rnf ApiMapping' {Maybe Text
Text
apiId :: Text
stage :: Text
apiMappingKey :: Maybe Text
apiMappingId :: Maybe Text
$sel:apiId:ApiMapping' :: ApiMapping -> Text
$sel:stage:ApiMapping' :: ApiMapping -> Text
$sel:apiMappingKey:ApiMapping' :: ApiMapping -> Maybe Text
$sel:apiMappingId:ApiMapping' :: ApiMapping -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
apiMappingId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
apiMappingKey
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
stage
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
apiId