{-# 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.GetUsagePlan
-- 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 of a given plan identifier.
module Amazonka.APIGateway.GetUsagePlan
  ( -- * Creating a Request
    GetUsagePlan (..),
    newGetUsagePlan,

    -- * Request Lenses
    getUsagePlan_usagePlanId,

    -- * Destructuring the Response
    UsagePlan (..),
    newUsagePlan,

    -- * Response Lenses
    usagePlan_apiStages,
    usagePlan_name,
    usagePlan_id,
    usagePlan_throttle,
    usagePlan_quota,
    usagePlan_description,
    usagePlan_productCode,
    usagePlan_tags,
  )
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 of a given plan identifier.
--
-- /See:/ 'newGetUsagePlan' smart constructor.
data GetUsagePlan = GetUsagePlan'
  { -- | [Required] The identifier of the UsagePlan resource to be retrieved.
    GetUsagePlan -> Text
usagePlanId :: Prelude.Text
  }
  deriving (GetUsagePlan -> GetUsagePlan -> Bool
(GetUsagePlan -> GetUsagePlan -> Bool)
-> (GetUsagePlan -> GetUsagePlan -> Bool) -> Eq GetUsagePlan
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetUsagePlan -> GetUsagePlan -> Bool
$c/= :: GetUsagePlan -> GetUsagePlan -> Bool
== :: GetUsagePlan -> GetUsagePlan -> Bool
$c== :: GetUsagePlan -> GetUsagePlan -> Bool
Prelude.Eq, ReadPrec [GetUsagePlan]
ReadPrec GetUsagePlan
Int -> ReadS GetUsagePlan
ReadS [GetUsagePlan]
(Int -> ReadS GetUsagePlan)
-> ReadS [GetUsagePlan]
-> ReadPrec GetUsagePlan
-> ReadPrec [GetUsagePlan]
-> Read GetUsagePlan
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetUsagePlan]
$creadListPrec :: ReadPrec [GetUsagePlan]
readPrec :: ReadPrec GetUsagePlan
$creadPrec :: ReadPrec GetUsagePlan
readList :: ReadS [GetUsagePlan]
$creadList :: ReadS [GetUsagePlan]
readsPrec :: Int -> ReadS GetUsagePlan
$creadsPrec :: Int -> ReadS GetUsagePlan
Prelude.Read, Int -> GetUsagePlan -> ShowS
[GetUsagePlan] -> ShowS
GetUsagePlan -> String
(Int -> GetUsagePlan -> ShowS)
-> (GetUsagePlan -> String)
-> ([GetUsagePlan] -> ShowS)
-> Show GetUsagePlan
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetUsagePlan] -> ShowS
$cshowList :: [GetUsagePlan] -> ShowS
show :: GetUsagePlan -> String
$cshow :: GetUsagePlan -> String
showsPrec :: Int -> GetUsagePlan -> ShowS
$cshowsPrec :: Int -> GetUsagePlan -> ShowS
Prelude.Show, (forall x. GetUsagePlan -> Rep GetUsagePlan x)
-> (forall x. Rep GetUsagePlan x -> GetUsagePlan)
-> Generic GetUsagePlan
forall x. Rep GetUsagePlan x -> GetUsagePlan
forall x. GetUsagePlan -> Rep GetUsagePlan x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetUsagePlan x -> GetUsagePlan
$cfrom :: forall x. GetUsagePlan -> Rep GetUsagePlan x
Prelude.Generic)

-- |
-- Create a value of 'GetUsagePlan' 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', 'getUsagePlan_usagePlanId' - [Required] The identifier of the UsagePlan resource to be retrieved.
newGetUsagePlan ::
  -- | 'usagePlanId'
  Prelude.Text ->
  GetUsagePlan
newGetUsagePlan :: Text -> GetUsagePlan
newGetUsagePlan Text
pUsagePlanId_ =
  GetUsagePlan' :: Text -> GetUsagePlan
GetUsagePlan' {$sel:usagePlanId:GetUsagePlan' :: Text
usagePlanId = Text
pUsagePlanId_}

-- | [Required] The identifier of the UsagePlan resource to be retrieved.
getUsagePlan_usagePlanId :: Lens.Lens' GetUsagePlan Prelude.Text
getUsagePlan_usagePlanId :: (Text -> f Text) -> GetUsagePlan -> f GetUsagePlan
getUsagePlan_usagePlanId = (GetUsagePlan -> Text)
-> (GetUsagePlan -> Text -> GetUsagePlan)
-> Lens GetUsagePlan GetUsagePlan Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetUsagePlan' {Text
usagePlanId :: Text
$sel:usagePlanId:GetUsagePlan' :: GetUsagePlan -> Text
usagePlanId} -> Text
usagePlanId) (\s :: GetUsagePlan
s@GetUsagePlan' {} Text
a -> GetUsagePlan
s {$sel:usagePlanId:GetUsagePlan' :: Text
usagePlanId = Text
a} :: GetUsagePlan)

instance Core.AWSRequest GetUsagePlan where
  type AWSResponse GetUsagePlan = UsagePlan
  request :: GetUsagePlan -> Request GetUsagePlan
request = Service -> GetUsagePlan -> Request GetUsagePlan
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetUsagePlan
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetUsagePlan)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetUsagePlan))
-> Logger
-> Service
-> Proxy GetUsagePlan
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetUsagePlan)))
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 UsagePlan
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)

instance Prelude.Hashable GetUsagePlan

instance Prelude.NFData GetUsagePlan

instance Core.ToHeaders GetUsagePlan where
  toHeaders :: GetUsagePlan -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetUsagePlan -> 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 GetUsagePlan where
  toPath :: GetUsagePlan -> ByteString
toPath GetUsagePlan' {Text
usagePlanId :: Text
$sel:usagePlanId:GetUsagePlan' :: GetUsagePlan -> 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]

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