{-# 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.GetStage
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Gets information about a Stage resource.
module Amazonka.APIGateway.GetStage
  ( -- * Creating a Request
    GetStage (..),
    newGetStage,

    -- * Request Lenses
    getStage_restApiId,
    getStage_stageName,

    -- * Destructuring the Response
    Stage (..),
    newStage,

    -- * Response Lenses
    stage_accessLogSettings,
    stage_cacheClusterEnabled,
    stage_cacheClusterSize,
    stage_cacheClusterStatus,
    stage_canarySettings,
    stage_clientCertificateId,
    stage_createdDate,
    stage_deploymentId,
    stage_description,
    stage_documentationVersion,
    stage_lastUpdatedDate,
    stage_methodSettings,
    stage_stageName,
    stage_tags,
    stage_tracingEnabled,
    stage_variables,
    stage_webAclArn,
  )
where

import Amazonka.APIGateway.Types
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
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | Requests API Gateway to get information about a Stage resource.
--
-- /See:/ 'newGetStage' smart constructor.
data GetStage = GetStage'
  { -- | The string identifier of the associated RestApi.
    GetStage -> Text
restApiId :: Prelude.Text,
    -- | The name of the Stage resource to get information about.
    GetStage -> Text
stageName :: Prelude.Text
  }
  deriving (GetStage -> GetStage -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetStage -> GetStage -> Bool
$c/= :: GetStage -> GetStage -> Bool
== :: GetStage -> GetStage -> Bool
$c== :: GetStage -> GetStage -> Bool
Prelude.Eq, ReadPrec [GetStage]
ReadPrec GetStage
Int -> ReadS GetStage
ReadS [GetStage]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetStage]
$creadListPrec :: ReadPrec [GetStage]
readPrec :: ReadPrec GetStage
$creadPrec :: ReadPrec GetStage
readList :: ReadS [GetStage]
$creadList :: ReadS [GetStage]
readsPrec :: Int -> ReadS GetStage
$creadsPrec :: Int -> ReadS GetStage
Prelude.Read, Int -> GetStage -> ShowS
[GetStage] -> ShowS
GetStage -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetStage] -> ShowS
$cshowList :: [GetStage] -> ShowS
show :: GetStage -> String
$cshow :: GetStage -> String
showsPrec :: Int -> GetStage -> ShowS
$cshowsPrec :: Int -> GetStage -> ShowS
Prelude.Show, forall x. Rep GetStage x -> GetStage
forall x. GetStage -> Rep GetStage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetStage x -> GetStage
$cfrom :: forall x. GetStage -> Rep GetStage x
Prelude.Generic)

-- |
-- Create a value of 'GetStage' 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:
--
-- 'restApiId', 'getStage_restApiId' - The string identifier of the associated RestApi.
--
-- 'stageName', 'getStage_stageName' - The name of the Stage resource to get information about.
newGetStage ::
  -- | 'restApiId'
  Prelude.Text ->
  -- | 'stageName'
  Prelude.Text ->
  GetStage
newGetStage :: Text -> Text -> GetStage
newGetStage Text
pRestApiId_ Text
pStageName_ =
  GetStage'
    { $sel:restApiId:GetStage' :: Text
restApiId = Text
pRestApiId_,
      $sel:stageName:GetStage' :: Text
stageName = Text
pStageName_
    }

-- | The string identifier of the associated RestApi.
getStage_restApiId :: Lens.Lens' GetStage Prelude.Text
getStage_restApiId :: Lens' GetStage Text
getStage_restApiId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetStage' {Text
restApiId :: Text
$sel:restApiId:GetStage' :: GetStage -> Text
restApiId} -> Text
restApiId) (\s :: GetStage
s@GetStage' {} Text
a -> GetStage
s {$sel:restApiId:GetStage' :: Text
restApiId = Text
a} :: GetStage)

-- | The name of the Stage resource to get information about.
getStage_stageName :: Lens.Lens' GetStage Prelude.Text
getStage_stageName :: Lens' GetStage Text
getStage_stageName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetStage' {Text
stageName :: Text
$sel:stageName:GetStage' :: GetStage -> Text
stageName} -> Text
stageName) (\s :: GetStage
s@GetStage' {} Text
a -> GetStage
s {$sel:stageName:GetStage' :: Text
stageName = Text
a} :: GetStage)

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

instance Prelude.Hashable GetStage where
  hashWithSalt :: Int -> GetStage -> Int
hashWithSalt Int
_salt GetStage' {Text
stageName :: Text
restApiId :: Text
$sel:stageName:GetStage' :: GetStage -> Text
$sel:restApiId:GetStage' :: GetStage -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
restApiId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
stageName

instance Prelude.NFData GetStage where
  rnf :: GetStage -> ()
rnf GetStage' {Text
stageName :: Text
restApiId :: Text
$sel:stageName:GetStage' :: GetStage -> Text
$sel:restApiId:GetStage' :: GetStage -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
restApiId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
stageName

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

instance Data.ToPath GetStage where
  toPath :: GetStage -> ByteString
toPath GetStage' {Text
stageName :: Text
restApiId :: Text
$sel:stageName:GetStage' :: GetStage -> Text
$sel:restApiId:GetStage' :: GetStage -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/restapis/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
restApiId,
        ByteString
"/stages/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
stageName
      ]

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