{-# 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-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.APIGateway.Types.UsagePlanKey where

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

-- | Represents a usage plan key to identify a plan customer.
--
-- To associate an API stage with a selected API key in a usage plan, you
-- must create a UsagePlanKey resource to represent the selected ApiKey.
--
-- \"
--
-- <https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-api-usage-plans.html Create and Use Usage Plans>
--
-- /See:/ 'newUsagePlanKey' smart constructor.
data UsagePlanKey = UsagePlanKey'
  { -- | The value of a usage plan key.
    UsagePlanKey -> Maybe Text
value :: Prelude.Maybe Prelude.Text,
    -- | The name of a usage plan key.
    UsagePlanKey -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The Id of a usage plan key.
    UsagePlanKey -> Maybe Text
id :: 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
  }
  deriving (UsagePlanKey -> UsagePlanKey -> Bool
(UsagePlanKey -> UsagePlanKey -> Bool)
-> (UsagePlanKey -> UsagePlanKey -> Bool) -> Eq UsagePlanKey
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]
(Int -> ReadS UsagePlanKey)
-> ReadS [UsagePlanKey]
-> ReadPrec UsagePlanKey
-> ReadPrec [UsagePlanKey]
-> Read 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
(Int -> UsagePlanKey -> ShowS)
-> (UsagePlanKey -> String)
-> ([UsagePlanKey] -> ShowS)
-> Show UsagePlanKey
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. UsagePlanKey -> Rep UsagePlanKey x)
-> (forall x. Rep UsagePlanKey x -> UsagePlanKey)
-> Generic UsagePlanKey
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:
--
-- 'value', 'usagePlanKey_value' - The value of a usage plan key.
--
-- 'name', 'usagePlanKey_name' - The name of a usage plan key.
--
-- 'id', 'usagePlanKey_id' - The Id of a usage plan key.
--
-- 'type'', 'usagePlanKey_type' - The type of a usage plan key. Currently, the valid key type is
-- @API_KEY@.
newUsagePlanKey ::
  UsagePlanKey
newUsagePlanKey :: UsagePlanKey
newUsagePlanKey =
  UsagePlanKey' :: Maybe Text
-> Maybe Text -> Maybe Text -> Maybe Text -> UsagePlanKey
UsagePlanKey'
    { $sel:value:UsagePlanKey' :: Maybe Text
value = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:UsagePlanKey' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:id:UsagePlanKey' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':UsagePlanKey' :: Maybe Text
type' = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The value of a usage plan key.
usagePlanKey_value :: Lens.Lens' UsagePlanKey (Prelude.Maybe Prelude.Text)
usagePlanKey_value :: (Maybe Text -> f (Maybe Text)) -> UsagePlanKey -> f UsagePlanKey
usagePlanKey_value = (UsagePlanKey -> Maybe Text)
-> (UsagePlanKey -> Maybe Text -> UsagePlanKey)
-> Lens UsagePlanKey UsagePlanKey (Maybe Text) (Maybe Text)
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)

-- | The name of a usage plan key.
usagePlanKey_name :: Lens.Lens' UsagePlanKey (Prelude.Maybe Prelude.Text)
usagePlanKey_name :: (Maybe Text -> f (Maybe Text)) -> UsagePlanKey -> f UsagePlanKey
usagePlanKey_name = (UsagePlanKey -> Maybe Text)
-> (UsagePlanKey -> Maybe Text -> UsagePlanKey)
-> Lens UsagePlanKey UsagePlanKey (Maybe Text) (Maybe Text)
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 Id of a usage plan key.
usagePlanKey_id :: Lens.Lens' UsagePlanKey (Prelude.Maybe Prelude.Text)
usagePlanKey_id :: (Maybe Text -> f (Maybe Text)) -> UsagePlanKey -> f UsagePlanKey
usagePlanKey_id = (UsagePlanKey -> Maybe Text)
-> (UsagePlanKey -> Maybe Text -> UsagePlanKey)
-> Lens UsagePlanKey UsagePlanKey (Maybe Text) (Maybe Text)
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 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 :: (Maybe Text -> f (Maybe Text)) -> UsagePlanKey -> f UsagePlanKey
usagePlanKey_type = (UsagePlanKey -> Maybe Text)
-> (UsagePlanKey -> Maybe Text -> UsagePlanKey)
-> Lens UsagePlanKey UsagePlanKey (Maybe Text) (Maybe Text)
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)

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

instance Prelude.Hashable UsagePlanKey

instance Prelude.NFData UsagePlanKey