{-# 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.APIGateway.Types.UsagePlanKey
-- 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.APIGateway.Types.UsagePlanKey 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 a usage plan key to identify a plan customer.
--
-- /See:/ 'newUsagePlanKey' smart constructor.
data UsagePlanKey = UsagePlanKey'
  { -- | The Id of a usage plan key.
    UsagePlanKey -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | The name of a usage plan key.
    UsagePlanKey -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The type of a usage plan key. Currently, the valid key type is
    -- @API_KEY@.
    UsagePlanKey -> Maybe Text
type' :: Prelude.Maybe Prelude.Text,
    -- | The value of a usage plan key.
    UsagePlanKey -> Maybe Text
value :: Prelude.Maybe Prelude.Text
  }
  deriving (UsagePlanKey -> UsagePlanKey -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UsagePlanKey -> UsagePlanKey -> Bool
$c/= :: UsagePlanKey -> UsagePlanKey -> Bool
== :: UsagePlanKey -> UsagePlanKey -> Bool
$c== :: UsagePlanKey -> UsagePlanKey -> Bool
Prelude.Eq, ReadPrec [UsagePlanKey]
ReadPrec UsagePlanKey
Int -> ReadS UsagePlanKey
ReadS [UsagePlanKey]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UsagePlanKey]
$creadListPrec :: ReadPrec [UsagePlanKey]
readPrec :: ReadPrec UsagePlanKey
$creadPrec :: ReadPrec UsagePlanKey
readList :: ReadS [UsagePlanKey]
$creadList :: ReadS [UsagePlanKey]
readsPrec :: Int -> ReadS UsagePlanKey
$creadsPrec :: Int -> ReadS UsagePlanKey
Prelude.Read, Int -> UsagePlanKey -> ShowS
[UsagePlanKey] -> ShowS
UsagePlanKey -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UsagePlanKey] -> ShowS
$cshowList :: [UsagePlanKey] -> ShowS
show :: UsagePlanKey -> String
$cshow :: UsagePlanKey -> String
showsPrec :: Int -> UsagePlanKey -> ShowS
$cshowsPrec :: Int -> UsagePlanKey -> ShowS
Prelude.Show, forall x. Rep UsagePlanKey x -> UsagePlanKey
forall x. UsagePlanKey -> Rep UsagePlanKey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UsagePlanKey x -> UsagePlanKey
$cfrom :: forall x. UsagePlanKey -> Rep UsagePlanKey x
Prelude.Generic)

-- |
-- Create a value of 'UsagePlanKey' 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:
--
-- 'id', 'usagePlanKey_id' - The Id of a usage plan key.
--
-- 'name', 'usagePlanKey_name' - The name of a usage plan key.
--
-- 'type'', 'usagePlanKey_type' - The type of a usage plan key. Currently, the valid key type is
-- @API_KEY@.
--
-- 'value', 'usagePlanKey_value' - The value of a usage plan key.
newUsagePlanKey ::
  UsagePlanKey
newUsagePlanKey :: UsagePlanKey
newUsagePlanKey =
  UsagePlanKey'
    { $sel:id:UsagePlanKey' :: Maybe Text
id = forall a. Maybe a
Prelude.Nothing,
      $sel:name:UsagePlanKey' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:type':UsagePlanKey' :: Maybe Text
type' = forall a. Maybe a
Prelude.Nothing,
      $sel:value:UsagePlanKey' :: Maybe Text
value = forall a. Maybe a
Prelude.Nothing
    }

-- | The Id of a usage plan key.
usagePlanKey_id :: Lens.Lens' UsagePlanKey (Prelude.Maybe Prelude.Text)
usagePlanKey_id :: Lens' UsagePlanKey (Maybe Text)
usagePlanKey_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UsagePlanKey' {Maybe Text
id :: Maybe Text
$sel:id:UsagePlanKey' :: UsagePlanKey -> Maybe Text
id} -> Maybe Text
id) (\s :: UsagePlanKey
s@UsagePlanKey' {} Maybe Text
a -> UsagePlanKey
s {$sel:id:UsagePlanKey' :: Maybe Text
id = Maybe Text
a} :: UsagePlanKey)

-- | The name of a usage plan key.
usagePlanKey_name :: Lens.Lens' UsagePlanKey (Prelude.Maybe Prelude.Text)
usagePlanKey_name :: Lens' UsagePlanKey (Maybe Text)
usagePlanKey_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UsagePlanKey' {Maybe Text
name :: Maybe Text
$sel:name:UsagePlanKey' :: UsagePlanKey -> Maybe Text
name} -> Maybe Text
name) (\s :: UsagePlanKey
s@UsagePlanKey' {} Maybe Text
a -> UsagePlanKey
s {$sel:name:UsagePlanKey' :: Maybe Text
name = Maybe Text
a} :: UsagePlanKey)

-- | The type of a usage plan key. Currently, the valid key type is
-- @API_KEY@.
usagePlanKey_type :: Lens.Lens' UsagePlanKey (Prelude.Maybe Prelude.Text)
usagePlanKey_type :: Lens' UsagePlanKey (Maybe Text)
usagePlanKey_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UsagePlanKey' {Maybe Text
type' :: Maybe Text
$sel:type':UsagePlanKey' :: UsagePlanKey -> Maybe Text
type'} -> Maybe Text
type') (\s :: UsagePlanKey
s@UsagePlanKey' {} Maybe Text
a -> UsagePlanKey
s {$sel:type':UsagePlanKey' :: Maybe Text
type' = Maybe Text
a} :: UsagePlanKey)

-- | The value of a usage plan key.
usagePlanKey_value :: Lens.Lens' UsagePlanKey (Prelude.Maybe Prelude.Text)
usagePlanKey_value :: Lens' UsagePlanKey (Maybe Text)
usagePlanKey_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UsagePlanKey' {Maybe Text
value :: Maybe Text
$sel:value:UsagePlanKey' :: UsagePlanKey -> Maybe Text
value} -> Maybe Text
value) (\s :: UsagePlanKey
s@UsagePlanKey' {} Maybe Text
a -> UsagePlanKey
s {$sel:value:UsagePlanKey' :: Maybe Text
value = Maybe Text
a} :: UsagePlanKey)

instance Data.FromJSON UsagePlanKey where
  parseJSON :: Value -> Parser UsagePlanKey
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"UsagePlanKey"
      ( \Object
x ->
          Maybe Text
-> Maybe Text -> Maybe Text -> Maybe Text -> UsagePlanKey
UsagePlanKey'
            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
"id")
            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
"name")
            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
"type")
            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
"value")
      )

instance Prelude.Hashable UsagePlanKey where
  hashWithSalt :: Int -> UsagePlanKey -> Int
hashWithSalt Int
_salt UsagePlanKey' {Maybe Text
value :: Maybe Text
type' :: Maybe Text
name :: Maybe Text
id :: Maybe Text
$sel:value:UsagePlanKey' :: UsagePlanKey -> Maybe Text
$sel:type':UsagePlanKey' :: UsagePlanKey -> Maybe Text
$sel:name:UsagePlanKey' :: UsagePlanKey -> Maybe Text
$sel:id:UsagePlanKey' :: UsagePlanKey -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
type'
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
value

instance Prelude.NFData UsagePlanKey where
  rnf :: UsagePlanKey -> ()
rnf UsagePlanKey' {Maybe Text
value :: Maybe Text
type' :: Maybe Text
name :: Maybe Text
id :: Maybe Text
$sel:value:UsagePlanKey' :: UsagePlanKey -> Maybe Text
$sel:type':UsagePlanKey' :: UsagePlanKey -> Maybe Text
$sel:name:UsagePlanKey' :: UsagePlanKey -> Maybe Text
$sel:id:UsagePlanKey' :: UsagePlanKey -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
type'
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
value