{-# 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-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 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_deploymentId,
    stage_variables,
    stage_accessLogSettings,
    stage_documentationVersion,
    stage_clientCertificateId,
    stage_tracingEnabled,
    stage_createdDate,
    stage_cacheClusterStatus,
    stage_methodSettings,
    stage_lastUpdatedDate,
    stage_cacheClusterSize,
    stage_webAclArn,
    stage_canarySettings,
    stage_cacheClusterEnabled,
    stage_stageName,
    stage_description,
    stage_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

-- | Requests API Gateway to get information about a Stage resource.
--
-- /See:/ 'newGetStage' smart constructor.
data GetStage = GetStage'
  { -- | [Required] The string identifier of the associated RestApi.
    GetStage -> Text
restApiId :: Prelude.Text,
    -- | [Required] The name of the Stage resource to get information about.
    GetStage -> Text
stageName :: Prelude.Text
  }
  deriving (GetStage -> GetStage -> Bool
(GetStage -> GetStage -> Bool)
-> (GetStage -> GetStage -> Bool) -> Eq GetStage
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]
(Int -> ReadS GetStage)
-> ReadS [GetStage]
-> ReadPrec GetStage
-> ReadPrec [GetStage]
-> Read 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
(Int -> GetStage -> ShowS)
-> (GetStage -> String) -> ([GetStage] -> ShowS) -> Show GetStage
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. GetStage -> Rep GetStage x)
-> (forall x. Rep GetStage x -> GetStage) -> Generic GetStage
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' - [Required] The string identifier of the associated RestApi.
--
-- 'stageName', 'getStage_stageName' - [Required] 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' :: Text -> Text -> GetStage
GetStage'
    { $sel:restApiId:GetStage' :: Text
restApiId = Text
pRestApiId_,
      $sel:stageName:GetStage' :: Text
stageName = Text
pStageName_
    }

-- | [Required] The string identifier of the associated RestApi.
getStage_restApiId :: Lens.Lens' GetStage Prelude.Text
getStage_restApiId :: (Text -> f Text) -> GetStage -> f GetStage
getStage_restApiId = (GetStage -> Text)
-> (GetStage -> Text -> GetStage)
-> Lens GetStage GetStage Text Text
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)

-- | [Required] The name of the Stage resource to get information about.
getStage_stageName :: Lens.Lens' GetStage Prelude.Text
getStage_stageName :: (Text -> f Text) -> GetStage -> f GetStage
getStage_stageName = (GetStage -> Text)
-> (GetStage -> Text -> GetStage)
-> Lens GetStage GetStage Text Text
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 :: GetStage -> Request GetStage
request = Service -> GetStage -> Request GetStage
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetStage
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetStage)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetStage))
-> Logger
-> Service
-> Proxy GetStage
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetStage)))
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 Stage
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)

instance Prelude.Hashable GetStage

instance Prelude.NFData GetStage

instance Core.ToHeaders GetStage where
  toHeaders :: GetStage -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetStage -> 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 GetStage where
  toPath :: GetStage -> ByteString
toPath GetStage' {Text
stageName :: Text
restApiId :: Text
$sel:stageName:GetStage' :: GetStage -> Text
$sel:restApiId:GetStage' :: GetStage -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/restapis/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
restApiId,
        ByteString
"/stages/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
stageName
      ]

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