{-# 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.GetStages
-- 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 one or more Stage resources.
module Amazonka.APIGateway.GetStages
  ( -- * Creating a Request
    GetStages (..),
    newGetStages,

    -- * Request Lenses
    getStages_deploymentId,
    getStages_restApiId,

    -- * Destructuring the Response
    GetStagesResponse (..),
    newGetStagesResponse,

    -- * Response Lenses
    getStagesResponse_item,
    getStagesResponse_httpStatus,
  )
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 one or more Stage
-- resources.
--
-- /See:/ 'newGetStages' smart constructor.
data GetStages = GetStages'
  { -- | The stages\' deployment identifiers.
    GetStages -> Maybe Text
deploymentId :: Prelude.Maybe Prelude.Text,
    -- | [Required] The string identifier of the associated RestApi.
    GetStages -> Text
restApiId :: Prelude.Text
  }
  deriving (GetStages -> GetStages -> Bool
(GetStages -> GetStages -> Bool)
-> (GetStages -> GetStages -> Bool) -> Eq GetStages
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetStages -> GetStages -> Bool
$c/= :: GetStages -> GetStages -> Bool
== :: GetStages -> GetStages -> Bool
$c== :: GetStages -> GetStages -> Bool
Prelude.Eq, ReadPrec [GetStages]
ReadPrec GetStages
Int -> ReadS GetStages
ReadS [GetStages]
(Int -> ReadS GetStages)
-> ReadS [GetStages]
-> ReadPrec GetStages
-> ReadPrec [GetStages]
-> Read GetStages
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetStages]
$creadListPrec :: ReadPrec [GetStages]
readPrec :: ReadPrec GetStages
$creadPrec :: ReadPrec GetStages
readList :: ReadS [GetStages]
$creadList :: ReadS [GetStages]
readsPrec :: Int -> ReadS GetStages
$creadsPrec :: Int -> ReadS GetStages
Prelude.Read, Int -> GetStages -> ShowS
[GetStages] -> ShowS
GetStages -> String
(Int -> GetStages -> ShowS)
-> (GetStages -> String)
-> ([GetStages] -> ShowS)
-> Show GetStages
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetStages] -> ShowS
$cshowList :: [GetStages] -> ShowS
show :: GetStages -> String
$cshow :: GetStages -> String
showsPrec :: Int -> GetStages -> ShowS
$cshowsPrec :: Int -> GetStages -> ShowS
Prelude.Show, (forall x. GetStages -> Rep GetStages x)
-> (forall x. Rep GetStages x -> GetStages) -> Generic GetStages
forall x. Rep GetStages x -> GetStages
forall x. GetStages -> Rep GetStages x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetStages x -> GetStages
$cfrom :: forall x. GetStages -> Rep GetStages x
Prelude.Generic)

-- |
-- Create a value of 'GetStages' 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:
--
-- 'deploymentId', 'getStages_deploymentId' - The stages\' deployment identifiers.
--
-- 'restApiId', 'getStages_restApiId' - [Required] The string identifier of the associated RestApi.
newGetStages ::
  -- | 'restApiId'
  Prelude.Text ->
  GetStages
newGetStages :: Text -> GetStages
newGetStages Text
pRestApiId_ =
  GetStages' :: Maybe Text -> Text -> GetStages
GetStages'
    { $sel:deploymentId:GetStages' :: Maybe Text
deploymentId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:restApiId:GetStages' :: Text
restApiId = Text
pRestApiId_
    }

-- | The stages\' deployment identifiers.
getStages_deploymentId :: Lens.Lens' GetStages (Prelude.Maybe Prelude.Text)
getStages_deploymentId :: (Maybe Text -> f (Maybe Text)) -> GetStages -> f GetStages
getStages_deploymentId = (GetStages -> Maybe Text)
-> (GetStages -> Maybe Text -> GetStages)
-> Lens GetStages GetStages (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetStages' {Maybe Text
deploymentId :: Maybe Text
$sel:deploymentId:GetStages' :: GetStages -> Maybe Text
deploymentId} -> Maybe Text
deploymentId) (\s :: GetStages
s@GetStages' {} Maybe Text
a -> GetStages
s {$sel:deploymentId:GetStages' :: Maybe Text
deploymentId = Maybe Text
a} :: GetStages)

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

instance Core.AWSRequest GetStages where
  type AWSResponse GetStages = GetStagesResponse
  request :: GetStages -> Request GetStages
request = Service -> GetStages -> Request GetStages
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetStages
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetStages)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetStages))
-> Logger
-> Service
-> Proxy GetStages
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetStages)))
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 ->
          Maybe [Stage] -> Int -> GetStagesResponse
GetStagesResponse'
            (Maybe [Stage] -> Int -> GetStagesResponse)
-> Either String (Maybe [Stage])
-> Either String (Int -> GetStagesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [Stage]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"item" Either String (Maybe (Maybe [Stage]))
-> Maybe [Stage] -> Either String (Maybe [Stage])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Stage]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> GetStagesResponse)
-> Either String Int -> Either String GetStagesResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable GetStages

instance Prelude.NFData GetStages

instance Core.ToHeaders GetStages where
  toHeaders :: GetStages -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetStages -> 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 GetStages where
  toPath :: GetStages -> ByteString
toPath GetStages' {Maybe Text
Text
restApiId :: Text
deploymentId :: Maybe Text
$sel:restApiId:GetStages' :: GetStages -> Text
$sel:deploymentId:GetStages' :: GetStages -> Maybe 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"]

instance Core.ToQuery GetStages where
  toQuery :: GetStages -> QueryString
toQuery GetStages' {Maybe Text
Text
restApiId :: Text
deploymentId :: Maybe Text
$sel:restApiId:GetStages' :: GetStages -> Text
$sel:deploymentId:GetStages' :: GetStages -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"deploymentId" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
deploymentId]

-- | A list of Stage resources that are associated with the ApiKey resource.
--
-- <https://docs.aws.amazon.com/apigateway/latest/developerguide/stages.html Deploying API in Stages>
--
-- /See:/ 'newGetStagesResponse' smart constructor.
data GetStagesResponse = GetStagesResponse'
  { -- | The current page of elements from this collection.
    GetStagesResponse -> Maybe [Stage]
item :: Prelude.Maybe [Stage],
    -- | The response's http status code.
    GetStagesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetStagesResponse -> GetStagesResponse -> Bool
(GetStagesResponse -> GetStagesResponse -> Bool)
-> (GetStagesResponse -> GetStagesResponse -> Bool)
-> Eq GetStagesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetStagesResponse -> GetStagesResponse -> Bool
$c/= :: GetStagesResponse -> GetStagesResponse -> Bool
== :: GetStagesResponse -> GetStagesResponse -> Bool
$c== :: GetStagesResponse -> GetStagesResponse -> Bool
Prelude.Eq, ReadPrec [GetStagesResponse]
ReadPrec GetStagesResponse
Int -> ReadS GetStagesResponse
ReadS [GetStagesResponse]
(Int -> ReadS GetStagesResponse)
-> ReadS [GetStagesResponse]
-> ReadPrec GetStagesResponse
-> ReadPrec [GetStagesResponse]
-> Read GetStagesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetStagesResponse]
$creadListPrec :: ReadPrec [GetStagesResponse]
readPrec :: ReadPrec GetStagesResponse
$creadPrec :: ReadPrec GetStagesResponse
readList :: ReadS [GetStagesResponse]
$creadList :: ReadS [GetStagesResponse]
readsPrec :: Int -> ReadS GetStagesResponse
$creadsPrec :: Int -> ReadS GetStagesResponse
Prelude.Read, Int -> GetStagesResponse -> ShowS
[GetStagesResponse] -> ShowS
GetStagesResponse -> String
(Int -> GetStagesResponse -> ShowS)
-> (GetStagesResponse -> String)
-> ([GetStagesResponse] -> ShowS)
-> Show GetStagesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetStagesResponse] -> ShowS
$cshowList :: [GetStagesResponse] -> ShowS
show :: GetStagesResponse -> String
$cshow :: GetStagesResponse -> String
showsPrec :: Int -> GetStagesResponse -> ShowS
$cshowsPrec :: Int -> GetStagesResponse -> ShowS
Prelude.Show, (forall x. GetStagesResponse -> Rep GetStagesResponse x)
-> (forall x. Rep GetStagesResponse x -> GetStagesResponse)
-> Generic GetStagesResponse
forall x. Rep GetStagesResponse x -> GetStagesResponse
forall x. GetStagesResponse -> Rep GetStagesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetStagesResponse x -> GetStagesResponse
$cfrom :: forall x. GetStagesResponse -> Rep GetStagesResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetStagesResponse' 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:
--
-- 'item', 'getStagesResponse_item' - The current page of elements from this collection.
--
-- 'httpStatus', 'getStagesResponse_httpStatus' - The response's http status code.
newGetStagesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetStagesResponse
newGetStagesResponse :: Int -> GetStagesResponse
newGetStagesResponse Int
pHttpStatus_ =
  GetStagesResponse' :: Maybe [Stage] -> Int -> GetStagesResponse
GetStagesResponse'
    { $sel:item:GetStagesResponse' :: Maybe [Stage]
item = Maybe [Stage]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetStagesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The current page of elements from this collection.
getStagesResponse_item :: Lens.Lens' GetStagesResponse (Prelude.Maybe [Stage])
getStagesResponse_item :: (Maybe [Stage] -> f (Maybe [Stage]))
-> GetStagesResponse -> f GetStagesResponse
getStagesResponse_item = (GetStagesResponse -> Maybe [Stage])
-> (GetStagesResponse -> Maybe [Stage] -> GetStagesResponse)
-> Lens
     GetStagesResponse GetStagesResponse (Maybe [Stage]) (Maybe [Stage])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetStagesResponse' {Maybe [Stage]
item :: Maybe [Stage]
$sel:item:GetStagesResponse' :: GetStagesResponse -> Maybe [Stage]
item} -> Maybe [Stage]
item) (\s :: GetStagesResponse
s@GetStagesResponse' {} Maybe [Stage]
a -> GetStagesResponse
s {$sel:item:GetStagesResponse' :: Maybe [Stage]
item = Maybe [Stage]
a} :: GetStagesResponse) ((Maybe [Stage] -> f (Maybe [Stage]))
 -> GetStagesResponse -> f GetStagesResponse)
-> ((Maybe [Stage] -> f (Maybe [Stage]))
    -> Maybe [Stage] -> f (Maybe [Stage]))
-> (Maybe [Stage] -> f (Maybe [Stage]))
-> GetStagesResponse
-> f GetStagesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Stage] [Stage] [Stage] [Stage]
-> Iso
     (Maybe [Stage]) (Maybe [Stage]) (Maybe [Stage]) (Maybe [Stage])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Stage] [Stage] [Stage] [Stage]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The response's http status code.
getStagesResponse_httpStatus :: Lens.Lens' GetStagesResponse Prelude.Int
getStagesResponse_httpStatus :: (Int -> f Int) -> GetStagesResponse -> f GetStagesResponse
getStagesResponse_httpStatus = (GetStagesResponse -> Int)
-> (GetStagesResponse -> Int -> GetStagesResponse)
-> Lens GetStagesResponse GetStagesResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetStagesResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetStagesResponse' :: GetStagesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetStagesResponse
s@GetStagesResponse' {} Int
a -> GetStagesResponse
s {$sel:httpStatus:GetStagesResponse' :: Int
httpStatus = Int
a} :: GetStagesResponse)

instance Prelude.NFData GetStagesResponse