{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.GetUsagePlanKey
-- 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)
--
-- Gets a usage plan key of a given key identifier.
module Amazonka.APIGateway.GetUsagePlanKey
  ( -- * Creating a Request
    GetUsagePlanKey (..),
    newGetUsagePlanKey,

    -- * Request Lenses
    getUsagePlanKey_usagePlanId,
    getUsagePlanKey_keyId,

    -- * Destructuring the Response
    UsagePlanKey (..),
    newUsagePlanKey,

    -- * Response Lenses
    usagePlanKey_value,
    usagePlanKey_name,
    usagePlanKey_id,
    usagePlanKey_type,
  )
where

import Amazonka.APIGateway.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | The GET request to get a usage plan key of a given key identifier.
--
-- /See:/ 'newGetUsagePlanKey' smart constructor.
data GetUsagePlanKey = GetUsagePlanKey'
  { -- | [Required] The Id of the UsagePlan resource representing the usage plan
    -- containing the to-be-retrieved UsagePlanKey resource representing a plan
    -- customer.
    GetUsagePlanKey -> Text
usagePlanId :: Prelude.Text,
    -- | [Required] The key Id of the to-be-retrieved UsagePlanKey resource
    -- representing a plan customer.
    GetUsagePlanKey -> Text
keyId :: Prelude.Text
  }
  deriving (GetUsagePlanKey -> GetUsagePlanKey -> Bool
(GetUsagePlanKey -> GetUsagePlanKey -> Bool)
-> (GetUsagePlanKey -> GetUsagePlanKey -> Bool)
-> Eq GetUsagePlanKey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetUsagePlanKey -> GetUsagePlanKey -> Bool
$c/= :: GetUsagePlanKey -> GetUsagePlanKey -> Bool
== :: GetUsagePlanKey -> GetUsagePlanKey -> Bool
$c== :: GetUsagePlanKey -> GetUsagePlanKey -> Bool
Prelude.Eq, ReadPrec [GetUsagePlanKey]
ReadPrec GetUsagePlanKey
Int -> ReadS GetUsagePlanKey
ReadS [GetUsagePlanKey]
(Int -> ReadS GetUsagePlanKey)
-> ReadS [GetUsagePlanKey]
-> ReadPrec GetUsagePlanKey
-> ReadPrec [GetUsagePlanKey]
-> Read GetUsagePlanKey
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetUsagePlanKey]
$creadListPrec :: ReadPrec [GetUsagePlanKey]
readPrec :: ReadPrec GetUsagePlanKey
$creadPrec :: ReadPrec GetUsagePlanKey
readList :: ReadS [GetUsagePlanKey]
$creadList :: ReadS [GetUsagePlanKey]
readsPrec :: Int -> ReadS GetUsagePlanKey
$creadsPrec :: Int -> ReadS GetUsagePlanKey
Prelude.Read, Int -> GetUsagePlanKey -> ShowS
[GetUsagePlanKey] -> ShowS
GetUsagePlanKey -> String
(Int -> GetUsagePlanKey -> ShowS)
-> (GetUsagePlanKey -> String)
-> ([GetUsagePlanKey] -> ShowS)
-> Show GetUsagePlanKey
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetUsagePlanKey] -> ShowS
$cshowList :: [GetUsagePlanKey] -> ShowS
show :: GetUsagePlanKey -> String
$cshow :: GetUsagePlanKey -> String
showsPrec :: Int -> GetUsagePlanKey -> ShowS
$cshowsPrec :: Int -> GetUsagePlanKey -> ShowS
Prelude.Show, (forall x. GetUsagePlanKey -> Rep GetUsagePlanKey x)
-> (forall x. Rep GetUsagePlanKey x -> GetUsagePlanKey)
-> Generic GetUsagePlanKey
forall x. Rep GetUsagePlanKey x -> GetUsagePlanKey
forall x. GetUsagePlanKey -> Rep GetUsagePlanKey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetUsagePlanKey x -> GetUsagePlanKey
$cfrom :: forall x. GetUsagePlanKey -> Rep GetUsagePlanKey x
Prelude.Generic)

-- |
-- Create a value of 'GetUsagePlanKey' 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:
--
-- 'usagePlanId', 'getUsagePlanKey_usagePlanId' - [Required] The Id of the UsagePlan resource representing the usage plan
-- containing the to-be-retrieved UsagePlanKey resource representing a plan
-- customer.
--
-- 'keyId', 'getUsagePlanKey_keyId' - [Required] The key Id of the to-be-retrieved UsagePlanKey resource
-- representing a plan customer.
newGetUsagePlanKey ::
  -- | 'usagePlanId'
  Prelude.Text ->
  -- | 'keyId'
  Prelude.Text ->
  GetUsagePlanKey
newGetUsagePlanKey :: Text -> Text -> GetUsagePlanKey
newGetUsagePlanKey Text
pUsagePlanId_ Text
pKeyId_ =
  GetUsagePlanKey' :: Text -> Text -> GetUsagePlanKey
GetUsagePlanKey'
    { $sel:usagePlanId:GetUsagePlanKey' :: Text
usagePlanId = Text
pUsagePlanId_,
      $sel:keyId:GetUsagePlanKey' :: Text
keyId = Text
pKeyId_
    }

-- | [Required] The Id of the UsagePlan resource representing the usage plan
-- containing the to-be-retrieved UsagePlanKey resource representing a plan
-- customer.
getUsagePlanKey_usagePlanId :: Lens.Lens' GetUsagePlanKey Prelude.Text
getUsagePlanKey_usagePlanId :: (Text -> f Text) -> GetUsagePlanKey -> f GetUsagePlanKey
getUsagePlanKey_usagePlanId = (GetUsagePlanKey -> Text)
-> (GetUsagePlanKey -> Text -> GetUsagePlanKey)
-> Lens GetUsagePlanKey GetUsagePlanKey Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetUsagePlanKey' {Text
usagePlanId :: Text
$sel:usagePlanId:GetUsagePlanKey' :: GetUsagePlanKey -> Text
usagePlanId} -> Text
usagePlanId) (\s :: GetUsagePlanKey
s@GetUsagePlanKey' {} Text
a -> GetUsagePlanKey
s {$sel:usagePlanId:GetUsagePlanKey' :: Text
usagePlanId = Text
a} :: GetUsagePlanKey)

-- | [Required] The key Id of the to-be-retrieved UsagePlanKey resource
-- representing a plan customer.
getUsagePlanKey_keyId :: Lens.Lens' GetUsagePlanKey Prelude.Text
getUsagePlanKey_keyId :: (Text -> f Text) -> GetUsagePlanKey -> f GetUsagePlanKey
getUsagePlanKey_keyId = (GetUsagePlanKey -> Text)
-> (GetUsagePlanKey -> Text -> GetUsagePlanKey)
-> Lens GetUsagePlanKey GetUsagePlanKey Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetUsagePlanKey' {Text
keyId :: Text
$sel:keyId:GetUsagePlanKey' :: GetUsagePlanKey -> Text
keyId} -> Text
keyId) (\s :: GetUsagePlanKey
s@GetUsagePlanKey' {} Text
a -> GetUsagePlanKey
s {$sel:keyId:GetUsagePlanKey' :: Text
keyId = Text
a} :: GetUsagePlanKey)

instance Core.AWSRequest GetUsagePlanKey where
  type AWSResponse GetUsagePlanKey = UsagePlanKey
  request :: GetUsagePlanKey -> Request GetUsagePlanKey
request = Service -> GetUsagePlanKey -> Request GetUsagePlanKey
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetUsagePlanKey
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetUsagePlanKey)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetUsagePlanKey))
-> Logger
-> Service
-> Proxy GetUsagePlanKey
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetUsagePlanKey)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      (\Int
s ResponseHeaders
h Object
x -> Object -> Either String UsagePlanKey
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)

instance Prelude.Hashable GetUsagePlanKey

instance Prelude.NFData GetUsagePlanKey

instance Core.ToHeaders GetUsagePlanKey where
  toHeaders :: GetUsagePlanKey -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetUsagePlanKey -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Accept"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# (ByteString
"application/json" :: Prelude.ByteString)
          ]
      )

instance Core.ToPath GetUsagePlanKey where
  toPath :: GetUsagePlanKey -> ByteString
toPath GetUsagePlanKey' {Text
keyId :: Text
usagePlanId :: Text
$sel:keyId:GetUsagePlanKey' :: GetUsagePlanKey -> Text
$sel:usagePlanId:GetUsagePlanKey' :: GetUsagePlanKey -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/usageplans/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
usagePlanId,
        ByteString
"/keys/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
keyId
      ]

instance Core.ToQuery GetUsagePlanKey where
  toQuery :: GetUsagePlanKey -> QueryString
toQuery = QueryString -> GetUsagePlanKey -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty